{-# 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.InputAttachment
-- 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.InputAttachment where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.AutomaticInputFailoverSettings
import Amazonka.MediaLive.Types.InputSettings
import qualified Amazonka.Prelude as Prelude

-- | Placeholder documentation for InputAttachment
--
-- /See:/ 'newInputAttachment' smart constructor.
data InputAttachment = InputAttachment'
  { -- | User-specified name for the attachment. This is required if the user
    -- wants to use this input in an input switch action.
    InputAttachment -> Maybe Text
inputAttachmentName :: Prelude.Maybe Prelude.Text,
    -- | The ID of the input
    InputAttachment -> Maybe Text
inputId :: Prelude.Maybe Prelude.Text,
    -- | User-specified settings for defining what the conditions are for
    -- declaring the input unhealthy and failing over to a different input.
    InputAttachment -> Maybe AutomaticInputFailoverSettings
automaticInputFailoverSettings :: Prelude.Maybe AutomaticInputFailoverSettings,
    -- | Settings of an input (caption selector, etc.)
    InputAttachment -> Maybe InputSettings
inputSettings :: Prelude.Maybe InputSettings
  }
  deriving (InputAttachment -> InputAttachment -> Bool
(InputAttachment -> InputAttachment -> Bool)
-> (InputAttachment -> InputAttachment -> Bool)
-> Eq InputAttachment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputAttachment -> InputAttachment -> Bool
$c/= :: InputAttachment -> InputAttachment -> Bool
== :: InputAttachment -> InputAttachment -> Bool
$c== :: InputAttachment -> InputAttachment -> Bool
Prelude.Eq, ReadPrec [InputAttachment]
ReadPrec InputAttachment
Int -> ReadS InputAttachment
ReadS [InputAttachment]
(Int -> ReadS InputAttachment)
-> ReadS [InputAttachment]
-> ReadPrec InputAttachment
-> ReadPrec [InputAttachment]
-> Read InputAttachment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputAttachment]
$creadListPrec :: ReadPrec [InputAttachment]
readPrec :: ReadPrec InputAttachment
$creadPrec :: ReadPrec InputAttachment
readList :: ReadS [InputAttachment]
$creadList :: ReadS [InputAttachment]
readsPrec :: Int -> ReadS InputAttachment
$creadsPrec :: Int -> ReadS InputAttachment
Prelude.Read, Int -> InputAttachment -> ShowS
[InputAttachment] -> ShowS
InputAttachment -> String
(Int -> InputAttachment -> ShowS)
-> (InputAttachment -> String)
-> ([InputAttachment] -> ShowS)
-> Show InputAttachment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputAttachment] -> ShowS
$cshowList :: [InputAttachment] -> ShowS
show :: InputAttachment -> String
$cshow :: InputAttachment -> String
showsPrec :: Int -> InputAttachment -> ShowS
$cshowsPrec :: Int -> InputAttachment -> ShowS
Prelude.Show, (forall x. InputAttachment -> Rep InputAttachment x)
-> (forall x. Rep InputAttachment x -> InputAttachment)
-> Generic InputAttachment
forall x. Rep InputAttachment x -> InputAttachment
forall x. InputAttachment -> Rep InputAttachment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputAttachment x -> InputAttachment
$cfrom :: forall x. InputAttachment -> Rep InputAttachment x
Prelude.Generic)

-- |
-- Create a value of 'InputAttachment' 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:
--
-- 'inputAttachmentName', 'inputAttachment_inputAttachmentName' - User-specified name for the attachment. This is required if the user
-- wants to use this input in an input switch action.
--
-- 'inputId', 'inputAttachment_inputId' - The ID of the input
--
-- 'automaticInputFailoverSettings', 'inputAttachment_automaticInputFailoverSettings' - User-specified settings for defining what the conditions are for
-- declaring the input unhealthy and failing over to a different input.
--
-- 'inputSettings', 'inputAttachment_inputSettings' - Settings of an input (caption selector, etc.)
newInputAttachment ::
  InputAttachment
newInputAttachment :: InputAttachment
newInputAttachment =
  InputAttachment' :: Maybe Text
-> Maybe Text
-> Maybe AutomaticInputFailoverSettings
-> Maybe InputSettings
-> InputAttachment
InputAttachment'
    { $sel:inputAttachmentName:InputAttachment' :: Maybe Text
inputAttachmentName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:inputId:InputAttachment' :: Maybe Text
inputId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:automaticInputFailoverSettings:InputAttachment' :: Maybe AutomaticInputFailoverSettings
automaticInputFailoverSettings = Maybe AutomaticInputFailoverSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:inputSettings:InputAttachment' :: Maybe InputSettings
inputSettings = Maybe InputSettings
forall a. Maybe a
Prelude.Nothing
    }

-- | User-specified name for the attachment. This is required if the user
-- wants to use this input in an input switch action.
inputAttachment_inputAttachmentName :: Lens.Lens' InputAttachment (Prelude.Maybe Prelude.Text)
inputAttachment_inputAttachmentName :: (Maybe Text -> f (Maybe Text))
-> InputAttachment -> f InputAttachment
inputAttachment_inputAttachmentName = (InputAttachment -> Maybe Text)
-> (InputAttachment -> Maybe Text -> InputAttachment)
-> Lens InputAttachment InputAttachment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputAttachment' {Maybe Text
inputAttachmentName :: Maybe Text
$sel:inputAttachmentName:InputAttachment' :: InputAttachment -> Maybe Text
inputAttachmentName} -> Maybe Text
inputAttachmentName) (\s :: InputAttachment
s@InputAttachment' {} Maybe Text
a -> InputAttachment
s {$sel:inputAttachmentName:InputAttachment' :: Maybe Text
inputAttachmentName = Maybe Text
a} :: InputAttachment)

-- | The ID of the input
inputAttachment_inputId :: Lens.Lens' InputAttachment (Prelude.Maybe Prelude.Text)
inputAttachment_inputId :: (Maybe Text -> f (Maybe Text))
-> InputAttachment -> f InputAttachment
inputAttachment_inputId = (InputAttachment -> Maybe Text)
-> (InputAttachment -> Maybe Text -> InputAttachment)
-> Lens InputAttachment InputAttachment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputAttachment' {Maybe Text
inputId :: Maybe Text
$sel:inputId:InputAttachment' :: InputAttachment -> Maybe Text
inputId} -> Maybe Text
inputId) (\s :: InputAttachment
s@InputAttachment' {} Maybe Text
a -> InputAttachment
s {$sel:inputId:InputAttachment' :: Maybe Text
inputId = Maybe Text
a} :: InputAttachment)

-- | User-specified settings for defining what the conditions are for
-- declaring the input unhealthy and failing over to a different input.
inputAttachment_automaticInputFailoverSettings :: Lens.Lens' InputAttachment (Prelude.Maybe AutomaticInputFailoverSettings)
inputAttachment_automaticInputFailoverSettings :: (Maybe AutomaticInputFailoverSettings
 -> f (Maybe AutomaticInputFailoverSettings))
-> InputAttachment -> f InputAttachment
inputAttachment_automaticInputFailoverSettings = (InputAttachment -> Maybe AutomaticInputFailoverSettings)
-> (InputAttachment
    -> Maybe AutomaticInputFailoverSettings -> InputAttachment)
-> Lens
     InputAttachment
     InputAttachment
     (Maybe AutomaticInputFailoverSettings)
     (Maybe AutomaticInputFailoverSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputAttachment' {Maybe AutomaticInputFailoverSettings
automaticInputFailoverSettings :: Maybe AutomaticInputFailoverSettings
$sel:automaticInputFailoverSettings:InputAttachment' :: InputAttachment -> Maybe AutomaticInputFailoverSettings
automaticInputFailoverSettings} -> Maybe AutomaticInputFailoverSettings
automaticInputFailoverSettings) (\s :: InputAttachment
s@InputAttachment' {} Maybe AutomaticInputFailoverSettings
a -> InputAttachment
s {$sel:automaticInputFailoverSettings:InputAttachment' :: Maybe AutomaticInputFailoverSettings
automaticInputFailoverSettings = Maybe AutomaticInputFailoverSettings
a} :: InputAttachment)

