{-# 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.Firehose.Types.DeliveryStreamEncryptionConfiguration
-- 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.Firehose.Types.DeliveryStreamEncryptionConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.Firehose.Types.DeliveryStreamEncryptionStatus
import Amazonka.Firehose.Types.FailureDescription
import Amazonka.Firehose.Types.KeyType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the server-side encryption (SSE) status for
-- the delivery stream, the type customer master key (CMK) in use, if any,
-- and the ARN of the CMK. You can get
-- @DeliveryStreamEncryptionConfiguration@ by invoking the
-- DescribeDeliveryStream operation.
--
-- /See:/ 'newDeliveryStreamEncryptionConfiguration' smart constructor.
data DeliveryStreamEncryptionConfiguration = DeliveryStreamEncryptionConfiguration'
  { -- | This is the server-side encryption (SSE) status for the delivery stream.
    -- For a full description of the different values of this status, see
    -- StartDeliveryStreamEncryption and StopDeliveryStreamEncryption. If this
    -- status is @ENABLING_FAILED@ or @DISABLING_FAILED@, it is the status of
    -- the most recent attempt to enable or disable SSE, respectively.
    DeliveryStreamEncryptionConfiguration
-> Maybe DeliveryStreamEncryptionStatus
status :: Prelude.Maybe DeliveryStreamEncryptionStatus,
    -- | Indicates the type of customer master key (CMK) that is used for
    -- encryption. The default setting is @AWS_OWNED_CMK@. For more information
    -- about CMKs, see
    -- <https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#master_keys Customer Master Keys (CMKs)>.
    DeliveryStreamEncryptionConfiguration -> Maybe KeyType
keyType :: Prelude.Maybe KeyType,
    -- | If @KeyType@ is @CUSTOMER_MANAGED_CMK@, this field contains the ARN of
    -- the customer managed CMK. If @KeyType@ is @AWS_OWNED_CMK@,
    -- @DeliveryStreamEncryptionConfiguration@ doesn\'t contain a value for
    -- @KeyARN@.
    DeliveryStreamEncryptionConfiguration -> Maybe Text
keyARN :: Prelude.Maybe Prelude.Text,
    -- | Provides details in case one of the following operations fails due to an
    -- error related to KMS: CreateDeliveryStream, DeleteDeliveryStream,
    -- StartDeliveryStreamEncryption, StopDeliveryStreamEncryption.
    DeliveryStreamEncryptionConfiguration -> Maybe FailureDescription
failureDescription :: Prelude.Maybe FailureDescription
  }
  deriving (DeliveryStreamEncryptionConfiguration
-> DeliveryStreamEncryptionConfiguration -> Bool
(DeliveryStreamEncryptionConfiguration
 -> DeliveryStreamEncryptionConfiguration -> Bool)
-> (DeliveryStreamEncryptionConfiguration
    -> DeliveryStreamEncryptionConfiguration -> Bool)
-> Eq DeliveryStreamEncryptionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeliveryStreamEncryptionConfiguration
-> DeliveryStreamEncryptionConfiguration -> Bool
$c/= :: DeliveryStreamEncryptionConfiguration
-> DeliveryStreamEncryptionConfiguration -> Bool
== :: DeliveryStreamEncryptionConfiguration
-> DeliveryStreamEncryptionConfiguration -> Bool
$c== :: DeliveryStreamEncryptionConfiguration
-> DeliveryStreamEncryptionConfiguration -> Bool
Prelude.Eq, ReadPrec [DeliveryStreamEncryptionConfiguration]
ReadPrec DeliveryStreamEncryptionConfiguration
Int -> ReadS DeliveryStreamEncryptionConfiguration
ReadS [DeliveryStreamEncryptionConfiguration]
(Int -> ReadS DeliveryStreamEncryptionConfiguration)
-> ReadS [DeliveryStreamEncryptionConfiguration]
-> ReadPrec DeliveryStreamEncryptionConfiguration
-> ReadPrec [DeliveryStreamEncryptionConfiguration]
-> Read DeliveryStreamEncryptionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeliveryStreamEncryptionConfiguration]
$creadListPrec :: ReadPrec [DeliveryStreamEncryptionConfiguration]
readPrec :: ReadPrec DeliveryStreamEncryptionConfiguration
$creadPrec :: ReadPrec DeliveryStreamEncryptionConfiguration
readList :: ReadS [DeliveryStreamEncryptionConfiguration]
$creadList :: ReadS [DeliveryStreamEncryptionConfiguration]
readsPrec :: Int -> ReadS DeliveryStreamEncryptionConfiguration
$creadsPrec :: Int -> ReadS DeliveryStreamEncryptionConfiguration
Prelude.Read, Int -> DeliveryStreamEncryptionConfiguration -> ShowS
[DeliveryStreamEncryptionConfiguration] -> ShowS
DeliveryStreamEncryptionConfiguration -> String
(Int -> DeliveryStreamEncryptionConfiguration -> ShowS)
-> (DeliveryStreamEncryptionConfiguration -> String)
-> ([DeliveryStreamEncryptionConfiguration] -> ShowS)
-> Show DeliveryStreamEncryptionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeliveryStreamEncryptionConfiguration] -> ShowS
$cshowList :: [DeliveryStreamEncryptionConfiguration] -> ShowS
show :: DeliveryStreamEncryptionConfiguration -> String
$cshow :: DeliveryStreamEncryptionConfiguration -> String
showsPrec :: Int -> DeliveryStreamEncryptionConfiguration -> ShowS
$cshowsPrec :: Int -> DeliveryStreamEncryptionConfiguration -> ShowS
Prelude.Show, (forall x.
 DeliveryStreamEncryptionConfiguration
 -> Rep DeliveryStreamEncryptionConfiguration x)
-> (forall x.
    Rep DeliveryStreamEncryptionConfiguration x
    -> DeliveryStreamEncryptionConfiguration)
-> Generic DeliveryStreamEncryptionConfiguration
forall x.
Rep DeliveryStreamEncryptionConfiguration x
-> DeliveryStreamEncryptionConfiguration
forall x.
DeliveryStreamEncryptionConfiguration
-> Rep DeliveryStreamEncryptionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeliveryStreamEncryptionConfiguration x
-> DeliveryStreamEncryptionConfiguration
$cfrom :: forall x.
DeliveryStreamEncryptionConfiguration
-> Rep DeliveryStreamEncryptionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'DeliveryStreamEncryptionConfiguration' 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', 'deliveryStreamEncryptionConfiguration_status' - This is the server-side encryption (SSE) status for the delivery stream.
-- For a full description of the different values of this status, see
-- StartDeliveryStreamEncryption and StopDeliveryStreamEncryption. If this
-- status is @ENABLING_FAILED@ or @DISABLING_FAILED@, it is the status of
-- the most recent attempt to enable or disable SSE, respectively.
--
-- 'keyType', 'deliveryStreamEncryptionConfiguration_keyType' - Indicates the type of customer master key (CMK) that is used for
-- encryption. The default setting is @AWS_OWNED_CMK@. For more information
-- about CMKs, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#master_keys Customer Master Keys (CMKs)>.
--
-- 'keyARN', 'deliveryStreamEncryptionConfiguration_keyARN' - If @KeyType@ is @CUSTOMER_MANAGED_CMK@, this field contains the ARN of
-- the customer managed CMK. If @KeyType@ is @AWS_OWNED_CMK@,
-- @DeliveryStreamEncryptionConfiguration@ doesn\'t contain a value for
-- @KeyARN@.
--
-- 'failureDescription', 'deliveryStreamEncryptionConfiguration_failureDescription' - Provides details in case one of the following operations fails due to an
-- error related to KMS: CreateDeliveryStream, DeleteDeliveryStream,
-- StartDeliveryStreamEncryption, StopDeliveryStreamEncryption.
newDeliveryStreamEncryptionConfiguration ::
  DeliveryStreamEncryptionConfiguration
newDeliveryStreamEncryptionConfiguration :: DeliveryStreamEncryptionConfiguration
newDeliveryStreamEncryptionConfiguration =
  DeliveryStreamEncryptionConfiguration' :: Maybe DeliveryStreamEncryptionStatus
-> Maybe KeyType
-> Maybe Text
-> Maybe FailureDescription
-> DeliveryStreamEncryptionConfiguration
DeliveryStreamEncryptionConfiguration'
    { $sel:status:DeliveryStreamEncryptionConfiguration' :: Maybe DeliveryStreamEncryptionStatus
status =
        Maybe DeliveryStreamEncryptionStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:keyType:DeliveryStreamEncryptionConfiguration' :: Maybe KeyType
keyType = Maybe KeyType
forall a. Maybe a
Prelude.Nothing,
      $sel:keyARN:DeliveryStreamEncryptionConfiguration' :: Maybe Text
keyARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:failureDescription:DeliveryStreamEncryptionConfiguration' :: Maybe FailureDescription
failureDescription = Maybe FailureDescription
forall a. Maybe a
Prelude.Nothing
    }

