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

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

-- | DVB Network Information Table (NIT)
--
-- /See:/ 'newDvbNitSettings' smart constructor.
data DvbNitSettings = DvbNitSettings'
  { -- | The number of milliseconds between instances of this table in the output
    -- transport stream.
    DvbNitSettings -> Maybe Natural
repInterval :: Prelude.Maybe Prelude.Natural,
    -- | The network name text placed in the networkNameDescriptor inside the
    -- Network Information Table. Maximum length is 256 characters.
    DvbNitSettings -> Text
networkName :: Prelude.Text,
    -- | The numeric value placed in the Network Information Table (NIT).
    DvbNitSettings -> Natural
networkId :: Prelude.Natural
  }
  deriving (DvbNitSettings -> DvbNitSettings -> Bool
(DvbNitSettings -> DvbNitSettings -> Bool)
-> (DvbNitSettings -> DvbNitSettings -> Bool) -> Eq DvbNitSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DvbNitSettings -> DvbNitSettings -> Bool
$c/= :: DvbNitSettings -> DvbNitSettings -> Bool
== :: DvbNitSettings -> DvbNitSettings -> Bool
$c== :: DvbNitSettings -> DvbNitSettings -> Bool
Prelude.Eq, ReadPrec [DvbNitSettings]
ReadPrec DvbNitSettings
Int -> ReadS DvbNitSettings
ReadS [DvbNitSettings]
(Int -> ReadS DvbNitSettings)
-> ReadS [DvbNitSettings]
-> ReadPrec DvbNitSettings
-> ReadPrec [DvbNitSettings]
-> Read DvbNitSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DvbNitSettings]
$creadListPrec :: ReadPrec [DvbNitSettings]
readPrec :: ReadPrec DvbNitSettings
$creadPrec :: ReadPrec DvbNitSettings
readList :: ReadS [DvbNitSettings]
$creadList :: ReadS [DvbNitSettings]
readsPrec :: Int -> ReadS DvbNitSettings
$creadsPrec :: Int -> ReadS DvbNitSettings
Prelude.Read, Int -> DvbNitSettings -> ShowS
[DvbNitSettings] -> ShowS
DvbNitSettings -> String
(Int -> DvbNitSettings -> ShowS)
-> (DvbNitSettings -> String)
-> ([DvbNitSettings] -> ShowS)
-> Show DvbNitSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DvbNitSettings] -> ShowS
$cshowList :: [DvbNitSettings] -> ShowS
show :: DvbNitSettings -> String
$cshow :: DvbNitSettings -> String
showsPrec :: Int -> DvbNitSettings -> ShowS
$cshowsPrec :: Int -> DvbNitSettings -> ShowS
Prelude.Show, (forall x. DvbNitSettings -> Rep DvbNitSettings x)
-> (forall x. Rep DvbNitSettings x -> DvbNitSettings)
-> Generic DvbNitSettings
forall x. Rep DvbNitSettings x -> DvbNitSettings
forall x. DvbNitSettings -> Rep DvbNitSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DvbNitSettings x -> DvbNitSettings
$cfrom :: forall x. DvbNitSettings -> Rep DvbNitSettings x
Prelude.Generic)

-- |
-- Create a value of 'DvbNitSettings' 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:
--
-- 'repInterval', 'dvbNitSettings_repInterval' - The number of milliseconds between instances of this table in the output
-- transport stream.
--
-- 'networkName', 'dvbNitSettings_networkName' - The network name text placed in the networkNameDescriptor inside the
-- Network Information Table. Maximum length is 256 characters.
--
-- 'networkId', 'dvbNitSettings_networkId' - The numeric value placed in the Network Information Table (NIT).
newDvbNitSettings ::
  -- | 'networkName'
  Prelude.Text ->
  -- | 'networkId'
  Prelude.Natural ->
  DvbNitSettings
newDvbNitSettings :: Text -> Natural -> DvbNitSettings
newDvbNitSettings Text
pNetworkName_ Natural
pNetworkId_ =
  DvbNitSettings' :: Maybe Natural -> Text -> Natural -> DvbNitSettings
DvbNitSettings'
    { $sel:repInterval:DvbNitSettings' :: Maybe Natural
repInterval = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:networkName:DvbNitSettings' :: Text
networkName = Text
pNetworkName_,
      $sel:networkId:DvbNitSettings' :: Natural
networkId = Natural
pNetworkId_
    }

