{-# 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.GenerateCredentialReport
-- 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 credential report for the Amazon Web Services account. For
-- more information about the credential report, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/credential-reports.html Getting credential reports>
-- in the /IAM User Guide/.
module Amazonka.IAM.GenerateCredentialReport
  ( -- * Creating a Request
    GenerateCredentialReport (..),
    newGenerateCredentialReport,

    -- * Destructuring the Response
    GenerateCredentialReportResponse (..),
    newGenerateCredentialReportResponse,

    -- * Response Lenses
    generateCredentialReportResponse_state,
    generateCredentialReportResponse_description,
    generateCredentialReportResponse_httpStatus,
  )
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:/ 'newGenerateCredentialReport' smart constructor.
data GenerateCredentialReport = GenerateCredentialReport'
  {
  }
  deriving (GenerateCredentialReport -> GenerateCredentialReport -> Bool
(GenerateCredentialReport -> GenerateCredentialReport -> Bool)
-> (GenerateCredentialReport -> GenerateCredentialReport -> Bool)
-> Eq GenerateCredentialReport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GenerateCredentialReport -> GenerateCredentialReport -> Bool
$c/= :: GenerateCredentialReport -> GenerateCredentialReport -> Bool
== :: GenerateCredentialReport -> GenerateCredentialReport -> Bool
$c== :: GenerateCredentialReport -> GenerateCredentialReport -> Bool
Prelude.Eq, ReadPrec [GenerateCredentialReport]
ReadPrec GenerateCredentialReport
Int -> ReadS GenerateCredentialReport
ReadS [GenerateCredentialReport]
(Int -> ReadS GenerateCredentialReport)
-> ReadS [GenerateCredentialReport]
-> ReadPrec GenerateCredentialReport
-> ReadPrec [GenerateCredentialReport]
-> Read GenerateCredentialReport
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GenerateCredentialReport]
$creadListPrec :: ReadPrec [GenerateCredentialReport]
readPrec :: ReadPrec GenerateCredentialReport
$creadPrec :: ReadPrec GenerateCredentialReport
readList :: ReadS [GenerateCredentialReport]
$creadList :: ReadS [GenerateCredentialReport]
readsPrec :: Int -> ReadS GenerateCredentialReport
$creadsPrec :: Int -> ReadS GenerateCredentialReport
Prelude.Read, Int -> GenerateCredentialReport -> ShowS
[GenerateCredentialReport] -> ShowS
GenerateCredentialReport -> String
(Int -> GenerateCredentialReport -> ShowS)
-> (GenerateCredentialReport -> String)
-> ([GenerateCredentialReport] -> ShowS)
-> Show GenerateCredentialReport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GenerateCredentialReport] -> ShowS
$cshowList :: [GenerateCredentialReport] -> ShowS
show :: GenerateCredentialReport -> String
$cshow :: GenerateCredentialReport -> String
showsPrec :: Int -> GenerateCredentialReport -> ShowS
$cshowsPrec :: Int -> GenerateCredentialReport -> ShowS
Prelude.Show, (forall x.
 GenerateCredentialReport -> Rep GenerateCredentialReport x)
-> (forall x.
    Rep GenerateCredentialReport x -> GenerateCredentialReport)
-> Generic GenerateCredentialReport
forall x.
Rep GenerateCredentialReport x -> GenerateCredentialReport
forall x.
GenerateCredentialReport -> Rep GenerateCredentialReport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GenerateCredentialReport x -> GenerateCredentialReport
$cfrom :: forall x.
GenerateCredentialReport -> Rep GenerateCredentialReport x
Prelude.Generic)

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

instance Core.AWSRequest GenerateCredentialReport where
  type
    AWSResponse GenerateCredentialReport =
      GenerateCredentialReportResponse
  request :: GenerateCredentialReport -> Request GenerateCredentialReport
request = Service
-> GenerateCredentialReport -> Request GenerateCredentialReport
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy GenerateCredentialReport
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GenerateCredentialReport)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse GenerateCredentialReport))
-> Logger
-> Service
-> Proxy GenerateCredentialReport
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GenerateCredentialReport)))
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
"GenerateCredentialReportResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe ReportStateType
-> Maybe Text -> Int -> GenerateCredentialReportResponse
GenerateCredentialReportResponse'
            (Maybe ReportStateType
 -> Maybe Text -> Int -> GenerateCredentialReportResponse)
-> Either String (Maybe ReportStateType)
-> Either
     String (Maybe Text -> Int -> GenerateCredentialReportResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe ReportStateType)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"State")
            Either
  String (Maybe Text -> Int -> GenerateCredentialReportResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GenerateCredentialReportResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Description")
            Either String (Int -> GenerateCredentialReportResponse)
-> Either String Int
-> Either String GenerateCredentialReportResponse
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 GenerateCredentialReport

instance Prelude.NFData GenerateCredentialReport

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

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

instance Core.ToQuery GenerateCredentialReport where
  toQuery :: GenerateCredentialReport -> QueryString
toQuery =
    QueryString -> GenerateCredentialReport -> 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
"GenerateCredentialReport" :: 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 GenerateCredentialReport request.
--
-- /See:/ 'newGenerateCredentialReportResponse' smart constructor.
data GenerateCredentialReportResponse = GenerateCredentialReportResponse'
  { -- | Information about the state of the credential report.
    GenerateCredentialReportResponse -> Maybe ReportStateType
state :: Prelude.Maybe ReportStateType,
    -- | Information about the credential report.
    GenerateCredentialReportResponse -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GenerateCredentialReportResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GenerateCredentialReportResponse
-> GenerateCredentialReportResponse -> Bool
(GenerateCredentialReportResponse
 -> GenerateCredentialReportResponse -> Bool)
-> (GenerateCredentialReportResponse
    -> GenerateCredentialReportResponse -> Bool)
-> Eq GenerateCredentialReportResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GenerateCredentialReportResponse
-> GenerateCredentialReportResponse -> Bool
$c/= :: GenerateCredentialReportResponse
-> GenerateCredentialReportResponse -> Bool
== :: GenerateCredentialReportResponse
-> GenerateCredentialReportResponse -> Bool
$c== :: GenerateCredentialReportResponse
-> GenerateCredentialReportResponse -> Bool
Prelude.Eq, ReadPrec [GenerateCredentialReportResponse]
ReadPrec GenerateCredentialReportResponse
Int -> ReadS GenerateCredentialReportResponse
ReadS [GenerateCredentialReportResponse]
(Int -> ReadS GenerateCredentialReportResponse)
-> ReadS [GenerateCredentialReportResponse]
-> ReadPrec GenerateCredentialReportResponse
-> ReadPrec [GenerateCredentialReportResponse]
-> Read GenerateCredentialReportResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GenerateCredentialReportResponse]
$creadListPrec :: ReadPrec [GenerateCredentialReportResponse]
readPrec :: ReadPrec GenerateCredentialReportResponse
$creadPrec :: ReadPrec GenerateCredentialReportResponse
readList :: ReadS [GenerateCredentialReportResponse]
$creadList :: ReadS [GenerateCredentialReportResponse]
readsPrec :: Int -> ReadS GenerateCredentialReportResponse
$creadsPrec :: Int -> ReadS GenerateCredentialReportResponse
Prelude.Read, Int -> GenerateCredentialReportResponse -> ShowS
[GenerateCredentialReportResponse] -> ShowS
GenerateCredentialReportResponse -> String
(Int -> GenerateCredentialReportResponse -> ShowS)
-> (GenerateCredentialReportResponse -> String)
-> ([GenerateCredentialReportResponse] -> ShowS)
-> Show GenerateCredentialReportResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GenerateCredentialReportResponse] -> ShowS
$cshowList :: [GenerateCredentialReportResponse] -> ShowS
show :: GenerateCredentialReportResponse -> String
$cshow :: GenerateCredentialReportResponse -> String
showsPrec :: Int -> GenerateCredentialReportResponse -> ShowS
$cshowsPrec :: Int -> GenerateCredentialReportResponse -> ShowS
Prelude.Show, (forall x.
 GenerateCredentialReportResponse
 -> Rep GenerateCredentialReportResponse x)
