{-# 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.RtmpOutputSettings
-- 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.RtmpOutputSettings 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.OutputLocationRef
import Amazonka.MediaLive.Types.RtmpOutputCertificateMode
import qualified Amazonka.Prelude as Prelude

-- | Rtmp Output Settings
--
-- /See:/ 'newRtmpOutputSettings' smart constructor.
data RtmpOutputSettings = RtmpOutputSettings'
  { -- | If set to verifyAuthenticity, verify the tls certificate chain to a
    -- trusted Certificate Authority (CA). This will cause rtmps outputs with
    -- self-signed certificates to fail.
    RtmpOutputSettings -> Maybe RtmpOutputCertificateMode
certificateMode :: Prelude.Maybe RtmpOutputCertificateMode,
    -- | Number of seconds to wait before retrying a connection to the Flash
    -- Media server if the connection is lost.
    RtmpOutputSettings -> Maybe Natural
connectionRetryInterval :: Prelude.Maybe Prelude.Natural,
    -- | Number of retry attempts.
    RtmpOutputSettings -> Maybe Natural
numRetries :: Prelude.Maybe Prelude.Natural,
    -- | The RTMP endpoint excluding the stream name (eg.
    -- rtmp:\/\/host\/appname). For connection to Akamai, a username and
    -- password must be supplied. URI fields accept format identifiers.
    RtmpOutputSettings -> OutputLocationRef
destination :: OutputLocationRef
  }
  deriving (RtmpOutputSettings -> RtmpOutputSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RtmpOutputSettings -> RtmpOutputSettings -> Bool
$c/= :: RtmpOutputSettings -> RtmpOutputSettings -> Bool
== :: RtmpOutputSettings -> RtmpOutputSettings -> Bool
$c== :: RtmpOutputSettings -> RtmpOutputSettings -> Bool
Prelude.Eq, ReadPrec [RtmpOutputSettings]
ReadPrec RtmpOutputSettings
Int -> ReadS RtmpOutputSettings
ReadS [RtmpOutputSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RtmpOutputSettings]
$creadListPrec :: ReadPrec [RtmpOutputSettings]
readPrec :: ReadPrec RtmpOutputSettings
$creadPrec :: ReadPrec RtmpOutputSettings
readList :: ReadS [RtmpOutputSettings]
$creadList :: ReadS [RtmpOutputSettings]
readsPrec :: Int -> ReadS RtmpOutputSettings
$creadsPrec :: Int -> ReadS RtmpOutputSettings
Prelude.Read, Int -> RtmpOutputSettings -> ShowS
[RtmpOutputSettings] -> ShowS
RtmpOutputSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RtmpOutputSettings] -> ShowS
$cshowList :: [RtmpOutputSettings] -> ShowS
show :: RtmpOutputSettings -> String
$cshow :: RtmpOutputSettings -> String
showsPrec :: Int -> RtmpOutputSettings -> ShowS
$cshowsPrec :: Int -> RtmpOutputSettings -> ShowS
Prelude.Show, forall x. Rep RtmpOutputSettings x -> RtmpOutputSettings
forall x. RtmpOutputSettings -> Rep RtmpOutputSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RtmpOutputSettings x -> RtmpOutputSettings
$cfrom :: forall x. RtmpOutputSettings -> Rep RtmpOutputSettings x
Prelude.Generic)

-- |
-- Create a value of 'RtmpOutputSettings' 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:
--
-- 'certificateMode', 'rtmpOutputSettings_certificateMode' - If set to verifyAuthenticity, verify the tls certificate chain to a
-- trusted Certificate Authority (CA). This will cause rtmps outputs with
-- self-signed certificates to fail.
--
-- 'connectionRetryInterval', 'rtmpOutputSettings_connectionRetryInterval' - Number of seconds to wait before retrying a connection to the Flash
-- Media server if the connection is lost.
--
-- 'numRetries', 'rtmpOutputSettings_numRetries' - Number of retry attempts.
--
-- 'destination', 'rtmpOutputSettings_destination' - The RTMP endpoint excluding the stream name (eg.
-- rtmp:\/\/host\/appname). For connection to Akamai, a username and
-- password must be supplied. URI fields accept format identifiers.
newRtmpOutputSettings ::
  -- | 'destination'
  OutputLocationRef ->
  RtmpOutputSettings
