{-# 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.PutMethod
-- 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)
--
-- Add a method to an existing Resource resource.
module Amazonka.APIGateway.PutMethod
  ( -- * Creating a Request
    PutMethod (..),
    newPutMethod,

    -- * Request Lenses
    putMethod_authorizationScopes,
    putMethod_requestValidatorId,
    putMethod_requestModels,
    putMethod_requestParameters,
    putMethod_authorizerId,
    putMethod_operationName,
    putMethod_apiKeyRequired,
    putMethod_restApiId,
    putMethod_resourceId,
    putMethod_httpMethod,
    putMethod_authorizationType,

    -- * Destructuring the Response
    Method (..),
    newMethod,

    -- * Response Lenses
    method_methodResponses,
    method_httpMethod,
    method_authorizationScopes,
    method_requestValidatorId,
    method_requestModels,
    method_requestParameters,
    method_authorizerId,
    method_operationName,
    method_authorizationType,
    method_apiKeyRequired,
    method_methodIntegration,
  )
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

-- | Request to add a method to an existing Resource resource.
--
-- /See:/ 'newPutMethod' smart constructor.
data PutMethod = PutMethod'
  { -- | A list of authorization scopes configured on the method. The scopes are
    -- used with a @COGNITO_USER_POOLS@ authorizer to authorize the method
    -- invocation. The authorization works by matching the method scopes
    -- against the scopes parsed from the access token in the incoming request.
    -- The method invocation is authorized if any method scopes matches a
    -- claimed scope in the access token. Otherwise, the invocation is not
    -- authorized. When the method scope is configured, the client must provide
    -- an access token instead of an identity token for authorization purposes.
    PutMethod -> Maybe [Text]
authorizationScopes :: Prelude.Maybe [Prelude.Text],
    -- | The identifier of a RequestValidator for validating the method request.
    PutMethod -> Maybe Text
requestValidatorId :: Prelude.Maybe Prelude.Text,
    -- | Specifies the Model resources used for the request\'s content type.
    -- Request models are represented as a key\/value map, with a content type
    -- as the key and a Model name as the value.
    PutMethod -> Maybe (HashMap Text Text)
requestModels :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | A key-value map defining required or optional method request parameters
    -- that can be accepted by API Gateway. A key defines a method request
    -- parameter name matching the pattern of
    -- @method.request.{location}.{name}@, where @location@ is @querystring@,
    -- @path@, or @header@ and @name@ is a valid and unique parameter name. The
    -- value associated with the key is a Boolean flag indicating whether the
    -- parameter is required (@true@) or optional (@false@). The method request
    -- parameter names defined here are available in Integration to be mapped
    -- to integration request parameters or body-mapping templates.
    PutMethod -> Maybe (HashMap Text Bool)
requestParameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Bool),
    -- | Specifies the identifier of an Authorizer to use on this Method, if the
    -- type is CUSTOM or COGNITO_USER_POOLS. The authorizer identifier is
    -- generated by API Gateway when you created the authorizer.
    PutMethod -> Maybe Text
authorizerId :: Prelude.Maybe Prelude.Text,
    -- | A human-friendly operation identifier for the method. For example, you
    -- can assign the @operationName@ of @ListPets@ for the @GET \/pets@ method
    -- in the @PetStore@ example.
    PutMethod -> Maybe Text
operationName :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether the method required a valid ApiKey.
    PutMethod -> Maybe Bool
apiKeyRequired :: Prelude.Maybe Prelude.Bool,
    -- | [Required] The string identifier of the associated RestApi.
    PutMethod -> Text
restApiId :: Prelude.Text,
    -- | [Required] The Resource identifier for the new Method resource.
    PutMethod -> Text
resourceId :: Prelude.Text,
    -- | [Required] Specifies the method request\'s HTTP method type.
    PutMethod -> Text
httpMethod :: Prelude.Text,
    -- | [Required] The method\'s authorization type. Valid values are @NONE@ for
    -- open access, @AWS_IAM@ for using AWS IAM permissions, @CUSTOM@ for using
    -- a custom authorizer, or @COGNITO_USER_POOLS@ for using a Cognito user
    -- pool.
    PutMethod -> Text