-> (forall x.
    Rep GenerateCredentialReportResponse x
    -> GenerateCredentialReportResponse)
-> Generic GenerateCredentialReportResponse
forall x.
Rep GenerateCredentialReportResponse x
-> GenerateCredentialReportResponse
forall x.
GenerateCredentialReportResponse
-> Rep GenerateCredentialReportResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GenerateCredentialReportResponse x
-> GenerateCredentialReportResponse
$cfrom :: forall x.
GenerateCredentialReportResponse
-> Rep GenerateCredentialReportResponse x
Prelude.Generic)

-- |
-- Create a value of 'GenerateCredentialReportResponse' 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:
--
-- 'state', 'generateCredentialReportResponse_state' - Information about the state of the credential report.
--
-- 'description', 'generateCredentialReportResponse_description' - Information about the credential report.
--
-- 'httpStatus', 'generateCredentialReportResponse_httpStatus' - The response's http status code.
newGenerateCredentialReportResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GenerateCredentialReportResponse
newGenerateCredentialReportResponse :: Int -> GenerateCredentialReportResponse
newGenerateCredentialReportResponse Int
pHttpStatus_ =
  GenerateCredentialReportResponse' :: Maybe ReportStateType
-> Maybe Text -> Int -> GenerateCredentialReportResponse
GenerateCredentialReportResponse'
    { $sel:state:GenerateCredentialReportResponse' :: Maybe ReportStateType
state =
        Maybe ReportStateType
forall a. Maybe a
Prelude.Nothing,
      $sel:description:GenerateCredentialReportResponse' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GenerateCredentialReportResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the state of the credential report.
generateCredentialReportResponse_state :: Lens.Lens' GenerateCredentialReportResponse (Prelude.Maybe ReportStateType)
generateCredentialReportResponse_state :: (Maybe ReportStateType -> f (Maybe ReportStateType))
-> GenerateCredentialReportResponse
-> f GenerateCredentialReportResponse
generateCredentialReportResponse_state = (GenerateCredentialReportResponse -> Maybe ReportStateType)
-> (GenerateCredentialReportResponse
    -> Maybe ReportStateType -> GenerateCredentialReportResponse)
-> Lens
     GenerateCredentialReportResponse
     GenerateCredentialReportResponse
     (Maybe ReportStateType)
     (Maybe ReportStateType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateCredentialReportResponse' {Maybe ReportStateType
state :: Maybe ReportStateType
$sel:state:GenerateCredentialReportResponse' :: GenerateCredentialReportResponse -> Maybe ReportStateType
state} -> Maybe ReportStateType
state) (\s :: GenerateCredentialReportResponse
s@GenerateCredentialReportResponse' {} Maybe ReportStateType
a -> GenerateCredentialReportResponse
s {$sel:state:GenerateCredentialReportResponse' :: Maybe ReportStateType
state = Maybe ReportStateType
a} :: GenerateCredentialReportResponse)

-- | Information about the credential report.
generateCredentialReportResponse_description :: Lens.Lens' GenerateCredentialReportResponse (Prelude.Maybe Prelude.Text)
generateCredentialReportResponse_description :: (Maybe Text -> f (Maybe Text))
-> GenerateCredentialReportResponse
-> f GenerateCredentialReportResponse
generateCredentialReportResponse_description = (GenerateCredentialReportResponse -> Maybe Text)
-> (GenerateCredentialReportResponse
    -> Maybe Text -> GenerateCredentialReportResponse)
-> Lens
     GenerateCredentialReportResponse
     GenerateCredentialReportResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateCredentialReportResponse' {Maybe Text
description :: Maybe Text
$sel:description:GenerateCredentialReportResponse' :: GenerateCredentialReportResponse -> Maybe Text
description} -> Maybe Text
description) (\s :: GenerateCredentialReportResponse
s@GenerateCredentialReportResponse' {} Maybe Text
a -> GenerateCredentialReportResponse
s {$sel:description:GenerateCredentialReportResponse' :: Maybe Text
description = Maybe Text
a} :: GenerateCredentialReportResponse)

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

instance
  Prelude.NFData
    GenerateCredentialReportResponse