-- | Settings of an input (caption selector, etc.)
inputAttachment_inputSettings :: Lens.Lens' InputAttachment (Prelude.Maybe InputSettings)
inputAttachment_inputSettings :: (Maybe InputSettings -> f (Maybe InputSettings))
-> InputAttachment -> f InputAttachment
inputAttachment_inputSettings = (InputAttachment -> Maybe InputSettings)
-> (InputAttachment -> Maybe InputSettings -> InputAttachment)
-> Lens
     InputAttachment
     InputAttachment
     (Maybe InputSettings)
     (Maybe InputSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputAttachment' {Maybe InputSettings
inputSettings :: Maybe InputSettings
$sel:inputSettings:InputAttachment' :: InputAttachment -> Maybe InputSettings
inputSettings} -> Maybe InputSettings
inputSettings) (\s :: InputAttachment
s@InputAttachment' {} Maybe InputSettings
a -> InputAttachment
s {$sel:inputSettings:InputAttachment' :: Maybe InputSettings
inputSettings = Maybe InputSettings
a} :: InputAttachment)

instance Core.FromJSON InputAttachment where
  parseJSON :: Value -> Parser InputAttachment
parseJSON =
    String
-> (Object -> Parser InputAttachment)
-> Value
-> Parser InputAttachment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputAttachment"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe AutomaticInputFailoverSettings
-> Maybe InputSettings
-> InputAttachment
InputAttachment'
            (Maybe Text
 -> Maybe Text
 -> Maybe AutomaticInputFailoverSettings
 -> Maybe InputSettings
 -> InputAttachment)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe AutomaticInputFailoverSettings
      -> Maybe InputSettings
      -> InputAttachment)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inputAttachmentName")
            Parser
  (Maybe Text
   -> Maybe AutomaticInputFailoverSettings
   -> Maybe InputSettings
   -> InputAttachment)
-> Parser (Maybe Text)
-> Parser
     (Maybe AutomaticInputFailoverSettings
      -> Maybe InputSettings -> InputAttachment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inputId")
            Parser
  (Maybe AutomaticInputFailoverSettings
   -> Maybe InputSettings -> InputAttachment)
-> Parser (Maybe AutomaticInputFailoverSettings)
-> Parser (Maybe InputSettings -> InputAttachment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AutomaticInputFailoverSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"automaticInputFailoverSettings")
            Parser (Maybe InputSettings -> InputAttachment)
-> Parser (Maybe InputSettings) -> Parser InputAttachment
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InputSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inputSettings")
      )

instance Prelude.Hashable InputAttachment

instance Prelude.NFData InputAttachment

instance Core.ToJSON InputAttachment where
  toJSON :: InputAttachment -> Value
toJSON InputAttachment' {Maybe Text
Maybe AutomaticInputFailoverSettings
Maybe InputSettings
inputSettings :: Maybe InputSettings
automaticInputFailoverSettings :: Maybe AutomaticInputFailoverSettings
inputId :: Maybe Text
inputAttachmentName :: Maybe Text
$sel:inputSettings:InputAttachment' :: InputAttachment -> Maybe InputSettings
$sel:automaticInputFailoverSettings:InputAttachment' :: InputAttachment -> Maybe AutomaticInputFailoverSettings
$sel:inputId:InputAttachment' :: InputAttachment -> Maybe Text
$sel:inputAttachmentName:InputAttachment' :: InputAttachment -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"inputAttachmentName" 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
inputAttachmentName,
            (Text
"inputId" 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
inputId,
            (Text
"automaticInputFailoverSettings" Text -> AutomaticInputFailoverSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AutomaticInputFailoverSettings -> Pair)
-> Maybe AutomaticInputFailoverSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AutomaticInputFailoverSettings
automaticInputFailoverSettings,
            (Text
"inputSettings" Text -> InputSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (InputSettings -> Pair) -> Maybe InputSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputSettings
inputSettings
          ]
      )