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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | Number of seconds to write to archive file before closing and starting a
    -- new one.
    ArchiveGroupSettings -> Maybe Natural
rolloverInterval :: Prelude.Maybe Prelude.Natural,
    -- | Parameters that control interactions with the CDN.
    ArchiveGroupSettings -> Maybe ArchiveCdnSettings
archiveCdnSettings :: Prelude.Maybe ArchiveCdnSettings,
    -- | A directory and base filename where archive files should be written.
    ArchiveGroupSettings -> OutputLocationRef
destination :: OutputLocationRef
  }
  deriving (ArchiveGroupSettings -> ArchiveGroupSettings -> Bool
(ArchiveGroupSettings -> ArchiveGroupSettings -> Bool)
-> (ArchiveGroupSettings -> ArchiveGroupSettings -> Bool)
-> Eq ArchiveGroupSettings
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]
(Int -> ReadS ArchiveGroupSettings)
-> ReadS [ArchiveGroupSettings]
-> ReadPrec ArchiveGroupSettings
-> ReadPrec [ArchiveGroupSettings]
-> Read 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
(Int -> ArchiveGroupSettings -> ShowS)
-> (ArchiveGroupSettings -> String)
-> ([ArchiveGroupSettings] -> ShowS)
-> Show ArchiveGroupSettings
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. ArchiveGroupSettings -> Rep ArchiveGroupSettings x)
-> (forall x. Rep ArchiveGroupSettings x -> ArchiveGroupSettings)
-> Generic ArchiveGroupSettings
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:
--
-- 'rolloverInterval', 'archiveGroupSettings_rolloverInterval' - Number of seconds to write to archive file before closing and starting a
-- new one.
--
-- 'archiveCdnSettings', 'archiveGroupSettings_archiveCdnSettings' - Parameters that control interactions with the CDN.
--
-- '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' :: Maybe Natural
-> Maybe ArchiveCdnSettings
-> OutputLocationRef
-> ArchiveGroupSettings
ArchiveGroupSettings'
    { $sel:rolloverInterval:ArchiveGroupSettings' :: Maybe Natural
rolloverInterval =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:archiveCdnSettings:ArchiveGroupSettings' :: Maybe ArchiveCdnSettings
archiveCdnSettings = Maybe ArchiveCdnSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:destination:ArchiveGroupSettings' :: OutputLocationRef
destination = OutputLocationRef
pDestination_
    }

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> ArchiveGroupSettings -> f ArchiveGroupSettings
archiveGroupSettings_rolloverInterval = (ArchiveGroupSettings -> Maybe Natural)
-> (ArchiveGroupSettings -> Maybe Natural -> ArchiveGroupSettings)
-> Lens
     ArchiveGroupSettings
     ArchiveGroupSettings
     (Maybe Natural)
     (Maybe Natural)
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)

-- | Parameters that control interactions with the CDN.
archiveGroupSettings_archiveCdnSettings :: Lens.Lens' ArchiveGroupSettings (Prelude.Maybe ArchiveCdnSettings)
archiveGroupSettings_archiveCdnSettings :: (Maybe ArchiveCdnSettings -> f (Maybe ArchiveCdnSettings))
-> ArchiveGroupSettings -> f ArchiveGroupSettings
archiveGroupSettings_archiveCdnSettings = (ArchiveGroupSettings -> Maybe ArchiveCdnSettings)
-> (ArchiveGroupSettings
    -> Maybe ArchiveCdnSettings -> ArchiveGroupSettings)
-> Lens
     ArchiveGroupSettings
     ArchiveGroupSettings
     (Maybe ArchiveCdnSettings)
     (Maybe 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)

-- | A directory and base filename where archive files should be written.
archiveGroupSettings_destination :: Lens.Lens' ArchiveGroupSettings OutputLocationRef
archiveGroupSettings_destination :: (OutputLocationRef -> f OutputLocationRef)
-> ArchiveGroupSettings -> f ArchiveGroupSettings
archiveGroupSettings_destination = (ArchiveGroupSettings -> OutputLocationRef)
-> (ArchiveGroupSettings
    -> OutputLocationRef -> ArchiveGroupSettings)
-> Lens
     ArchiveGroupSettings
     ArchiveGroupSettings
     OutputLocationRef
     OutputLocationRef
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 Core.FromJSON ArchiveGroupSettings where
  parseJSON :: Value -> Parser ArchiveGroupSettings
parseJSON =
    String
-> (Object -> Parser ArchiveGroupSettings)
-> Value
-> Parser ArchiveGroupSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ArchiveGroupSettings"
      ( \Object
x ->
          Maybe Natural
-> Maybe ArchiveCdnSettings
-> OutputLocationRef
-> ArchiveGroupSettings
ArchiveGroupSettings'
            (Maybe Natural
 -> Maybe ArchiveCdnSettings
 -> OutputLocationRef
 -> ArchiveGroupSettings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe ArchiveCdnSettings
      -> OutputLocationRef -> ArchiveGroupSettings)
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
"rolloverInterval")
            Parser
  (Maybe ArchiveCdnSettings
   -> OutputLocationRef -> ArchiveGroupSettings)
-> Parser (Maybe ArchiveCdnSettings)
-> Parser (OutputLocationRef -> ArchiveGroupSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ArchiveCdnSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"archiveCdnSettings")
            Parser (OutputLocationRef -> ArchiveGroupSettings)
-> Parser OutputLocationRef -> Parser ArchiveGroupSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser OutputLocationRef
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"destination")
      )

instance Prelude.Hashable ArchiveGroupSettings

instance Prelude.NFData ArchiveGroupSettings

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