{-# 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.DeletionConfig
-- 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.DeletionConfig 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.LocalSizeConfig
import qualified Amazonka.Prelude as Prelude

-- | The configuration details required to delete the connection of the
-- stream from the Edge Agent.
--
-- /See:/ 'newDeletionConfig' smart constructor.
data DeletionConfig = DeletionConfig'
  { -- | The @boolean@ value used to indicate whether or not you want to mark the
    -- media for deletion, once it has been uploaded to the Kinesis Video
    -- Stream cloud. The media files can be deleted if any of the deletion
    -- configuration values are set to @true@, such as when the limit for the
    -- @EdgeRetentionInHours@, or the @MaxLocalMediaSizeInMB@, has been
    -- reached.
    --
    -- Since the default value is set to @true@, configure the uploader
    -- schedule such that the media files are not being deleted before they are
    -- initially uploaded to AWS cloud.
    DeletionConfig -> Maybe Bool
deleteAfterUpload :: Prelude.Maybe Prelude.Bool,
    -- | The number of hours that you want to retain the data in the stream on
    -- the Edge Agent. The default value of the retention time is 720 hours,
    -- which translates to 30 days.
    DeletionConfig -> Maybe Natural
edgeRetentionInHours :: Prelude.Maybe Prelude.Natural,
    -- | The value of the local size required in order to delete the edge
    -- configuration.
    DeletionConfig -> Maybe LocalSizeConfig
localSizeConfig :: Prelude.Maybe LocalSizeConfig
  }
  deriving (DeletionConfig -> DeletionConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletionConfig -> DeletionConfig -> Bool
$c/= :: DeletionConfig -> DeletionConfig -> Bool
== :: DeletionConfig -> DeletionConfig -> Bool
$c== :: DeletionConfig -> DeletionConfig -> Bool
Prelude.Eq, ReadPrec [DeletionConfig]
ReadPrec DeletionConfig
Int -> ReadS DeletionConfig
ReadS [DeletionConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletionConfig]
$creadListPrec :: ReadPrec [DeletionConfig]
readPrec :: ReadPrec DeletionConfig
$creadPrec :: ReadPrec DeletionConfig
readList :: ReadS [DeletionConfig]
$creadList :: ReadS [DeletionConfig]
readsPrec :: Int -> ReadS DeletionConfig
$creadsPrec :: Int -> ReadS DeletionConfig
Prelude.Read, Int -> DeletionConfig -> ShowS
[DeletionConfig] -> ShowS
DeletionConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletionConfig] -> ShowS
$cshowList :: [DeletionConfig] -> ShowS
show :: DeletionConfig -> String
$cshow :: DeletionConfig -> String
showsPrec :: Int -> DeletionConfig -> ShowS
$cshowsPrec :: Int -> DeletionConfig -> ShowS
Prelude.Show, forall x. Rep DeletionConfig x -> DeletionConfig
forall x. DeletionConfig -> Rep DeletionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeletionConfig x -> DeletionConfig
$cfrom :: forall x. DeletionConfig -> Rep DeletionConfig x
Prelude.Generic)

-- |
-- Create a value of 'DeletionConfig' 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:
--
-- 'deleteAfterUpload', 'deletionConfig_deleteAfterUpload' - The @boolean@ value used to indicate whether or not you want to mark the
-- media for deletion, once it has been uploaded to the Kinesis Video
-- Stream cloud. The media files can be deleted if any of the deletion
-- configuration values are set to @true@, such as when the limit for the
-- @EdgeRetentionInHours@, or the @MaxLocalMediaSizeInMB@, has been
-- reached.
--
-- Since the default value is set to @true@, configure the uploader
-- schedule such that the media files are not being deleted before they are
-- initially uploaded to AWS cloud.
--
-- 'edgeRetentionInHours', 'deletionConfig_edgeRetentionInHours' - The number of hours that you want to retain the data in the stream on
-- the Edge Agent. The default value of the retention time is 720 hours,
-- which translates to 30 days.
--
-- 'localSizeConfig', 'deletionConfig_localSizeConfig' - The value of the local size required in order to delete the edge
-- configuration.
newDeletionConfig ::
  DeletionConfig
newDeletionConfig :: DeletionConfig
newDeletionConfig =
  DeletionConfig'
    { $sel:deleteAfterUpload:DeletionConfig' :: Maybe Bool
deleteAfterUpload =
        forall a. Maybe a
Prelude.Nothing,
      $sel:edgeRetentionInHours:DeletionConfig' :: Maybe Natural
edgeRetentionInHours = forall a. Maybe a
Prelude.Nothing,
      $sel:localSizeConfig:DeletionConfig' :: Maybe LocalSizeConfig
localSizeConfig = forall a. Maybe a
Prelude.Nothing
    }

-- | The @boolean@ value used to indicate whether or not you want to mark the
-- media for deletion, once it has been uploaded to the Kinesis Video
-- Stream cloud. The media files can be deleted if any of the deletion
-- configuration values are set to @true@, such as when the limit for the
-- @EdgeRetentionInHours@, or the @MaxLocalMediaSizeInMB@, has been
-- reached.
--
-- Since the default value is set to @true@, configure the uploader
-- schedule such that the media files are not being deleted before they are
-- initially uploaded to AWS cloud.
deletionConfig_deleteAfterUpload :: Lens.Lens' DeletionConfig (Prelude.Maybe Prelude.Bool)
deletionConfig_deleteAfterUpload :: Lens' DeletionConfig (Maybe Bool)
deletionConfig_deleteAfterUpload = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletionConfig' {Maybe Bool
deleteAfterUpload :: Maybe Bool
$sel:deleteAfterUpload:DeletionConfig' :: DeletionConfig -> Maybe Bool
deleteAfterUpload} -> Maybe Bool
deleteAfterUpload) (\s :: DeletionConfig
s@DeletionConfig' {} Maybe Bool
a -> DeletionConfig
s {$sel:deleteAfterUpload:DeletionConfig' :: Maybe Bool
deleteAfterUpload = Maybe Bool
a} :: DeletionConfig)