newRtmpOutputSettings :: OutputLocationRef -> RtmpOutputSettings
newRtmpOutputSettings OutputLocationRef
pDestination_ =
  RtmpOutputSettings'
    { $sel:certificateMode:RtmpOutputSettings' :: Maybe RtmpOutputCertificateMode
certificateMode =
        forall a. Maybe a
Prelude.Nothing,
      $sel:connectionRetryInterval:RtmpOutputSettings' :: Maybe Natural
connectionRetryInterval = forall a. Maybe a
Prelude.Nothing,
      $sel:numRetries:RtmpOutputSettings' :: Maybe Natural
numRetries = forall a. Maybe a
Prelude.Nothing,
      $sel:destination:RtmpOutputSettings' :: OutputLocationRef
destination = OutputLocationRef
pDestination_
    }

-- | If set to verifyAuthenticity, verify the tls certificate chain to a
-- trusted Certificate Authority (CA). This will cause rtmps outputs with
-- self-signed certificates to fail.
rtmpOutputSettings_certificateMode :: Lens.Lens' RtmpOutputSettings (Prelude.Maybe RtmpOutputCertificateMode)
rtmpOutputSettings_certificateMode :: Lens' RtmpOutputSettings (Maybe RtmpOutputCertificateMode)
rtmpOutputSettings_certificateMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RtmpOutputSettings' {Maybe RtmpOutputCertificateMode
certificateMode :: Maybe RtmpOutputCertificateMode
$sel:certificateMode:RtmpOutputSettings' :: RtmpOutputSettings -> Maybe RtmpOutputCertificateMode
certificateMode} -> Maybe RtmpOutputCertificateMode
certificateMode) (\s :: RtmpOutputSettings
s@RtmpOutputSettings' {} Maybe RtmpOutputCertificateMode
a -> RtmpOutputSettings
s {$sel:certificateMode:RtmpOutputSettings' :: Maybe RtmpOutputCertificateMode
certificateMode = Maybe RtmpOutputCertificateMode
a} :: RtmpOutputSettings)

-- | Number of seconds to wait before retrying a connection to the Flash
-- Media server if the connection is lost.
rtmpOutputSettings_connectionRetryInterval :: Lens.Lens' RtmpOutputSettings (Prelude.Maybe Prelude.Natural)
rtmpOutputSettings_connectionRetryInterval :: Lens' RtmpOutputSettings (Maybe Natural)
rtmpOutputSettings_connectionRetryInterval = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RtmpOutputSettings' {Maybe Natural
connectionRetryInterval :: Maybe Natural
$sel:connectionRetryInterval:RtmpOutputSettings' :: RtmpOutputSettings -> Maybe Natural
connectionRetryInterval} -> Maybe Natural
connectionRetryInterval) (\s :: RtmpOutputSettings
s@RtmpOutputSettings' {} Maybe Natural
a -> RtmpOutputSettings
s {$sel:connectionRetryInterval:RtmpOutputSettings' :: Maybe Natural
connectionRetryInterval = Maybe Natural
a} :: RtmpOutputSettings)

-- | Number of retry attempts.
rtmpOutputSettings_numRetries :: Lens.Lens' RtmpOutputSettings (Prelude.Maybe Prelude.Natural)
rtmpOutputSettings_numRetries :: Lens' RtmpOutputSettings (Maybe Natural)
rtmpOutputSettings_numRetries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RtmpOutputSettings' {Maybe Natural
numRetries :: Maybe Natural
$sel:numRetries:RtmpOutputSettings' :: RtmpOutputSettings -> Maybe Natural
numRetries} -> Maybe Natural
numRetries) (\s :: RtmpOutputSettings
s@RtmpOutputSettings' {} Maybe Natural
a -> RtmpOutputSettings
s {$sel:numRetries:RtmpOutputSettings' :: Maybe Natural
numRetries = Maybe Natural
a} :: RtmpOutputSettings)

