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

-- | Archive Group Settings
--
-- /See:/ 'newArchiveGroupSettings' smart constructor.
data ArchiveGroupSettings = ArchiveGroupSettings'
  { -- | Parameters that control interactions with the CDN.
    ArchiveGroupSettings -> Maybe ArchiveCdnSettings
archiveCdnSettings :: Prelude.Maybe ArchiveCdnSettings,
    -- | Number of seconds to write to archive file before closing and starting a
    -- new one.
    ArchiveGroupSettings -> Maybe Natural
rolloverInterval :: Prelude.Maybe Prelude.Natural,
    -- | A directory and base filename where archive files should be written.
    ArchiveGroupSettings -> OutputLocationRef
destination :: OutputLocationRef
  }
  deriving (ArchiveGroupSettings -> ArchiveGroupSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArchiveGroupSettings -> ArchiveGroupSettings -> Bool
$c/= :: ArchiveGroupSettings -> ArchiveGroupSettings -> Bool
== :: ArchiveGroupSettings -> ArchiveGroupSettings -> Bool
$c== :: ArchiveGroupSettings -> ArchiveGroupSettings -> Bool
Prelude.Eq, ReadPrec [ArchiveGroupSettings]
ReadPrec ArchiveGroupSettings
Int -> ReadS ArchiveGroupSettings
ReadS [ArchiveGroupSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ArchiveGroupSettings]
$creadListPrec :: ReadPrec [ArchiveGroupSettings]
readPrec :: ReadPrec ArchiveGroupSettings
$creadPrec :: ReadPrec ArchiveGroupSettings
readList :: ReadS [ArchiveGroupSettings]
$creadList :: ReadS [ArchiveGroupSettings]
readsPrec :: Int -> ReadS ArchiveGroupSettings
$creadsPrec :: Int -> ReadS ArchiveGroupSettings
Prelude.Read, Int -> ArchiveGroupSettings -> ShowS
[ArchiveGroupSettings] -> ShowS
ArchiveGroupSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ArchiveGroupSettings] -> ShowS
$cshowList :: [ArchiveGroupSettings] -> ShowS
show :: ArchiveGroupSettings -> String
$cshow :: ArchiveGroupSettings -> String
showsPrec :: Int -> ArchiveGroupSettings -> ShowS
$cshowsPrec :: Int -> ArchiveGroupSettings -> ShowS
Prelude.Show, forall x. Rep ArchiveGroupSettings x -> ArchiveGroupSettings
forall x. ArchiveGroupSettings -> Rep ArchiveGroupSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ArchiveGroupSettings x -> ArchiveGroupSettings
$cfrom :: forall x. ArchiveGroupSettings -> Rep ArchiveGroupSettings x
Prelude.Generic)

-- |
-- Create a value of 'ArchiveGroupSettings' 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:
--
-- 'archiveCdnSettings', 'archiveGroupSettings_archiveCdnSettings' - Parameters that control interactions with the CDN.
--
-- 'rolloverInterval', 'archiveGroupSettings_rolloverInterval' - Number of seconds to write to archive file before closing and starting a
-- new one.
--
-- 'destination', 'archiveGroupSettings_destination' - A directory and base filename where archive files should be written.
newArchiveGroupSettings ::
  -- | 'destination'
  OutputLocationRef ->
  ArchiveGroupSettings
newArchiveGroupSettings :: OutputLocationRef -> ArchiveGroupSettings
newArchiveGroupSettings OutputLocationRef
pDestination_ =
  ArchiveGroupSettings'
    { $sel:archiveCdnSettings:ArchiveGroupSettings' :: Maybe ArchiveCdnSettings
archiveCdnSettings =
        forall a. Maybe a
Prelude.Nothing,
      $sel:rolloverInterval:ArchiveGroupSettings' :: Maybe Natural
rolloverInterval = forall a. Maybe a
Prelude.Nothing,
      $sel:destination:ArchiveGroupSettings' :: OutputLocationRef
destination = OutputLocationRef
pDestination_
    }