-- | The number of hours that you want to retain the data in the stream on
-- the Edge Agent. The default value of the retention time is 720 hours,
-- which translates to 30 days.
deletionConfig_edgeRetentionInHours :: Lens.Lens' DeletionConfig (Prelude.Maybe Prelude.Natural)
deletionConfig_edgeRetentionInHours :: Lens' DeletionConfig (Maybe Natural)
deletionConfig_edgeRetentionInHours = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletionConfig' {Maybe Natural
edgeRetentionInHours :: Maybe Natural
$sel:edgeRetentionInHours:DeletionConfig' :: DeletionConfig -> Maybe Natural
edgeRetentionInHours} -> Maybe Natural
edgeRetentionInHours) (\s :: DeletionConfig
s@DeletionConfig' {} Maybe Natural
a -> DeletionConfig
s {$sel:edgeRetentionInHours:DeletionConfig' :: Maybe Natural
edgeRetentionInHours = Maybe Natural
a} :: DeletionConfig)

-- | The value of the local size required in order to delete the edge
-- configuration.
deletionConfig_localSizeConfig :: Lens.Lens' DeletionConfig (Prelude.Maybe LocalSizeConfig)
deletionConfig_localSizeConfig :: Lens' DeletionConfig (Maybe LocalSizeConfig)
deletionConfig_localSizeConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletionConfig' {Maybe LocalSizeConfig
localSizeConfig :: Maybe LocalSizeConfig
$sel:localSizeConfig:DeletionConfig' :: DeletionConfig -> Maybe LocalSizeConfig
localSizeConfig} -> Maybe LocalSizeConfig
localSizeConfig) (\s :: DeletionConfig
s@DeletionConfig' {} Maybe LocalSizeConfig
a -> DeletionConfig
s {$sel:localSizeConfig:DeletionConfig' :: Maybe LocalSizeConfig
localSizeConfig = Maybe LocalSizeConfig
a} :: DeletionConfig)

instance Data.FromJSON DeletionConfig where
  parseJSON :: Value -> Parser DeletionConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DeletionConfig"
      ( \Object
x ->
          Maybe Bool
-> Maybe Natural -> Maybe LocalSizeConfig -> DeletionConfig
DeletionConfig'
            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
"DeleteAfterUpload")
            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
"EdgeRetentionInHours")
            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
"LocalSizeConfig")
      )

instance Prelude.Hashable DeletionConfig where
  hashWithSalt :: Int -> DeletionConfig -> Int
hashWithSalt Int
_salt DeletionConfig' {Maybe Bool
Maybe Natural
Maybe LocalSizeConfig
localSizeConfig :: Maybe LocalSizeConfig
edgeRetentionInHours :: Maybe Natural
deleteAfterUpload :: Maybe Bool
$sel:localSizeConfig:DeletionConfig' :: DeletionConfig -> Maybe LocalSizeConfig
$sel:edgeRetentionInHours:DeletionConfig' :: DeletionConfig -> Maybe Natural
$sel:deleteAfterUpload:DeletionConfig' :: DeletionConfig -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
deleteAfterUpload
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
edgeRetentionInHours
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LocalSizeConfig
localSizeConfig

instance Prelude.NFData DeletionConfig where
  rnf :: DeletionConfig -> ()
rnf DeletionConfig' {Maybe Bool
Maybe Natural
Maybe LocalSizeConfig
localSizeConfig :: Maybe LocalSizeConfig
edgeRetentionInHours :: Maybe Natural
deleteAfterUpload :: Maybe Bool
$sel:localSizeConfig:DeletionConfig' :: DeletionConfig -> Maybe LocalSizeConfig
$sel:edgeRetentionInHours:DeletionConfig' :: DeletionConfig -> Maybe Natural
$sel:deleteAfterUpload:DeletionConfig' :: DeletionConfig -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
deleteAfterUpload
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
edgeRetentionInHours
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe LocalSizeConfig
localSizeConfig

instance Data.ToJSON DeletionConfig where
  toJSON :: DeletionConfig -> Value
toJSON DeletionConfig' {Maybe Bool
Maybe Natural
Maybe LocalSizeConfig
localSizeConfig :: Maybe LocalSizeConfig
edgeRetentionInHours :: Maybe Natural
deleteAfterUpload :: Maybe Bool
$sel:localSizeConfig:DeletionConfig' :: DeletionConfig -> Maybe LocalSizeConfig
$sel:edgeRetentionInHours:DeletionConfig' :: DeletionConfig -> Maybe Natural
$sel:deleteAfterUpload:DeletionConfig' :: DeletionConfig -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DeleteAfterUpload" 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 Bool
deleteAfterUpload,
            (Key
"EdgeRetentionInHours" 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
edgeRetentionInHours,
            (Key
"LocalSizeConfig" 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 LocalSizeConfig
localSizeConfig
          ]
      )