{-# 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.IAM.GetAccountPasswordPolicy
-- 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)
--
-- Retrieves the password policy for the Amazon Web Services account. This
-- tells you the complexity requirements and mandatory rotation periods for
-- the IAM user passwords in your account. For more information about using
-- a password policy, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_ManagingPasswordPolicies.html Managing an IAM password policy>.
module Amazonka.IAM.GetAccountPasswordPolicy
  ( -- * Creating a Request
    GetAccountPasswordPolicy (..),
    newGetAccountPasswordPolicy,

    -- * Destructuring the Response
    GetAccountPasswordPolicyResponse (..),
    newGetAccountPasswordPolicyResponse,

    -- * Response Lenses
    getAccountPasswordPolicyResponse_httpStatus,
    getAccountPasswordPolicyResponse_passwordPolicy,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetAccountPasswordPolicy' smart constructor.
data GetAccountPasswordPolicy = GetAccountPasswordPolicy'
  {
  }
  deriving (GetAccountPasswordPolicy -> GetAccountPasswordPolicy -> Bool
(GetAccountPasswordPolicy -> GetAccountPasswordPolicy -> Bool)
-> (GetAccountPasswordPolicy -> GetAccountPasswordPolicy -> Bool)
-> Eq GetAccountPasswordPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAccountPasswordPolicy -> GetAccountPasswordPolicy -> Bool
$c/= :: GetAccountPasswordPolicy -> GetAccountPasswordPolicy -> Bool
== :: GetAccountPasswordPolicy -> GetAccountPasswordPolicy -> Bool
$c== :: GetAccountPasswordPolicy -> GetAccountPasswordPolicy -> Bool
Prelude.Eq, ReadPrec [GetAccountPasswordPolicy]
ReadPrec GetAccountPasswordPolicy
Int -> ReadS GetAccountPasswordPolicy
ReadS [GetAccountPasswordPolicy]
(Int -> ReadS GetAccountPasswordPolicy)
-> ReadS [GetAccountPasswordPolicy]
-> ReadPrec GetAccountPasswordPolicy
-> ReadPrec [GetAccountPasswordPolicy]
-> Read GetAccountPasswordPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAccountPasswordPolicy]
$creadListPrec :: ReadPrec [GetAccountPasswordPolicy]
readPrec :: ReadPrec GetAccountPasswordPolicy
$creadPrec :: ReadPrec GetAccountPasswordPolicy
readList :: ReadS [GetAccountPasswordPolicy]
$creadList :: ReadS [GetAccountPasswordPolicy]
readsPrec :: Int -> ReadS GetAccountPasswordPolicy
$creadsPrec :: Int -> ReadS GetAccountPasswordPolicy
Prelude.Read, Int -> GetAccountPasswordPolicy -> ShowS
[GetAccountPasswordPolicy] -> ShowS
GetAccountPasswordPolicy -> String
(Int -> GetAccountPasswordPolicy -> ShowS)
-> (GetAccountPasswordPolicy -> String)
-> ([GetAccountPasswordPolicy] -> ShowS)
-> Show GetAccountPasswordPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAccountPasswordPolicy] -> ShowS
$cshowList :: [GetAccountPasswordPolicy] -> ShowS
show :: GetAccountPasswordPolicy -> String
$cshow :: GetAccountPasswordPolicy -> String
showsPrec :: Int -> GetAccountPasswordPolicy -> ShowS
$cshowsPrec :: Int -> GetAccountPasswordPolicy -> ShowS
Prelude.Show, (forall x.
 GetAccountPasswordPolicy -> Rep GetAccountPasswordPolicy x)
-> (forall x.
    Rep GetAccountPasswordPolicy x -> GetAccountPasswordPolicy)
-> Generic GetAccountPasswordPolicy
forall x.
Rep GetAccountPasswordPolicy x -> GetAccountPasswordPolicy
forall x.
GetAccountPasswordPolicy -> Rep GetAccountPasswordPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetAccountPasswordPolicy x -> GetAccountPasswordPolicy
$cfrom :: forall x.
GetAccountPasswordPolicy -> Rep GetAccountPasswordPolicy x
Prelude.Generic)

-- |
-- Create a value of 'GetAccountPasswordPolicy' 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.
newGetAccountPasswordPolicy ::
  GetAccountPasswordPolicy
newGetAccountPasswordPolicy :: GetAccountPasswordPolicy
newGetAccountPasswordPolicy =
  GetAccountPasswordPolicy
