{-# 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.CloudFormation.DescribeAccountLimits
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves your account\'s CloudFormation limits, such as the maximum
-- number of stacks that you can create in your account. For more
-- information about account limits, see
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html CloudFormation Quotas>
-- in the /CloudFormation User Guide/.
--
-- This operation returns paginated results.
module Amazonka.CloudFormation.DescribeAccountLimits
  ( -- * Creating a Request
    DescribeAccountLimits (..),
    newDescribeAccountLimits,

    -- * Request Lenses
    describeAccountLimits_nextToken,

    -- * Destructuring the Response
    DescribeAccountLimitsResponse (..),
    newDescribeAccountLimitsResponse,

    -- * Response Lenses
    describeAccountLimitsResponse_accountLimits,
    describeAccountLimitsResponse_nextToken,
    describeAccountLimitsResponse_httpStatus,
  )
where

import Amazonka.CloudFormation.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The input for the DescribeAccountLimits action.
--
-- /See:/ 'newDescribeAccountLimits' smart constructor.
data DescribeAccountLimits = DescribeAccountLimits'
  { -- | A string that identifies the next page of limits that you want to
    -- retrieve.
    DescribeAccountLimits -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (DescribeAccountLimits -> DescribeAccountLimits -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAccountLimits -> DescribeAccountLimits -> Bool
$c/= :: DescribeAccountLimits -> DescribeAccountLimits -> Bool
== :: DescribeAccountLimits -> DescribeAccountLimits -> Bool
$c== :: DescribeAccountLimits -> DescribeAccountLimits -> Bool
Prelude.Eq, ReadPrec [DescribeAccountLimits]
ReadPrec DescribeAccountLimits
Int -> ReadS DescribeAccountLimits
ReadS [DescribeAccountLimits]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAccountLimits]
$creadListPrec :: ReadPrec [DescribeAccountLimits]
readPrec :: ReadPrec DescribeAccountLimits
$creadPrec :: ReadPrec DescribeAccountLimits
readList :: ReadS [DescribeAccountLimits]
$creadList :: ReadS [DescribeAccountLimits]
readsPrec :: Int -> ReadS DescribeAccountLimits
$creadsPrec :: Int -> ReadS DescribeAccountLimits
Prelude.Read, Int -> DescribeAccountLimits -> ShowS
[DescribeAccountLimits] -> ShowS
DescribeAccountLimits -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAccountLimits] -> ShowS
$cshowList :: [DescribeAccountLimits] -> ShowS
show :: DescribeAccountLimits -> String
$cshow :: DescribeAccountLimits -> String
showsPrec :: Int -> DescribeAccountLimits -> ShowS
$cshowsPrec :: Int -> DescribeAccountLimits -> ShowS
Prelude.Show, forall x. Rep DescribeAccountLimits x -> DescribeAccountLimits
forall x. DescribeAccountLimits -> Rep DescribeAccountLimits x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAccountLimits x -> DescribeAccountLimits
$cfrom :: forall x. DescribeAccountLimits -> Rep DescribeAccountLimits x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAccountLimits' 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:
--
-- 'nextToken', 'describeAccountLimits_nextToken' - A string that identifies the next page of limits that you want to
-- retrieve.
newDescribeAccountLimits ::
  DescribeAccountLimits
newDescribeAccountLimits :: DescribeAccountLimits
newDescribeAccountLimits =
  DescribeAccountLimits' {$sel:nextToken:DescribeAccountLimits' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing}

