{-# 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.AccessAnalyzer.Types.RdsDbClusterSnapshotConfiguration
-- 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.AccessAnalyzer.Types.RdsDbClusterSnapshotConfiguration where

import Amazonka.AccessAnalyzer.Types.RdsDbClusterSnapshotAttributeValue
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The proposed access control configuration for an Amazon RDS DB cluster
-- snapshot. You can propose a configuration for a new Amazon RDS DB
-- cluster snapshot or an Amazon RDS DB cluster snapshot that you own by
-- specifying the @RdsDbClusterSnapshotAttributeValue@ and optional KMS
-- encryption key. For more information, see
-- <https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_ModifyDBClusterSnapshotAttribute.html ModifyDBClusterSnapshotAttribute>.
--
-- /See:/ 'newRdsDbClusterSnapshotConfiguration' smart constructor.
data RdsDbClusterSnapshotConfiguration = RdsDbClusterSnapshotConfiguration'
  { -- | The names and values of manual DB cluster snapshot attributes. Manual DB
    -- cluster snapshot attributes are used to authorize other Amazon Web
    -- Services accounts to restore a manual DB cluster snapshot. The only
    -- valid value for @AttributeName@ for the attribute map is @restore@
    RdsDbClusterSnapshotConfiguration
-> Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text RdsDbClusterSnapshotAttributeValue),
    -- | The KMS key identifier for an encrypted Amazon RDS DB cluster snapshot.
    -- The KMS key identifier is the key ARN, key ID, alias ARN, or alias name
    -- for the KMS key.
    --
    -- -   If the configuration is for an existing Amazon RDS DB cluster
    --     snapshot and you do not specify the @kmsKeyId@, or you specify an
    --     empty string, then the access preview uses the existing @kmsKeyId@
    --     of the snapshot.
    --
    -- -   If the access preview is for a new resource and you do not specify
    --     the specify the @kmsKeyId@, then the access preview considers the
    --     snapshot as unencrypted.
    RdsDbClusterSnapshotConfiguration -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text
  }
  deriving (RdsDbClusterSnapshotConfiguration
-> RdsDbClusterSnapshotConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RdsDbClusterSnapshotConfiguration
-> RdsDbClusterSnapshotConfiguration -> Bool
$c/= :: RdsDbClusterSnapshotConfiguration
-> RdsDbClusterSnapshotConfiguration -> Bool
== :: RdsDbClusterSnapshotConfiguration
-> RdsDbClusterSnapshotConfiguration -> Bool
$c== :: RdsDbClusterSnapshotConfiguration
-> RdsDbClusterSnapshotConfiguration -> Bool
Prelude.Eq, ReadPrec [RdsDbClusterSnapshotConfiguration]
ReadPrec RdsDbClusterSnapshotConfiguration
Int -> ReadS RdsDbClusterSnapshotConfiguration
ReadS [RdsDbClusterSnapshotConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RdsDbClusterSnapshotConfiguration]
$creadListPrec :: ReadPrec [RdsDbClusterSnapshotConfiguration]
readPrec :: ReadPrec RdsDbClusterSnapshotConfiguration
$creadPrec :: ReadPrec RdsDbClusterSnapshotConfiguration
readList :: ReadS [RdsDbClusterSnapshotConfiguration]
$creadList :: ReadS [RdsDbClusterSnapshotConfiguration]
readsPrec :: Int -> ReadS RdsDbClusterSnapshotConfiguration
$creadsPrec :: Int -> ReadS RdsDbClusterSnapshotConfiguration
Prelude.Read, Int -> RdsDbClusterSnapshotConfiguration -> ShowS
[RdsDbClusterSnapshotConfiguration] -> ShowS
RdsDbClusterSnapshotConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RdsDbClusterSnapshotConfiguration] -> ShowS
$cshowList :: [RdsDbClusterSnapshotConfiguration] -> ShowS
show :: RdsDbClusterSnapshotConfiguration -> String
$cshow :: RdsDbClusterSnapshotConfiguration -> String
showsPrec :: Int -> RdsDbClusterSnapshotConfiguration -> ShowS
$cshowsPrec :: Int -> RdsDbClusterSnapshotConfiguration -> ShowS
Prelude.Show, forall x.
Rep RdsDbClusterSnapshotConfiguration x
-> RdsDbClusterSnapshotConfiguration
forall x.
RdsDbClusterSnapshotConfiguration
-> Rep RdsDbClusterSnapshotConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RdsDbClusterSnapshotConfiguration x
-> RdsDbClusterSnapshotConfiguration
$cfrom :: forall x.
RdsDbClusterSnapshotConfiguration
-> Rep RdsDbClusterSnapshotConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'RdsDbClusterSnapshotConfiguration' 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:
--
-- 'attributes', 'rdsDbClusterSnapshotConfiguration_attributes' - The names and values of manual DB cluster snapshot attributes. Manual DB
-- cluster snapshot attributes are used to authorize other Amazon Web
-- Services accounts to restore a manual DB cluster snapshot. The only
-- valid value for @AttributeName@ for the attribute map is @restore@
--
-- 'kmsKeyId', 'rdsDbClusterSnapshotConfiguration_kmsKeyId' - The KMS key identifier for an encrypted Amazon RDS DB cluster snapshot.
-- The KMS key identifier is the key ARN, key ID, alias ARN, or alias name
-- for the KMS key.
--
-- -   If the configuration is for an existing Amazon RDS DB cluster
--     snapshot and you do not specify the @kmsKeyId@, or you specify an
--     empty string, then the access preview uses the existing @kmsKeyId@
--     of the snapshot.
--
-- -   If the access preview is for a new resource and you do not specify
--     the specify the @kmsKeyId@, then the access preview considers the
--     snapshot as unencrypted.
newRdsDbClusterSnapshotConfiguration ::
  RdsDbClusterSnapshotConfiguration
