{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.APIGateway.Types.Account
-- 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)
module Amazonka.APIGateway.Types.Account where

import Amazonka.APIGateway.Types.ThrottleSettings
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents an AWS account that is associated with API Gateway.
--
-- To view the account info, call @GET@ on this resource.
--
-- ==== Error Codes
--
-- The following exception may be thrown when the request fails.
--
-- -   UnauthorizedException
-- -   NotFoundException
-- -   TooManyRequestsException
--
-- For detailed error code information, including the corresponding HTTP
-- Status Codes, see
-- <https://docs.aws.amazon.com/apigateway/api-reference/handling-errors/#api-error-codes API Gateway Error Codes>
--
-- ==== Example: Get the information about an account.
--
-- ===== Request
--
-- > GET /account HTTP/1.1 Content-Type: application/json Host: apigateway.us-east-1.amazonaws.com X-Amz-Date: 20160531T184618Z Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/us-east-1/apigateway/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash}
--
-- ===== Response
--
-- The successful response returns a @200 OK@ status code and a payload
-- similar to the following:
--
-- > { "_links": { "curies": { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/account-apigateway-{rel}.html", "name": "account", "templated": true }, "self": { "href": "/account" }, "account:update": { "href": "/account" } }, "cloudwatchRoleArn": "arn:aws:iam::123456789012:role/apigAwsProxyRole", "throttleSettings": { "rateLimit": 500, "burstLimit": 1000 } }
--
-- In addition to making the REST API call directly, you can use the AWS
-- CLI and an AWS SDK to access this resource.
--
-- <https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-limits.html API Gateway Limits>
-- <https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html Developer Guide>,
-- <https://docs.aws.amazon.com/cli/latest/reference/apigateway/get-account.html AWS CLI>
--
-- /See:/ 'newAccount' smart constructor.
data Account = Account'
  { -- | The version of the API keys used for the account.
    Account -> Maybe Text
apiKeyVersion :: Prelude.Maybe Prelude.Text,
    -- | The ARN of an Amazon CloudWatch role for the current Account.
    Account -> Maybe Text
cloudwatchRoleArn :: Prelude.Maybe Prelude.Text,
    -- | A list of features supported for the account. When usage plans are
    -- enabled, the features list will include an entry of @\"UsagePlans\"@.
    Account -> Maybe [Text]
features :: Prelude.Maybe [Prelude.Text],
    -- | Specifies the API request limits configured for the current Account.
    Account -> Maybe ThrottleSettings
throttleSettings :: Prelude.Maybe ThrottleSettings
  }
  deriving (Account -> Account -> Bool
(Account -> Account -> Bool)
-> (Account -> Account -> Bool) -> Eq Account
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Account -> Account -> Bool
$c/= :: Account -> Account -> Bool
== :: Account -> Account -> Bool
$c== :: Account -> Account -> Bool
Prelude.Eq, ReadPrec [Account]
ReadPrec Account
Int -> ReadS Account
ReadS [Account]
(Int -> ReadS Account)
-> ReadS [Account]
-> ReadPrec Account
-> ReadPrec [Account]
-> Read Account
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Account]
$creadListPrec :: ReadPrec [Account]
readPrec :: ReadPrec Account
$creadPrec :: ReadPrec Account
readList :: ReadS [Account]
$creadList :: ReadS [Account]
readsPrec :: Int -> ReadS Account
$creadsPrec :: Int -> ReadS Account
Prelude.Read, Int -> Account -> ShowS
[Account] -> ShowS
Account -> String
(Int -> Account -> ShowS)
-> (Account -> String) -> ([Account] -> ShowS) -> Show Account
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Account] -> ShowS
$cshowList :: [Account] -> ShowS
show :: Account -> String
$cshow :: Account -> String
showsPrec :: Int -> Account -> ShowS
$cshowsPrec :: Int -> Account -> ShowS
Prelude.Show, (forall x. Account -> Rep Account x)
-> (forall x. Rep Account x -> Account) -> Generic Account
forall x. Rep Account x -> Account
forall x. Account -> Rep Account x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Account x -> Account
$cfrom :: forall x. Account -> Rep Account x
Prelude.Generic)

-- |
-- Create a value of 'Account' 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:
--
-- 'apiKeyVersion', 'account_apiKeyVersion' - The version of the API keys used for the account.
--
-- 'cloudwatchRoleArn', 'account_cloudwatchRoleArn' - The ARN of an Amazon CloudWatch role for the current Account.
--
-- 'features', 'account_features' - A list of features supported for the account. When usage plans are
-- enabled, the features list will include an entry of @\"UsagePlans\"@.
--
-- 'throttleSettings', 'account_throttleSettings' - Specifies the API request limits configured for the current Account.
newAccount ::
  Account
newAccount :: Account
newAccount =
  Account' :: Maybe Text
-> Maybe Text -> Maybe [Text] -> Maybe ThrottleSettings -> Account
Account'
    { $sel:apiKeyVersion:Account' :: Maybe Text
apiKeyVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudwatchRoleArn:Account' :: Maybe Text
cloudwatchRoleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:features:Account' :: Maybe [Text]
features = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:throttleSettings:Account' :: Maybe ThrottleSettings
throttleSettings = Maybe ThrottleSettings
forall a. Maybe a
Prelude.Nothing
    }

-- | The version of the API keys used for the account.
account_apiKeyVersion :: Lens.Lens' Account (Prelude.Maybe Prelude.Text)
account_apiKeyVersion :: (Maybe Text -> f (Maybe Text)) -> Account -> f Account
account_apiKeyVersion = (Account -> Maybe Text)
-> (Account -> Maybe Text -> Account)
-> Lens Account Account (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Maybe Text
apiKeyVersion :: Maybe Text
$sel:apiKeyVersion:Account' :: Account -> Maybe Text
apiKeyVersion} -> Maybe Text
apiKeyVersion) (\s :: Account
s@Account' {} Maybe Text
a -> Account
s {$sel:apiKeyVersion:Account' :: Maybe Text
apiKeyVersion = Maybe Text
a} :: Account)

-- | The ARN of an Amazon CloudWatch role for the current Account.
account_cloudwatchRoleArn :: Lens.Lens' Account (Prelude.Maybe Prelude.Text)
account_cloudwatchRoleArn :: (Maybe Text -> f (Maybe Text)) -> Account -> f Account
account_cloudwatchRoleArn = (Account -> Maybe Text)
-> (Account -> Maybe Text -> Account)
-> Lens Account Account (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Maybe Text
cloudwatchRoleArn :: Maybe Text
$sel:cloudwatchRoleArn:Account' :: Account -> Maybe Text
cloudwatchRoleArn} -> Maybe Text
cloudwatchRoleArn) (\s :: Account
s@Account' {} Maybe Text
a -> Account
s {$sel:cloudwatchRoleArn:Account' :: Maybe Text
cloudwatchRoleArn = Maybe Text
a} :: Account)

-- | A list of features supported for the account. When usage plans are
-- enabled, the features list will include an entry of @\"UsagePlans\"@.
account_features :: Lens.Lens' Account (Prelude.Maybe [Prelude.Text])
account_features :: (Maybe [Text] -> f (Maybe [Text])) -> Account -> f Account
account_features = (Account -> Maybe [Text])
-> (Account -> Maybe [Text] -> Account)
-> Lens Account Account (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Maybe [Text]
features :: Maybe [Text]
$sel:features:Account' :: Account -> Maybe [Text]
features} -> Maybe [Text]
features) (\s :: Account
s@Account' {} Maybe [Text]
a -> Account
s {$sel:features:Account' :: Maybe [Text]
features = Maybe [Text]
a} :: Account) ((Maybe [Text] -> f (Maybe [Text])) -> Account -> f Account)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Account
-> f Account
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the API request limits configured for the current Account.
account_throttleSettings :: Lens.Lens' Account (Prelude.Maybe ThrottleSettings)
account_throttleSettings :: (Maybe ThrottleSettings -> f (Maybe ThrottleSettings))
-> Account -> f Account
account_throttleSettings = (Account -> Maybe ThrottleSettings)
-> (Account -> Maybe ThrottleSettings -> Account)
-> Lens
     Account Account (Maybe ThrottleSettings) (Maybe ThrottleSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Maybe ThrottleSettings
throttleSettings :: Maybe ThrottleSettings
$sel:throttleSettings:Account' :: Account -> Maybe ThrottleSettings
throttleSettings} -> Maybe ThrottleSettings
throttleSettings) (\s :: Account
s@Account' {} Maybe ThrottleSettings
a -> Account
s {$sel:throttleSettings:Account' :: Maybe ThrottleSettings
throttleSettings = Maybe ThrottleSettings
a} :: Account)

instance Core.FromJSON Account where
  parseJSON :: Value -> Parser Account
parseJSON =
    String -> (Object -> Parser Account) -> Value -> Parser Account
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Account"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe [Text] -> Maybe ThrottleSettings -> Account
Account'
            (Maybe Text
 -> Maybe Text -> Maybe [Text] -> Maybe ThrottleSettings -> Account)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe [Text] -> Maybe ThrottleSettings -> Account)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"apiKeyVersion")
            Parser
  (Maybe Text -> Maybe [Text] -> Maybe ThrottleSettings -> Account)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> Maybe ThrottleSettings -> Account)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"cloudwatchRoleArn")
            Parser (Maybe [Text] -> Maybe ThrottleSettings -> Account)
-> Parser (Maybe [Text])
-> Parser (Maybe ThrottleSettings -> Account)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"features" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe ThrottleSettings -> Account)
-> Parser (Maybe ThrottleSettings) -> Parser Account
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ThrottleSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"throttleSettings")
      )

instance Prelude.Hashable Account

instance Prelude.NFData Account