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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The configuration for a Secrets Manager secret. For more information,
-- see
-- <https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_CreateSecret.html CreateSecret>.
--
-- You can propose a configuration for a new secret or an existing secret
-- that you own by specifying the secret policy and optional KMS encryption
-- key. If the configuration is for an existing secret and you do not
-- specify the secret policy, the access preview uses the existing policy
-- for the secret. If the access preview is for a new resource and you do
-- not specify the policy, the access preview assumes a secret without a
-- policy. To propose deletion of an existing policy, you can specify an
-- empty string. If the proposed configuration is for a new secret and you
-- do not specify the KMS key ID, the access preview uses the default CMK
-- of the Amazon Web Services account. If you specify an empty string for
-- the KMS key ID, the access preview uses the default CMK of the Amazon
-- Web Services account. For more information about secret policy limits,
-- see
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_limits.html Quotas for Secrets Manager.>.
--
-- /See:/ 'newSecretsManagerSecretConfiguration' smart constructor.
data SecretsManagerSecretConfiguration = SecretsManagerSecretConfiguration'
  { -- | The proposed ARN, key ID, or alias of the KMS customer master key (CMK).
    SecretsManagerSecretConfiguration -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The proposed resource policy defining who can access or manage the
    -- secret.
    SecretsManagerSecretConfiguration -> Maybe Text
secretPolicy :: Prelude.Maybe Prelude.Text
  }
  deriving (SecretsManagerSecretConfiguration
-> SecretsManagerSecretConfiguration -> Bool
(SecretsManagerSecretConfiguration
 -> SecretsManagerSecretConfiguration -> Bool)
-> (SecretsManagerSecretConfiguration
    -> SecretsManagerSecretConfiguration -> Bool)
-> Eq SecretsManagerSecretConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SecretsManagerSecretConfiguration
-> SecretsManagerSecretConfiguration -> Bool
$c/= :: SecretsManagerSecretConfiguration
-> SecretsManagerSecretConfiguration -> Bool
== :: SecretsManagerSecretConfiguration
-> SecretsManagerSecretConfiguration -> Bool
$c== :: SecretsManagerSecretConfiguration
-> SecretsManagerSecretConfiguration -> Bool
Prelude.Eq, ReadPrec [SecretsManagerSecretConfiguration]
ReadPrec SecretsManagerSecretConfiguration
Int -> ReadS SecretsManagerSecretConfiguration
ReadS [SecretsManagerSecretConfiguration]
(Int -> ReadS SecretsManagerSecretConfiguration)
-> ReadS [SecretsManagerSecretConfiguration]
-> ReadPrec SecretsManagerSecretConfiguration
-> ReadPrec [SecretsManagerSecretConfiguration]
-> Read SecretsManagerSecretConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SecretsManagerSecretConfiguration]
$creadListPrec :: ReadPrec [SecretsManagerSecretConfiguration]
readPrec :: ReadPrec SecretsManagerSecretConfiguration
$creadPrec :: ReadPrec SecretsManagerSecretConfiguration
readList :: ReadS [SecretsManagerSecretConfiguration]
$creadList :: ReadS [SecretsManagerSecretConfiguration]
readsPrec :: Int -> ReadS SecretsManagerSecretConfiguration
$creadsPrec :: Int -> ReadS SecretsManagerSecretConfiguration
Prelude.Read, Int -> SecretsManagerSecretConfiguration -> ShowS
[SecretsManagerSecretConfiguration] -> ShowS
SecretsManagerSecretConfiguration -> String
(Int -> SecretsManagerSecretConfiguration -> ShowS)
-> (SecretsManagerSecretConfiguration -> String)
-> ([SecretsManagerSecretConfiguration] -> ShowS)
-> Show SecretsManagerSecretConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SecretsManagerSecretConfiguration] -> ShowS
$cshowList :: [SecretsManagerSecretConfiguration] -> ShowS
show :: SecretsManagerSecretConfiguration -> String
$cshow :: SecretsManagerSecretConfiguration -> String
showsPrec :: Int -> SecretsManagerSecretConfiguration -> ShowS
$cshowsPrec :: Int -> SecretsManagerSecretConfiguration -> ShowS
Prelude.Show, (forall x.
 SecretsManagerSecretConfiguration
 -> Rep SecretsManagerSecretConfiguration x)
-> (forall x.
    Rep SecretsManagerSecretConfiguration x
    -> SecretsManagerSecretConfiguration)
-> Generic SecretsManagerSecretConfiguration
forall x.
Rep SecretsManagerSecretConfiguration x
-> SecretsManagerSecretConfiguration
forall x.
SecretsManagerSecretConfiguration
-> Rep SecretsManagerSecretConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SecretsManagerSecretConfiguration x
-> SecretsManagerSecretConfiguration
$cfrom :: forall x.
SecretsManagerSecretConfiguration
-> Rep SecretsManagerSecretConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SecretsManagerSecretConfiguration' 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:
--
-- 'kmsKeyId', 'secretsManagerSecretConfiguration_kmsKeyId' - The proposed ARN, key ID, or alias of the KMS customer master key (CMK).
--
-- 'secretPolicy', 'secretsManagerSecretConfiguration_secretPolicy' - The proposed resource policy defining who can access or manage the
-- secret.
newSecretsManagerSecretConfiguration ::
  SecretsManagerSecretConfiguration
newSecretsManagerSecretConfiguration :: SecretsManagerSecretConfiguration
newSecretsManagerSecretConfiguration =
  SecretsManagerSecretConfiguration' :: Maybe Text -> Maybe Text -> SecretsManagerSecretConfiguration
SecretsManagerSecretConfiguration'
    { $sel:kmsKeyId:SecretsManagerSecretConfiguration' :: Maybe Text
kmsKeyId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:secretPolicy:SecretsManagerSecretConfiguration' :: Maybe Text
secretPolicy = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The proposed ARN, key ID, or alias of the KMS customer master key (CMK).
secretsManagerSecretConfiguration_kmsKeyId :: Lens.Lens' SecretsManagerSecretConfiguration (Prelude.Maybe Prelude.Text)
secretsManagerSecretConfiguration_kmsKeyId :: (Maybe Text -> f (Maybe Text))
-> SecretsManagerSecretConfiguration
-> f SecretsManagerSecretConfiguration
secretsManagerSecretConfiguration_kmsKeyId = (SecretsManagerSecretConfiguration -> Maybe Text)
-> (SecretsManagerSecretConfiguration
    -> Maybe Text -> SecretsManagerSecretConfiguration)
-> Lens
     SecretsManagerSecretConfiguration
     SecretsManagerSecretConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecretsManagerSecretConfiguration' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:SecretsManagerSecretConfiguration' :: SecretsManagerSecretConfiguration -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: SecretsManagerSecretConfiguration
s@SecretsManagerSecretConfiguration' {} Maybe Text
a -> SecretsManagerSecretConfiguration
s {$sel:kmsKeyId:SecretsManagerSecretConfiguration' :: Maybe Text
kmsKeyId = Maybe Text
a} :: SecretsManagerSecretConfiguration)

-- | The proposed resource policy defining who can access or manage the
-- secret.
secretsManagerSecretConfiguration_secretPolicy :: Lens.Lens' SecretsManagerSecretConfiguration (Prelude.Maybe Prelude.Text)
secretsManagerSecretConfiguration_secretPolicy :: (Maybe Text -> f (Maybe Text))
-> SecretsManagerSecretConfiguration
-> f SecretsManagerSecretConfiguration
secretsManagerSecretConfiguration_secretPolicy = (SecretsManagerSecretConfiguration -> Maybe Text)
-> (SecretsManagerSecretConfiguration
    -> Maybe Text -> SecretsManagerSecretConfiguration)
-> Lens
     SecretsManagerSecretConfiguration
     SecretsManagerSecretConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecretsManagerSecretConfiguration' {Maybe Text
secretPolicy :: Maybe Text
$sel:secretPolicy:SecretsManagerSecretConfiguration' :: SecretsManagerSecretConfiguration -> Maybe Text
secretPolicy} -> Maybe Text
secretPolicy) (\s :: SecretsManagerSecretConfiguration
s@SecretsManagerSecretConfiguration' {} Maybe Text
a -> SecretsManagerSecretConfiguration
s {$sel:secretPolicy:SecretsManagerSecretConfiguration' :: Maybe Text
secretPolicy = Maybe Text
a} :: SecretsManagerSecretConfiguration)

instance
  Core.FromJSON
    SecretsManagerSecretConfiguration
  where
  parseJSON :: Value -> Parser SecretsManagerSecretConfiguration
parseJSON =
    String
-> (Object -> Parser SecretsManagerSecretConfiguration)
-> Value
-> Parser SecretsManagerSecretConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SecretsManagerSecretConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> SecretsManagerSecretConfiguration
SecretsManagerSecretConfiguration'
            (Maybe Text -> Maybe Text -> SecretsManagerSecretConfiguration)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> SecretsManagerSecretConfiguration)
forall (f :: * -> *) a b. Functor 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
"kmsKeyId")
            Parser (Maybe Text -> SecretsManagerSecretConfiguration)
-> Parser (Maybe Text) -> Parser SecretsManagerSecretConfiguration
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
"secretPolicy")
      )

instance
  Prelude.Hashable
    SecretsManagerSecretConfiguration

instance
  Prelude.NFData
    SecretsManagerSecretConfiguration

instance
  Core.ToJSON
    SecretsManagerSecretConfiguration
  where
  toJSON :: SecretsManagerSecretConfiguration -> Value
toJSON SecretsManagerSecretConfiguration' {Maybe Text
secretPolicy :: Maybe Text
kmsKeyId :: Maybe Text
$sel:secretPolicy:SecretsManagerSecretConfiguration' :: SecretsManagerSecretConfiguration -> Maybe Text
$sel:kmsKeyId:SecretsManagerSecretConfiguration' :: SecretsManagerSecretConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"kmsKeyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
kmsKeyId,
            (Text
"secretPolicy" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
secretPolicy
          ]
      )