authorizationType :: Prelude.Text
  }
  deriving (PutMethod -> PutMethod -> Bool
(PutMethod -> PutMethod -> Bool)
-> (PutMethod -> PutMethod -> Bool) -> Eq PutMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutMethod -> PutMethod -> Bool
$c/= :: PutMethod -> PutMethod -> Bool
== :: PutMethod -> PutMethod -> Bool
$c== :: PutMethod -> PutMethod -> Bool
Prelude.Eq, ReadPrec [PutMethod]
ReadPrec PutMethod
Int -> ReadS PutMethod
ReadS [PutMethod]
(Int -> ReadS PutMethod)
-> ReadS [PutMethod]
-> ReadPrec PutMethod
-> ReadPrec [PutMethod]
-> Read PutMethod
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutMethod]
$creadListPrec :: ReadPrec [PutMethod]
readPrec :: ReadPrec PutMethod
$creadPrec :: ReadPrec PutMethod
readList :: ReadS [PutMethod]
$creadList :: ReadS [PutMethod]
readsPrec :: Int -> ReadS PutMethod
$creadsPrec :: Int -> ReadS PutMethod
Prelude.Read, Int -> PutMethod -> ShowS
[PutMethod] -> ShowS
PutMethod -> String
(Int -> PutMethod -> ShowS)
-> (PutMethod -> String)
-> ([PutMethod] -> ShowS)
-> Show PutMethod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutMethod] -> ShowS
$cshowList :: [PutMethod] -> ShowS
show :: PutMethod -> String
$cshow :: PutMethod -> String
showsPrec :: Int -> PutMethod -> ShowS
$cshowsPrec :: Int -> PutMethod -> ShowS
Prelude.Show, (forall x. PutMethod -> Rep PutMethod x)
-> (forall x. Rep PutMethod x -> PutMethod) -> Generic PutMethod
forall x. Rep PutMethod x -> PutMethod
forall x. PutMethod -> Rep PutMethod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutMethod x -> PutMethod
$cfrom :: forall x. PutMethod -> Rep PutMethod x
Prelude.Generic)

-- |
-- Create a value of 'PutMethod' 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:
--
-- 'authorizationScopes', 'putMethod_authorizationScopes' - A list of authorization scopes configured on the method. The scopes are
-- used with a @COGNITO_USER_POOLS@ authorizer to authorize the method
-- invocation. The authorization works by matching the method scopes
-- against the scopes parsed from the access token in the incoming request.
-- The method invocation is authorized if any method scopes matches a
-- claimed scope in the access token. Otherwise, the invocation is not
-- authorized. When the method scope is configured, the client must provide
-- an access token instead of an identity token for authorization purposes.
--
-- 'requestValidatorId', 'putMethod_requestValidatorId' - The identifier of a RequestValidator for validating the method request.
--
-- 'requestModels', 'putMethod_requestModels' - Specifies the Model resources used for the request\'s content type.
-- Request models are represented as a key\/value map, with a content type
-- as the key and a Model name as the value.
--
-- 'requestParameters', 'putMethod_requestParameters' - A key-value map defining required or optional method request parameters
-- that can be accepted by API Gateway. A key defines a method request
-- parameter name matching the pattern of
-- @method.request.{location}.{name}@, where @location@ is @querystring@,
-- @path@, or @header@ and @name@ is a valid and unique parameter name. The
-- value associated with the key is a Boolean flag indicating whether the
-- parameter is required (@true@) or optional (@false@). The method request
-- parameter names defined here are available in Integration to be mapped
-- to integration request parameters or body-mapping templates.
--
-- 'authorizerId', 'putMethod_authorizerId' - Specifies the identifier of an Authorizer to use on this Method, if the
-- type is CUSTOM or COGNITO_USER_POOLS. The authorizer identifier is
-- generated by API Gateway when you created the authorizer.
--
-- 'operationName', 'putMethod_operationName' - A human-friendly operation identifier for the method. For example, you
-- can assign the @operationName@ of @ListPets@ for the @GET \/pets@ method
-- in the @PetStore@ example.
--
-- 'apiKeyRequired', 'putMethod_apiKeyRequired' - Specifies whether the method required a valid ApiKey.
--
-- 'restApiId', 'putMethod_restApiId' - [Required] The string identifier of the associated RestApi.
--
-- 'resourceId', 'putMethod_resourceId' - [Required] The Resource identifier for the new Method resource.
--
-- 'httpMethod', 'putMethod_httpMethod' - [Required] Specifies the method request\'s HTTP method type.
--
-- 'authorizationType', 'putMethod_authorizationType' - [Required] The method\'s authorization type. Valid values are @NONE@ for
-- open access, @AWS_IAM@ for using AWS IAM permissions, @CUSTOM@ for using
-- a custom authorizer, or @COGNITO_USER_POOLS@ for using a Cognito user
-- pool.
newPutMethod ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'httpMethod'
  Prelude.Text ->
  -- | 'authorizationType'
  Prelude.Text ->
  PutMethod
newPutMethod :: Text -> Text -> Text -> Text -> PutMethod
newPutMethod
  Text
pRestApiId_
  Text
pResourceId_
  Text
pHttpMethod_
  Text
pAuthorizationType_ =
    PutMethod' :: Maybe [Text]
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe (HashMap Text Bool)
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Text
-> Text
-> Text
-> Text
-> PutMethod
PutMethod'
      { $sel:authorizationScopes:PutMethod' :: Maybe [Text]
authorizationScopes = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:requestValidatorId:PutMethod' :: Maybe Text
requestValidatorId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:requestModels:PutMethod' :: Maybe (HashMap Text Text)
requestModels = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:requestParameters:PutMethod' :: Maybe (HashMap Text Bool)
requestParameters = Maybe (HashMap Text Bool)
forall a. Maybe a
Prelude.Nothing,
        $sel:authorizerId:PutMethod' :: Maybe Text
authorizerId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:operationName:PutMethod' :: Maybe Text
operationName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:apiKeyRequired:PutMethod' :: Maybe Bool
apiKeyRequired = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:restApiId:PutMethod' :: Text
restApiId = Text
pRestApiId_,
        $sel:resourceId:PutMethod' :: Text
resourceId = Text
pResourceId_,
        $sel:httpMethod:PutMethod' :: Text
httpMethod = Text
pHttpMethod_,
        $sel:authorizationType:PutMethod' :: Text
authorizationType = Text
pAuthorizationType_
      }

-- | A list of authorization scopes configured on the method. The scopes are
-- used with a @COGNITO_USER_POOLS@ authorizer to authorize the method
-- invocation. The authorization works by matching the method scopes
-- against the scopes parsed from the access token in the incoming request.
-- The method invocation is authorized if any method scopes matches a
-- claimed scope in the access token. Otherwise, the invocation is not
-- authorized. When the method scope is configured, the client must provide
-- an access token instead of an identity token for authorization purposes.
putMethod_authorizationScopes :: Lens.Lens' PutMethod (Prelude.Maybe [Prelude.Text])
putMethod_authorizationScopes :: (Maybe [Text] -> f (Maybe [Text])) -> PutMethod -> f PutMethod
putMethod_authorizationScopes = (PutMethod -> Maybe [Text])
-> (PutMethod -> Maybe [Text] -> PutMethod)
-> Lens PutMethod PutMethod (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMethod' {Maybe [Text]
authorizationScopes :: Maybe [Text]
$sel:authorizationScopes:PutMethod' :: PutMethod -> Maybe [Text]
authorizationScopes} -> Maybe [Text]
authorizationScopes) (\s :: PutMethod
s@PutMethod' {} Maybe [Text]
a -> PutMethod
s {$sel:authorizationScopes:PutMethod' :: Maybe [Text]
authorizationScopes = Maybe [Text]
a} :: PutMethod) ((Maybe [Text] -> f (Maybe [Text])) -> PutMethod -> f PutMethod)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PutMethod
-> f PutMethod
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

-- | The identifier of a RequestValidator for validating the method request.
putMethod_requestValidatorId :: Lens.Lens' PutMethod (Prelude.Maybe Prelude.Text)
putMethod_requestValidatorId :: (Maybe Text -> f (Maybe Text)) -> PutMethod -> f PutMethod
putMethod_requestValidatorId = (PutMethod -> Maybe Text)
-> (PutMethod -> Maybe Text -> PutMethod)
-> Lens PutMethod PutMethod (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMethod' {Maybe Text
requestValidatorId :: Maybe Text
$sel:requestValidatorId:PutMethod' :: PutMethod -> Maybe Text
requestValidatorId} -> Maybe Text
requestValidatorId) (\s :: PutMethod
s@PutMethod' {} Maybe Text
a -> PutMethod
s {$sel:requestValidatorId:PutMethod' :: Maybe Text
requestValidatorId = Maybe Text
a} :: PutMethod)