-- | A string that identifies the next page of limits that you want to
-- retrieve.
describeAccountLimits_nextToken :: Lens.Lens' DescribeAccountLimits (Prelude.Maybe Prelude.Text)
describeAccountLimits_nextToken :: Lens' DescribeAccountLimits (Maybe Text)
describeAccountLimits_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAccountLimits' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeAccountLimits' :: DescribeAccountLimits -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeAccountLimits
s@DescribeAccountLimits' {} Maybe Text
a -> DescribeAccountLimits
s {$sel:nextToken:DescribeAccountLimits' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeAccountLimits)

instance Core.AWSPager DescribeAccountLimits where
  page :: DescribeAccountLimits
-> AWSResponse DescribeAccountLimits -> Maybe DescribeAccountLimits
page DescribeAccountLimits
rq AWSResponse DescribeAccountLimits
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeAccountLimits
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeAccountLimitsResponse (Maybe Text)
describeAccountLimitsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeAccountLimits
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeAccountLimitsResponse (Maybe [AccountLimit])
describeAccountLimitsResponse_accountLimits
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ DescribeAccountLimits
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' DescribeAccountLimits (Maybe Text)
describeAccountLimits_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeAccountLimits
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeAccountLimitsResponse (Maybe Text)
describeAccountLimitsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeAccountLimits where
  type
    AWSResponse DescribeAccountLimits =
      DescribeAccountLimitsResponse
  request :: (Service -> Service)
-> DescribeAccountLimits -> Request DescribeAccountLimits
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeAccountLimits
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeAccountLimits)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DescribeAccountLimitsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [AccountLimit]
-> Maybe Text -> Int -> DescribeAccountLimitsResponse
DescribeAccountLimitsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"AccountLimits"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"NextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeAccountLimits where
  hashWithSalt :: Int -> DescribeAccountLimits -> Int
hashWithSalt Int
_salt DescribeAccountLimits' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeAccountLimits' :: DescribeAccountLimits -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData DescribeAccountLimits where
  rnf :: DescribeAccountLimits -> ()
rnf DescribeAccountLimits' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeAccountLimits' :: DescribeAccountLimits -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

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

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

instance Data.ToQuery DescribeAccountLimits where
  toQuery :: DescribeAccountLimits -> QueryString
