{-# 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 #-}
module Amazonka.SecretsManager.RotateSecret
(
RotateSecret (..),
newRotateSecret,
rotateSecret_rotationRules,
rotateSecret_clientRequestToken,
rotateSecret_rotationLambdaARN,
rotateSecret_secretId,
RotateSecretResponse (..),
newRotateSecretResponse,
rotateSecretResponse_versionId,
rotateSecretResponse_arn,
rotateSecretResponse_name,
rotateSecretResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SecretsManager.Types
data RotateSecret = RotateSecret'
{
RotateSecret -> Maybe RotationRulesType
rotationRules :: Prelude.Maybe RotationRulesType,
RotateSecret -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
RotateSecret -> Maybe Text
rotationLambdaARN :: Prelude.Maybe Prelude.Text,
RotateSecret -> Text
secretId :: Prelude.Text
}
deriving (RotateSecret -> RotateSecret -> Bool
(RotateSecret -> RotateSecret -> Bool)
-> (RotateSecret -> RotateSecret -> Bool) -> Eq RotateSecret
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]
(Int -> ReadS RotateSecret)
-> ReadS [RotateSecret]
-> ReadPrec RotateSecret
-> ReadPrec [RotateSecret]
-> Read 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
(Int -> RotateSecret -> ShowS)
-> (RotateSecret -> String)
-> ([RotateSecret] -> ShowS)
-> Show RotateSecret
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. RotateSecret -> Rep RotateSecret x)
-> (forall x. Rep RotateSecret x -> RotateSecret)
-> Generic RotateSecret
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)
newRotateSecret ::
Prelude.Text ->
RotateSecret
newRotateSecret :: Text -> RotateSecret
newRotateSecret Text
pSecretId_ =
RotateSecret' :: Maybe RotationRulesType
-> Maybe Text -> Maybe Text -> Text -> RotateSecret
RotateSecret'
{ $sel:rotationRules:RotateSecret' :: Maybe RotationRulesType
rotationRules = Maybe RotationRulesType
forall a. Maybe a
Prelude.Nothing,
$sel:clientRequestToken:RotateSecret' :: Maybe Text
clientRequestToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:rotationLambdaARN:RotateSecret' :: Maybe Text
rotationLambdaARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:secretId:RotateSecret' :: Text
secretId = Text
pSecretId_
}
rotateSecret_rotationRules :: Lens.Lens' RotateSecret (Prelude.Maybe RotationRulesType)
rotateSecret_rotationRules :: (Maybe RotationRulesType -> f (Maybe RotationRulesType))
-> RotateSecret -> f RotateSecret
rotateSecret_rotationRules = (RotateSecret -> Maybe RotationRulesType)
-> (RotateSecret -> Maybe RotationRulesType -> RotateSecret)
-> Lens
RotateSecret
RotateSecret
(Maybe RotationRulesType)
(Maybe RotationRulesType)
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)
rotateSecret_clientRequestToken :: Lens.Lens' RotateSecret (Prelude.Maybe Prelude.Text)
rotateSecret_clientRequestToken :: (Maybe Text -> f (Maybe Text)) -> RotateSecret -> f RotateSecret
rotateSecret_clientRequestToken = (RotateSecret -> Maybe Text)
-> (RotateSecret -> Maybe Text -> RotateSecret)
-> Lens RotateSecret RotateSecret (Maybe Text) (Maybe Text)
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)
rotateSecret_rotationLambdaARN :: Lens.Lens' RotateSecret (Prelude.Maybe Prelude.Text)
rotateSecret_rotationLambdaARN :: (Maybe Text -> f (Maybe Text)) -> RotateSecret -> f RotateSecret
rotateSecret_rotationLambdaARN = (RotateSecret -> Maybe Text)
-> (RotateSecret -> Maybe Text -> RotateSecret)
-> Lens RotateSecret RotateSecret (Maybe Text) (Maybe Text)
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)
rotateSecret_secretId :: Lens.Lens' RotateSecret Prelude.Text
rotateSecret_secretId :: (Text -> f Text) -> RotateSecret -> f RotateSecret
rotateSecret_secretId = (RotateSecret -> Text)
-> (RotateSecret -> Text -> RotateSecret)
-> Lens RotateSecret RotateSecret Text Text
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 :: RotateSecret -> Request RotateSecret
request = Service -> RotateSecret -> Request RotateSecret
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy RotateSecret
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RotateSecret)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse RotateSecret))
-> Logger
-> Service
-> Proxy RotateSecret
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RotateSecret)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> 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'
(Maybe Text
-> Maybe Text -> Maybe Text -> Int -> RotateSecretResponse)
-> Either String (Maybe Text)
-> Either
String (Maybe Text -> Maybe Text -> Int -> RotateSecretResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"VersionId")
Either
String (Maybe Text -> Maybe Text -> Int -> RotateSecretResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> RotateSecretResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ARN")
Either String (Maybe Text -> Int -> RotateSecretResponse)
-> Either String (Maybe Text)
-> Either String (Int -> RotateSecretResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Name")
Either String (Int -> RotateSecretResponse)
-> Either String Int -> Either String RotateSecretResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable RotateSecret
instance Prelude.NFData RotateSecret
instance Core.ToHeaders RotateSecret where
toHeaders :: RotateSecret -> ResponseHeaders
toHeaders =
ResponseHeaders -> RotateSecret -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"secretsmanager.RotateSecret" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON RotateSecret where
toJSON :: RotateSecret -> Value
toJSON RotateSecret' {Maybe Text
Maybe RotationRulesType
Text
secretId :: Text
rotationLambdaARN :: Maybe Text
clientRequestToken :: Maybe Text
rotationRules :: Maybe RotationRulesType
$sel:secretId:RotateSecret' :: RotateSecret -> Text
$sel:rotationLambdaARN:RotateSecret' :: RotateSecret -> Maybe Text
$sel:clientRequestToken:RotateSecret' :: RotateSecret -> Maybe Text
$sel:rotationRules:RotateSecret' :: RotateSecret -> Maybe RotationRulesType
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"RotationRules" Text -> RotationRulesType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RotationRulesType -> Pair)
-> Maybe RotationRulesType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RotationRulesType
rotationRules,
(Text
"ClientRequestToken" 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
clientRequestToken,
(Text
"RotationLambdaARN" 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
rotationLambdaARN,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SecretId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
secretId)
]
)
instance Core.ToPath RotateSecret where
toPath :: RotateSecret -> ByteString
toPath = ByteString -> RotateSecret -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery RotateSecret where
toQuery :: RotateSecret -> QueryString
toQuery = QueryString -> RotateSecret -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data RotateSecretResponse = RotateSecretResponse'
{
RotateSecretResponse -> Maybe Text
versionId :: Prelude.Maybe Prelude.Text,
RotateSecretResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
RotateSecretResponse -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
RotateSecretResponse -> Int
httpStatus :: Prelude.Int
}
deriving (RotateSecretResponse -> RotateSecretResponse -> Bool
(RotateSecretResponse -> RotateSecretResponse -> Bool)
-> (RotateSecretResponse -> RotateSecretResponse -> Bool)
-> Eq RotateSecretResponse
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]
(Int -> ReadS RotateSecretResponse)
-> ReadS [RotateSecretResponse]
-> ReadPrec RotateSecretResponse
-> ReadPrec [RotateSecretResponse]
-> Read 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
(Int -> RotateSecretResponse -> ShowS)
-> (RotateSecretResponse -> String)
-> ([RotateSecretResponse] -> ShowS)
-> Show RotateSecretResponse
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. RotateSecretResponse -> Rep RotateSecretResponse x)
-> (forall x. Rep RotateSecretResponse x -> RotateSecretResponse)
-> Generic RotateSecretResponse
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)
newRotateSecretResponse ::
Prelude.Int ->
RotateSecretResponse
newRotateSecretResponse :: Int -> RotateSecretResponse
newRotateSecretResponse Int
pHttpStatus_ =
RotateSecretResponse' :: Maybe Text
-> Maybe Text -> Maybe Text -> Int -> RotateSecretResponse
RotateSecretResponse'
{ $sel:versionId:RotateSecretResponse' :: Maybe Text
versionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:arn:RotateSecretResponse' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:RotateSecretResponse' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:RotateSecretResponse' :: Int
httpStatus = Int
pHttpStatus_
}
rotateSecretResponse_versionId :: Lens.Lens' RotateSecretResponse (Prelude.Maybe Prelude.Text)
rotateSecretResponse_versionId :: (Maybe Text -> f (Maybe Text))
-> RotateSecretResponse -> f RotateSecretResponse
rotateSecretResponse_versionId = (RotateSecretResponse -> Maybe Text)
-> (RotateSecretResponse -> Maybe Text -> RotateSecretResponse)
-> Lens
RotateSecretResponse RotateSecretResponse (Maybe Text) (Maybe Text)
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)
rotateSecretResponse_arn :: Lens.Lens' RotateSecretResponse (Prelude.Maybe Prelude.Text)
rotateSecretResponse_arn :: (Maybe Text -> f (Maybe Text))
-> RotateSecretResponse -> f RotateSecretResponse
rotateSecretResponse_arn = (RotateSecretResponse -> Maybe Text)
-> (RotateSecretResponse -> Maybe Text -> RotateSecretResponse)
-> Lens
RotateSecretResponse RotateSecretResponse (Maybe Text) (Maybe Text)
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)
rotateSecretResponse_name :: Lens.Lens' RotateSecretResponse (Prelude.Maybe Prelude.Text)
rotateSecretResponse_name :: (Maybe Text -> f (Maybe Text))
-> RotateSecretResponse -> f RotateSecretResponse
rotateSecretResponse_name = (RotateSecretResponse -> Maybe Text)
-> (RotateSecretResponse -> Maybe Text -> RotateSecretResponse)
-> Lens
RotateSecretResponse RotateSecretResponse (Maybe Text) (Maybe Text)
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)
rotateSecretResponse_httpStatus :: Lens.Lens' RotateSecretResponse Prelude.Int
rotateSecretResponse_httpStatus :: (Int -> f Int) -> RotateSecretResponse -> f RotateSecretResponse
rotateSecretResponse_httpStatus = (RotateSecretResponse -> Int)
-> (RotateSecretResponse -> Int -> RotateSecretResponse)
-> Lens RotateSecretResponse RotateSecretResponse Int Int
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