-- | Specifies the Model resources used for the request\'s content type.
-- Request models are represented as a key\/value map, with a content type
-- as the key and a Model name as the value.
putMethod_requestModels :: Lens.Lens' PutMethod (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
putMethod_requestModels :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> PutMethod -> f PutMethod
putMethod_requestModels = (PutMethod -> Maybe (HashMap Text Text))
-> (PutMethod -> Maybe (HashMap Text Text) -> PutMethod)
-> Lens
     PutMethod
     PutMethod
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMethod' {Maybe (HashMap Text Text)
requestModels :: Maybe (HashMap Text Text)
$sel:requestModels:PutMethod' :: PutMethod -> Maybe (HashMap Text Text)
requestModels} -> Maybe (HashMap Text Text)
requestModels) (\s :: PutMethod
s@PutMethod' {} Maybe (HashMap Text Text)
a -> PutMethod
s {$sel:requestModels:PutMethod' :: Maybe (HashMap Text Text)
requestModels = Maybe (HashMap Text Text)
a} :: PutMethod) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> PutMethod -> f PutMethod)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> PutMethod
-> f PutMethod
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A key-value map defining required or optional method request parameters
-- that can be accepted by API Gateway. A key defines a method request
-- parameter name matching the pattern of
-- @method.request.{location}.{name}@, where @location@ is @querystring@,
-- @path@, or @header@ and @name@ is a valid and unique parameter name. The
-- value associated with the key is a Boolean flag indicating whether the
-- parameter is required (@true@) or optional (@false@). The method request
-- parameter names defined here are available in Integration to be mapped
-- to integration request parameters or body-mapping templates.
putMethod_requestParameters :: Lens.Lens' PutMethod (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Bool))
putMethod_requestParameters :: (Maybe (HashMap Text Bool) -> f (Maybe (HashMap Text Bool)))
-> PutMethod -> f PutMethod
putMethod_requestParameters = (PutMethod -> Maybe (HashMap Text Bool))
-> (PutMethod -> Maybe (HashMap Text Bool) -> PutMethod)
-> Lens
     PutMethod
     PutMethod
     (Maybe (HashMap Text Bool))
     (Maybe (HashMap Text Bool))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMethod' {Maybe (HashMap Text Bool)
requestParameters :: Maybe (HashMap Text Bool)
$sel:requestParameters:PutMethod' :: PutMethod -> Maybe (HashMap Text Bool)
requestParameters} -> Maybe (HashMap Text Bool)
requestParameters) (\s :: PutMethod
s@PutMethod' {} Maybe (HashMap Text Bool)
a -> PutMethod
s {$sel:requestParameters:PutMethod' :: Maybe (HashMap Text Bool)
requestParameters = Maybe (HashMap Text Bool)
a} :: PutMethod) ((Maybe (HashMap Text Bool) -> f (Maybe (HashMap Text Bool)))
 -> PutMethod -> f PutMethod)
-> ((Maybe (HashMap Text Bool) -> f (Maybe (HashMap Text Bool)))
    -> Maybe (HashMap Text Bool) -> f (Maybe (HashMap Text Bool)))
-> (Maybe (HashMap Text Bool) -> f (Maybe (HashMap Text Bool)))
-> PutMethod
-> f PutMethod
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Bool)
  (HashMap Text Bool)
  (HashMap Text Bool)
  (HashMap Text Bool)
-> Iso
     (Maybe (HashMap Text Bool))
     (Maybe (HashMap Text Bool))
     (Maybe (HashMap Text Bool))
     (Maybe (HashMap Text Bool))
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
  (HashMap Text Bool)
  (HashMap Text Bool)
  (HashMap Text Bool)
  (HashMap Text Bool)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the identifier of an Authorizer to use on this Method, if the
-- type is CUSTOM or COGNITO_USER_POOLS. The authorizer identifier is
-- generated by API Gateway when you created the authorizer.
putMethod_authorizerId :: Lens.Lens' PutMethod (Prelude.Maybe Prelude.Text)
putMethod_authorizerId :: (Maybe Text -> f (Maybe Text)) -> PutMethod -> f PutMethod
putMethod_authorizerId = (PutMethod -> Maybe Text)
-> (PutMethod -> Maybe Text -> PutMethod)
-> Lens PutMethod PutMethod (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMethod' {Maybe Text
authorizerId :: Maybe Text
$sel:authorizerId:PutMethod' :: PutMethod -> Maybe Text
authorizerId} -> Maybe Text
authorizerId) (\s :: PutMethod
s@PutMethod' {} Maybe Text
a -> PutMethod
s {$sel:authorizerId:PutMethod' :: Maybe Text
authorizerId = Maybe Text
a} :: PutMethod)