-- | The number of milliseconds between instances of this table in the output
-- transport stream.
dvbNitSettings_repInterval :: Lens.Lens' DvbNitSettings (Prelude.Maybe Prelude.Natural)
dvbNitSettings_repInterval :: (Maybe Natural -> f (Maybe Natural))
-> DvbNitSettings -> f DvbNitSettings
dvbNitSettings_repInterval = (DvbNitSettings -> Maybe Natural)
-> (DvbNitSettings -> Maybe Natural -> DvbNitSettings)
-> Lens
     DvbNitSettings DvbNitSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DvbNitSettings' {Maybe Natural
repInterval :: Maybe Natural
$sel:repInterval:DvbNitSettings' :: DvbNitSettings -> Maybe Natural
repInterval} -> Maybe Natural
repInterval) (\s :: DvbNitSettings
s@DvbNitSettings' {} Maybe Natural
a -> DvbNitSettings
s {$sel:repInterval:DvbNitSettings' :: Maybe Natural
repInterval = Maybe Natural
a} :: DvbNitSettings)

-- | The network name text placed in the networkNameDescriptor inside the
-- Network Information Table. Maximum length is 256 characters.
dvbNitSettings_networkName :: Lens.Lens' DvbNitSettings Prelude.Text
dvbNitSettings_networkName :: (Text -> f Text) -> DvbNitSettings -> f DvbNitSettings
dvbNitSettings_networkName = (DvbNitSettings -> Text)
-> (DvbNitSettings -> Text -> DvbNitSettings)
-> Lens DvbNitSettings DvbNitSettings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DvbNitSettings' {Text
networkName :: Text
$sel:networkName:DvbNitSettings' :: DvbNitSettings -> Text
networkName} -> Text
networkName) (\s :: DvbNitSettings
s@DvbNitSettings' {} Text
a -> DvbNitSettings
s {$sel:networkName:DvbNitSettings' :: Text
networkName = Text
a} :: DvbNitSettings)

-- | The numeric value placed in the Network Information Table (NIT).
dvbNitSettings_networkId :: Lens.Lens' DvbNitSettings Prelude.Natural
dvbNitSettings_networkId :: (Natural -> f Natural) -> DvbNitSettings -> f DvbNitSettings
dvbNitSettings_networkId = (DvbNitSettings -> Natural)
-> (DvbNitSettings -> Natural -> DvbNitSettings)
-> Lens DvbNitSettings DvbNitSettings Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DvbNitSettings' {Natural
networkId :: Natural
$sel:networkId:DvbNitSettings' :: DvbNitSettings -> Natural
networkId} -> Natural
networkId) (\s :: DvbNitSettings
s@DvbNitSettings' {} Natural
a -> DvbNitSettings
s {$sel:networkId:DvbNitSettings' :: Natural
networkId = Natural
a} :: DvbNitSettings)

instance Core.FromJSON DvbNitSettings where
  parseJSON :: Value -> Parser DvbNitSettings
parseJSON =
    String
-> (Object -> Parser DvbNitSettings)
-> Value
-> Parser DvbNitSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DvbNitSettings"
      ( \Object
x ->
          Maybe Natural -> Text -> Natural -> DvbNitSettings
DvbNitSettings'
            (Maybe Natural -> Text -> Natural -> DvbNitSettings)
-> Parser (Maybe Natural)
-> Parser (Text -> Natural -> DvbNitSettings)
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
"repInterval")
            Parser (Text -> Natural -> DvbNitSettings)
-> Parser Text -> Parser (Natural -> DvbNitSettings)
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
"networkName")
            Parser (Natural -> DvbNitSettings)
-> Parser Natural -> Parser DvbNitSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"networkId")
      )

instance Prelude.Hashable DvbNitSettings

instance Prelude.NFData DvbNitSettings

instance Core.ToJSON DvbNitSettings where
  toJSON :: DvbNitSettings -> Value
toJSON DvbNitSettings' {Natural
Maybe Natural
Text
networkId :: Natural
networkName :: Text
repInterval :: Maybe Natural
$sel:networkId:DvbNitSettings' :: DvbNitSettings -> Natural
$sel:networkName:DvbNitSettings' :: DvbNitSettings -> Text
$sel:repInterval:DvbNitSettings' :: DvbNitSettings -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"repInterval" 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
repInterval,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"networkName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
networkName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"networkId" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
networkId)
          ]
      )