{-# 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 #-}
module Amazonka.APIGateway.UpdateMethod
(
UpdateMethod (..),
newUpdateMethod,
updateMethod_patchOperations,
updateMethod_restApiId,
updateMethod_resourceId,
updateMethod_httpMethod,
Method (..),
newMethod,
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
data UpdateMethod = UpdateMethod'
{
UpdateMethod -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation],
UpdateMethod -> Text
restApiId :: Prelude.Text,
UpdateMethod -> Text
resourceId :: Prelude.Text,
UpdateMethod -> Text
httpMethod :: Prelude.Text
}
deriving (UpdateMethod -> UpdateMethod -> Bool
(UpdateMethod -> UpdateMethod -> Bool)
-> (UpdateMethod -> UpdateMethod -> Bool) -> Eq UpdateMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateMethod -> UpdateMethod -> Bool
$c/= :: UpdateMethod -> UpdateMethod -> Bool
== :: UpdateMethod -> UpdateMethod -> Bool
$c== :: UpdateMethod -> UpdateMethod -> Bool
Prelude.Eq, ReadPrec [UpdateMethod]
ReadPrec UpdateMethod
Int -> ReadS UpdateMethod
ReadS [UpdateMethod]
(Int -> ReadS UpdateMethod)
-> ReadS [UpdateMethod]
-> ReadPrec UpdateMethod
-> ReadPrec [UpdateMethod]
-> Read UpdateMethod
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateMethod]
$creadListPrec :: ReadPrec [UpdateMethod]
readPrec :: ReadPrec UpdateMethod
$creadPrec :: ReadPrec UpdateMethod
readList :: ReadS [UpdateMethod]
$creadList :: ReadS [UpdateMethod]
readsPrec :: Int -> ReadS UpdateMethod
$creadsPrec :: Int -> ReadS UpdateMethod
Prelude.Read, Int -> UpdateMethod -> ShowS
[UpdateMethod] -> ShowS
UpdateMethod -> String
(Int -> UpdateMethod -> ShowS)
-> (UpdateMethod -> String)
-> ([UpdateMethod] -> ShowS)
-> Show UpdateMethod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateMethod] -> ShowS
$cshowList :: [UpdateMethod] -> ShowS
show :: UpdateMethod -> String
$cshow :: UpdateMethod -> String
showsPrec :: Int -> UpdateMethod -> ShowS
$cshowsPrec :: Int -> UpdateMethod -> ShowS
Prelude.Show, (forall x. UpdateMethod -> Rep UpdateMethod x)
-> (forall x. Rep UpdateMethod x -> UpdateMethod)
-> Generic UpdateMethod
forall x. Rep UpdateMethod x -> UpdateMethod
forall x. UpdateMethod -> Rep UpdateMethod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateMethod x -> UpdateMethod
$cfrom :: forall x. UpdateMethod -> Rep UpdateMethod x
Prelude.Generic)
newUpdateMethod ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
UpdateMethod
newUpdateMethod :: Text -> Text -> Text -> UpdateMethod
newUpdateMethod Text
pRestApiId_ Text
pResourceId_ Text
pHttpMethod_ =
UpdateMethod' :: Maybe [PatchOperation] -> Text -> Text -> Text -> UpdateMethod
UpdateMethod'
{ $sel:patchOperations:UpdateMethod' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
forall a. Maybe a
Prelude.Nothing,
$sel:restApiId:UpdateMethod' :: Text
restApiId = Text
pRestApiId_,
$sel:resourceId:UpdateMethod' :: Text
resourceId = Text
pResourceId_,
$sel:httpMethod:UpdateMethod' :: Text
httpMethod = Text
pHttpMethod_
}
updateMethod_patchOperations :: Lens.Lens' UpdateMethod (Prelude.Maybe [PatchOperation])
updateMethod_patchOperations :: (Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateMethod -> f UpdateMethod
updateMethod_patchOperations = (UpdateMethod -> Maybe [PatchOperation])
-> (UpdateMethod -> Maybe [PatchOperation] -> UpdateMethod)
-> Lens
UpdateMethod
UpdateMethod
(Maybe [PatchOperation])
(Maybe [PatchOperation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMethod' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateMethod' :: UpdateMethod -> Maybe [PatchOperation]
patchOperations} -> Maybe [PatchOperation]
patchOperations) (\s :: UpdateMethod
s@UpdateMethod' {} Maybe [PatchOperation]
a -> UpdateMethod
s {$sel:patchOperations:UpdateMethod' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
a} :: UpdateMethod) ((Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateMethod -> f UpdateMethod)
-> ((Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> (Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateMethod
-> f UpdateMethod
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
updateMethod_restApiId :: Lens.Lens' UpdateMethod Prelude.Text
updateMethod_restApiId :: (Text -> f Text) -> UpdateMethod -> f UpdateMethod
updateMethod_restApiId = (UpdateMethod -> Text)
-> (UpdateMethod -> Text -> UpdateMethod)
-> Lens UpdateMethod UpdateMethod Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMethod' {Text
restApiId :: Text
$sel:restApiId:UpdateMethod' :: UpdateMethod -> Text
restApiId} -> Text
restApiId) (\s :: UpdateMethod
s@UpdateMethod' {} Text
a -> UpdateMethod
s {$sel:restApiId:UpdateMethod' :: Text
restApiId = Text
a} :: UpdateMethod)
updateMethod_resourceId :: Lens.Lens' UpdateMethod Prelude.Text
updateMethod_resourceId :: (Text -> f Text) -> UpdateMethod -> f UpdateMethod
updateMethod_resourceId = (UpdateMethod -> Text)
-> (UpdateMethod -> Text -> UpdateMethod)
-> Lens UpdateMethod UpdateMethod Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMethod' {Text
resourceId :: Text
$sel:resourceId:UpdateMethod' :: UpdateMethod -> Text
resourceId} -> Text
resourceId) (\s :: UpdateMethod
s@UpdateMethod' {} Text
a -> UpdateMethod
s {$sel:resourceId:UpdateMethod' :: Text
resourceId = Text
a} :: UpdateMethod)
updateMethod_httpMethod :: Lens.Lens' UpdateMethod Prelude.Text
updateMethod_httpMethod :: (Text -> f Text) -> UpdateMethod -> f UpdateMethod
updateMethod_httpMethod = (UpdateMethod -> Text)
-> (UpdateMethod -> Text -> UpdateMethod)
-> Lens UpdateMethod UpdateMethod Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMethod' {Text
httpMethod :: Text
$sel:httpMethod:UpdateMethod' :: UpdateMethod -> Text
httpMethod} -> Text
httpMethod) (\s :: UpdateMethod
s@UpdateMethod' {} Text
a -> UpdateMethod
s {$sel:httpMethod:UpdateMethod' :: Text
httpMethod = Text
a} :: UpdateMethod)
instance Core.AWSRequest UpdateMethod where
type AWSResponse UpdateMethod = Method
request :: UpdateMethod -> Request UpdateMethod
request = Service -> UpdateMethod -> Request UpdateMethod
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
response :: Logger
-> Service
-> Proxy UpdateMethod
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateMethod)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse UpdateMethod))
-> Logger
-> Service
-> Proxy UpdateMethod
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateMethod)))
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 UpdateMethod
instance Prelude.NFData UpdateMethod
instance Core.ToHeaders UpdateMethod where
toHeaders :: UpdateMethod -> ResponseHeaders
toHeaders =
ResponseHeaders -> UpdateMethod -> 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 UpdateMethod where
toJSON :: UpdateMethod -> Value
toJSON UpdateMethod' {Maybe [PatchOperation]
Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:httpMethod:UpdateMethod' :: UpdateMethod -> Text
$sel:resourceId:UpdateMethod' :: UpdateMethod -> Text
$sel:restApiId:UpdateMethod' :: UpdateMethod -> Text
$sel:patchOperations:UpdateMethod' :: UpdateMethod -> 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 UpdateMethod where
toPath :: UpdateMethod -> ByteString
toPath UpdateMethod' {Maybe [PatchOperation]
Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:httpMethod:UpdateMethod' :: UpdateMethod -> Text
$sel:resourceId:UpdateMethod' :: UpdateMethod -> Text
$sel:restApiId:UpdateMethod' :: UpdateMethod -> Text
$sel:patchOperations:UpdateMethod' :: UpdateMethod -> Maybe [PatchOperation]
..} =
[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 UpdateMethod where
toQuery :: UpdateMethod -> QueryString
toQuery = QueryString -> UpdateMethod -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty