{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SecretsManager.RotateSecret
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Configures and starts the asynchronous process of rotating the secret.
-- For more information about rotation, see
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-secrets.html Rotate secrets>.
--
-- If you include the configuration parameters, the operation sets the
-- values for the secret and then immediately starts a rotation. If you
-- don\'t include the configuration parameters, the operation starts a
-- rotation with the values already stored in the secret.
--
-- For database credentials you want to rotate, for Secrets Manager to be
-- able to rotate the secret, you must make sure the secret value is in the
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_secret_json_structure.html JSON structure of a database secret>.
-- In particular, if you want to use the
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-secrets_strategies.html#rotating-secrets-two-users alternating users strategy>,
-- your secret must contain the ARN of a superuser secret.
--
-- To configure rotation, you also need the ARN of an Amazon Web Services
-- Lambda function and the schedule for the rotation. The Lambda rotation
-- function creates a new version of the secret and creates or updates the
-- credentials on the database or service to match. After testing the new
-- credentials, the function marks the new secret version with the staging
-- label @AWSCURRENT@. Then anyone who retrieves the secret gets the new
-- version. For more information, see
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotate-secrets_how.html How rotation works>.
--
-- You can create the Lambda rotation function based on the
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_available-rotation-templates.html rotation function templates>
-- that Secrets Manager provides. Choose a template that matches your
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-secrets_strategies.html Rotation strategy>.
--
-- When rotation is successful, the @AWSPENDING@ staging label might be
-- attached to the same version as the @AWSCURRENT@ version, or it might
-- not be attached to any version. If the @AWSPENDING@ staging label is
-- present but not attached to the same version as @AWSCURRENT@, then any
-- later invocation of @RotateSecret@ assumes that a previous rotation
-- request is still in progress and returns an error.
--
-- When rotation is unsuccessful, the @AWSPENDING@ staging label might be
-- attached to an empty secret version. For more information, see
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/troubleshoot_rotation.html Troubleshoot rotation>
-- in the /Secrets Manager User Guide/.
--
-- Secrets Manager generates a CloudTrail log entry when you call this
-- action. Do not include sensitive information in request parameters
-- because it might be logged. For more information, see
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieve-ct-entries.html Logging Secrets Manager events with CloudTrail>.
--
-- __Required permissions:__ @secretsmanager:RotateSecret@. For more
-- information, see
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_iam-permissions.html#reference_iam-permissions_actions IAM policy actions for Secrets Manager>
-- and
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access.html Authentication and access control in Secrets Manager>.
-- You also need @lambda:InvokeFunction@ permissions on the rotation
-- function. For more information, see
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-secrets-required-permissions-function.html Permissions for rotation>.
module Amazonka.SecretsManager.RotateSecret
  ( -- * Creating a Request
    RotateSecret (..),
    newRotateSecret,

    -- * Request Lenses
    rotateSecret_clientRequestToken,
    rotateSecret_rotateImmediately,
    rotateSecret_rotationLambdaARN,
    rotateSecret_rotationRules,
    rotateSecret_secretId,

    -- * Destructuring the Response
    RotateSecretResponse (..),
    newRotateSecretResponse,

    -- * Response Lenses
    rotateSecretResponse_arn,
    rotateSecretResponse_name,
    rotateSecretResponse_versionId,
    rotateSecretResponse_httpStatus,
  )
where

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
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SecretsManager.Types

-- | /See:/ 'newRotateSecret' smart constructor.
data RotateSecret = RotateSecret'
  { -- | A unique identifier for the new version of the secret that helps ensure
    -- idempotency. Secrets Manager uses this value to prevent the accidental
    -- creation of duplicate versions if there are failures and retries during
    -- rotation. This value becomes the @VersionId@ of the new version.
    --
    -- If you use the Amazon Web Services CLI or one of the Amazon Web Services
    -- SDK to call this operation, then you can leave this parameter empty. The
    -- CLI or SDK generates a random UUID for you and includes that in the
    -- request for this parameter. If you don\'t use the SDK and instead
    -- generate a raw HTTP request to the Secrets Manager service endpoint,
    -- then you must generate a @ClientRequestToken@ yourself for new versions
    -- and include that value in the request.
    --
    -- You only need to specify this value if you implement your own retry
    -- logic and you want to ensure that Secrets Manager doesn\'t attempt to
    -- create a secret version twice. We recommend that you generate a
    -- <https://wikipedia.org/wiki/Universally_unique_identifier UUID-type>
    -- value to ensure uniqueness within the specified secret.
    RotateSecret -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether to rotate the secret immediately or wait until the
    -- next scheduled rotation window. The rotation schedule is defined in
    -- RotateSecretRequest$RotationRules.
    --
    -- If you don\'t immediately rotate the secret, Secrets Manager tests the
    -- rotation configuration by running the
    -- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotate-secrets_how.html testSecret step>
    -- of the Lambda rotation function. The test creates an @AWSPENDING@
    -- version of the secret and then removes it.
    --
    -- If you don\'t specify this value, then by default, Secrets Manager
    -- rotates the secret immediately.
    RotateSecret -> Maybe Bool
rotateImmediately :: Prelude.Maybe Prelude.Bool,
    -- | The ARN of the Lambda rotation function that can rotate the secret.
    RotateSecret -> Maybe Text
rotationLambdaARN :: Prelude.Maybe Prelude.Text,
    -- | A structure that defines the rotation configuration for this secret.
    RotateSecret -> Maybe RotationRulesType
rotationRules :: Prelude.Maybe RotationRulesType,
    -- | The ARN or name of the secret to rotate.
    --
    -- For an ARN, we recommend that you specify a complete ARN rather than a
    -- partial ARN. See
    -- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/troubleshoot.html#ARN_secretnamehyphen Finding a secret from a partial ARN>.
    RotateSecret -> Text
secretId :: Prelude.Text
  }
  deriving (RotateSecret -> RotateSecret -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RotateSecret -> RotateSecret -> Bool
$c/= :: RotateSecret -> RotateSecret -> Bool
== :: RotateSecret -> RotateSecret -> Bool
$c== :: RotateSecret -> RotateSecret -> Bool
Prelude.Eq, ReadPrec [RotateSecret]
ReadPrec RotateSecret
Int -> ReadS RotateSecret
ReadS [RotateSecret]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RotateSecret]
$creadListPrec :: ReadPrec [RotateSecret]
readPrec :: ReadPrec RotateSecret
$creadPrec :: ReadPrec RotateSecret
readList :: ReadS [RotateSecret]
$creadList :: ReadS [RotateSecret]
readsPrec :: Int -> ReadS RotateSecret
$creadsPrec :: Int -> ReadS RotateSecret
Prelude.Read, Int -> RotateSecret -> ShowS
[RotateSecret] -> ShowS
RotateSecret -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RotateSecret] -> ShowS
$cshowList :: [RotateSecret] -> ShowS
show :: RotateSecret -> String
$cshow :: RotateSecret -> String
showsPrec :: Int -> RotateSecret -> ShowS
$cshowsPrec :: Int -> RotateSecret -> ShowS
Prelude.Show, forall x. Rep RotateSecret x -> RotateSecret
forall x. RotateSecret -> Rep RotateSecret x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RotateSecret x -> RotateSecret
$cfrom :: forall x. RotateSecret -> Rep RotateSecret x
Prelude.Generic)

