{-# 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.KinesisVideo.Types.SingleMasterConfiguration
-- 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.KinesisVideo.Types.SingleMasterConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A structure that contains the configuration for the @SINGLE_MASTER@
-- channel type.
--
-- /See:/ 'newSingleMasterConfiguration' smart constructor.
data SingleMasterConfiguration = SingleMasterConfiguration'
  { -- | The period of time a signaling channel retains undelivered messages
    -- before they are discarded.
    SingleMasterConfiguration -> Maybe Natural
messageTtlSeconds :: Prelude.Maybe Prelude.Natural
  }
  deriving (SingleMasterConfiguration -> SingleMasterConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SingleMasterConfiguration -> SingleMasterConfiguration -> Bool
$c/= :: SingleMasterConfiguration -> SingleMasterConfiguration -> Bool
== :: SingleMasterConfiguration -> SingleMasterConfiguration -> Bool
$c== :: SingleMasterConfiguration -> SingleMasterConfiguration -> Bool
Prelude.Eq, ReadPrec [SingleMasterConfiguration]
ReadPrec SingleMasterConfiguration
Int -> ReadS SingleMasterConfiguration
ReadS [SingleMasterConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SingleMasterConfiguration]
$creadListPrec :: ReadPrec [SingleMasterConfiguration]
readPrec :: ReadPrec SingleMasterConfiguration
$creadPrec :: ReadPrec SingleMasterConfiguration
readList :: ReadS [SingleMasterConfiguration]
$creadList :: ReadS [SingleMasterConfiguration]
readsPrec :: Int -> ReadS SingleMasterConfiguration
$creadsPrec :: Int -> ReadS SingleMasterConfiguration
Prelude.Read, Int -> SingleMasterConfiguration -> ShowS
[SingleMasterConfiguration] -> ShowS
SingleMasterConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SingleMasterConfiguration] -> ShowS
$cshowList :: [SingleMasterConfiguration] -> ShowS
show :: SingleMasterConfiguration -> String
$cshow :: SingleMasterConfiguration -> String
showsPrec :: Int -> SingleMasterConfiguration -> ShowS
$cshowsPrec :: Int -> SingleMasterConfiguration -> ShowS
Prelude.Show, forall x.
Rep SingleMasterConfiguration x -> SingleMasterConfiguration
forall x.
SingleMasterConfiguration -> Rep SingleMasterConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SingleMasterConfiguration x -> SingleMasterConfiguration
$cfrom :: forall x.
SingleMasterConfiguration -> Rep SingleMasterConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SingleMasterConfiguration' 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:
--
-- 'messageTtlSeconds', 'singleMasterConfiguration_messageTtlSeconds' - The period of time a signaling channel retains undelivered messages
-- before they are discarded.
newSingleMasterConfiguration ::
  SingleMasterConfiguration
newSingleMasterConfiguration :: SingleMasterConfiguration
newSingleMasterConfiguration =
  SingleMasterConfiguration'
    { $sel:messageTtlSeconds:SingleMasterConfiguration' :: Maybe Natural
messageTtlSeconds =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The period of time a signaling channel retains undelivered messages
-- before they are discarded.
singleMasterConfiguration_messageTtlSeconds :: Lens.Lens' SingleMasterConfiguration (Prelude.Maybe Prelude.Natural)
singleMasterConfiguration_messageTtlSeconds :: Lens' SingleMasterConfiguration (Maybe Natural)
singleMasterConfiguration_messageTtlSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SingleMasterConfiguration' {Maybe Natural
messageTtlSeconds :: Maybe Natural
$sel:messageTtlSeconds:SingleMasterConfiguration' :: SingleMasterConfiguration -> Maybe Natural
messageTtlSeconds} -> Maybe Natural
messageTtlSeconds) (\s :: SingleMasterConfiguration
s@SingleMasterConfiguration' {} Maybe Natural
a -> SingleMasterConfiguration
s {$sel:messageTtlSeconds:SingleMasterConfiguration' :: Maybe Natural
messageTtlSeconds = Maybe Natural
a} :: SingleMasterConfiguration)

instance Data.FromJSON SingleMasterConfiguration where
  parseJSON :: Value -> Parser SingleMasterConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SingleMasterConfiguration"
      ( \Object
x ->
          Maybe Natural -> SingleMasterConfiguration
SingleMasterConfiguration'
            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
"MessageTtlSeconds")
      )

instance Prelude.Hashable SingleMasterConfiguration where
  hashWithSalt :: Int -> SingleMasterConfiguration -> Int
hashWithSalt Int
_salt SingleMasterConfiguration' {Maybe Natural
messageTtlSeconds :: Maybe Natural
$sel:messageTtlSeconds:SingleMasterConfiguration' :: SingleMasterConfiguration -> Maybe Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
messageTtlSeconds

instance Prelude.NFData SingleMasterConfiguration where
  rnf :: SingleMasterConfiguration -> ()
rnf SingleMasterConfiguration' {Maybe Natural
messageTtlSeconds :: Maybe Natural
$sel:messageTtlSeconds:SingleMasterConfiguration' :: SingleMasterConfiguration -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
messageTtlSeconds

instance Data.ToJSON SingleMasterConfiguration where
  toJSON :: SingleMasterConfiguration -> Value
toJSON SingleMasterConfiguration' {Maybe Natural
messageTtlSeconds :: Maybe Natural
$sel:messageTtlSeconds:SingleMasterConfiguration' :: SingleMasterConfiguration -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MessageTtlSeconds" 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 Natural
messageTtlSeconds
          ]
      )