-- | This is the server-side encryption (SSE) status for the delivery stream.
-- For a full description of the different values of this status, see
-- StartDeliveryStreamEncryption and StopDeliveryStreamEncryption. If this
-- status is @ENABLING_FAILED@ or @DISABLING_FAILED@, it is the status of
-- the most recent attempt to enable or disable SSE, respectively.
deliveryStreamEncryptionConfiguration_status :: Lens.Lens' DeliveryStreamEncryptionConfiguration (Prelude.Maybe DeliveryStreamEncryptionStatus)
deliveryStreamEncryptionConfiguration_status :: (Maybe DeliveryStreamEncryptionStatus
 -> f (Maybe DeliveryStreamEncryptionStatus))
-> DeliveryStreamEncryptionConfiguration
-> f DeliveryStreamEncryptionConfiguration
deliveryStreamEncryptionConfiguration_status = (DeliveryStreamEncryptionConfiguration
 -> Maybe DeliveryStreamEncryptionStatus)
-> (DeliveryStreamEncryptionConfiguration
    -> Maybe DeliveryStreamEncryptionStatus
    -> DeliveryStreamEncryptionConfiguration)
-> Lens
     DeliveryStreamEncryptionConfiguration
     DeliveryStreamEncryptionConfiguration
     (Maybe DeliveryStreamEncryptionStatus)
     (Maybe DeliveryStreamEncryptionStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeliveryStreamEncryptionConfiguration' {Maybe DeliveryStreamEncryptionStatus
status :: Maybe DeliveryStreamEncryptionStatus
$sel:status:DeliveryStreamEncryptionConfiguration' :: DeliveryStreamEncryptionConfiguration
-> Maybe DeliveryStreamEncryptionStatus
status} -> Maybe DeliveryStreamEncryptionStatus
status) (\s :: DeliveryStreamEncryptionConfiguration
s@DeliveryStreamEncryptionConfiguration' {} Maybe DeliveryStreamEncryptionStatus
a -> DeliveryStreamEncryptionConfiguration
s {$sel:status:DeliveryStreamEncryptionConfiguration' :: Maybe DeliveryStreamEncryptionStatus
status = Maybe DeliveryStreamEncryptionStatus
a} :: DeliveryStreamEncryptionConfiguration)

-- | Indicates the type of customer master key (CMK) that is used for
-- encryption. The default setting is @AWS_OWNED_CMK@. For more information
-- about CMKs, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#master_keys Customer Master Keys (CMKs)>.
deliveryStreamEncryptionConfiguration_keyType :: Lens.Lens' DeliveryStreamEncryptionConfiguration (Prelude.Maybe KeyType)
deliveryStreamEncryptionConfiguration_keyType :: (Maybe KeyType -> f (Maybe KeyType))
-> DeliveryStreamEncryptionConfiguration
-> f DeliveryStreamEncryptionConfiguration
deliveryStreamEncryptionConfiguration_keyType = (DeliveryStreamEncryptionConfiguration -> Maybe KeyType)
-> (DeliveryStreamEncryptionConfiguration
    -> Maybe KeyType -> DeliveryStreamEncryptionConfiguration)
-> Lens
     DeliveryStreamEncryptionConfiguration
     DeliveryStreamEncryptionConfiguration
     (Maybe KeyType)
     (Maybe KeyType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeliveryStreamEncryptionConfiguration' {Maybe KeyType
keyType :: Maybe KeyType
$sel:keyType:DeliveryStreamEncryptionConfiguration' :: DeliveryStreamEncryptionConfiguration -> Maybe KeyType
keyType} -> Maybe KeyType
keyType) (\s :: DeliveryStreamEncryptionConfiguration
s@DeliveryStreamEncryptionConfiguration' {} Maybe KeyType
a -> DeliveryStreamEncryptionConfiguration
s {$sel:keyType:DeliveryStreamEncryptionConfiguration' :: Maybe KeyType
keyType = Maybe KeyType
a} :: DeliveryStreamEncryptionConfiguration)

-- | If @KeyType@ is @CUSTOMER_MANAGED_CMK@, this field contains the ARN of
-- the customer managed CMK. If @KeyType@ is @AWS_OWNED_CMK@,
-- @DeliveryStreamEncryptionConfiguration@ doesn\'t contain a value for
-- @KeyARN@.
deliveryStreamEncryptionConfiguration_keyARN :: Lens.Lens' DeliveryStreamEncryptionConfiguration (Prelude.Maybe Prelude.Text)
deliveryStreamEncryptionConfiguration_keyARN :: (Maybe Text -> f (Maybe Text))
-> DeliveryStreamEncryptionConfiguration
-> f DeliveryStreamEncryptionConfiguration
deliveryStreamEncryptionConfiguration_keyARN = (DeliveryStreamEncryptionConfiguration -> Maybe Text)
-> (DeliveryStreamEncryptionConfiguration
    -> Maybe Text -> DeliveryStreamEncryptionConfiguration)