GetAccountPasswordPolicy'

instance Core.AWSRequest GetAccountPasswordPolicy where
  type
    AWSResponse GetAccountPasswordPolicy =
      GetAccountPasswordPolicyResponse
  request :: GetAccountPasswordPolicy -> Request GetAccountPasswordPolicy
request = Service
-> GetAccountPasswordPolicy -> Request GetAccountPasswordPolicy
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy GetAccountPasswordPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetAccountPasswordPolicy)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse GetAccountPasswordPolicy))
-> Logger
-> Service
-> Proxy GetAccountPasswordPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetAccountPasswordPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"GetAccountPasswordPolicyResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> PasswordPolicy -> GetAccountPasswordPolicyResponse
GetAccountPasswordPolicyResponse'
            (Int -> PasswordPolicy -> GetAccountPasswordPolicyResponse)
-> Either String Int
-> Either
     String (PasswordPolicy -> GetAccountPasswordPolicyResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (PasswordPolicy -> GetAccountPasswordPolicyResponse)
-> Either String PasswordPolicy
-> Either String GetAccountPasswordPolicyResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String PasswordPolicy
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"PasswordPolicy")
      )

instance Prelude.Hashable GetAccountPasswordPolicy

instance Prelude.NFData GetAccountPasswordPolicy

instance Core.ToHeaders GetAccountPasswordPolicy where
  toHeaders :: GetAccountPasswordPolicy -> ResponseHeaders
toHeaders = ResponseHeaders -> GetAccountPasswordPolicy -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery GetAccountPasswordPolicy where
  toQuery :: GetAccountPasswordPolicy -> QueryString
toQuery =
    QueryString -> GetAccountPasswordPolicy -> QueryString
forall a b. a -> b -> a
Prelude.const
      ( [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ ByteString
"Action"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"GetAccountPasswordPolicy" :: Prelude.ByteString),
            ByteString
"Version"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString)
          ]
      )

-- | Contains the response to a successful GetAccountPasswordPolicy request.
--
-- /See:/ 'newGetAccountPasswordPolicyResponse' smart constructor.
data GetAccountPasswordPolicyResponse = GetAccountPasswordPolicyResponse'
  { -- | The response's http status code.
    GetAccountPasswordPolicyResponse -> Int
httpStatus :: Prelude.Int,
    -- | A structure that contains details about the account\'s password policy.
    GetAccountPasswordPolicyResponse -> PasswordPolicy
passwordPolicy :: PasswordPolicy
  }
  deriving (GetAccountPasswordPolicyResponse
-> GetAccountPasswordPolicyResponse -> Bool
(GetAccountPasswordPolicyResponse
 -> GetAccountPasswordPolicyResponse -> Bool)
-> (GetAccountPasswordPolicyResponse
    -> GetAccountPasswordPolicyResponse -> Bool)
-> Eq GetAccountPasswordPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAccountPasswordPolicyResponse
-> GetAccountPasswordPolicyResponse -> Bool
$c/= :: GetAccountPasswordPolicyResponse
-> GetAccountPasswordPolicyResponse -> Bool
== :: GetAccountPasswordPolicyResponse
-> GetAccountPasswordPolicyResponse -> Bool
$c== :: GetAccountPasswordPolicyResponse
-> GetAccountPasswordPolicyResponse -> Bool
Prelude.Eq, ReadPrec [GetAccountPasswordPolicyResponse]
ReadPrec GetAccountPasswordPolicyResponse
Int -> ReadS GetAccountPasswordPolicyResponse
ReadS [GetAccountPasswordPolicyResponse]
(Int -> ReadS GetAccountPasswordPolicyResponse)
-> ReadS [GetAccountPasswordPolicyResponse]
-> ReadPrec GetAccountPasswordPolicyResponse
-> ReadPrec [GetAccountPasswordPolicyResponse]
-> Read GetAccountPasswordPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAccountPasswordPolicyResponse]
$creadListPrec :: ReadPrec [GetAccountPasswordPolicyResponse]
readPrec :: ReadPrec GetAccountPasswordPolicyResponse
$creadPrec :: ReadPrec GetAccountPasswordPolicyResponse
readList :: ReadS [GetAccountPasswordPolicyResponse]
$creadList :: ReadS [GetAccountPasswordPolicyResponse]
readsPrec :: Int -> ReadS GetAccountPasswordPolicyResponse
$creadsPrec :: Int -> ReadS GetAccountPasswordPolicyResponse
Prelude.Read, Int -> GetAccountPasswordPolicyResponse -> ShowS
[GetAccountPasswordPolicyResponse] -> ShowS
GetAccountPasswordPolicyResponse -> String
(Int -> GetAccountPasswordPolicyResponse -> ShowS)
-> (GetAccountPasswordPolicyResponse -> String)
-> ([GetAccountPasswordPolicyResponse] -> ShowS)
-> Show GetAccountPasswordPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAccountPasswordPolicyResponse] -> ShowS
$cshowList :: [GetAccountPasswordPolicyResponse] -> ShowS
show :: GetAccountPasswordPolicyResponse -> String
$cshow :: GetAccountPasswordPolicyResponse -> String
showsPrec :: Int -> GetAccountPasswordPolicyResponse -> ShowS
$cshowsPrec :: Int -> GetAccountPasswordPolicyResponse -> ShowS
Prelude.Show, (forall x.
 GetAccountPasswordPolicyResponse
 -> Rep GetAccountPasswordPolicyResponse x)
