{-# 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.DynamoDB.Types.SSEDescription
-- 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.DynamoDB.Types.SSEDescription where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.SSEStatus
import Amazonka.DynamoDB.Types.SSEType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The description of the server-side encryption status on the specified
-- table.
--
-- /See:/ 'newSSEDescription' smart constructor.
data SSEDescription = SSEDescription'
  { -- | Represents the current state of server-side encryption. The only
    -- supported values are:
    --
    -- -   @ENABLED@ - Server-side encryption is enabled.
    --
    -- -   @UPDATING@ - Server-side encryption is being updated.
    SSEDescription -> Maybe SSEStatus
status :: Prelude.Maybe SSEStatus,
    -- | Indicates the time, in UNIX epoch date format, when DynamoDB detected
    -- that the table\'s AWS KMS key was inaccessible. This attribute will
    -- automatically be cleared when DynamoDB detects that the table\'s AWS KMS
    -- key is accessible again. DynamoDB will initiate the table archival
    -- process when table\'s AWS KMS key remains inaccessible for more than
    -- seven days from this date.
    SSEDescription -> Maybe POSIX
inaccessibleEncryptionDateTime :: Prelude.Maybe Core.POSIX,
    -- | Server-side encryption type. The only supported value is:
    --
    -- -   @KMS@ - Server-side encryption that uses AWS Key Management Service.
    --     The key is stored in your account and is managed by AWS KMS (AWS KMS
    --     charges apply).
    SSEDescription -> Maybe SSEType
sSEType :: Prelude.Maybe SSEType,
    -- | The AWS KMS customer master key (CMK) ARN used for the AWS KMS
    -- encryption.
    SSEDescription -> Maybe Text
kmsMasterKeyArn :: Prelude.Maybe Prelude.Text
  }
  deriving (SSEDescription -> SSEDescription -> Bool
(SSEDescription -> SSEDescription -> Bool)
-> (SSEDescription -> SSEDescription -> Bool) -> Eq SSEDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SSEDescription -> SSEDescription -> Bool
$c/= :: SSEDescription -> SSEDescription -> Bool
== :: SSEDescription -> SSEDescription -> Bool
$c== :: SSEDescription -> SSEDescription -> Bool
Prelude.Eq, ReadPrec [SSEDescription]
ReadPrec SSEDescription
Int -> ReadS SSEDescription
ReadS [SSEDescription]
(Int -> ReadS SSEDescription)
-> ReadS [SSEDescription]
-> ReadPrec SSEDescription
-> ReadPrec [SSEDescription]
-> Read SSEDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SSEDescription]
$creadListPrec :: ReadPrec [SSEDescription]
readPrec :: ReadPrec SSEDescription
$creadPrec :: ReadPrec SSEDescription
readList :: ReadS [SSEDescription]
$creadList :: ReadS [SSEDescription]
readsPrec :: Int -> ReadS SSEDescription
$creadsPrec :: Int -> ReadS SSEDescription
Prelude.Read, Int -> SSEDescription -> ShowS
[SSEDescription] -> ShowS
SSEDescription -> String
(Int -> SSEDescription -> ShowS)
-> (SSEDescription -> String)
-> ([SSEDescription] -> ShowS)
-> Show SSEDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SSEDescription] -> ShowS
$cshowList :: [SSEDescription] -> ShowS
show :: SSEDescription -> String
$cshow :: SSEDescription -> String
showsPrec :: Int -> SSEDescription -> ShowS
$cshowsPrec :: Int -> SSEDescription -> ShowS
Prelude.Show, (forall x. SSEDescription -> Rep SSEDescription x)
-> (forall x. Rep SSEDescription x -> SSEDescription)
-> Generic SSEDescription
forall x. Rep SSEDescription x -> SSEDescription
forall x. SSEDescription -> Rep SSEDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SSEDescription x -> SSEDescription
$cfrom :: forall x. SSEDescription -> Rep SSEDescription x
Prelude.Generic)