toQuery DescribeAccountLimits' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeAccountLimits' :: DescribeAccountLimits -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DescribeAccountLimits" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"NextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | The output for the DescribeAccountLimits action.
--
-- /See:/ 'newDescribeAccountLimitsResponse' smart constructor.
data DescribeAccountLimitsResponse = DescribeAccountLimitsResponse'
  { -- | An account limit structure that contain a list of CloudFormation account
    -- limits and their values.
    DescribeAccountLimitsResponse -> Maybe [AccountLimit]
accountLimits :: Prelude.Maybe [AccountLimit],
    -- | If the output exceeds 1 MB in size, a string that identifies the next
    -- page of limits. If no additional page exists, this value is null.
    DescribeAccountLimitsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeAccountLimitsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAccountLimitsResponse
-> DescribeAccountLimitsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAccountLimitsResponse
-> DescribeAccountLimitsResponse -> Bool
$c/= :: DescribeAccountLimitsResponse
-> DescribeAccountLimitsResponse -> Bool
== :: DescribeAccountLimitsResponse
-> DescribeAccountLimitsResponse -> Bool
$c== :: DescribeAccountLimitsResponse
-> DescribeAccountLimitsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAccountLimitsResponse]
ReadPrec DescribeAccountLimitsResponse
Int -> ReadS DescribeAccountLimitsResponse
ReadS [DescribeAccountLimitsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAccountLimitsResponse]
$creadListPrec :: ReadPrec [DescribeAccountLimitsResponse]
readPrec :: ReadPrec DescribeAccountLimitsResponse
$creadPrec :: ReadPrec DescribeAccountLimitsResponse
readList :: ReadS [DescribeAccountLimitsResponse]
$creadList :: ReadS [DescribeAccountLimitsResponse]
readsPrec :: Int -> ReadS DescribeAccountLimitsResponse
$creadsPrec :: Int -> ReadS DescribeAccountLimitsResponse
Prelude.Read, Int -> DescribeAccountLimitsResponse -> ShowS
[DescribeAccountLimitsResponse] -> ShowS
DescribeAccountLimitsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAccountLimitsResponse] -> ShowS
$cshowList :: [DescribeAccountLimitsResponse] -> ShowS
show :: DescribeAccountLimitsResponse -> String
$cshow :: DescribeAccountLimitsResponse -> String
showsPrec :: Int -> DescribeAccountLimitsResponse -> ShowS
$cshowsPrec :: Int -> DescribeAccountLimitsResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeAccountLimitsResponse x
-> DescribeAccountLimitsResponse
forall x.
DescribeAccountLimitsResponse
-> Rep DescribeAccountLimitsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAccountLimitsResponse x
-> DescribeAccountLimitsResponse
$cfrom :: forall x.
DescribeAccountLimitsResponse
-> Rep DescribeAccountLimitsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAccountLimitsResponse' 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:
--
-- 'accountLimits', 'describeAccountLimitsResponse_accountLimits' - An account limit structure that contain a list of CloudFormation account
-- limits and their values.
--
-- 'nextToken', 'describeAccountLimitsResponse_nextToken' - If the output exceeds 1 MB in size, a string that identifies the next
-- page of limits. If no additional page exists, this value is null.
--
-- 'httpStatus', 'describeAccountLimitsResponse_httpStatus' - The response's http status code.
newDescribeAccountLimitsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAccountLimitsResponse
newDescribeAccountLimitsResponse :: Int -> DescribeAccountLimitsResponse
newDescribeAccountLimitsResponse Int
pHttpStatus_ =
  DescribeAccountLimitsResponse'
    { $sel:accountLimits:DescribeAccountLimitsResponse' :: Maybe [AccountLimit]
accountLimits =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeAccountLimitsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAccountLimitsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An account limit structure that contain a list of CloudFormation account
-- limits and their values.
describeAccountLimitsResponse_accountLimits :: Lens.Lens' DescribeAccountLimitsResponse (Prelude.Maybe [AccountLimit])
describeAccountLimitsResponse_accountLimits :: Lens' DescribeAccountLimitsResponse (Maybe [AccountLimit])
describeAccountLimitsResponse_accountLimits = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAccountLimitsResponse' {Maybe [AccountLimit]
accountLimits :: Maybe [AccountLimit]
$sel:accountLimits:DescribeAccountLimitsResponse' :: DescribeAccountLimitsResponse -> Maybe [AccountLimit]
accountLimits} -> Maybe [AccountLimit]
accountLimits) (\s :: DescribeAccountLimitsResponse
s@DescribeAccountLimitsResponse' {} Maybe [AccountLimit]
a -> DescribeAccountLimitsResponse
s {$sel:accountLimits:DescribeAccountLimitsResponse' :: Maybe [AccountLimit]
accountLimits = Maybe [AccountLimit]
a} :: DescribeAccountLimitsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If the output exceeds 1 MB in size, a string that identifies the next
-- page of limits. If no additional page exists, this value is null.
describeAccountLimitsResponse_nextToken :: Lens.Lens' DescribeAccountLimitsResponse (Prelude.Maybe Prelude.Text)
describeAccountLimitsResponse_nextToken :: Lens' DescribeAccountLimitsResponse (Maybe Text)
describeAccountLimitsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAccountLimitsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeAccountLimitsResponse' :: DescribeAccountLimitsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeAccountLimitsResponse
s@DescribeAccountLimitsResponse' {} Maybe Text
a -> DescribeAccountLimitsResponse
s {$sel:nextToken:DescribeAccountLimitsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeAccountLimitsResponse)

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

instance Prelude.NFData DescribeAccountLimitsResponse where
  rnf :: DescribeAccountLimitsResponse -> ()
rnf DescribeAccountLimitsResponse' {Int
Maybe [AccountLimit]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
accountLimits :: Maybe [AccountLimit]
$sel:httpStatus:DescribeAccountLimitsResponse' :: DescribeAccountLimitsResponse -> Int
$sel:nextToken:DescribeAccountLimitsResponse' :: DescribeAccountLimitsResponse -> Maybe Text
$sel:accountLimits:DescribeAccountLimitsResponse' :: DescribeAccountLimitsResponse -> Maybe [AccountLimit]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AccountLimit]
accountLimits
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus