{-# 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-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)
--
-- 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.Lens as Lens
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'
  { -- | A list of update operations to be applied to the specified resource and
    -- in the order specified in this list.
    UpdateAccount -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation]
  }
  deriving (UpdateAccount -> UpdateAccount -> Bool
(UpdateAccount -> UpdateAccount -> Bool)
-> (UpdateAccount -> UpdateAccount -> Bool) -> Eq UpdateAccount
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]
(Int -> ReadS UpdateAccount)
-> ReadS [UpdateAccount]
-> ReadPrec UpdateAccount
-> ReadPrec [UpdateAccount]
-> Read 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
(Int -> UpdateAccount -> ShowS)
-> (UpdateAccount -> String)
-> ([UpdateAccount] -> ShowS)
-> Show UpdateAccount
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. UpdateAccount -> Rep UpdateAccount x)
-> (forall x. Rep UpdateAccount x -> UpdateAccount)
-> Generic UpdateAccount
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' - A list of update operations to be applied to the specified resource and
-- in the order specified in this list.
newUpdateAccount ::
  UpdateAccount
newUpdateAccount :: UpdateAccount
newUpdateAccount =
  UpdateAccount' :: Maybe [PatchOperation] -> UpdateAccount
UpdateAccount' {$sel:patchOperations:UpdateAccount' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
forall a. Maybe a
Prelude.Nothing}

-- | A list of update operations to be applied to the specified resource and
-- in the order specified in this list.
updateAccount_patchOperations :: Lens.Lens' UpdateAccount (Prelude.Maybe [PatchOperation])
updateAccount_patchOperations :: (Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateAccount -> f UpdateAccount
updateAccount_patchOperations = (UpdateAccount -> Maybe [PatchOperation])
-> (UpdateAccount -> Maybe [PatchOperation] -> UpdateAccount)
-> Lens
     UpdateAccount
     UpdateAccount
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
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) ((Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
 -> UpdateAccount -> f UpdateAccount)
-> ((Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
    -> Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> (Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateAccount
-> f UpdateAccount
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PatchOperation] [PatchOperation] [PatchOperation] [PatchOperation]
-> Iso
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
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
  [PatchOperation] [PatchOperation] [PatchOperation] [PatchOperation]
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 :: UpdateAccount -> Request UpdateAccount
request = Service -> UpdateAccount -> Request UpdateAccount
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateAccount
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateAccount)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateAccount))
-> Logger
-> Service
-> Proxy UpdateAccount
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateAccount)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String Account
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable UpdateAccount

instance Prelude.NFData UpdateAccount

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

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

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

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