{-# 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.EdgeConfig
-- 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.EdgeConfig 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.DeletionConfig
import Amazonka.KinesisVideo.Types.RecorderConfig
import Amazonka.KinesisVideo.Types.UploaderConfig
import qualified Amazonka.Prelude as Prelude

-- | A description of the stream\'s edge configuration that will be used to
-- sync with the Edge Agent IoT Greengrass component. The Edge Agent
-- component will run on an IoT Hub Device setup at your premise.
--
-- /See:/ 'newEdgeConfig' smart constructor.
data EdgeConfig = EdgeConfig'
  { -- | The deletion configuration is made up of the retention time
    -- (@EdgeRetentionInHours@) and local size configuration
    -- (@LocalSizeConfig@) details that are used to make the deletion.
    EdgeConfig -> Maybe DeletionConfig
deletionConfig :: Prelude.Maybe DeletionConfig,
    -- | The uploader configuration contains the @ScheduleExpression@ details
    -- that are used to schedule upload jobs for the recorded media files from
    -- the Edge Agent to a Kinesis Video Stream.
    EdgeConfig -> Maybe UploaderConfig
uploaderConfig :: Prelude.Maybe UploaderConfig,
    -- | The \"__Internet of Things (IoT) Thing__\" Arn of the stream.
    EdgeConfig -> Text
hubDeviceArn :: Prelude.Text,
    -- | The recorder configuration consists of the local @MediaSourceConfig@
    -- details, that are used as credentials to access the local media files
    -- streamed on the camera.
    EdgeConfig -> RecorderConfig
recorderConfig :: RecorderConfig
  }
  deriving (EdgeConfig -> EdgeConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EdgeConfig -> EdgeConfig -> Bool
$c/= :: EdgeConfig -> EdgeConfig -> Bool
== :: EdgeConfig -> EdgeConfig -> Bool
$c== :: EdgeConfig -> EdgeConfig -> Bool
Prelude.Eq, Int -> EdgeConfig -> ShowS
[EdgeConfig] -> ShowS
EdgeConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EdgeConfig] -> ShowS
$cshowList :: [EdgeConfig] -> ShowS
show :: EdgeConfig -> String
$cshow :: EdgeConfig -> String
showsPrec :: Int -> EdgeConfig -> ShowS
$cshowsPrec :: Int -> EdgeConfig -> ShowS
Prelude.Show, forall x. Rep EdgeConfig x -> EdgeConfig
forall x. EdgeConfig -> Rep EdgeConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EdgeConfig x -> EdgeConfig
$cfrom :: forall x. EdgeConfig -> Rep EdgeConfig x
Prelude.Generic)

-- |
-- Create a value of 'EdgeConfig' 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:
--
-- 'deletionConfig', 'edgeConfig_deletionConfig' - The deletion configuration is made up of the retention time
-- (@EdgeRetentionInHours@) and local size configuration
-- (@LocalSizeConfig@) details that are used to make the deletion.
--
-- 'uploaderConfig', 'edgeConfig_uploaderConfig' - The uploader configuration contains the @ScheduleExpression@ details
-- that are used to schedule upload jobs for the recorded media files from
-- the Edge Agent to a Kinesis Video Stream.
--
-- 'hubDeviceArn', 'edgeConfig_hubDeviceArn' - The \"__Internet of Things (IoT) Thing__\" Arn of the stream.
--
-- 'recorderConfig', 'edgeConfig_recorderConfig' - The recorder configuration consists of the local @MediaSourceConfig@
-- details, that are used as credentials to access the local media files
-- streamed on the camera.
newEdgeConfig ::
  -- | 'hubDeviceArn'
  Prelude.Text ->
  -- | 'recorderConfig'
  RecorderConfig ->
  EdgeConfig
newEdgeConfig :: Text -> RecorderConfig -> EdgeConfig
newEdgeConfig Text
pHubDeviceArn_ RecorderConfig
pRecorderConfig_ =
  EdgeConfig'
    { $sel:deletionConfig:EdgeConfig' :: Maybe DeletionConfig
deletionConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:uploaderConfig:EdgeConfig' :: Maybe UploaderConfig
uploaderConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:hubDeviceArn:EdgeConfig' :: Text
hubDeviceArn = Text
pHubDeviceArn_,
      $sel:recorderConfig:EdgeConfig' :: RecorderConfig
recorderConfig = RecorderConfig
pRecorderConfig_
    }

-- | The deletion configuration is made up of the retention time
-- (@EdgeRetentionInHours@) and local size configuration
-- (@LocalSizeConfig@) details that are used to make the deletion.
edgeConfig_deletionConfig :: Lens.Lens' EdgeConfig (Prelude.Maybe DeletionConfig)
edgeConfig_deletionConfig :: Lens' EdgeConfig (Maybe DeletionConfig)
edgeConfig_deletionConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdgeConfig' {Maybe DeletionConfig
deletionConfig :: Maybe DeletionConfig
$sel:deletionConfig:EdgeConfig' :: EdgeConfig -> Maybe DeletionConfig
deletionConfig} -> Maybe DeletionConfig
deletionConfig) (\s :: EdgeConfig
s@EdgeConfig' {} Maybe DeletionConfig
a -> EdgeConfig
s {$sel:deletionConfig:EdgeConfig' :: Maybe DeletionConfig
deletionConfig = Maybe DeletionConfig
a} :: EdgeConfig)

