{-# 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.APIGateway.UpdateAccount
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Changes information about the current Account resource.
module Amazonka.APIGateway.UpdateAccount
  ( -- * Creating a Request
    UpdateAccount (..),
    newUpdateAccount,

    -- * Request Lenses
    updateAccount_patchOperations,

    -- * Destructuring the Response
    Account (..),
    newAccount,

    -- * Response Lenses
    account_apiKeyVersion,
    account_cloudwatchRoleArn,
    account_features,
    account_throttleSettings,
  )
where

import Amazonka.APIGateway.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

-- | Requests API Gateway to change information about the current Account
-- resource.
--
-- /See:/ 'newUpdateAccount' smart constructor.
data UpdateAccount = UpdateAccount'
  { -- | For more information about supported patch operations, see
    -- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
    UpdateAccount -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation]
  }
  deriving (UpdateAccount -> UpdateAccount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAccount -> UpdateAccount -> Bool
$c/= :: UpdateAccount -> UpdateAccount -> Bool
== :: UpdateAccount -> UpdateAccount -> Bool
$c== :: UpdateAccount -> UpdateAccount -> Bool
Prelude.Eq, ReadPrec [UpdateAccount]
ReadPrec UpdateAccount
Int -> ReadS UpdateAccount
ReadS [UpdateAccount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAccount]
$creadListPrec :: ReadPrec [UpdateAccount]
readPrec :: ReadPrec UpdateAccount
$creadPrec :: ReadPrec UpdateAccount
readList :: ReadS [UpdateAccount]
$creadList :: ReadS [UpdateAccount]
readsPrec :: Int -> ReadS UpdateAccount
$creadsPrec :: Int -> ReadS UpdateAccount
Prelude.Read, Int -> UpdateAccount -> ShowS
[UpdateAccount] -> ShowS
UpdateAccount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAccount] -> ShowS
$cshowList :: [UpdateAccount] -> ShowS
show :: UpdateAccount -> String
$cshow :: UpdateAccount -> String
showsPrec :: Int -> UpdateAccount -> ShowS
$cshowsPrec :: Int -> UpdateAccount -> ShowS
Prelude.Show, forall x. Rep UpdateAccount x -> UpdateAccount
forall x. UpdateAccount -> Rep UpdateAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAccount x -> UpdateAccount
$cfrom :: forall x. UpdateAccount -> Rep UpdateAccount x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAccount' 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:
--
-- 'patchOperations', 'updateAccount_patchOperations' - For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
newUpdateAccount ::
  UpdateAccount
newUpdateAccount :: UpdateAccount
newUpdateAccount =
  UpdateAccount' {$sel:patchOperations:UpdateAccount' :: Maybe [PatchOperation]
patchOperations = forall a. Maybe a
Prelude.Nothing}

-- | For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
updateAccount_patchOperations :: Lens.Lens' UpdateAccount (Prelude.Maybe [PatchOperation])
updateAccount_patchOperations :: Lens' UpdateAccount (Maybe [PatchOperation])
updateAccount_patchOperations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAccount' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateAccount' :: UpdateAccount -> Maybe [PatchOperation]
patchOperations} -> Maybe [PatchOperation]
patchOperations) (\s :: UpdateAccount
s@UpdateAccount' {} Maybe [PatchOperation]
a -> UpdateAccount
s {$sel:patchOperations:UpdateAccount' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
a} :: UpdateAccount) 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

instance Core.AWSRequest UpdateAccount where
  type AWSResponse UpdateAccount = Account
  request :: (Service -> Service) -> UpdateAccount -> Request UpdateAccount
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateAccount
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateAccount)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable UpdateAccount where
  hashWithSalt :: Int -> UpdateAccount -> Int
hashWithSalt Int
_salt UpdateAccount' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateAccount' :: UpdateAccount -> Maybe [PatchOperation]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PatchOperation]
patchOperations

instance Prelude.NFData UpdateAccount where
  rnf :: UpdateAccount -> ()
rnf UpdateAccount' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateAccount' :: UpdateAccount -> Maybe [PatchOperation]
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe [PatchOperation]
patchOperations

instance Data.ToHeaders UpdateAccount where
  toHeaders :: UpdateAccount -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

instance Data.ToJSON UpdateAccount where
  toJSON :: UpdateAccount -> Value
toJSON UpdateAccount' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateAccount' :: UpdateAccount -> Maybe [PatchOperation]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"patchOperations" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PatchOperation]
patchOperations
          ]
      )

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

instance Data.ToQuery UpdateAccount where
  toQuery :: UpdateAccount -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty