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

-- | 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
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]
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
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. 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'
    { $sel:repInterval:DvbNitSettings' :: Maybe Natural
repInterval = 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 :: Lens' DvbNitSettings (Maybe Natural)
dvbNitSettings_repInterval = 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 :: Lens' DvbNitSettings Text
dvbNitSettings_networkName = 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 :: Lens' DvbNitSettings Natural
dvbNitSettings_networkId = 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 Data.FromJSON DvbNitSettings where
  parseJSON :: Value -> Parser DvbNitSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DvbNitSettings"
      ( \Object
x ->
          Maybe Natural -> Text -> Natural -> DvbNitSettings
DvbNitSettings'
            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
"repInterval")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"networkName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"networkId")
      )

instance Prelude.Hashable DvbNitSettings where
  hashWithSalt :: Int -> DvbNitSettings -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
repInterval
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
networkName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
networkId

instance Prelude.NFData DvbNitSettings where
  rnf :: DvbNitSettings -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
repInterval
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
networkName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
networkId

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"repInterval" 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
repInterval,
            forall a. a -> Maybe a
Prelude.Just (Key
"networkName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
networkName),
            forall a. a -> Maybe a
Prelude.Just (Key
"networkId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
networkId)
          ]
      )