{-# 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.GetRandomPassword
-- 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)
--
-- Generates a random password of the specified complexity. This operation
-- is intended for use in the Lambda rotation function. Per best practice,
-- we recommend that you specify the maximum length and include every
-- character type that the system you are generating a password for can
-- support.
--
-- __Minimum permissions__
--
-- To run this command, you must have the following permissions:
--
-- -   secretsmanager:GetRandomPassword
module Amazonka.SecretsManager.GetRandomPassword
  ( -- * Creating a Request
    GetRandomPassword (..),
    newGetRandomPassword,

    -- * Request Lenses
    getRandomPassword_includeSpace,
    getRandomPassword_excludeNumbers,
    getRandomPassword_excludeLowercase,
    getRandomPassword_excludeCharacters,
    getRandomPassword_excludePunctuation,
    getRandomPassword_requireEachIncludedType,
    getRandomPassword_excludeUppercase,
    getRandomPassword_passwordLength,

    -- * Destructuring the Response
    GetRandomPasswordResponse (..),
    newGetRandomPasswordResponse,

    -- * Response Lenses
    getRandomPasswordResponse_randomPassword,
    getRandomPasswordResponse_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

-- | /See:/ 'newGetRandomPassword' smart constructor.
data GetRandomPassword = GetRandomPassword'
  { -- | Specifies that the generated password can include the space character.
    -- The default if you do not include this switch parameter is that the
    -- space character is not included.
    GetRandomPassword -> Maybe Bool
includeSpace :: Prelude.Maybe Prelude.Bool,
    -- | Specifies that the generated password should not include digits. The
    -- default if you do not include this switch parameter is that digits can
    -- be included.
    GetRandomPassword -> Maybe Bool
excludeNumbers :: Prelude.Maybe Prelude.Bool,
    -- | Specifies that the generated password should not include lowercase
    -- letters. The default if you do not include this switch parameter is that
    -- lowercase letters can be included.
    GetRandomPassword -> Maybe Bool
excludeLowercase :: Prelude.Maybe Prelude.Bool,
    -- | A string that includes characters that should not be included in the
    -- generated password. The default is that all characters from the included
    -- sets can be used.
    GetRandomPassword -> Maybe Text
excludeCharacters :: Prelude.Maybe Prelude.Text,
    -- | Specifies that the generated password should not include punctuation
    -- characters. The default if you do not include this switch parameter is
    -- that punctuation characters can be included.
    --
    -- The following are the punctuation characters that /can/ be included in
    -- the generated password if you don\'t explicitly exclude them with
    -- @ExcludeCharacters@ or @ExcludePunctuation@:
    --
    -- @! \" # $ % & \' ( ) * + , - . \/ : ; \< = > ? \@ [ \\ ] ^ _ \` { | } ~@
    GetRandomPassword -> Maybe Bool
excludePunctuation :: Prelude.Maybe Prelude.Bool,
    -- | A boolean value that specifies whether the generated password must
    -- include at least one of every allowed character type. The default value
    -- is @True@ and the operation requires at least one of every character
    -- type.
    GetRandomPassword -> Maybe Bool
requireEachIncludedType :: Prelude.Maybe Prelude.Bool,
    -- | Specifies that the generated password should not include uppercase
    -- letters. The default if you do not include this switch parameter is that
    -- uppercase letters can be included.
    GetRandomPassword -> Maybe Bool
excludeUppercase :: Prelude.Maybe Prelude.Bool,
    -- | The desired length of the generated password. The default value if you
    -- do not include this parameter is 32 characters.
    GetRandomPassword -> Maybe Natural
passwordLength :: Prelude.Maybe Prelude.Natural
  }
  deriving (GetRandomPassword -> GetRandomPassword -> Bool
(GetRandomPassword -> GetRandomPassword -> Bool)
-> (GetRandomPassword -> GetRandomPassword -> Bool)
-> Eq GetRandomPassword
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRandomPassword -> GetRandomPassword -> Bool
$c/= :: GetRandomPassword -> GetRandomPassword -> Bool
== :: GetRandomPassword -> GetRandomPassword -> Bool
$c== :: GetRandomPassword -> GetRandomPassword -> Bool
Prelude.Eq, ReadPrec [GetRandomPassword]
ReadPrec GetRandomPassword
Int -> ReadS GetRandomPassword
ReadS [GetRandomPassword]
(Int -> ReadS GetRandomPassword)
-> ReadS [GetRandomPassword]
-> ReadPrec GetRandomPassword
-> ReadPrec [GetRandomPassword]
-> Read GetRandomPassword
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRandomPassword]
$creadListPrec :: ReadPrec [GetRandomPassword]
readPrec :: ReadPrec GetRandomPassword
$creadPrec :: ReadPrec GetRandomPassword
readList :: ReadS [GetRandomPassword]
$creadList :: ReadS [GetRandomPassword]
readsPrec :: Int -> ReadS GetRandomPassword
$creadsPrec :: Int -> ReadS GetRandomPassword
Prelude.Read, Int -> GetRandomPassword -> ShowS
[GetRandomPassword] -> ShowS
GetRandomPassword -> String
(Int -> GetRandomPassword -> ShowS)
-> (GetRandomPassword -> String)
-> ([GetRandomPassword] -> ShowS)
-> Show GetRandomPassword
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRandomPassword] -> ShowS
$cshowList :: [GetRandomPassword] -> ShowS
show :: GetRandomPassword -> String
$cshow :: GetRandomPassword -> String
showsPrec :: Int -> GetRandomPassword -> ShowS
$cshowsPrec :: Int -> GetRandomPassword -> ShowS
Prelude.Show, (forall x. GetRandomPassword -> Rep GetRandomPassword x)
-> (forall x. Rep GetRandomPassword x -> GetRandomPassword)
-> Generic GetRandomPassword
forall x. Rep GetRandomPassword x -> GetRandomPassword
forall x. GetRandomPassword -> Rep GetRandomPassword x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRandomPassword x -> GetRandomPassword
$cfrom :: forall x. GetRandomPassword -> Rep GetRandomPassword x
Prelude.Generic)