newRdsDbClusterSnapshotConfiguration :: RdsDbClusterSnapshotConfiguration
newRdsDbClusterSnapshotConfiguration =
  RdsDbClusterSnapshotConfiguration'
    { $sel:attributes:RdsDbClusterSnapshotConfiguration' :: Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
attributes =
        forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:RdsDbClusterSnapshotConfiguration' :: Maybe Text
kmsKeyId = forall a. Maybe a
Prelude.Nothing
    }

-- | The names and values of manual DB cluster snapshot attributes. Manual DB
-- cluster snapshot attributes are used to authorize other Amazon Web
-- Services accounts to restore a manual DB cluster snapshot. The only
-- valid value for @AttributeName@ for the attribute map is @restore@
rdsDbClusterSnapshotConfiguration_attributes :: Lens.Lens' RdsDbClusterSnapshotConfiguration (Prelude.Maybe (Prelude.HashMap Prelude.Text RdsDbClusterSnapshotAttributeValue))
rdsDbClusterSnapshotConfiguration_attributes :: Lens'
  RdsDbClusterSnapshotConfiguration
  (Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue))
rdsDbClusterSnapshotConfiguration_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RdsDbClusterSnapshotConfiguration' {Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
attributes :: Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
$sel:attributes:RdsDbClusterSnapshotConfiguration' :: RdsDbClusterSnapshotConfiguration
-> Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
attributes} -> Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
attributes) (\s :: RdsDbClusterSnapshotConfiguration
s@RdsDbClusterSnapshotConfiguration' {} Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
a -> RdsDbClusterSnapshotConfiguration
s {$sel:attributes:RdsDbClusterSnapshotConfiguration' :: Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
attributes = Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
a} :: RdsDbClusterSnapshotConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The KMS key identifier for an encrypted Amazon RDS DB cluster snapshot.
-- The KMS key identifier is the key ARN, key ID, alias ARN, or alias name
-- for the KMS key.
--
-- -   If the configuration is for an existing Amazon RDS DB cluster
--     snapshot and you do not specify the @kmsKeyId@, or you specify an
--     empty string, then the access preview uses the existing @kmsKeyId@
--     of the snapshot.
--
-- -   If the access preview is for a new resource and you do not specify
--     the specify the @kmsKeyId@, then the access preview considers the
--     snapshot as unencrypted.
rdsDbClusterSnapshotConfiguration_kmsKeyId :: Lens.Lens' RdsDbClusterSnapshotConfiguration (Prelude.Maybe Prelude.Text)
rdsDbClusterSnapshotConfiguration_kmsKeyId :: Lens' RdsDbClusterSnapshotConfiguration (Maybe Text)
rdsDbClusterSnapshotConfiguration_kmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RdsDbClusterSnapshotConfiguration' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:RdsDbClusterSnapshotConfiguration' :: RdsDbClusterSnapshotConfiguration -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: RdsDbClusterSnapshotConfiguration
s@RdsDbClusterSnapshotConfiguration' {} Maybe Text
a -> RdsDbClusterSnapshotConfiguration
s {$sel:kmsKeyId:RdsDbClusterSnapshotConfiguration' :: Maybe Text
kmsKeyId = Maybe Text
a} :: RdsDbClusterSnapshotConfiguration)