-- |
-- Create a value of 'RotateSecret' 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:
--
-- 'clientRequestToken', 'rotateSecret_clientRequestToken' - A unique identifier for the new version of the secret that helps ensure
-- idempotency. Secrets Manager uses this value to prevent the accidental
-- creation of duplicate versions if there are failures and retries during
-- rotation. This value becomes the @VersionId@ of the new version.
--
-- If you use the Amazon Web Services CLI or one of the Amazon Web Services
-- SDK to call this operation, then you can leave this parameter empty. The
-- CLI or SDK generates a random UUID for you and includes that in the
-- request for this parameter. If you don\'t use the SDK and instead
-- generate a raw HTTP request to the Secrets Manager service endpoint,
-- then you must generate a @ClientRequestToken@ yourself for new versions
-- and include that value in the request.
--
-- You only need to specify this value if you implement your own retry
-- logic and you want to ensure that Secrets Manager doesn\'t attempt to
-- create a secret version twice. We recommend that you generate a
-- <https://wikipedia.org/wiki/Universally_unique_identifier UUID-type>
-- value to ensure uniqueness within the specified secret.
--
-- 'rotateImmediately', 'rotateSecret_rotateImmediately' - Specifies whether to rotate the secret immediately or wait until the
-- next scheduled rotation window. The rotation schedule is defined in
-- RotateSecretRequest$RotationRules.
--
-- If you don\'t immediately rotate the secret, Secrets Manager tests the
-- rotation configuration by running the
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotate-secrets_how.html testSecret step>
-- of the Lambda rotation function. The test creates an @AWSPENDING@
-- version of the secret and then removes it.
--
-- If you don\'t specify this value, then by default, Secrets Manager
-- rotates the secret immediately.
--
-- 'rotationLambdaARN', 'rotateSecret_rotationLambdaARN' - The ARN of the Lambda rotation function that can rotate the secret.
--
-- 'rotationRules', 'rotateSecret_rotationRules' - A structure that defines the rotation configuration for this secret.
--
-- 'secretId', 'rotateSecret_secretId' - The ARN or name of the secret to rotate.
--
-- For an ARN, we recommend that you specify a complete ARN rather than a
-- partial ARN. See
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/troubleshoot.html#ARN_secretnamehyphen Finding a secret from a partial ARN>.
newRotateSecret ::
  -- | 'secretId'
  Prelude.Text ->
  RotateSecret