-- |
-- Create a value of 'GetRandomPassword' 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:
--
-- 'includeSpace', 'getRandomPassword_includeSpace' - Specifies that the generated password can include the space character.
-- The default if you do not include this switch parameter is that the
-- space character is not included.
--
-- 'excludeNumbers', 'getRandomPassword_excludeNumbers' - Specifies that the generated password should not include digits. The
-- default if you do not include this switch parameter is that digits can
-- be included.
--
-- 'excludeLowercase', 'getRandomPassword_excludeLowercase' - Specifies that the generated password should not include lowercase
-- letters. The default if you do not include this switch parameter is that
-- lowercase letters can be included.
--
-- 'excludeCharacters', 'getRandomPassword_excludeCharacters' - A string that includes characters that should not be included in the
-- generated password. The default is that all characters from the included
-- sets can be used.
--
-- 'excludePunctuation', 'getRandomPassword_excludePunctuation' - Specifies that the generated password should not include punctuation
-- characters. The default if you do not include this switch parameter is
-- that punctuation characters can be included.
--
-- The following are the punctuation characters that /can/ be included in
-- the generated password if you don\'t explicitly exclude them with
-- @ExcludeCharacters@ or @ExcludePunctuation@:
--
-- @! \" # $ % & \' ( ) * + , - . \/ : ; \< = > ? \@ [ \\ ] ^ _ \` { | } ~@
--
-- 'requireEachIncludedType', 'getRandomPassword_requireEachIncludedType' - A boolean value that specifies whether the generated password must
-- include at least one of every allowed character type. The default value
-- is @True@ and the operation requires at least one of every character
-- type.
--
-- 'excludeUppercase', 'getRandomPassword_excludeUppercase' - Specifies that the generated password should not include uppercase
-- letters. The default if you do not include this switch parameter is that
-- uppercase letters can be included.
--
-- 'passwordLength', 'getRandomPassword_passwordLength' - The desired length of the generated password. The default value if you
-- do not include this parameter is 32 characters.
newGetRandomPassword ::
  GetRandomPassword
newGetRandomPassword :: GetRandomPassword
newGetRandomPassword =
  GetRandomPassword' :: Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Natural
-> GetRandomPassword
GetRandomPassword'
    { $sel:includeSpace:GetRandomPassword' :: Maybe Bool
includeSpace = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:excludeNumbers:GetRandomPassword' :: Maybe Bool
excludeNumbers = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:excludeLowercase:GetRandomPassword' :: Maybe Bool
excludeLowercase = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:excludeCharacters:GetRandomPassword' :: Maybe Text
excludeCharacters = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:excludePunctuation:GetRandomPassword' :: Maybe Bool
excludePunctuation = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:requireEachIncludedType:GetRandomPassword' :: Maybe Bool
requireEachIncludedType = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:excludeUppercase:GetRandomPassword' :: Maybe Bool
excludeUppercase = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:passwordLength:GetRandomPassword' :: Maybe Natural
passwordLength = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies that the generated password can include the space character.
-- The default if you do not include this switch parameter is that the
-- space character is not included.
getRandomPassword_includeSpace :: Lens.Lens' GetRandomPassword (Prelude.Maybe Prelude.Bool)
getRandomPassword_includeSpace :: (Maybe Bool -> f (Maybe Bool))
-> GetRandomPassword -> f GetRandomPassword
getRandomPassword_includeSpace = (GetRandomPassword -> Maybe Bool)
-> (GetRandomPassword -> Maybe Bool -> GetRandomPassword)
-> Lens
     GetRandomPassword GetRandomPassword (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRandomPassword' {Maybe Bool
includeSpace :: Maybe Bool
$sel:includeSpace:GetRandomPassword' :: GetRandomPassword -> Maybe Bool
includeSpace} -> Maybe Bool
includeSpace) (\s :: GetRandomPassword
s@GetRandomPassword' {} Maybe Bool
a -> GetRandomPassword
s {$sel:includeSpace:GetRandomPassword' :: Maybe Bool
includeSpace = Maybe Bool
a} :: GetRandomPassword)

-- | Specifies that the generated password should not include digits. The
-- default if you do not include this switch parameter is that digits can
-- be included.
getRandomPassword_excludeNumbers :: Lens.Lens' GetRandomPassword (Prelude.Maybe Prelude.Bool)
getRandomPassword_excludeNumbers :: (Maybe Bool -> f (Maybe Bool))
-> GetRandomPassword -> f GetRandomPassword
getRandomPassword_excludeNumbers = (GetRandomPassword -> Maybe Bool)
-> (GetRandomPassword -> Maybe Bool -> GetRandomPassword)
-> Lens
     GetRandomPassword GetRandomPassword (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRandomPassword' {Maybe Bool
excludeNumbers :: Maybe Bool
$sel:excludeNumbers:GetRandomPassword' :: GetRandomPassword -> Maybe Bool
excludeNumbers} -> Maybe Bool
excludeNumbers) (\s :: GetRandomPassword
s@GetRandomPassword' {} Maybe Bool
a -> GetRandomPassword
s {$sel:excludeNumbers:GetRandomPassword' :: Maybe Bool
excludeNumbers = Maybe Bool
a} :: GetRandomPassword)

-- | Specifies that the generated password should not include lowercase
-- letters. The default if you do not include this switch parameter is that
-- lowercase letters can be included.
getRandomPassword_excludeLowercase :: Lens.Lens' GetRandomPassword (Prelude.Maybe Prelude.Bool)
getRandomPassword_excludeLowercase :: (Maybe Bool -> f (Maybe Bool))
-> GetRandomPassword -> f GetRandomPassword
getRandomPassword_excludeLowercase = (GetRandomPassword -> Maybe Bool)
-> (GetRandomPassword -> Maybe Bool -> GetRandomPassword)
-> Lens
     GetRandomPassword GetRandomPassword (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRandomPassword' {Maybe Bool
excludeLowercase :: Maybe Bool
$sel:excludeLowercase:GetRandomPassword' :: GetRandomPassword -> Maybe Bool
excludeLowercase} -> Maybe Bool
excludeLowercase) (\s :: GetRandomPassword
s@GetRandomPassword' {} Maybe Bool
a -> GetRandomPassword
s {$sel:excludeLowercase:GetRandomPassword' :: Maybe Bool
excludeLowercase = Maybe Bool
a} :: GetRandomPassword)

-- | A string that includes characters that should not be included in the
-- generated password. The default is that all characters from the included
-- sets can be used.
getRandomPassword_excludeCharacters :: Lens.Lens' GetRandomPassword (Prelude.Maybe Prelude.Text)
getRandomPassword_excludeCharacters :: (Maybe Text -> f (Maybe Text))
-> GetRandomPassword -> f GetRandomPassword
getRandomPassword_excludeCharacters = (GetRandomPassword -> Maybe Text)
-> (GetRandomPassword -> Maybe Text -> GetRandomPassword)
-> Lens
     GetRandomPassword GetRandomPassword (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRandomPassword' {Maybe Text
excludeCharacters :: Maybe Text
$sel:excludeCharacters:GetRandomPassword' :: GetRandomPassword -> Maybe Text
excludeCharacters} -> Maybe Text
excludeCharacters) (\s :: GetRandomPassword
s@GetRandomPassword' {} Maybe Text
a -> GetRandomPassword
s {$sel:excludeCharacters:GetRandomPassword' :: Maybe Text
excludeCharacters = Maybe Text
a} :: GetRandomPassword)