-- | The RTMP endpoint excluding the stream name (eg.
-- rtmp:\/\/host\/appname). For connection to Akamai, a username and
-- password must be supplied. URI fields accept format identifiers.
rtmpOutputSettings_destination :: Lens.Lens' RtmpOutputSettings OutputLocationRef
rtmpOutputSettings_destination :: Lens' RtmpOutputSettings OutputLocationRef
rtmpOutputSettings_destination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RtmpOutputSettings' {OutputLocationRef
destination :: OutputLocationRef
$sel:destination:RtmpOutputSettings' :: RtmpOutputSettings -> OutputLocationRef
destination} -> OutputLocationRef
destination) (\s :: RtmpOutputSettings
s@RtmpOutputSettings' {} OutputLocationRef
a -> RtmpOutputSettings
s {$sel:destination:RtmpOutputSettings' :: OutputLocationRef
destination = OutputLocationRef
a} :: RtmpOutputSettings)

instance Data.FromJSON RtmpOutputSettings where
  parseJSON :: Value -> Parser RtmpOutputSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RtmpOutputSettings"
      ( \Object
x ->
          Maybe RtmpOutputCertificateMode
-> Maybe Natural
-> Maybe Natural
-> OutputLocationRef
-> RtmpOutputSettings
RtmpOutputSettings'
            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
"certificateMode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"connectionRetryInterval")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"numRetries")
            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
"destination")
      )

instance Prelude.Hashable RtmpOutputSettings where
  hashWithSalt :: Int -> RtmpOutputSettings -> Int
hashWithSalt Int
_salt RtmpOutputSettings' {Maybe Natural
Maybe RtmpOutputCertificateMode
OutputLocationRef
destination :: OutputLocationRef
numRetries :: Maybe Natural
connectionRetryInterval :: Maybe Natural
certificateMode :: Maybe RtmpOutputCertificateMode
$sel:destination:RtmpOutputSettings' :: RtmpOutputSettings -> OutputLocationRef
$sel:numRetries:RtmpOutputSettings' :: RtmpOutputSettings -> Maybe Natural
$sel:connectionRetryInterval:RtmpOutputSettings' :: RtmpOutputSettings -> Maybe Natural
$sel:certificateMode:RtmpOutputSettings' :: RtmpOutputSettings -> Maybe RtmpOutputCertificateMode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RtmpOutputCertificateMode
certificateMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
connectionRetryInterval
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
numRetries
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` OutputLocationRef
destination

instance Prelude.NFData RtmpOutputSettings where
  rnf :: RtmpOutputSettings -> ()
rnf RtmpOutputSettings' {Maybe Natural
Maybe RtmpOutputCertificateMode
OutputLocationRef
destination :: OutputLocationRef
numRetries :: Maybe Natural
connectionRetryInterval :: Maybe Natural
certificateMode :: Maybe RtmpOutputCertificateMode
$sel:destination:RtmpOutputSettings' :: RtmpOutputSettings -> OutputLocationRef
$sel:numRetries:RtmpOutputSettings' :: RtmpOutputSettings -> Maybe Natural
$sel:connectionRetryInterval:RtmpOutputSettings' :: RtmpOutputSettings -> Maybe Natural
$sel:certificateMode:RtmpOutputSettings' :: RtmpOutputSettings -> Maybe RtmpOutputCertificateMode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RtmpOutputCertificateMode
certificateMode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
connectionRetryInterval
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
numRetries
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf OutputLocationRef
destination

instance Data.ToJSON RtmpOutputSettings where
  toJSON :: RtmpOutputSettings -> Value
toJSON RtmpOutputSettings' {Maybe Natural
Maybe RtmpOutputCertificateMode
OutputLocationRef
destination :: OutputLocationRef
numRetries :: Maybe Natural
connectionRetryInterval :: Maybe Natural
certificateMode :: Maybe RtmpOutputCertificateMode
$sel:destination:RtmpOutputSettings' :: RtmpOutputSettings -> OutputLocationRef
$sel:numRetries:RtmpOutputSettings' :: RtmpOutputSettings -> Maybe Natural
$sel:connectionRetryInterval:RtmpOutputSettings' :: RtmpOutputSettings -> Maybe Natural
$sel:certificateMode:RtmpOutputSettings' :: RtmpOutputSettings -> Maybe RtmpOutputCertificateMode
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"certificateMode" 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 RtmpOutputCertificateMode
certificateMode,
            (Key
"connectionRetryInterval" 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
connectionRetryInterval,
            (Key
"numRetries" 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
numRetries,
            forall a. a -> Maybe a
Prelude.Just (Key
"destination" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= OutputLocationRef
destination)
          ]
      )