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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 underlivered messages
    -- before they are discarded.
    SingleMasterConfiguration -> Maybe Natural
messageTtlSeconds :: Prelude.Maybe Prelude.Natural
  }
  deriving (SingleMasterConfiguration -> SingleMasterConfiguration -> Bool
(SingleMasterConfiguration -> SingleMasterConfiguration -> Bool)
-> (SingleMasterConfiguration -> SingleMasterConfiguration -> Bool)
-> Eq SingleMasterConfiguration
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]
(Int -> ReadS SingleMasterConfiguration)
-> ReadS [SingleMasterConfiguration]
-> ReadPrec SingleMasterConfiguration
-> ReadPrec [SingleMasterConfiguration]
-> Read 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
(Int -> SingleMasterConfiguration -> ShowS)
-> (SingleMasterConfiguration -> String)
-> ([SingleMasterConfiguration] -> ShowS)
-> Show SingleMasterConfiguration
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.
 SingleMasterConfiguration -> Rep SingleMasterConfiguration x)
-> (forall x.
    Rep SingleMasterConfiguration x -> SingleMasterConfiguration)
-> Generic SingleMasterConfiguration
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 underlivered messages
-- before they are discarded.
newSingleMasterConfiguration ::
  SingleMasterConfiguration
newSingleMasterConfiguration :: SingleMasterConfiguration
newSingleMasterConfiguration =
  SingleMasterConfiguration' :: Maybe Natural -> SingleMasterConfiguration
SingleMasterConfiguration'
    { $sel:messageTtlSeconds:SingleMasterConfiguration' :: Maybe Natural
messageTtlSeconds =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The period of time a signaling channel retains underlivered messages
-- before they are discarded.
singleMasterConfiguration_messageTtlSeconds :: Lens.Lens' SingleMasterConfiguration (Prelude.Maybe Prelude.Natural)
singleMasterConfiguration_messageTtlSeconds :: (Maybe Natural -> f (Maybe Natural))
-> SingleMasterConfiguration -> f SingleMasterConfiguration
singleMasterConfiguration_messageTtlSeconds = (SingleMasterConfiguration -> Maybe Natural)
-> (SingleMasterConfiguration
    -> Maybe Natural -> SingleMasterConfiguration)
-> Lens
     SingleMasterConfiguration
     SingleMasterConfiguration
     (Maybe Natural)
     (Maybe Natural)
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 Core.FromJSON SingleMasterConfiguration where
  parseJSON :: Value -> Parser SingleMasterConfiguration
parseJSON =
    String
-> (Object -> Parser SingleMasterConfiguration)
-> Value
-> Parser SingleMasterConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SingleMasterConfiguration"
      ( \Object
x ->
          Maybe Natural -> SingleMasterConfiguration
SingleMasterConfiguration'
            (Maybe Natural -> SingleMasterConfiguration)
-> Parser (Maybe Natural) -> Parser SingleMasterConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MessageTtlSeconds")
      )

instance Prelude.Hashable SingleMasterConfiguration

instance Prelude.NFData SingleMasterConfiguration

instance Core.ToJSON SingleMasterConfiguration where
  toJSON :: SingleMasterConfiguration -> Value
toJSON SingleMasterConfiguration' {Maybe Natural
messageTtlSeconds :: Maybe Natural
$sel:messageTtlSeconds:SingleMasterConfiguration' :: SingleMasterConfiguration -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MessageTtlSeconds" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
messageTtlSeconds
          ]
      )