-- | Specifies that the generated password should not include punctuation
-- characters. The default if you do not include this switch parameter is
-- that punctuation characters can be included.
--
-- The following are the punctuation characters that /can/ be included in
-- the generated password if you don\'t explicitly exclude them with
-- @ExcludeCharacters@ or @ExcludePunctuation@:
--
-- @! \" # $ % & \' ( ) * + , - . \/ : ; \< = > ? \@ [ \\ ] ^ _ \` { | } ~@
getRandomPassword_excludePunctuation :: Lens.Lens' GetRandomPassword (Prelude.Maybe Prelude.Bool)
getRandomPassword_excludePunctuation :: (Maybe Bool -> f (Maybe Bool))
-> GetRandomPassword -> f GetRandomPassword
getRandomPassword_excludePunctuation = (GetRandomPassword -> Maybe Bool)
-> (GetRandomPassword -> Maybe Bool -> GetRandomPassword)
-> Lens
     GetRandomPassword GetRandomPassword (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRandomPassword' {Maybe Bool
excludePunctuation :: Maybe Bool
$sel:excludePunctuation:GetRandomPassword' :: GetRandomPassword -> Maybe Bool
excludePunctuation} -> Maybe Bool
excludePunctuation) (\s :: GetRandomPassword
s@GetRandomPassword' {} Maybe Bool
a -> GetRandomPassword
s {$sel:excludePunctuation:GetRandomPassword' :: Maybe Bool
excludePunctuation = Maybe Bool
a} :: GetRandomPassword)

-- | A boolean value that specifies whether the generated password must
-- include at least one of every allowed character type. The default value
-- is @True@ and the operation requires at least one of every character
-- type.
getRandomPassword_requireEachIncludedType :: Lens.Lens' GetRandomPassword (Prelude.Maybe Prelude.Bool)
getRandomPassword_requireEachIncludedType :: (Maybe Bool -> f (Maybe Bool))
-> GetRandomPassword -> f GetRandomPassword
getRandomPassword_requireEachIncludedType = (GetRandomPassword -> Maybe Bool)
-> (GetRandomPassword -> Maybe Bool -> GetRandomPassword)
-> Lens
     GetRandomPassword GetRandomPassword (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRandomPassword' {Maybe Bool
requireEachIncludedType :: Maybe Bool
$sel:requireEachIncludedType:GetRandomPassword' :: GetRandomPassword -> Maybe Bool
requireEachIncludedType} -> Maybe Bool
requireEachIncludedType) (\s :: GetRandomPassword
s@GetRandomPassword' {} Maybe Bool
a -> GetRandomPassword
s {$sel:requireEachIncludedType:GetRandomPassword' :: Maybe Bool
requireEachIncludedType = Maybe Bool
a} :: GetRandomPassword)

-- | Specifies that the generated password should not include uppercase
-- letters. The default if you do not include this switch parameter is that
-- uppercase letters can be included.
getRandomPassword_excludeUppercase :: Lens.Lens' GetRandomPassword (Prelude.Maybe Prelude.Bool)
getRandomPassword_excludeUppercase :: (Maybe Bool -> f (Maybe Bool))
-> GetRandomPassword -> f GetRandomPassword
getRandomPassword_excludeUppercase = (GetRandomPassword -> Maybe Bool)
-> (GetRandomPassword -> Maybe Bool -> GetRandomPassword)
-> Lens
     GetRandomPassword GetRandomPassword (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRandomPassword' {Maybe Bool
excludeUppercase :: Maybe Bool
$sel:excludeUppercase:GetRandomPassword' :: GetRandomPassword -> Maybe Bool
excludeUppercase} -> Maybe Bool
excludeUppercase) (\s :: GetRandomPassword
s@GetRandomPassword' {} Maybe Bool
a -> GetRandomPassword
s {$sel:excludeUppercase:GetRandomPassword' :: Maybe Bool
excludeUppercase = Maybe Bool
a} :: GetRandomPassword)

