{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.MediaLive.Types.InputSwitchScheduleActionSettings
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaLive.Types.InputSwitchScheduleActionSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.InputClippingSettings
import qualified Amazonka.Prelude as Prelude

-- | Settings for the \"switch input\" action: to switch from ingesting one
-- input to ingesting another input.
--
-- /See:/ 'newInputSwitchScheduleActionSettings' smart constructor.
data InputSwitchScheduleActionSettings = InputSwitchScheduleActionSettings'
  { -- | Settings to let you create a clip of the file input, in order to set up
    -- the input to ingest only a portion of the file.
    InputSwitchScheduleActionSettings -> Maybe InputClippingSettings
inputClippingSettings :: Prelude.Maybe InputClippingSettings,
    -- | The value for the variable portion of the URL for the dynamic input, for
    -- this instance of the input. Each time you use the same dynamic input in
    -- an input switch action, you can provide a different value, in order to
    -- connect the input to a different content source.
    InputSwitchScheduleActionSettings -> Maybe [Text]
urlPath :: Prelude.Maybe [Prelude.Text],
    -- | The name of the input attachment (not the name of the input!) to switch
    -- to. The name is specified in the channel configuration.
    InputSwitchScheduleActionSettings -> Text
inputAttachmentNameReference :: Prelude.Text
  }
  deriving (InputSwitchScheduleActionSettings
-> InputSwitchScheduleActionSettings -> Bool
(InputSwitchScheduleActionSettings
 -> InputSwitchScheduleActionSettings -> Bool)
-> (InputSwitchScheduleActionSettings
    -> InputSwitchScheduleActionSettings -> Bool)
-> Eq InputSwitchScheduleActionSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputSwitchScheduleActionSettings
-> InputSwitchScheduleActionSettings -> Bool
$c/= :: InputSwitchScheduleActionSettings
-> InputSwitchScheduleActionSettings -> Bool
== :: InputSwitchScheduleActionSettings
-> InputSwitchScheduleActionSettings -> Bool
$c== :: InputSwitchScheduleActionSettings
-> InputSwitchScheduleActionSettings -> Bool
Prelude.Eq, ReadPrec [InputSwitchScheduleActionSettings]
ReadPrec InputSwitchScheduleActionSettings
Int -> ReadS InputSwitchScheduleActionSettings
ReadS [InputSwitchScheduleActionSettings]
(Int -> ReadS InputSwitchScheduleActionSettings)
-> ReadS [InputSwitchScheduleActionSettings]
-> ReadPrec InputSwitchScheduleActionSettings
-> ReadPrec [InputSwitchScheduleActionSettings]
-> Read InputSwitchScheduleActionSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputSwitchScheduleActionSettings]
$creadListPrec :: ReadPrec [InputSwitchScheduleActionSettings]
readPrec :: ReadPrec InputSwitchScheduleActionSettings
$creadPrec :: ReadPrec InputSwitchScheduleActionSettings
readList :: ReadS [InputSwitchScheduleActionSettings]
$creadList :: ReadS [InputSwitchScheduleActionSettings]
readsPrec :: Int -> ReadS InputSwitchScheduleActionSettings
$creadsPrec :: Int -> ReadS InputSwitchScheduleActionSettings
Prelude.Read, Int -> InputSwitchScheduleActionSettings -> ShowS
[InputSwitchScheduleActionSettings] -> ShowS
InputSwitchScheduleActionSettings -> String
(Int -> InputSwitchScheduleActionSettings -> ShowS)
-> (InputSwitchScheduleActionSettings -> String)
-> ([InputSwitchScheduleActionSettings] -> ShowS)
-> Show InputSwitchScheduleActionSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputSwitchScheduleActionSettings] -> ShowS
$cshowList :: [InputSwitchScheduleActionSettings] -> ShowS
show :: InputSwitchScheduleActionSettings -> String
$cshow :: InputSwitchScheduleActionSettings -> String
showsPrec :: Int -> InputSwitchScheduleActionSettings -> ShowS
$cshowsPrec :: Int -> InputSwitchScheduleActionSettings -> ShowS
Prelude.Show, (forall x.
 InputSwitchScheduleActionSettings
 -> Rep InputSwitchScheduleActionSettings x)
-> (forall x.
    Rep InputSwitchScheduleActionSettings x
    -> InputSwitchScheduleActionSettings)
-> Generic InputSwitchScheduleActionSettings
forall x.
Rep InputSwitchScheduleActionSettings x
-> InputSwitchScheduleActionSettings
forall x.
InputSwitchScheduleActionSettings
-> Rep InputSwitchScheduleActionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InputSwitchScheduleActionSettings x
-> InputSwitchScheduleActionSettings
$cfrom :: forall x.
InputSwitchScheduleActionSettings
-> Rep InputSwitchScheduleActionSettings x
Prelude.Generic)

-- |
-- Create a value of 'InputSwitchScheduleActionSettings' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'inputClippingSettings', 'inputSwitchScheduleActionSettings_inputClippingSettings' - Settings to let you create a clip of the file input, in order to set up
-- the input to ingest only a portion of the file.
--
-- 'urlPath', 'inputSwitchScheduleActionSettings_urlPath' - The value for the variable portion of the URL for the dynamic input, for
-- this instance of the input. Each time you use the same dynamic input in
-- an input switch action, you can provide a different value, in order to
-- connect the input to a different content source.
--
-- 'inputAttachmentNameReference', 'inputSwitchScheduleActionSettings_inputAttachmentNameReference' - The name of the input attachment (not the name of the input!) to switch
-- to. The name is specified in the channel configuration.
newInputSwitchScheduleActionSettings ::
  -- | 'inputAttachmentNameReference'
  Prelude.Text ->
  InputSwitchScheduleActionSettings
newInputSwitchScheduleActionSettings :: Text -> InputSwitchScheduleActionSettings
newInputSwitchScheduleActionSettings
  Text
pInputAttachmentNameReference_ =
    InputSwitchScheduleActionSettings' :: Maybe InputClippingSettings
-> Maybe [Text] -> Text -> InputSwitchScheduleActionSettings
InputSwitchScheduleActionSettings'
      { $sel:inputClippingSettings:InputSwitchScheduleActionSettings' :: Maybe InputClippingSettings
inputClippingSettings =
          Maybe InputClippingSettings
forall a. Maybe a
Prelude.Nothing,
        $sel:urlPath:InputSwitchScheduleActionSettings' :: Maybe [Text]
urlPath = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:inputAttachmentNameReference:InputSwitchScheduleActionSettings' :: Text
inputAttachmentNameReference =
          Text
pInputAttachmentNameReference_
      }

-- | Settings to let you create a clip of the file input, in order to set up
-- the input to ingest only a portion of the file.
inputSwitchScheduleActionSettings_inputClippingSettings :: Lens.Lens' InputSwitchScheduleActionSettings (Prelude.Maybe InputClippingSettings)
inputSwitchScheduleActionSettings_inputClippingSettings :: (Maybe InputClippingSettings -> f (Maybe InputClippingSettings))
-> InputSwitchScheduleActionSettings
-> f InputSwitchScheduleActionSettings
inputSwitchScheduleActionSettings_inputClippingSettings = (InputSwitchScheduleActionSettings -> Maybe InputClippingSettings)
-> (InputSwitchScheduleActionSettings
    -> Maybe InputClippingSettings
    -> InputSwitchScheduleActionSettings)
-> Lens
     InputSwitchScheduleActionSettings
     InputSwitchScheduleActionSettings
     (Maybe InputClippingSettings)
     (Maybe InputClippingSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSwitchScheduleActionSettings' {Maybe InputClippingSettings
inputClippingSettings :: Maybe InputClippingSettings
$sel:inputClippingSettings:InputSwitchScheduleActionSettings' :: InputSwitchScheduleActionSettings -> Maybe InputClippingSettings
inputClippingSettings} -> Maybe InputClippingSettings
inputClippingSettings) (\s :: InputSwitchScheduleActionSettings
s@InputSwitchScheduleActionSettings' {} Maybe InputClippingSettings
a -> InputSwitchScheduleActionSettings
s {$sel:inputClippingSettings:InputSwitchScheduleActionSettings' :: Maybe InputClippingSettings
inputClippingSettings = Maybe InputClippingSettings
a} :: InputSwitchScheduleActionSettings)

-- | The value for the variable portion of the URL for the dynamic input, for
-- this instance of the input. Each time you use the same dynamic input in
-- an input switch action, you can provide a different value, in order to
-- connect the input to a different content source.
inputSwitchScheduleActionSettings_urlPath :: Lens.Lens' InputSwitchScheduleActionSettings (Prelude.Maybe [Prelude.Text])
inputSwitchScheduleActionSettings_urlPath :: (Maybe [Text] -> f (Maybe [Text]))
-> InputSwitchScheduleActionSettings
-> f InputSwitchScheduleActionSettings
inputSwitchScheduleActionSettings_urlPath = (InputSwitchScheduleActionSettings -> Maybe [Text])
-> (InputSwitchScheduleActionSettings
    -> Maybe [Text] -> InputSwitchScheduleActionSettings)
-> Lens
     InputSwitchScheduleActionSettings
     InputSwitchScheduleActionSettings
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSwitchScheduleActionSettings' {Maybe [Text]
urlPath :: Maybe [Text]
$sel:urlPath:InputSwitchScheduleActionSettings' :: InputSwitchScheduleActionSettings -> Maybe [Text]
urlPath} -> Maybe [Text]
urlPath) (\s :: InputSwitchScheduleActionSettings
s@InputSwitchScheduleActionSettings' {} Maybe [Text]
a -> InputSwitchScheduleActionSettings
s {$sel:urlPath:InputSwitchScheduleActionSettings' :: Maybe [Text]
urlPath = Maybe [Text]
a} :: InputSwitchScheduleActionSettings) ((Maybe [Text] -> f (Maybe [Text]))
 -> InputSwitchScheduleActionSettings
 -> f InputSwitchScheduleActionSettings)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> InputSwitchScheduleActionSettings
-> f InputSwitchScheduleActionSettings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the input attachment (not the name of the input!) to switch
-- to. The name is specified in the channel configuration.
inputSwitchScheduleActionSettings_inputAttachmentNameReference :: Lens.Lens' InputSwitchScheduleActionSettings Prelude.Text
inputSwitchScheduleActionSettings_inputAttachmentNameReference :: (Text -> f Text)
-> InputSwitchScheduleActionSettings
-> f InputSwitchScheduleActionSettings
inputSwitchScheduleActionSettings_inputAttachmentNameReference = (InputSwitchScheduleActionSettings -> Text)
-> (InputSwitchScheduleActionSettings
    -> Text -> InputSwitchScheduleActionSettings)
-> Lens
     InputSwitchScheduleActionSettings
     InputSwitchScheduleActionSettings
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSwitchScheduleActionSettings' {Text
inputAttachmentNameReference :: Text
$sel:inputAttachmentNameReference:InputSwitchScheduleActionSettings' :: InputSwitchScheduleActionSettings -> Text
inputAttachmentNameReference} -> Text
inputAttachmentNameReference) (\s :: InputSwitchScheduleActionSettings
s@InputSwitchScheduleActionSettings' {} Text
a -> InputSwitchScheduleActionSettings
s {$sel:inputAttachmentNameReference:InputSwitchScheduleActionSettings' :: Text
inputAttachmentNameReference = Text
a} :: InputSwitchScheduleActionSettings)

instance
  Core.FromJSON
    InputSwitchScheduleActionSettings
  where
  parseJSON :: Value -> Parser InputSwitchScheduleActionSettings
parseJSON =
    String
-> (Object -> Parser InputSwitchScheduleActionSettings)
-> Value
-> Parser InputSwitchScheduleActionSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputSwitchScheduleActionSettings"
      ( \Object
x ->
          Maybe InputClippingSettings
-> Maybe [Text] -> Text -> InputSwitchScheduleActionSettings
InputSwitchScheduleActionSettings'
            (Maybe InputClippingSettings
 -> Maybe [Text] -> Text -> InputSwitchScheduleActionSettings)
-> Parser (Maybe InputClippingSettings)
-> Parser
     (Maybe [Text] -> Text -> InputSwitchScheduleActionSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe InputClippingSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inputClippingSettings")
            Parser (Maybe [Text] -> Text -> InputSwitchScheduleActionSettings)
-> Parser (Maybe [Text])
-> Parser (Text -> InputSwitchScheduleActionSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"urlPath" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> InputSwitchScheduleActionSettings)
-> Parser Text -> Parser InputSwitchScheduleActionSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"inputAttachmentNameReference")
      )

instance
  Prelude.Hashable
    InputSwitchScheduleActionSettings

instance
  Prelude.NFData
    InputSwitchScheduleActionSettings

instance
  Core.ToJSON
    InputSwitchScheduleActionSettings
  where
  toJSON :: InputSwitchScheduleActionSettings -> Value
toJSON InputSwitchScheduleActionSettings' {Maybe [Text]
Maybe InputClippingSettings
Text
inputAttachmentNameReference :: Text
urlPath :: Maybe [Text]
inputClippingSettings :: Maybe InputClippingSettings
$sel:inputAttachmentNameReference:InputSwitchScheduleActionSettings' :: InputSwitchScheduleActionSettings -> Text
$sel:urlPath:InputSwitchScheduleActionSettings' :: InputSwitchScheduleActionSettings -> Maybe [Text]
$sel:inputClippingSettings:InputSwitchScheduleActionSettings' :: InputSwitchScheduleActionSettings -> Maybe InputClippingSettings
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"inputClippingSettings" Text -> InputClippingSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (InputClippingSettings -> Pair)
-> Maybe InputClippingSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputClippingSettings
inputClippingSettings,
            (Text
"urlPath" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
urlPath,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"inputAttachmentNameReference"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
inputAttachmentNameReference
              )
          ]
      )