{-# 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.GetAccountSummary
-- 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 information about IAM entity usage and IAM quotas in the
-- Amazon Web Services account.
--
-- For information about IAM quotas, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html IAM and STS quotas>
-- in the /IAM User Guide/.
module Amazonka.IAM.GetAccountSummary
  ( -- * Creating a Request
    GetAccountSummary (..),
    newGetAccountSummary,

    -- * Destructuring the Response
    GetAccountSummaryResponse (..),
    newGetAccountSummaryResponse,

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

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

instance Core.AWSRequest GetAccountSummary where
  type
    AWSResponse GetAccountSummary =
      GetAccountSummaryResponse
  request :: GetAccountSummary -> Request GetAccountSummary
request = Service -> GetAccountSummary -> Request GetAccountSummary
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy GetAccountSummary
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetAccountSummary)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse GetAccountSummary))
-> Logger
-> Service
-> Proxy GetAccountSummary
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetAccountSummary)))
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
"GetAccountSummaryResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe (HashMap SummaryKeyType Int)
-> Int -> GetAccountSummaryResponse
GetAccountSummaryResponse'
            (Maybe (HashMap SummaryKeyType Int)
 -> Int -> GetAccountSummaryResponse)
-> Either String (Maybe (HashMap SummaryKeyType Int))
-> Either String (Int -> GetAccountSummaryResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SummaryMap" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe (HashMap SummaryKeyType Int)))
-> Either String (Maybe (HashMap SummaryKeyType Int))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String (HashMap SummaryKeyType Int))
-> [Node] -> Either String (Maybe (HashMap SummaryKeyType Int))
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text
-> Text
-> Text
-> [Node]
-> Either String (HashMap SummaryKeyType Int)
forall k v.
(Eq k, Hashable k, FromText k, FromXML v) =>
Text -> Text -> Text -> [Node] -> Either String (HashMap k v)
Core.parseXMLMap Text
"entry" Text
"key" Text
"value")
                        )
            Either String (Int -> GetAccountSummaryResponse)
-> Either String Int -> Either String GetAccountSummaryResponse
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 GetAccountSummary

instance Prelude.NFData GetAccountSummary

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

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

instance Core.ToQuery GetAccountSummary where
  toQuery :: GetAccountSummary -> QueryString
toQuery =
    QueryString -> GetAccountSummary -> 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
"GetAccountSummary" :: 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 GetAccountSummary request.
--
-- /See:/ 'newGetAccountSummaryResponse' smart constructor.
data GetAccountSummaryResponse = GetAccountSummaryResponse'
  { -- | A set of key–value pairs containing information about IAM entity usage
    -- and IAM quotas.
    GetAccountSummaryResponse -> Maybe (HashMap SummaryKeyType Int)
summaryMap :: Prelude.Maybe (Prelude.HashMap SummaryKeyType Prelude.Int),
    -- | The response's http status code.
    GetAccountSummaryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetAccountSummaryResponse -> GetAccountSummaryResponse -> Bool
(GetAccountSummaryResponse -> GetAccountSummaryResponse -> Bool)
-> (GetAccountSummaryResponse -> GetAccountSummaryResponse -> Bool)
-> Eq GetAccountSummaryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAccountSummaryResponse -> GetAccountSummaryResponse -> Bool
$c/= :: GetAccountSummaryResponse -> GetAccountSummaryResponse -> Bool
== :: GetAccountSummaryResponse -> GetAccountSummaryResponse -> Bool
$c== :: GetAccountSummaryResponse -> GetAccountSummaryResponse -> Bool
Prelude.Eq, ReadPrec [GetAccountSummaryResponse]
ReadPrec GetAccountSummaryResponse
Int -> ReadS GetAccountSummaryResponse
ReadS [GetAccountSummaryResponse]
(Int -> ReadS GetAccountSummaryResponse)
-> ReadS [GetAccountSummaryResponse]
-> ReadPrec GetAccountSummaryResponse
-> ReadPrec [GetAccountSummaryResponse]
-> Read GetAccountSummaryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAccountSummaryResponse]
$creadListPrec :: ReadPrec [GetAccountSummaryResponse]
readPrec :: ReadPrec GetAccountSummaryResponse
$creadPrec :: ReadPrec GetAccountSummaryResponse
readList :: ReadS [GetAccountSummaryResponse]
$creadList :: ReadS [GetAccountSummaryResponse]
readsPrec :: Int -> ReadS GetAccountSummaryResponse
$creadsPrec :: Int -> ReadS GetAccountSummaryResponse
Prelude.Read, Int -> GetAccountSummaryResponse -> ShowS
[GetAccountSummaryResponse] -> ShowS
GetAccountSummaryResponse -> String
(Int -> GetAccountSummaryResponse -> ShowS)
-> (GetAccountSummaryResponse -> String)
-> ([GetAccountSummaryResponse] -> ShowS)
-> Show GetAccountSummaryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAccountSummaryResponse] -> ShowS
$cshowList :: [GetAccountSummaryResponse] -> ShowS
show :: GetAccountSummaryResponse -> String
$cshow :: GetAccountSummaryResponse -> String
showsPrec :: Int -> GetAccountSummaryResponse -> ShowS
$cshowsPrec :: Int -> GetAccountSummaryResponse -> ShowS
Prelude.Show, (forall x.
 GetAccountSummaryResponse -> Rep GetAccountSummaryResponse x)