newRotateSecret :: Text -> RotateSecret
newRotateSecret Text
pSecretId_ =
  RotateSecret'
    { $sel:clientRequestToken:RotateSecret' :: Maybe Text
clientRequestToken = forall a. Maybe a
Prelude.Nothing,
      $sel:rotateImmediately:RotateSecret' :: Maybe Bool
rotateImmediately = forall a. Maybe a
Prelude.Nothing,
      $sel:rotationLambdaARN:RotateSecret' :: Maybe Text
rotationLambdaARN = forall a. Maybe a
Prelude.Nothing,
      $sel:rotationRules:RotateSecret' :: Maybe RotationRulesType
rotationRules = forall a. Maybe a
Prelude.Nothing,
      $sel:secretId:RotateSecret' :: Text
secretId = Text
pSecretId_
    }

-- | A unique identifier for the new version of the secret that helps ensure
-- idempotency. Secrets Manager uses this value to prevent the accidental
-- creation of duplicate versions if there are failures and retries during
-- rotation. This value becomes the @VersionId@ of the new version.
--
-- If you use the Amazon Web Services CLI or one of the Amazon Web Services
-- SDK to call this operation, then you can leave this parameter empty. The
-- CLI or SDK generates a random UUID for you and includes that in the
-- request for this parameter. If you don\'t use the SDK and instead
-- generate a raw HTTP request to the Secrets Manager service endpoint,
-- then you must generate a @ClientRequestToken@ yourself for new versions
-- and include that value in the request.
--
-- You only need to specify this value if you implement your own retry
-- logic and you want to ensure that Secrets Manager doesn\'t attempt to
-- create a secret version twice. We recommend that you generate a
-- <https://wikipedia.org/wiki/Universally_unique_identifier UUID-type>
-- value to ensure uniqueness within the specified secret.
rotateSecret_clientRequestToken :: Lens.Lens' RotateSecret (Prelude.Maybe Prelude.Text)
rotateSecret_clientRequestToken :: Lens' RotateSecret (Maybe Text)
rotateSecret_clientRequestToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RotateSecret' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:RotateSecret' :: RotateSecret -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: RotateSecret
s@RotateSecret' {} Maybe Text
a -> RotateSecret
s {$sel:clientRequestToken:RotateSecret' :: Maybe Text
clientRequestToken = Maybe Text
a} :: RotateSecret)

-- | Specifies whether to rotate the secret immediately or wait until the
-- next scheduled rotation window. The rotation schedule is defined in
-- RotateSecretRequest$RotationRules.
--
-- If you don\'t immediately rotate the secret, Secrets Manager tests the
-- rotation configuration by running the
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotate-secrets_how.html testSecret step>
-- of the Lambda rotation function. The test creates an @AWSPENDING@
-- version of the secret and then removes it.
--
-- If you don\'t specify this value, then by default, Secrets Manager
-- rotates the secret immediately.
rotateSecret_rotateImmediately :: Lens.Lens' RotateSecret (Prelude.Maybe Prelude.Bool)
rotateSecret_rotateImmediately :: Lens' RotateSecret (Maybe Bool)
rotateSecret_rotateImmediately = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RotateSecret' {Maybe Bool
rotateImmediately :: Maybe Bool
$sel:rotateImmediately:RotateSecret' :: RotateSecret -> Maybe Bool
rotateImmediately} -> Maybe Bool
rotateImmediately) (\s :: RotateSecret
s@RotateSecret' {} Maybe Bool
a -> RotateSecret
s {$sel:rotateImmediately:RotateSecret' :: Maybe Bool
rotateImmediately = Maybe Bool
a} :: RotateSecret)

-- | The ARN of the Lambda rotation function that can rotate the secret.
rotateSecret_rotationLambdaARN :: Lens.Lens' RotateSecret (Prelude.Maybe Prelude.Text)
rotateSecret_rotationLambdaARN :: Lens' RotateSecret (Maybe Text)
rotateSecret_rotationLambdaARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RotateSecret' {Maybe Text
rotationLambdaARN :: Maybe Text
$sel:rotationLambdaARN:RotateSecret' :: RotateSecret -> Maybe Text
rotationLambdaARN} -> Maybe Text
rotationLambdaARN) (\s :: RotateSecret
s@RotateSecret' {} Maybe Text
a -> RotateSecret
s {$sel:rotationLambdaARN:RotateSecret' :: Maybe Text
rotationLambdaARN = Maybe Text
a} :: RotateSecret)

-- | A structure that defines the rotation configuration for this secret.
rotateSecret_rotationRules :: Lens.Lens' RotateSecret (Prelude.Maybe RotationRulesType)
rotateSecret_rotationRules :: Lens' RotateSecret (Maybe RotationRulesType)
rotateSecret_rotationRules = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RotateSecret' {Maybe RotationRulesType
rotationRules :: Maybe RotationRulesType
$sel:rotationRules:RotateSecret' :: RotateSecret -> Maybe RotationRulesType
rotationRules} -> Maybe RotationRulesType
rotationRules) (\s :: RotateSecret
s@RotateSecret' {} Maybe RotationRulesType
a -> RotateSecret
s {$sel:rotationRules:RotateSecret' :: Maybe RotationRulesType
rotationRules = Maybe RotationRulesType
a} :: RotateSecret)

-- | The ARN or name of the secret to rotate.
--
-- For an ARN, we recommend that you specify a complete ARN rather than a
-- partial ARN. See
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/troubleshoot.html#ARN_secretnamehyphen Finding a secret from a partial ARN>.
rotateSecret_secretId :: Lens.Lens' RotateSecret Prelude.Text
rotateSecret_secretId :: Lens' RotateSecret Text
rotateSecret_secretId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RotateSecret' {Text
secretId :: Text
$sel:secretId:RotateSecret' :: RotateSecret -> Text
secretId} -> Text
secretId) (\s :: RotateSecret
s@RotateSecret' {} Text
a -> RotateSecret
s {$sel:secretId:RotateSecret' :: Text
secretId = Text
a} :: RotateSecret)

instance Core.AWSRequest RotateSecret where
  type AWSResponse RotateSecret = RotateSecretResponse
  request :: (Service -> Service) -> RotateSecret -> Request RotateSecret
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy RotateSecret
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RotateSecret)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Int -> RotateSecretResponse
RotateSecretResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ARN")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"VersionId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable RotateSecret where
  hashWithSalt :: Int -> RotateSecret -> Int
hashWithSalt Int
_salt RotateSecret' {Maybe Bool
Maybe Text
Maybe RotationRulesType
Text
secretId :: Text
rotationRules :: Maybe RotationRulesType
rotationLambdaARN :: Maybe Text
rotateImmediately :: Maybe Bool
clientRequestToken :: Maybe Text
$sel:secretId:RotateSecret' :: RotateSecret -> Text
$sel:rotationRules:RotateSecret' :: RotateSecret -> Maybe RotationRulesType
$sel:rotationLambdaARN:RotateSecret' :: RotateSecret -> Maybe Text
$sel:rotateImmediately:RotateSecret' :: RotateSecret -> Maybe Bool
$sel:clientRequestToken:RotateSecret' :: RotateSecret -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientRequestToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
rotateImmediately
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
rotationLambdaARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RotationRulesType
rotationRules
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
secretId