-- | A human-friendly operation identifier for the method. For example, you
-- can assign the @operationName@ of @ListPets@ for the @GET \/pets@ method
-- in the @PetStore@ example.
putMethod_operationName :: Lens.Lens' PutMethod (Prelude.Maybe Prelude.Text)
putMethod_operationName :: (Maybe Text -> f (Maybe Text)) -> PutMethod -> f PutMethod
putMethod_operationName = (PutMethod -> Maybe Text)
-> (PutMethod -> Maybe Text -> PutMethod)
-> Lens PutMethod PutMethod (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMethod' {Maybe Text
operationName :: Maybe Text
$sel:operationName:PutMethod' :: PutMethod -> Maybe Text
operationName} -> Maybe Text
operationName) (\s :: PutMethod
s@PutMethod' {} Maybe Text
a -> PutMethod
s {$sel:operationName:PutMethod' :: Maybe Text
operationName = Maybe Text
a} :: PutMethod)

-- | Specifies whether the method required a valid ApiKey.
putMethod_apiKeyRequired :: Lens.Lens' PutMethod (Prelude.Maybe Prelude.Bool)
putMethod_apiKeyRequired :: (Maybe Bool -> f (Maybe Bool)) -> PutMethod -> f PutMethod
putMethod_apiKeyRequired = (PutMethod -> Maybe Bool)
-> (PutMethod -> Maybe Bool -> PutMethod)
-> Lens PutMethod PutMethod (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMethod' {Maybe Bool
apiKeyRequired :: Maybe Bool
$sel:apiKeyRequired:PutMethod' :: PutMethod -> Maybe Bool
apiKeyRequired} -> Maybe Bool
apiKeyRequired) (\s :: PutMethod
s@PutMethod' {} Maybe Bool
a -> PutMethod
s {$sel:apiKeyRequired:PutMethod' :: Maybe Bool
apiKeyRequired = Maybe Bool
a} :: PutMethod)

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

-- | [Required] The Resource identifier for the new Method resource.
putMethod_resourceId :: Lens.Lens' PutMethod Prelude.Text
putMethod_resourceId :: (Text -> f Text) -> PutMethod -> f PutMethod
putMethod_resourceId = (PutMethod -> Text)
-> (PutMethod -> Text -> PutMethod)
-> Lens PutMethod PutMethod Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMethod' {Text
resourceId :: Text
$sel:resourceId:PutMethod' :: PutMethod -> Text
resourceId} -> Text
resourceId) (\s :: PutMethod
s@PutMethod' {} Text
a -> PutMethod
s {$sel:resourceId:PutMethod' :: Text
resourceId = Text
a} :: PutMethod)

-- | [Required] Specifies the method request\'s HTTP method type.
putMethod_httpMethod :: Lens.Lens' PutMethod Prelude.Text
putMethod_httpMethod :: (Text -> f Text) -> PutMethod -> f PutMethod
putMethod_httpMethod = (PutMethod -> Text)
-> (PutMethod -> Text -> PutMethod)
-> Lens PutMethod PutMethod Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMethod' {Text
httpMethod :: Text
$sel:httpMethod:PutMethod' :: PutMethod -> Text
httpMethod} -> Text
httpMethod) (\s :: PutMethod
s@PutMethod' {} Text
a -> PutMethod
s {$sel:httpMethod:PutMethod' :: Text
httpMethod = Text
a} :: PutMethod)

-- | [Required] The method\'s authorization type. Valid values are @NONE@ for
-- open access, @AWS_IAM@ for using AWS IAM permissions, @CUSTOM@ for using
-- a custom authorizer, or @COGNITO_USER_POOLS@ for using a Cognito user
-- pool.
putMethod_authorizationType :: Lens.Lens' PutMethod Prelude.Text
putMethod_authorizationType :: (Text -> f Text) -> PutMethod -> f PutMethod
putMethod_authorizationType = (PutMethod -> Text)
-> (PutMethod -> Text -> PutMethod)
-> Lens PutMethod PutMethod Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMethod' {Text
authorizationType :: Text
$sel:authorizationType:PutMethod' :: PutMethod -> Text
authorizationType} -> Text
authorizationType) (\s :: PutMethod
s@PutMethod' {} Text
a -> PutMethod
s {$sel:authorizationType:PutMethod' :: Text
authorizationType = Text
a} :: PutMethod)

instance Core.AWSRequest PutMethod where
  type AWSResponse PutMethod = Method
  request :: PutMethod -> Request PutMethod
request = Service -> PutMethod -> Request PutMethod
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutMethod
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutMethod)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PutMethod))
-> Logger
-> Service
-> Proxy PutMethod
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutMethod)))
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 Method
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable PutMethod

instance Prelude.NFData PutMethod

instance Core.ToHeaders PutMethod where
  toHeaders :: PutMethod -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutMethod -> 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 PutMethod where
  toJSON :: PutMethod -> Value
toJSON PutMethod' {Maybe Bool
Maybe [Text]
Maybe Text
Maybe (HashMap Text Bool)
Maybe (HashMap Text Text)
Text
authorizationType :: Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
apiKeyRequired :: Maybe Bool
operationName :: Maybe Text
authorizerId :: Maybe Text
requestParameters :: Maybe (HashMap Text Bool)
requestModels :: Maybe (HashMap Text Text)
requestValidatorId :: Maybe Text
authorizationScopes :: Maybe [Text]
$sel:authorizationType:PutMethod' :: PutMethod -> Text
$sel:httpMethod:PutMethod' :: PutMethod -> Text
$sel:resourceId:PutMethod' :: PutMethod -> Text
$sel:restApiId:PutMethod' :: PutMethod -> Text
$sel:apiKeyRequired:PutMethod' :: PutMethod -> Maybe Bool
$sel:operationName:PutMethod' :: PutMethod -> Maybe Text
$sel:authorizerId:PutMethod' :: PutMethod -> Maybe Text
$sel:requestParameters:PutMethod' :: PutMethod -> Maybe (HashMap Text Bool)
$sel:requestModels:PutMethod' :: PutMethod -> Maybe (HashMap Text Text)
$sel:requestValidatorId:PutMethod' :: PutMethod -> Maybe Text
$sel:authorizationScopes:PutMethod' :: PutMethod -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"authorizationScopes" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
authorizationScopes,
            (Text
"requestValidatorId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
requestValidatorId,
            (Text
"requestModels" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
requestModels,
            (Text
"requestParameters" Text -> HashMap Text Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Bool -> Pair)
-> Maybe (HashMap Text Bool) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Bool)
requestParameters,
            (Text
"authorizerId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
authorizerId,
            (Text
"operationName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
operationName,
            (Text
"apiKeyRequired" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
apiKeyRequired,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"authorizationType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
authorizationType)
          ]
      )

instance Core.ToPath PutMethod where
  toPath :: PutMethod -> ByteString
toPath PutMethod' {Maybe Bool
Maybe [Text]
Maybe Text
Maybe (HashMap Text Bool)
Maybe (HashMap Text Text)
Text
authorizationType :: Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
apiKeyRequired :: Maybe Bool
operationName :: Maybe Text
authorizerId :: Maybe Text
requestParameters :: Maybe (HashMap Text Bool)
requestModels :: Maybe (HashMap Text Text)
requestValidatorId :: Maybe Text
authorizationScopes :: Maybe [Text]
$sel:authorizationType:PutMethod' :: PutMethod -> Text
$sel:httpMethod:PutMethod' :: PutMethod -> Text
$sel:resourceId:PutMethod' :: PutMethod -> Text
$sel:restApiId:PutMethod' :: PutMethod -> Text
$sel:apiKeyRequired:PutMethod' :: PutMethod -> Maybe Bool
$sel:operationName:PutMethod' :: PutMethod -> Maybe Text
$sel:authorizerId:PutMethod' :: PutMethod -> Maybe Text
$sel:requestParameters:PutMethod' :: PutMethod -> Maybe (HashMap Text Bool)
$sel:requestModels:PutMethod' :: PutMethod -> Maybe (HashMap Text Text)
$sel:requestValidatorId:PutMethod' :: PutMethod -> Maybe Text
$sel:authorizationScopes:PutMethod' :: PutMethod -> Maybe [Text]
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/restapis/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
restApiId,
        ByteString
"/resources/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
resourceId,
        ByteString
"/methods/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
httpMethod
      ]

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