-- |
-- Create a value of 'SSEDescription' 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:
--
-- 'status', 'sSEDescription_status' - Represents the current state of server-side encryption. The only
-- supported values are:
--
-- -   @ENABLED@ - Server-side encryption is enabled.
--
-- -   @UPDATING@ - Server-side encryption is being updated.
--
-- 'inaccessibleEncryptionDateTime', 'sSEDescription_inaccessibleEncryptionDateTime' - Indicates the time, in UNIX epoch date format, when DynamoDB detected
-- that the table\'s AWS KMS key was inaccessible. This attribute will
-- automatically be cleared when DynamoDB detects that the table\'s AWS KMS
-- key is accessible again. DynamoDB will initiate the table archival
-- process when table\'s AWS KMS key remains inaccessible for more than
-- seven days from this date.
--
-- 'sSEType', 'sSEDescription_sSEType' - Server-side encryption type. The only supported value is:
--
-- -   @KMS@ - Server-side encryption that uses AWS Key Management Service.
--     The key is stored in your account and is managed by AWS KMS (AWS KMS
--     charges apply).
--
-- 'kmsMasterKeyArn', 'sSEDescription_kmsMasterKeyArn' - The AWS KMS customer master key (CMK) ARN used for the AWS KMS
-- encryption.
newSSEDescription ::
  SSEDescription
newSSEDescription :: SSEDescription
newSSEDescription =
  SSEDescription' :: Maybe SSEStatus
-> Maybe POSIX -> Maybe SSEType -> Maybe Text -> SSEDescription
SSEDescription'
    { $sel:status:SSEDescription' :: Maybe SSEStatus
status = Maybe SSEStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:inaccessibleEncryptionDateTime:SSEDescription' :: Maybe POSIX
inaccessibleEncryptionDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:sSEType:SSEDescription' :: Maybe SSEType
sSEType = Maybe SSEType
forall a. Maybe a
Prelude.Nothing,
      $sel:kmsMasterKeyArn:SSEDescription' :: Maybe Text
kmsMasterKeyArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Represents the current state of server-side encryption. The only
-- supported values are:
--
-- -   @ENABLED@ - Server-side encryption is enabled.
--
-- -   @UPDATING@ - Server-side encryption is being updated.
sSEDescription_status :: Lens.Lens' SSEDescription (Prelude.Maybe SSEStatus)
sSEDescription_status :: (Maybe SSEStatus -> f (Maybe SSEStatus))
-> SSEDescription -> f SSEDescription
sSEDescription_status = (SSEDescription -> Maybe SSEStatus)
-> (SSEDescription -> Maybe SSEStatus -> SSEDescription)
-> Lens
     SSEDescription SSEDescription (Maybe SSEStatus) (Maybe SSEStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SSEDescription' {Maybe SSEStatus
status :: Maybe SSEStatus
$sel:status:SSEDescription' :: SSEDescription -> Maybe SSEStatus
status} -> Maybe SSEStatus
status) (\s :: SSEDescription
s@SSEDescription' {} Maybe SSEStatus
a -> SSEDescription
s {$sel:status:SSEDescription' :: Maybe SSEStatus
status = Maybe SSEStatus
a} :: SSEDescription)

-- | Indicates the time, in UNIX epoch date format, when DynamoDB detected
-- that the table\'s AWS KMS key was inaccessible. This attribute will
-- automatically be cleared when DynamoDB detects that the table\'s AWS KMS
-- key is accessible again. DynamoDB will initiate the table archival
-- process when table\'s AWS KMS key remains inaccessible for more than
-- seven days from this date.
sSEDescription_inaccessibleEncryptionDateTime :: Lens.Lens' SSEDescription (Prelude.Maybe Prelude.UTCTime)
sSEDescription_inaccessibleEncryptionDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> SSEDescription -> f SSEDescription
sSEDescription_inaccessibleEncryptionDateTime = (SSEDescription -> Maybe POSIX)
-> (SSEDescription -> Maybe POSIX -> SSEDescription)
-> Lens SSEDescription SSEDescription (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SSEDescription' {Maybe POSIX
inaccessibleEncryptionDateTime :: Maybe POSIX
$sel:inaccessibleEncryptionDateTime:SSEDescription' :: SSEDescription -> Maybe POSIX
inaccessibleEncryptionDateTime} -> Maybe POSIX
inaccessibleEncryptionDateTime) (\s :: SSEDescription
s@SSEDescription' {} Maybe POSIX
a -> SSEDescription
s {$sel:inaccessibleEncryptionDateTime:SSEDescription' :: Maybe POSIX
inaccessibleEncryptionDateTime = Maybe POSIX
a} :: SSEDescription) ((Maybe POSIX -> f (Maybe POSIX))
 -> SSEDescription -> f SSEDescription)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> SSEDescription