instance
  Data.FromJSON
    RdsDbClusterSnapshotConfiguration
  where
  parseJSON :: Value -> Parser RdsDbClusterSnapshotConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RdsDbClusterSnapshotConfiguration"
      ( \Object
x ->
          Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
-> Maybe Text -> RdsDbClusterSnapshotConfiguration
RdsDbClusterSnapshotConfiguration'
            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
"attributes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"kmsKeyId")
      )

instance
  Prelude.Hashable
    RdsDbClusterSnapshotConfiguration
  where
  hashWithSalt :: Int -> RdsDbClusterSnapshotConfiguration -> Int
hashWithSalt
    Int
_salt
    RdsDbClusterSnapshotConfiguration' {Maybe Text
Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
kmsKeyId :: Maybe Text
attributes :: Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
$sel:kmsKeyId:RdsDbClusterSnapshotConfiguration' :: RdsDbClusterSnapshotConfiguration -> Maybe Text
$sel:attributes:RdsDbClusterSnapshotConfiguration' :: RdsDbClusterSnapshotConfiguration
-> Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
attributes
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyId

instance
  Prelude.NFData
    RdsDbClusterSnapshotConfiguration
  where
  rnf :: RdsDbClusterSnapshotConfiguration -> ()
rnf RdsDbClusterSnapshotConfiguration' {Maybe Text
Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
kmsKeyId :: Maybe Text
attributes :: Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
$sel:kmsKeyId:RdsDbClusterSnapshotConfiguration' :: RdsDbClusterSnapshotConfiguration -> Maybe Text
$sel:attributes:RdsDbClusterSnapshotConfiguration' :: RdsDbClusterSnapshotConfiguration
-> Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyId

instance
  Data.ToJSON
    RdsDbClusterSnapshotConfiguration
  where
  toJSON :: RdsDbClusterSnapshotConfiguration -> Value
toJSON RdsDbClusterSnapshotConfiguration' {Maybe Text
Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
kmsKeyId :: Maybe Text
attributes :: Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
$sel:kmsKeyId:RdsDbClusterSnapshotConfiguration' :: RdsDbClusterSnapshotConfiguration -> Maybe Text
$sel:attributes:RdsDbClusterSnapshotConfiguration' :: RdsDbClusterSnapshotConfiguration
-> Maybe (HashMap Text RdsDbClusterSnapshotAttributeValue)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"attributes" 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 (HashMap Text RdsDbClusterSnapshotAttributeValue)
attributes,
            (Key
"kmsKeyId" 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 Text
kmsKeyId
          ]
      )