-> (forall x.
    Rep GetAccountSummaryResponse x -> GetAccountSummaryResponse)
-> Generic GetAccountSummaryResponse
forall x.
Rep GetAccountSummaryResponse x -> GetAccountSummaryResponse
forall x.
GetAccountSummaryResponse -> Rep GetAccountSummaryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetAccountSummaryResponse x -> GetAccountSummaryResponse
$cfrom :: forall x.
GetAccountSummaryResponse -> Rep GetAccountSummaryResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetAccountSummaryResponse' 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:
--
-- 'summaryMap', 'getAccountSummaryResponse_summaryMap' - A set of key–value pairs containing information about IAM entity usage
-- and IAM quotas.
--
-- 'httpStatus', 'getAccountSummaryResponse_httpStatus' - The response's http status code.
newGetAccountSummaryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAccountSummaryResponse
newGetAccountSummaryResponse :: Int -> GetAccountSummaryResponse
newGetAccountSummaryResponse Int
pHttpStatus_ =
  GetAccountSummaryResponse' :: Maybe (HashMap SummaryKeyType Int)
-> Int -> GetAccountSummaryResponse
GetAccountSummaryResponse'
    { $sel:summaryMap:GetAccountSummaryResponse' :: Maybe (HashMap SummaryKeyType Int)
summaryMap =
        Maybe (HashMap SummaryKeyType Int)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAccountSummaryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A set of key–value pairs containing information about IAM entity usage
-- and IAM quotas.
getAccountSummaryResponse_summaryMap :: Lens.Lens' GetAccountSummaryResponse (Prelude.Maybe (Prelude.HashMap SummaryKeyType Prelude.Int))
getAccountSummaryResponse_summaryMap :: (Maybe (HashMap SummaryKeyType Int)
 -> f (Maybe (HashMap SummaryKeyType Int)))
-> GetAccountSummaryResponse -> f GetAccountSummaryResponse
getAccountSummaryResponse_summaryMap = (GetAccountSummaryResponse -> Maybe (HashMap SummaryKeyType Int))
-> (GetAccountSummaryResponse
    -> Maybe (HashMap SummaryKeyType Int) -> GetAccountSummaryResponse)
-> Lens
     GetAccountSummaryResponse
     GetAccountSummaryResponse
     (Maybe (HashMap SummaryKeyType Int))
     (Maybe (HashMap SummaryKeyType Int))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAccountSummaryResponse' {Maybe (HashMap SummaryKeyType Int)
summaryMap :: Maybe (HashMap SummaryKeyType Int)
$sel:summaryMap:GetAccountSummaryResponse' :: GetAccountSummaryResponse -> Maybe (HashMap SummaryKeyType Int)
summaryMap} -> Maybe (HashMap SummaryKeyType Int)
summaryMap) (\s :: GetAccountSummaryResponse
s@GetAccountSummaryResponse' {} Maybe (HashMap SummaryKeyType Int)
a -> GetAccountSummaryResponse
s {$sel:summaryMap:GetAccountSummaryResponse' :: Maybe (HashMap SummaryKeyType Int)
summaryMap = Maybe (HashMap SummaryKeyType Int)
a} :: GetAccountSummaryResponse) ((Maybe (HashMap SummaryKeyType Int)
  -> f (Maybe (HashMap SummaryKeyType Int)))
 -> GetAccountSummaryResponse -> f GetAccountSummaryResponse)
-> ((Maybe (HashMap SummaryKeyType Int)
     -> f (Maybe (HashMap SummaryKeyType Int)))
    -> Maybe (HashMap SummaryKeyType Int)
    -> f (Maybe (HashMap SummaryKeyType Int)))
-> (Maybe (HashMap SummaryKeyType Int)
    -> f (Maybe (HashMap SummaryKeyType Int)))
-> GetAccountSummaryResponse
-> f GetAccountSummaryResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap SummaryKeyType Int)
  (HashMap SummaryKeyType Int)
  (HashMap SummaryKeyType Int)
  (HashMap SummaryKeyType Int)
-> Iso
     (Maybe (HashMap SummaryKeyType Int))
     (Maybe (HashMap SummaryKeyType Int))
     (Maybe (HashMap SummaryKeyType Int))
     (Maybe (HashMap SummaryKeyType Int))
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
  (HashMap SummaryKeyType Int)
  (HashMap SummaryKeyType Int)
  (HashMap SummaryKeyType Int)
  (HashMap SummaryKeyType Int)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetAccountSummaryResponse