{-# 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.UpdateAuthorizer
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates an existing Authorizer resource.
module Amazonka.APIGateway.UpdateAuthorizer
  ( -- * Creating a Request
    UpdateAuthorizer (..),
    newUpdateAuthorizer,

    -- * Request Lenses
    updateAuthorizer_patchOperations,
    updateAuthorizer_restApiId,
    updateAuthorizer_authorizerId,

    -- * Destructuring the Response
    Authorizer (..),
    newAuthorizer,

    -- * Response Lenses
    authorizer_authType,
    authorizer_authorizerCredentials,
    authorizer_authorizerResultTtlInSeconds,
    authorizer_authorizerUri,
    authorizer_id,
    authorizer_identitySource,
    authorizer_identityValidationExpression,
    authorizer_name,
    authorizer_providerARNs,
    authorizer_type,
  )
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

-- | Request to update an existing Authorizer resource.
--
-- /See:/ 'newUpdateAuthorizer' smart constructor.
data UpdateAuthorizer = UpdateAuthorizer'
  { -- | For more information about supported patch operations, see
    -- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
    UpdateAuthorizer -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation],
    -- | The string identifier of the associated RestApi.
    UpdateAuthorizer -> Text
restApiId :: Prelude.Text,
    -- | The identifier of the Authorizer resource.
    UpdateAuthorizer -> Text
authorizerId :: Prelude.Text
  }
  deriving (UpdateAuthorizer -> UpdateAuthorizer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAuthorizer -> UpdateAuthorizer -> Bool
$c/= :: UpdateAuthorizer -> UpdateAuthorizer -> Bool
== :: UpdateAuthorizer -> UpdateAuthorizer -> Bool
$c== :: UpdateAuthorizer -> UpdateAuthorizer -> Bool
Prelude.Eq, ReadPrec [UpdateAuthorizer]
ReadPrec UpdateAuthorizer
Int -> ReadS UpdateAuthorizer
ReadS [UpdateAuthorizer]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAuthorizer]
$creadListPrec :: ReadPrec [UpdateAuthorizer]
readPrec :: ReadPrec UpdateAuthorizer
$creadPrec :: ReadPrec UpdateAuthorizer
readList :: ReadS [UpdateAuthorizer]
$creadList :: ReadS [UpdateAuthorizer]
readsPrec :: Int -> ReadS UpdateAuthorizer
$creadsPrec :: Int -> ReadS UpdateAuthorizer
Prelude.Read, Int -> UpdateAuthorizer -> ShowS
[UpdateAuthorizer] -> ShowS
UpdateAuthorizer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAuthorizer] -> ShowS
$cshowList :: [UpdateAuthorizer] -> ShowS
show :: UpdateAuthorizer -> String
$cshow :: UpdateAuthorizer -> String
showsPrec :: Int -> UpdateAuthorizer -> ShowS
$cshowsPrec :: Int -> UpdateAuthorizer -> ShowS
Prelude.Show, forall x. Rep UpdateAuthorizer x -> UpdateAuthorizer
forall x. UpdateAuthorizer -> Rep UpdateAuthorizer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAuthorizer x -> UpdateAuthorizer
$cfrom :: forall x. UpdateAuthorizer -> Rep UpdateAuthorizer x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAuthorizer' 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', 'updateAuthorizer_patchOperations' - For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
--
-- 'restApiId', 'updateAuthorizer_restApiId' - The string identifier of the associated RestApi.
--
-- 'authorizerId', 'updateAuthorizer_authorizerId' - The identifier of the Authorizer resource.
newUpdateAuthorizer ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'authorizerId'
  Prelude.Text ->
  UpdateAuthorizer
newUpdateAuthorizer :: Text -> Text -> UpdateAuthorizer
newUpdateAuthorizer Text
pRestApiId_ Text
pAuthorizerId_ =
  UpdateAuthorizer'
    { $sel:patchOperations:UpdateAuthorizer' :: Maybe [PatchOperation]
patchOperations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:restApiId:UpdateAuthorizer' :: Text
restApiId = Text
pRestApiId_,
      $sel:authorizerId:UpdateAuthorizer' :: Text
authorizerId = Text
pAuthorizerId_
    }

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

-- | The string identifier of the associated RestApi.
updateAuthorizer_restApiId :: Lens.Lens' UpdateAuthorizer Prelude.Text
updateAuthorizer_restApiId :: Lens' UpdateAuthorizer Text
updateAuthorizer_restApiId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAuthorizer' {Text
restApiId :: Text
$sel:restApiId:UpdateAuthorizer' :: UpdateAuthorizer -> Text
restApiId} -> Text
restApiId) (\s :: UpdateAuthorizer
s@UpdateAuthorizer' {} Text
a -> UpdateAuthorizer
s {$sel:restApiId:UpdateAuthorizer' :: Text
restApiId = Text
a} :: UpdateAuthorizer)

-- | The identifier of the Authorizer resource.
updateAuthorizer_authorizerId :: Lens.Lens' UpdateAuthorizer Prelude.Text
updateAuthorizer_authorizerId :: Lens' UpdateAuthorizer Text
updateAuthorizer_authorizerId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAuthorizer' {Text
authorizerId :: Text
$sel:authorizerId:UpdateAuthorizer' :: UpdateAuthorizer -> Text
authorizerId} -> Text
authorizerId) (\s :: UpdateAuthorizer
s@UpdateAuthorizer' {} Text
a -> UpdateAuthorizer
s {$sel:authorizerId:UpdateAuthorizer' :: Text
authorizerId = Text
a} :: UpdateAuthorizer)

instance Core.AWSRequest UpdateAuthorizer where
  type AWSResponse UpdateAuthorizer = Authorizer
  request :: (Service -> Service)
-> UpdateAuthorizer -> Request UpdateAuthorizer
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 UpdateAuthorizer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateAuthorizer)))
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 UpdateAuthorizer where
  hashWithSalt :: Int -> UpdateAuthorizer -> Int
hashWithSalt Int
_salt UpdateAuthorizer' {Maybe [PatchOperation]
Text
authorizerId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:authorizerId:UpdateAuthorizer' :: UpdateAuthorizer -> Text
$sel:restApiId:UpdateAuthorizer' :: UpdateAuthorizer -> Text
$sel:patchOperations:UpdateAuthorizer' :: UpdateAuthorizer -> Maybe [PatchOperation]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PatchOperation]
patchOperations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
restApiId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
authorizerId

instance Prelude.NFData UpdateAuthorizer where
  rnf :: UpdateAuthorizer -> ()
rnf UpdateAuthorizer' {Maybe [PatchOperation]
Text
authorizerId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:authorizerId:UpdateAuthorizer' :: UpdateAuthorizer -> Text
$sel:restApiId:UpdateAuthorizer' :: UpdateAuthorizer -> Text
$sel:patchOperations:UpdateAuthorizer' :: UpdateAuthorizer -> Maybe [PatchOperation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [PatchOperation]
patchOperations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
restApiId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
authorizerId

instance Data.ToHeaders UpdateAuthorizer where
  toHeaders :: UpdateAuthorizer -> 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 UpdateAuthorizer where
  toJSON :: UpdateAuthorizer -> Value
toJSON UpdateAuthorizer' {Maybe [PatchOperation]
Text
authorizerId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:authorizerId:UpdateAuthorizer' :: UpdateAuthorizer -> Text
$sel:restApiId:UpdateAuthorizer' :: UpdateAuthorizer -> Text
$sel:patchOperations:UpdateAuthorizer' :: UpdateAuthorizer -> 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 UpdateAuthorizer where
  toPath :: UpdateAuthorizer -> ByteString
toPath UpdateAuthorizer' {Maybe [PatchOperation]
Text
authorizerId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:authorizerId:UpdateAuthorizer' :: UpdateAuthorizer -> Text
$sel:restApiId:UpdateAuthorizer' :: UpdateAuthorizer -> Text
$sel:patchOperations:UpdateAuthorizer' :: UpdateAuthorizer -> Maybe [PatchOperation]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/restapis/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
restApiId,
        ByteString
"/authorizers/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
authorizerId
      ]

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