-> (forall x.
    Rep GetAccountPasswordPolicyResponse x
    -> GetAccountPasswordPolicyResponse)
-> Generic GetAccountPasswordPolicyResponse
forall x.
Rep GetAccountPasswordPolicyResponse x
-> GetAccountPasswordPolicyResponse
forall x.
GetAccountPasswordPolicyResponse
-> Rep GetAccountPasswordPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetAccountPasswordPolicyResponse x
-> GetAccountPasswordPolicyResponse
$cfrom :: forall x.
GetAccountPasswordPolicyResponse
-> Rep GetAccountPasswordPolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetAccountPasswordPolicyResponse' 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:
--
-- 'httpStatus', 'getAccountPasswordPolicyResponse_httpStatus' - The response's http status code.
--
-- 'passwordPolicy', 'getAccountPasswordPolicyResponse_passwordPolicy' - A structure that contains details about the account\'s password policy.
newGetAccountPasswordPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'passwordPolicy'
  PasswordPolicy ->
  GetAccountPasswordPolicyResponse
newGetAccountPasswordPolicyResponse :: Int -> PasswordPolicy -> GetAccountPasswordPolicyResponse
newGetAccountPasswordPolicyResponse
  Int
pHttpStatus_
  PasswordPolicy
pPasswordPolicy_ =
    GetAccountPasswordPolicyResponse' :: Int -> PasswordPolicy -> GetAccountPasswordPolicyResponse
GetAccountPasswordPolicyResponse'
      { $sel:httpStatus:GetAccountPasswordPolicyResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:passwordPolicy:GetAccountPasswordPolicyResponse' :: PasswordPolicy
passwordPolicy = PasswordPolicy
pPasswordPolicy_
      }

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

-- | A structure that contains details about the account\'s password policy.
getAccountPasswordPolicyResponse_passwordPolicy :: Lens.Lens' GetAccountPasswordPolicyResponse PasswordPolicy
getAccountPasswordPolicyResponse_passwordPolicy :: (PasswordPolicy -> f PasswordPolicy)
-> GetAccountPasswordPolicyResponse
-> f GetAccountPasswordPolicyResponse
getAccountPasswordPolicyResponse_passwordPolicy = (GetAccountPasswordPolicyResponse -> PasswordPolicy)
-> (GetAccountPasswordPolicyResponse
    -> PasswordPolicy -> GetAccountPasswordPolicyResponse)
-> Lens
     GetAccountPasswordPolicyResponse
     GetAccountPasswordPolicyResponse
     PasswordPolicy
     PasswordPolicy
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAccountPasswordPolicyResponse' {PasswordPolicy
passwordPolicy :: PasswordPolicy
$sel:passwordPolicy:GetAccountPasswordPolicyResponse' :: GetAccountPasswordPolicyResponse -> PasswordPolicy
passwordPolicy} -> PasswordPolicy
passwordPolicy) (\s :: GetAccountPasswordPolicyResponse
s@GetAccountPasswordPolicyResponse' {} PasswordPolicy
a -> GetAccountPasswordPolicyResponse
s {$sel:passwordPolicy:GetAccountPasswordPolicyResponse' :: PasswordPolicy
passwordPolicy = PasswordPolicy
a} :: GetAccountPasswordPolicyResponse)

instance
  Prelude.NFData
    GetAccountPasswordPolicyResponse