-- | The uploader configuration contains the @ScheduleExpression@ details
-- that are used to schedule upload jobs for the recorded media files from
-- the Edge Agent to a Kinesis Video Stream.
edgeConfig_uploaderConfig :: Lens.Lens' EdgeConfig (Prelude.Maybe UploaderConfig)
edgeConfig_uploaderConfig :: Lens' EdgeConfig (Maybe UploaderConfig)
edgeConfig_uploaderConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdgeConfig' {Maybe UploaderConfig
uploaderConfig :: Maybe UploaderConfig
$sel:uploaderConfig:EdgeConfig' :: EdgeConfig -> Maybe UploaderConfig
uploaderConfig} -> Maybe UploaderConfig
uploaderConfig) (\s :: EdgeConfig
s@EdgeConfig' {} Maybe UploaderConfig
a -> EdgeConfig
s {$sel:uploaderConfig:EdgeConfig' :: Maybe UploaderConfig
uploaderConfig = Maybe UploaderConfig
a} :: EdgeConfig)

-- | The \"__Internet of Things (IoT) Thing__\" Arn of the stream.
edgeConfig_hubDeviceArn :: Lens.Lens' EdgeConfig Prelude.Text
edgeConfig_hubDeviceArn :: Lens' EdgeConfig Text
edgeConfig_hubDeviceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdgeConfig' {Text
hubDeviceArn :: Text
$sel:hubDeviceArn:EdgeConfig' :: EdgeConfig -> Text
hubDeviceArn} -> Text
hubDeviceArn) (\s :: EdgeConfig
s@EdgeConfig' {} Text
a -> EdgeConfig
s {$sel:hubDeviceArn:EdgeConfig' :: Text
hubDeviceArn = Text
a} :: EdgeConfig)

-- | The recorder configuration consists of the local @MediaSourceConfig@
-- details, that are used as credentials to access the local media files
-- streamed on the camera.
edgeConfig_recorderConfig :: Lens.Lens' EdgeConfig RecorderConfig
edgeConfig_recorderConfig :: Lens' EdgeConfig RecorderConfig
edgeConfig_recorderConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdgeConfig' {RecorderConfig
recorderConfig :: RecorderConfig
$sel:recorderConfig:EdgeConfig' :: EdgeConfig -> RecorderConfig
recorderConfig} -> RecorderConfig
recorderConfig) (\s :: EdgeConfig
s@EdgeConfig' {} RecorderConfig
a -> EdgeConfig
s {$sel:recorderConfig:EdgeConfig' :: RecorderConfig
recorderConfig = RecorderConfig
a} :: EdgeConfig)

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

instance Prelude.Hashable EdgeConfig where
  hashWithSalt :: Int -> EdgeConfig -> Int
hashWithSalt Int
_salt EdgeConfig' {Maybe DeletionConfig
Maybe UploaderConfig
Text
RecorderConfig
recorderConfig :: RecorderConfig
hubDeviceArn :: Text
uploaderConfig :: Maybe UploaderConfig
deletionConfig :: Maybe DeletionConfig
$sel:recorderConfig:EdgeConfig' :: EdgeConfig -> RecorderConfig
$sel:hubDeviceArn:EdgeConfig' :: EdgeConfig -> Text
$sel:uploaderConfig:EdgeConfig' :: EdgeConfig -> Maybe UploaderConfig
$sel:deletionConfig:EdgeConfig' :: EdgeConfig -> Maybe DeletionConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DeletionConfig
deletionConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UploaderConfig
uploaderConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
hubDeviceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RecorderConfig
recorderConfig

instance Prelude.NFData EdgeConfig where
  rnf :: EdgeConfig -> ()
rnf EdgeConfig' {Maybe DeletionConfig
Maybe UploaderConfig
Text
RecorderConfig
recorderConfig :: RecorderConfig
hubDeviceArn :: Text
uploaderConfig :: Maybe UploaderConfig
deletionConfig :: Maybe DeletionConfig
$sel:recorderConfig:EdgeConfig' :: EdgeConfig -> RecorderConfig
$sel:hubDeviceArn:EdgeConfig' :: EdgeConfig -> Text
$sel:uploaderConfig:EdgeConfig' :: EdgeConfig -> Maybe UploaderConfig
$sel:deletionConfig:EdgeConfig' :: EdgeConfig -> Maybe DeletionConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DeletionConfig
deletionConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UploaderConfig
uploaderConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
hubDeviceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RecorderConfig
recorderConfig

instance Data.ToJSON EdgeConfig where
  toJSON :: EdgeConfig -> Value
toJSON EdgeConfig' {Maybe DeletionConfig
Maybe UploaderConfig
Text
RecorderConfig
recorderConfig :: RecorderConfig
hubDeviceArn :: Text
uploaderConfig :: Maybe UploaderConfig
deletionConfig :: Maybe DeletionConfig
$sel:recorderConfig:EdgeConfig' :: EdgeConfig -> RecorderConfig
$sel:hubDeviceArn:EdgeConfig' :: EdgeConfig -> Text
$sel:uploaderConfig:EdgeConfig' :: EdgeConfig -> Maybe UploaderConfig
$sel:deletionConfig:EdgeConfig' :: EdgeConfig -> Maybe DeletionConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DeletionConfig" 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 DeletionConfig
deletionConfig,
            (Key
"UploaderConfig" 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 UploaderConfig
uploaderConfig,
            forall a. a -> Maybe a
Prelude.Just (Key
"HubDeviceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
hubDeviceArn),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"RecorderConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RecorderConfig
recorderConfig)
          ]
      )