-> Lens
     DeliveryStreamEncryptionConfiguration
     DeliveryStreamEncryptionConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeliveryStreamEncryptionConfiguration' {Maybe Text
keyARN :: Maybe Text
$sel:keyARN:DeliveryStreamEncryptionConfiguration' :: DeliveryStreamEncryptionConfiguration -> Maybe Text
keyARN} -> Maybe Text
keyARN) (\s :: DeliveryStreamEncryptionConfiguration
s@DeliveryStreamEncryptionConfiguration' {} Maybe Text
a -> DeliveryStreamEncryptionConfiguration
s {$sel:keyARN:DeliveryStreamEncryptionConfiguration' :: Maybe Text
keyARN = Maybe Text
a} :: DeliveryStreamEncryptionConfiguration)

-- | Provides details in case one of the following operations fails due to an
-- error related to KMS: CreateDeliveryStream, DeleteDeliveryStream,
-- StartDeliveryStreamEncryption, StopDeliveryStreamEncryption.
deliveryStreamEncryptionConfiguration_failureDescription :: Lens.Lens' DeliveryStreamEncryptionConfiguration (Prelude.Maybe FailureDescription)
deliveryStreamEncryptionConfiguration_failureDescription :: (Maybe FailureDescription -> f (Maybe FailureDescription))
-> DeliveryStreamEncryptionConfiguration
-> f DeliveryStreamEncryptionConfiguration
deliveryStreamEncryptionConfiguration_failureDescription = (DeliveryStreamEncryptionConfiguration -> Maybe FailureDescription)
-> (DeliveryStreamEncryptionConfiguration
    -> Maybe FailureDescription
    -> DeliveryStreamEncryptionConfiguration)
-> Lens
     DeliveryStreamEncryptionConfiguration
     DeliveryStreamEncryptionConfiguration
     (Maybe FailureDescription)
     (Maybe FailureDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeliveryStreamEncryptionConfiguration' {Maybe FailureDescription
failureDescription :: Maybe FailureDescription
$sel:failureDescription:DeliveryStreamEncryptionConfiguration' :: DeliveryStreamEncryptionConfiguration -> Maybe FailureDescription
failureDescription} -> Maybe FailureDescription
failureDescription) (\s :: DeliveryStreamEncryptionConfiguration
s@DeliveryStreamEncryptionConfiguration' {} Maybe FailureDescription
a -> DeliveryStreamEncryptionConfiguration
s {$sel:failureDescription:DeliveryStreamEncryptionConfiguration' :: Maybe FailureDescription
failureDescription = Maybe FailureDescription
a} :: DeliveryStreamEncryptionConfiguration)

instance
  Core.FromJSON
    DeliveryStreamEncryptionConfiguration
  where
  parseJSON :: Value -> Parser DeliveryStreamEncryptionConfiguration
parseJSON =
    String
-> (Object -> Parser DeliveryStreamEncryptionConfiguration)
-> Value
-> Parser DeliveryStreamEncryptionConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeliveryStreamEncryptionConfiguration"
      ( \Object
x ->
          Maybe DeliveryStreamEncryptionStatus
-> Maybe KeyType
-> Maybe Text
-> Maybe FailureDescription
-> DeliveryStreamEncryptionConfiguration
DeliveryStreamEncryptionConfiguration'
            (Maybe DeliveryStreamEncryptionStatus
 -> Maybe KeyType
 -> Maybe Text
 -> Maybe FailureDescription
 -> DeliveryStreamEncryptionConfiguration)
-> Parser (Maybe DeliveryStreamEncryptionStatus)
-> Parser
     (Maybe KeyType
      -> Maybe Text
      -> Maybe FailureDescription
      -> DeliveryStreamEncryptionConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DeliveryStreamEncryptionStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe KeyType
   -> Maybe Text
   -> Maybe FailureDescription
   -> DeliveryStreamEncryptionConfiguration)
-> Parser (Maybe KeyType)
-> Parser
     (Maybe Text
      -> Maybe FailureDescription
      -> DeliveryStreamEncryptionConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe KeyType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"KeyType")
            Parser
  (Maybe Text
   -> Maybe FailureDescription
   -> DeliveryStreamEncryptionConfiguration)
-> Parser (Maybe Text)
-> Parser
     (Maybe FailureDescription -> DeliveryStreamEncryptionConfiguration)
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
"KeyARN")
            Parser
  (Maybe FailureDescription -> DeliveryStreamEncryptionConfiguration)
-> Parser (Maybe FailureDescription)
-> Parser DeliveryStreamEncryptionConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FailureDescription)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FailureDescription")
      )

instance
  Prelude.Hashable
    DeliveryStreamEncryptionConfiguration

instance
  Prelude.NFData
    DeliveryStreamEncryptionConfiguration