-> f SSEDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Server-side encryption type. The only supported value is:
--
-- -   @KMS@ - Server-side encryption that uses AWS Key Management Service.
--     The key is stored in your account and is managed by AWS KMS (AWS KMS
--     charges apply).
sSEDescription_sSEType :: Lens.Lens' SSEDescription (Prelude.Maybe SSEType)
sSEDescription_sSEType :: (Maybe SSEType -> f (Maybe SSEType))
-> SSEDescription -> f SSEDescription
sSEDescription_sSEType = (SSEDescription -> Maybe SSEType)
-> (SSEDescription -> Maybe SSEType -> SSEDescription)
-> Lens
     SSEDescription SSEDescription (Maybe SSEType) (Maybe SSEType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SSEDescription' {Maybe SSEType
sSEType :: Maybe SSEType
$sel:sSEType:SSEDescription' :: SSEDescription -> Maybe SSEType
sSEType} -> Maybe SSEType
sSEType) (\s :: SSEDescription
s@SSEDescription' {} Maybe SSEType
a -> SSEDescription
s {$sel:sSEType:SSEDescription' :: Maybe SSEType
sSEType = Maybe SSEType
a} :: SSEDescription)

-- | The AWS KMS customer master key (CMK) ARN used for the AWS KMS
-- encryption.
sSEDescription_kmsMasterKeyArn :: Lens.Lens' SSEDescription (Prelude.Maybe Prelude.Text)
sSEDescription_kmsMasterKeyArn :: (Maybe Text -> f (Maybe Text))
-> SSEDescription -> f SSEDescription
sSEDescription_kmsMasterKeyArn = (SSEDescription -> Maybe Text)
-> (SSEDescription -> Maybe Text -> SSEDescription)
-> Lens SSEDescription SSEDescription (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SSEDescription' {Maybe Text
kmsMasterKeyArn :: Maybe Text
$sel:kmsMasterKeyArn:SSEDescription' :: SSEDescription -> Maybe Text
kmsMasterKeyArn} -> Maybe Text
kmsMasterKeyArn) (\s :: SSEDescription
s@SSEDescription' {} Maybe Text
a -> SSEDescription
s {$sel:kmsMasterKeyArn:SSEDescription' :: Maybe Text
kmsMasterKeyArn = Maybe Text
a} :: SSEDescription)

instance Core.FromJSON SSEDescription where
  parseJSON :: Value -> Parser SSEDescription
parseJSON =
    String
-> (Object -> Parser SSEDescription)
-> Value
-> Parser SSEDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SSEDescription"
      ( \Object
x ->
          Maybe SSEStatus
-> Maybe POSIX -> Maybe SSEType -> Maybe Text -> SSEDescription
SSEDescription'
            (Maybe SSEStatus
 -> Maybe POSIX -> Maybe SSEType -> Maybe Text -> SSEDescription)
-> Parser (Maybe SSEStatus)
-> Parser
     (Maybe POSIX -> Maybe SSEType -> Maybe Text -> SSEDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SSEStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe POSIX -> Maybe SSEType -> Maybe Text -> SSEDescription)
-> Parser (Maybe POSIX)
-> Parser (Maybe SSEType -> Maybe Text -> SSEDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InaccessibleEncryptionDateTime")
            Parser (Maybe SSEType -> Maybe Text -> SSEDescription)
-> Parser (Maybe SSEType) -> Parser (Maybe Text -> SSEDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SSEType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SSEType")
            Parser (Maybe Text -> SSEDescription)
-> Parser (Maybe Text) -> Parser SSEDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"KMSMasterKeyArn")
      )

instance Prelude.Hashable SSEDescription

instance Prelude.NFData SSEDescription