instance Prelude.NFData RotateSecret where
  rnf :: RotateSecret -> ()
rnf RotateSecret' {Maybe Bool
Maybe Text
Maybe RotationRulesType
Text
secretId :: Text
rotationRules :: Maybe RotationRulesType
rotationLambdaARN :: Maybe Text
rotateImmediately :: Maybe Bool
clientRequestToken :: Maybe Text
$sel:secretId:RotateSecret' :: RotateSecret -> Text
$sel:rotationRules:RotateSecret' :: RotateSecret -> Maybe RotationRulesType
$sel:rotationLambdaARN:RotateSecret' :: RotateSecret -> Maybe Text
$sel:rotateImmediately:RotateSecret' :: RotateSecret -> Maybe Bool
$sel:clientRequestToken:RotateSecret' :: RotateSecret -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientRequestToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
rotateImmediately
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
rotationLambdaARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RotationRulesType
rotationRules
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
secretId

instance Data.ToHeaders RotateSecret where
  toHeaders :: RotateSecret -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"secretsmanager.RotateSecret" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON RotateSecret where
  toJSON :: RotateSecret -> Value
toJSON RotateSecret' {Maybe Bool
Maybe Text
Maybe RotationRulesType
Text
secretId :: Text
rotationRules :: Maybe RotationRulesType
rotationLambdaARN :: Maybe Text
rotateImmediately :: Maybe Bool
clientRequestToken :: Maybe Text
$sel:secretId:RotateSecret' :: RotateSecret -> Text
$sel:rotationRules:RotateSecret' :: RotateSecret -> Maybe RotationRulesType
$sel:rotationLambdaARN:RotateSecret' :: RotateSecret -> Maybe Text
$sel:rotateImmediately:RotateSecret' :: RotateSecret -> Maybe Bool
$sel:clientRequestToken:RotateSecret' :: RotateSecret -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ClientRequestToken" 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
clientRequestToken,
            (Key
"RotateImmediately" 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
rotateImmediately,
            (Key
"RotationLambdaARN" 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
rotationLambdaARN,
            (Key
"RotationRules" 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 RotationRulesType
rotationRules,
            forall a. a -> Maybe a
Prelude.Just (Key
"SecretId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
secretId)
          ]
      )

instance Data.ToPath RotateSecret where
  toPath :: RotateSecret -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery RotateSecret where
  toQuery :: RotateSecret -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newRotateSecretResponse' smart constructor.
data RotateSecretResponse = RotateSecretResponse'
  { -- | The ARN of the secret.
    RotateSecretResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The name of the secret.
    RotateSecretResponse -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ID of the new version of the secret.
    RotateSecretResponse -> Maybe Text
versionId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    RotateSecretResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (RotateSecretResponse -> RotateSecretResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RotateSecretResponse -> RotateSecretResponse -> Bool
$c/= :: RotateSecretResponse -> RotateSecretResponse -> Bool
== :: RotateSecretResponse -> RotateSecretResponse -> Bool
$c== :: RotateSecretResponse -> RotateSecretResponse -> Bool
Prelude.Eq, ReadPrec [RotateSecretResponse]
ReadPrec RotateSecretResponse
Int -> ReadS RotateSecretResponse
ReadS [RotateSecretResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RotateSecretResponse]
$creadListPrec :: ReadPrec [RotateSecretResponse]
readPrec :: ReadPrec RotateSecretResponse
$creadPrec :: ReadPrec RotateSecretResponse
readList :: ReadS [RotateSecretResponse]
$creadList :: ReadS [RotateSecretResponse]
readsPrec :: Int -> ReadS RotateSecretResponse
$creadsPrec :: Int -> ReadS RotateSecretResponse
Prelude.Read, Int -> RotateSecretResponse -> ShowS
[RotateSecretResponse] -> ShowS
RotateSecretResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RotateSecretResponse] -> ShowS
$cshowList :: [RotateSecretResponse] -> ShowS
show :: RotateSecretResponse -> String
$cshow :: RotateSecretResponse -> String
showsPrec :: Int -> RotateSecretResponse -> ShowS
$cshowsPrec :: Int -> RotateSecretResponse -> ShowS
Prelude.Show, forall x. Rep RotateSecretResponse x -> RotateSecretResponse
forall x. RotateSecretResponse -> Rep RotateSecretResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RotateSecretResponse x -> RotateSecretResponse
$cfrom :: forall x. RotateSecretResponse -> Rep RotateSecretResponse x
Prelude.Generic)

-- |
-- Create a value of 'RotateSecretResponse' 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:
--
-- 'arn', 'rotateSecretResponse_arn' - The ARN of the secret.
--
-- 'name', 'rotateSecretResponse_name' - The name of the secret.
--
-- 'versionId', 'rotateSecretResponse_versionId' - The ID of the new version of the secret.
--
-- 'httpStatus', 'rotateSecretResponse_httpStatus' - The response's http status code.
newRotateSecretResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RotateSecretResponse
newRotateSecretResponse :: Int -> RotateSecretResponse
newRotateSecretResponse Int
pHttpStatus_ =
  RotateSecretResponse'
    { $sel:arn:RotateSecretResponse' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:name:RotateSecretResponse' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:versionId:RotateSecretResponse' :: Maybe Text
versionId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RotateSecretResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the secret.
rotateSecretResponse_arn :: Lens.Lens' RotateSecretResponse (Prelude.Maybe Prelude.Text)
rotateSecretResponse_arn :: Lens' RotateSecretResponse (Maybe Text)
rotateSecretResponse_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RotateSecretResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:RotateSecretResponse' :: RotateSecretResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: RotateSecretResponse
s@RotateSecretResponse' {} Maybe Text
a -> RotateSecretResponse
s {$sel:arn:RotateSecretResponse' :: Maybe Text
arn = Maybe Text
a} :: RotateSecretResponse)

-- | The name of the secret.
rotateSecretResponse_name :: Lens.Lens' RotateSecretResponse (Prelude.Maybe Prelude.Text)
rotateSecretResponse_name :: Lens' RotateSecretResponse (Maybe Text)
rotateSecretResponse_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RotateSecretResponse' {Maybe Text
name :: Maybe Text
$sel:name:RotateSecretResponse' :: RotateSecretResponse -> Maybe Text
name} -> Maybe Text
name) (\s :: RotateSecretResponse
s@RotateSecretResponse' {} Maybe Text
a -> RotateSecretResponse
s {$sel:name:RotateSecretResponse' :: Maybe Text
name = Maybe Text
a} :: RotateSecretResponse)

-- | The ID of the new version of the secret.
rotateSecretResponse_versionId :: Lens.Lens' RotateSecretResponse (Prelude.Maybe Prelude.Text)
rotateSecretResponse_versionId :: Lens' RotateSecretResponse (Maybe Text)
rotateSecretResponse_versionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RotateSecretResponse' {Maybe Text
versionId :: Maybe Text
$sel:versionId:RotateSecretResponse' :: RotateSecretResponse -> Maybe Text
versionId} -> Maybe Text
versionId) (\s :: RotateSecretResponse
s@RotateSecretResponse' {} Maybe Text
a -> RotateSecretResponse
s {$sel:versionId:RotateSecretResponse' :: Maybe Text
versionId = Maybe Text
a} :: RotateSecretResponse)

-- | The response's http status code.
rotateSecretResponse_httpStatus :: Lens.Lens' RotateSecretResponse Prelude.Int
rotateSecretResponse_httpStatus :: Lens' RotateSecretResponse Int
rotateSecretResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RotateSecretResponse' {Int
httpStatus :: Int
$sel:httpStatus:RotateSecretResponse' :: RotateSecretResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: RotateSecretResponse
s@RotateSecretResponse' {} Int
a -> RotateSecretResponse
s {$sel:httpStatus:RotateSecretResponse' :: Int
httpStatus = Int
a} :: RotateSecretResponse)

instance Prelude.NFData RotateSecretResponse where
  rnf :: RotateSecretResponse -> ()
rnf RotateSecretResponse' {Int
Maybe Text
httpStatus :: Int
versionId :: Maybe Text
name :: Maybe Text
arn :: Maybe Text
$sel:httpStatus:RotateSecretResponse' :: RotateSecretResponse -> Int
$sel:versionId:RotateSecretResponse' :: RotateSecretResponse -> Maybe Text
$sel:name:RotateSecretResponse' :: RotateSecretResponse -> Maybe Text
$sel:arn:RotateSecretResponse' :: RotateSecretResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
versionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus