{-# 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.KinesisVideo.Types.RecorderConfig
-- 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.KinesisVideo.Types.RecorderConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KinesisVideo.Types.MediaSourceConfig
import Amazonka.KinesisVideo.Types.ScheduleConfig
import qualified Amazonka.Prelude as Prelude

-- | The recorder configuration consists of the local @MediaSourceConfig@
-- details that are used as credentials to accesss the local media files
-- streamed on the camera.
--
-- /See:/ 'newRecorderConfig' smart constructor.
data RecorderConfig = RecorderConfig'
  { -- | The configuration that consists of the @ScheduleExpression@ and the
    -- @DurationInMinutes@ details that specify the scheduling to record from a
    -- camera, or local media file, onto the Edge Agent. If the
    -- @ScheduleExpression@ attribute is not provided, then the Edge Agent will
    -- always be set to recording mode.
    RecorderConfig -> Maybe ScheduleConfig
scheduleConfig :: Prelude.Maybe ScheduleConfig,
    -- | The configuration details that consist of the credentials required
    -- (@MediaUriSecretArn@ and @MediaUriType@) to access the media files
    -- streamed to the camera.
    RecorderConfig -> MediaSourceConfig
mediaSourceConfig :: MediaSourceConfig
  }
  deriving (RecorderConfig -> RecorderConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecorderConfig -> RecorderConfig -> Bool
$c/= :: RecorderConfig -> RecorderConfig -> Bool
== :: RecorderConfig -> RecorderConfig -> Bool
$c== :: RecorderConfig -> RecorderConfig -> Bool
Prelude.Eq, Int -> RecorderConfig -> ShowS
[RecorderConfig] -> ShowS
RecorderConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecorderConfig] -> ShowS
$cshowList :: [RecorderConfig] -> ShowS
show :: RecorderConfig -> String
$cshow :: RecorderConfig -> String
showsPrec :: Int -> RecorderConfig -> ShowS
$cshowsPrec :: Int -> RecorderConfig -> ShowS
Prelude.Show, forall x. Rep RecorderConfig x -> RecorderConfig
forall x. RecorderConfig -> Rep RecorderConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RecorderConfig x -> RecorderConfig
$cfrom :: forall x. RecorderConfig -> Rep RecorderConfig x
Prelude.Generic)

-- |
-- Create a value of 'RecorderConfig' 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:
--
-- 'scheduleConfig', 'recorderConfig_scheduleConfig' - The configuration that consists of the @ScheduleExpression@ and the
-- @DurationInMinutes@ details that specify the scheduling to record from a
-- camera, or local media file, onto the Edge Agent. If the
-- @ScheduleExpression@ attribute is not provided, then the Edge Agent will
-- always be set to recording mode.
--
-- 'mediaSourceConfig', 'recorderConfig_mediaSourceConfig' - The configuration details that consist of the credentials required
-- (@MediaUriSecretArn@ and @MediaUriType@) to access the media files
-- streamed to the camera.
newRecorderConfig ::
  -- | 'mediaSourceConfig'
  MediaSourceConfig ->
  RecorderConfig
newRecorderConfig :: MediaSourceConfig -> RecorderConfig
newRecorderConfig MediaSourceConfig
pMediaSourceConfig_ =
  RecorderConfig'
    { $sel:scheduleConfig:RecorderConfig' :: Maybe ScheduleConfig
scheduleConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:mediaSourceConfig:RecorderConfig' :: MediaSourceConfig
mediaSourceConfig = MediaSourceConfig
pMediaSourceConfig_
    }

-- | The configuration that consists of the @ScheduleExpression@ and the
-- @DurationInMinutes@ details that specify the scheduling to record from a
-- camera, or local media file, onto the Edge Agent. If the
-- @ScheduleExpression@ attribute is not provided, then the Edge Agent will
-- always be set to recording mode.
recorderConfig_scheduleConfig :: Lens.Lens' RecorderConfig (Prelude.Maybe ScheduleConfig)
recorderConfig_scheduleConfig :: Lens' RecorderConfig (Maybe ScheduleConfig)
recorderConfig_scheduleConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecorderConfig' {Maybe ScheduleConfig
scheduleConfig :: Maybe ScheduleConfig
$sel:scheduleConfig:RecorderConfig' :: RecorderConfig -> Maybe ScheduleConfig
scheduleConfig} -> Maybe ScheduleConfig
scheduleConfig) (\s :: RecorderConfig
s@RecorderConfig' {} Maybe ScheduleConfig
a -> RecorderConfig
s {$sel:scheduleConfig:RecorderConfig' :: Maybe ScheduleConfig
scheduleConfig = Maybe ScheduleConfig
a} :: RecorderConfig)

-- | The configuration details that consist of the credentials required
-- (@MediaUriSecretArn@ and @MediaUriType@) to access the media files
-- streamed to the camera.
recorderConfig_mediaSourceConfig :: Lens.Lens' RecorderConfig MediaSourceConfig
recorderConfig_mediaSourceConfig :: Lens' RecorderConfig MediaSourceConfig
recorderConfig_mediaSourceConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecorderConfig' {MediaSourceConfig
mediaSourceConfig :: MediaSourceConfig
$sel:mediaSourceConfig:RecorderConfig' :: RecorderConfig -> MediaSourceConfig
mediaSourceConfig} -> MediaSourceConfig
mediaSourceConfig) (\s :: RecorderConfig
s@RecorderConfig' {} MediaSourceConfig
a -> RecorderConfig
s {$sel:mediaSourceConfig:RecorderConfig' :: MediaSourceConfig
mediaSourceConfig = MediaSourceConfig
a} :: RecorderConfig)

instance Data.FromJSON RecorderConfig where
  parseJSON :: Value -> Parser RecorderConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RecorderConfig"
      ( \Object
x ->
          Maybe ScheduleConfig -> MediaSourceConfig -> RecorderConfig
RecorderConfig'
            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
"ScheduleConfig")
            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
"MediaSourceConfig")
      )

instance Prelude.Hashable RecorderConfig where
  hashWithSalt :: Int -> RecorderConfig -> Int
hashWithSalt Int
_salt RecorderConfig' {Maybe ScheduleConfig
MediaSourceConfig
mediaSourceConfig :: MediaSourceConfig
scheduleConfig :: Maybe ScheduleConfig
$sel:mediaSourceConfig:RecorderConfig' :: RecorderConfig -> MediaSourceConfig
$sel:scheduleConfig:RecorderConfig' :: RecorderConfig -> Maybe ScheduleConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ScheduleConfig
scheduleConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` MediaSourceConfig
mediaSourceConfig

instance Prelude.NFData RecorderConfig where
  rnf :: RecorderConfig -> ()
rnf RecorderConfig' {Maybe ScheduleConfig
MediaSourceConfig
mediaSourceConfig :: MediaSourceConfig
scheduleConfig :: Maybe ScheduleConfig
$sel:mediaSourceConfig:RecorderConfig' :: RecorderConfig -> MediaSourceConfig
$sel:scheduleConfig:RecorderConfig' :: RecorderConfig -> Maybe ScheduleConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ScheduleConfig
scheduleConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf MediaSourceConfig
mediaSourceConfig

instance Data.ToJSON RecorderConfig where
  toJSON :: RecorderConfig -> Value
toJSON RecorderConfig' {Maybe ScheduleConfig
MediaSourceConfig
mediaSourceConfig :: MediaSourceConfig
scheduleConfig :: Maybe ScheduleConfig
$sel:mediaSourceConfig:RecorderConfig' :: RecorderConfig -> MediaSourceConfig
$sel:scheduleConfig:RecorderConfig' :: RecorderConfig -> Maybe ScheduleConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ScheduleConfig" 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 ScheduleConfig
scheduleConfig,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"MediaSourceConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= MediaSourceConfig
mediaSourceConfig)
          ]
      )