-- | Parameters that control interactions with the CDN.
archiveGroupSettings_archiveCdnSettings :: Lens.Lens' ArchiveGroupSettings (Prelude.Maybe ArchiveCdnSettings)
archiveGroupSettings_archiveCdnSettings :: Lens' ArchiveGroupSettings (Maybe ArchiveCdnSettings)
archiveGroupSettings_archiveCdnSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArchiveGroupSettings' {Maybe ArchiveCdnSettings
archiveCdnSettings :: Maybe ArchiveCdnSettings
$sel:archiveCdnSettings:ArchiveGroupSettings' :: ArchiveGroupSettings -> Maybe ArchiveCdnSettings
archiveCdnSettings} -> Maybe ArchiveCdnSettings
archiveCdnSettings) (\s :: ArchiveGroupSettings
s@ArchiveGroupSettings' {} Maybe ArchiveCdnSettings
a -> ArchiveGroupSettings
s {$sel:archiveCdnSettings:ArchiveGroupSettings' :: Maybe ArchiveCdnSettings
archiveCdnSettings = Maybe ArchiveCdnSettings
a} :: ArchiveGroupSettings)

-- | Number of seconds to write to archive file before closing and starting a
-- new one.
archiveGroupSettings_rolloverInterval :: Lens.Lens' ArchiveGroupSettings (Prelude.Maybe Prelude.Natural)
archiveGroupSettings_rolloverInterval :: Lens' ArchiveGroupSettings (Maybe Natural)
archiveGroupSettings_rolloverInterval = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArchiveGroupSettings' {Maybe Natural
rolloverInterval :: Maybe Natural
$sel:rolloverInterval:ArchiveGroupSettings' :: ArchiveGroupSettings -> Maybe Natural
rolloverInterval} -> Maybe Natural
rolloverInterval) (\s :: ArchiveGroupSettings
s@ArchiveGroupSettings' {} Maybe Natural
a -> ArchiveGroupSettings
s {$sel:rolloverInterval:ArchiveGroupSettings' :: Maybe Natural
rolloverInterval = Maybe Natural
a} :: ArchiveGroupSettings)

-- | A directory and base filename where archive files should be written.
archiveGroupSettings_destination :: Lens.Lens' ArchiveGroupSettings OutputLocationRef
archiveGroupSettings_destination :: Lens' ArchiveGroupSettings OutputLocationRef
archiveGroupSettings_destination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArchiveGroupSettings' {OutputLocationRef
destination :: OutputLocationRef
$sel:destination:ArchiveGroupSettings' :: ArchiveGroupSettings -> OutputLocationRef
destination} -> OutputLocationRef
destination) (\s :: ArchiveGroupSettings
s@ArchiveGroupSettings' {} OutputLocationRef
a -> ArchiveGroupSettings
s {$sel:destination:ArchiveGroupSettings' :: OutputLocationRef
destination = OutputLocationRef
a} :: ArchiveGroupSettings)

instance Data.FromJSON ArchiveGroupSettings where
  parseJSON :: Value -> Parser ArchiveGroupSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ArchiveGroupSettings"
      ( \Object
x ->
          Maybe ArchiveCdnSettings
-> Maybe Natural -> OutputLocationRef -> ArchiveGroupSettings
ArchiveGroupSettings'
            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
"archiveCdnSettings")
            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
"rolloverInterval")
            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 ArchiveGroupSettings where
  hashWithSalt :: Int -> ArchiveGroupSettings -> Int
hashWithSalt Int
_salt ArchiveGroupSettings' {Maybe Natural
Maybe ArchiveCdnSettings
OutputLocationRef
destination :: OutputLocationRef
rolloverInterval :: Maybe Natural
archiveCdnSettings :: Maybe ArchiveCdnSettings
$sel:destination:ArchiveGroupSettings' :: ArchiveGroupSettings -> OutputLocationRef
$sel:rolloverInterval:ArchiveGroupSettings' :: ArchiveGroupSettings -> Maybe Natural
$sel:archiveCdnSettings:ArchiveGroupSettings' :: ArchiveGroupSettings -> Maybe ArchiveCdnSettings
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ArchiveCdnSettings
archiveCdnSettings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
rolloverInterval
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` OutputLocationRef
destination

instance Prelude.NFData ArchiveGroupSettings where
  rnf :: ArchiveGroupSettings -> ()
rnf ArchiveGroupSettings' {Maybe Natural
Maybe ArchiveCdnSettings
OutputLocationRef
destination :: OutputLocationRef
rolloverInterval :: Maybe Natural
archiveCdnSettings :: Maybe ArchiveCdnSettings
$sel:destination:ArchiveGroupSettings' :: ArchiveGroupSettings -> OutputLocationRef
$sel:rolloverInterval:ArchiveGroupSettings' :: ArchiveGroupSettings -> Maybe Natural
$sel:archiveCdnSettings:ArchiveGroupSettings' :: ArchiveGroupSettings -> Maybe ArchiveCdnSettings
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ArchiveCdnSettings
archiveCdnSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
rolloverInterval
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf OutputLocationRef
destination

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