-- | The desired length of the generated password. The default value if you
-- do not include this parameter is 32 characters.
getRandomPassword_passwordLength :: Lens.Lens' GetRandomPassword (Prelude.Maybe Prelude.Natural)
getRandomPassword_passwordLength :: (Maybe Natural -> f (Maybe Natural))
-> GetRandomPassword -> f GetRandomPassword
getRandomPassword_passwordLength = (GetRandomPassword -> Maybe Natural)
-> (GetRandomPassword -> Maybe Natural -> GetRandomPassword)
-> Lens
     GetRandomPassword GetRandomPassword (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRandomPassword' {Maybe Natural
passwordLength :: Maybe Natural
$sel:passwordLength:GetRandomPassword' :: GetRandomPassword -> Maybe Natural
passwordLength} -> Maybe Natural
passwordLength) (\s :: GetRandomPassword
s@GetRandomPassword' {} Maybe Natural
a -> GetRandomPassword
s {$sel:passwordLength:GetRandomPassword' :: Maybe Natural
passwordLength = Maybe Natural
a} :: GetRandomPassword)

instance Core.AWSRequest GetRandomPassword where
  type
    AWSResponse GetRandomPassword =
      GetRandomPasswordResponse
  request :: GetRandomPassword -> Request GetRandomPassword
request = Service -> GetRandomPassword -> Request GetRandomPassword
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetRandomPassword
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRandomPassword)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetRandomPassword))
-> Logger
-> Service
-> Proxy GetRandomPassword
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRandomPassword)))
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 (Sensitive Text) -> Int -> GetRandomPasswordResponse
GetRandomPasswordResponse'
            (Maybe (Sensitive Text) -> Int -> GetRandomPasswordResponse)
-> Either String (Maybe (Sensitive Text))
-> Either String (Int -> GetRandomPasswordResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"RandomPassword")
            Either String (Int -> GetRandomPasswordResponse)
-> Either String Int -> Either String GetRandomPasswordResponse
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 GetRandomPassword

instance Prelude.NFData GetRandomPassword

instance Core.ToHeaders GetRandomPassword where
  toHeaders :: GetRandomPassword -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetRandomPassword -> 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.GetRandomPassword" ::
                          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 GetRandomPassword where
  toJSON :: GetRandomPassword -> Value
toJSON GetRandomPassword' {Maybe Bool
Maybe Natural
Maybe Text
passwordLength :: Maybe Natural
excludeUppercase :: Maybe Bool
requireEachIncludedType :: Maybe Bool
excludePunctuation :: Maybe Bool
excludeCharacters :: Maybe Text
excludeLowercase :: Maybe Bool
excludeNumbers :: Maybe Bool
includeSpace :: Maybe Bool
$sel:passwordLength:GetRandomPassword' :: GetRandomPassword -> Maybe Natural
$sel:excludeUppercase:GetRandomPassword' :: GetRandomPassword -> Maybe Bool
$sel:requireEachIncludedType:GetRandomPassword' :: GetRandomPassword -> Maybe Bool
$sel:excludePunctuation:GetRandomPassword' :: GetRandomPassword -> Maybe Bool
$sel:excludeCharacters:GetRandomPassword' :: GetRandomPassword -> Maybe Text
$sel:excludeLowercase:GetRandomPassword' :: GetRandomPassword -> Maybe Bool
$sel:excludeNumbers:GetRandomPassword' :: GetRandomPassword -> Maybe Bool
$sel:includeSpace:GetRandomPassword' :: GetRandomPassword -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IncludeSpace" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeSpace,
            (Text
"ExcludeNumbers" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
excludeNumbers,
            (Text
"ExcludeLowercase" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
excludeLowercase,
            (Text
"ExcludeCharacters" 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
excludeCharacters,
            (Text
"ExcludePunctuation" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
excludePunctuation,
            (Text
"RequireEachIncludedType" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
requireEachIncludedType,
            (Text
"ExcludeUppercase" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
excludeUppercase,
            (Text
"PasswordLength" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
passwordLength
          ]
      )

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

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

-- | /See:/ 'newGetRandomPasswordResponse' smart constructor.
data GetRandomPasswordResponse = GetRandomPasswordResponse'
  { -- | A string with the generated password.
    GetRandomPasswordResponse -> Maybe (Sensitive Text)
randomPassword :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The response's http status code.
    GetRandomPasswordResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetRandomPasswordResponse -> GetRandomPasswordResponse -> Bool
(GetRandomPasswordResponse -> GetRandomPasswordResponse -> Bool)
-> (GetRandomPasswordResponse -> GetRandomPasswordResponse -> Bool)
-> Eq GetRandomPasswordResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRandomPasswordResponse -> GetRandomPasswordResponse -> Bool
$c/= :: GetRandomPasswordResponse -> GetRandomPasswordResponse -> Bool
== :: GetRandomPasswordResponse -> GetRandomPasswordResponse -> Bool
$c== :: GetRandomPasswordResponse -> GetRandomPasswordResponse -> Bool
Prelude.Eq, Int -> GetRandomPasswordResponse -> ShowS
[GetRandomPasswordResponse] -> ShowS
GetRandomPasswordResponse -> String
(Int -> GetRandomPasswordResponse -> ShowS)
-> (GetRandomPasswordResponse -> String)
-> ([GetRandomPasswordResponse] -> ShowS)
-> Show GetRandomPasswordResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRandomPasswordResponse] -> ShowS
$cshowList :: [GetRandomPasswordResponse] -> ShowS
show :: GetRandomPasswordResponse -> String
$cshow :: GetRandomPasswordResponse -> String
showsPrec :: Int -> GetRandomPasswordResponse -> ShowS
$cshowsPrec :: Int -> GetRandomPasswordResponse -> ShowS
Prelude.Show, (forall x.
 GetRandomPasswordResponse -> Rep GetRandomPasswordResponse x)
-> (forall x.
    Rep GetRandomPasswordResponse x -> GetRandomPasswordResponse)
-> Generic GetRandomPasswordResponse
forall x.
Rep GetRandomPasswordResponse x -> GetRandomPasswordResponse
forall x.
GetRandomPasswordResponse -> Rep GetRandomPasswordResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetRandomPasswordResponse x -> GetRandomPasswordResponse
$cfrom :: forall x.
GetRandomPasswordResponse -> Rep GetRandomPasswordResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetRandomPasswordResponse' 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:
--
-- 'randomPassword', 'getRandomPasswordResponse_randomPassword' - A string with the generated password.
--
-- 'httpStatus', 'getRandomPasswordResponse_httpStatus' - The response's http status code.
newGetRandomPasswordResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRandomPasswordResponse
newGetRandomPasswordResponse :: Int -> GetRandomPasswordResponse
newGetRandomPasswordResponse Int
pHttpStatus_ =
  GetRandomPasswordResponse' :: Maybe (Sensitive Text) -> Int -> GetRandomPasswordResponse
GetRandomPasswordResponse'
    { $sel:randomPassword:GetRandomPasswordResponse' :: Maybe (Sensitive Text)
randomPassword =
        Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRandomPasswordResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A string with the generated password.
getRandomPasswordResponse_randomPassword :: Lens.Lens' GetRandomPasswordResponse (Prelude.Maybe Prelude.Text)
getRandomPasswordResponse_randomPassword :: (Maybe Text -> f (Maybe Text))
-> GetRandomPasswordResponse -> f GetRandomPasswordResponse
getRandomPasswordResponse_randomPassword = (GetRandomPasswordResponse -> Maybe (Sensitive Text))
-> (GetRandomPasswordResponse
    -> Maybe (Sensitive Text) -> GetRandomPasswordResponse)
-> Lens
     GetRandomPasswordResponse
     GetRandomPasswordResponse
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRandomPasswordResponse' {Maybe (Sensitive Text)
randomPassword :: Maybe (Sensitive Text)
$sel:randomPassword:GetRandomPasswordResponse' :: GetRandomPasswordResponse -> Maybe (Sensitive Text)
randomPassword} -> Maybe (Sensitive Text)
randomPassword) (\s :: GetRandomPasswordResponse
s@GetRandomPasswordResponse' {} Maybe (Sensitive Text)
a -> GetRandomPasswordResponse
s {$sel:randomPassword:GetRandomPasswordResponse' :: Maybe (Sensitive Text)
randomPassword = Maybe (Sensitive Text)
a} :: GetRandomPasswordResponse) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> GetRandomPasswordResponse -> f GetRandomPasswordResponse)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> GetRandomPasswordResponse
-> f GetRandomPasswordResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

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

instance Prelude.NFData GetRandomPasswordResponse