{-# 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.AvailConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaLive.Types.AvailConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaLive.Types.AvailSettings
import qualified Amazonka.Prelude as Prelude

-- | Avail Configuration
--
-- /See:/ 'newAvailConfiguration' smart constructor.
data AvailConfiguration = AvailConfiguration'
  { -- | Ad avail settings.
    AvailConfiguration -> Maybe AvailSettings
availSettings :: Prelude.Maybe AvailSettings
  }
  deriving (AvailConfiguration -> AvailConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AvailConfiguration -> AvailConfiguration -> Bool
$c/= :: AvailConfiguration -> AvailConfiguration -> Bool
== :: AvailConfiguration -> AvailConfiguration -> Bool
$c== :: AvailConfiguration -> AvailConfiguration -> Bool
Prelude.Eq, ReadPrec [AvailConfiguration]
ReadPrec AvailConfiguration
Int -> ReadS AvailConfiguration
ReadS [AvailConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AvailConfiguration]
$creadListPrec :: ReadPrec [AvailConfiguration]
readPrec :: ReadPrec AvailConfiguration
$creadPrec :: ReadPrec AvailConfiguration
readList :: ReadS [AvailConfiguration]
$creadList :: ReadS [AvailConfiguration]
readsPrec :: Int -> ReadS AvailConfiguration
$creadsPrec :: Int -> ReadS AvailConfiguration
Prelude.Read, Int -> AvailConfiguration -> ShowS
[AvailConfiguration] -> ShowS
AvailConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AvailConfiguration] -> ShowS
$cshowList :: [AvailConfiguration] -> ShowS
show :: AvailConfiguration -> String
$cshow :: AvailConfiguration -> String
showsPrec :: Int -> AvailConfiguration -> ShowS
$cshowsPrec :: Int -> AvailConfiguration -> ShowS
Prelude.Show, forall x. Rep AvailConfiguration x -> AvailConfiguration
forall x. AvailConfiguration -> Rep AvailConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AvailConfiguration x -> AvailConfiguration
$cfrom :: forall x. AvailConfiguration -> Rep AvailConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'AvailConfiguration' 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:
--
-- 'availSettings', 'availConfiguration_availSettings' - Ad avail settings.
newAvailConfiguration ::
  AvailConfiguration
newAvailConfiguration :: AvailConfiguration
newAvailConfiguration =
  AvailConfiguration'
    { $sel:availSettings:AvailConfiguration' :: Maybe AvailSettings
availSettings =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Ad avail settings.
availConfiguration_availSettings :: Lens.Lens' AvailConfiguration (Prelude.Maybe AvailSettings)
availConfiguration_availSettings :: Lens' AvailConfiguration (Maybe AvailSettings)
availConfiguration_availSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AvailConfiguration' {Maybe AvailSettings
availSettings :: Maybe AvailSettings
$sel:availSettings:AvailConfiguration' :: AvailConfiguration -> Maybe AvailSettings
availSettings} -> Maybe AvailSettings
availSettings) (\s :: AvailConfiguration
s@AvailConfiguration' {} Maybe AvailSettings
a -> AvailConfiguration
s {$sel:availSettings:AvailConfiguration' :: Maybe AvailSettings
availSettings = Maybe AvailSettings
a} :: AvailConfiguration)

instance Data.FromJSON AvailConfiguration where
  parseJSON :: Value -> Parser AvailConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AvailConfiguration"
      ( \Object
x ->
          Maybe AvailSettings -> AvailConfiguration
AvailConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"availSettings")
      )

instance Prelude.Hashable AvailConfiguration where
  hashWithSalt :: Int -> AvailConfiguration -> Int
hashWithSalt Int
_salt AvailConfiguration' {Maybe AvailSettings
availSettings :: Maybe AvailSettings
$sel:availSettings:AvailConfiguration' :: AvailConfiguration -> Maybe AvailSettings
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AvailSettings
availSettings

instance Prelude.NFData AvailConfiguration where
  rnf :: AvailConfiguration -> ()
rnf AvailConfiguration' {Maybe AvailSettings
availSettings :: Maybe AvailSettings
$sel:availSettings:AvailConfiguration' :: AvailConfiguration -> Maybe AvailSettings
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AvailSettings
availSettings

instance Data.ToJSON AvailConfiguration where
  toJSON :: AvailConfiguration -> Value
toJSON AvailConfiguration' {Maybe AvailSettings
availSettings :: Maybe AvailSettings
$sel:availSettings:AvailConfiguration' :: AvailConfiguration -> Maybe AvailSettings
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"availSettings" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AvailSettings
availSettings
          ]
      )