{-# 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.Lambda.CreateAlias
(
CreateAlias (..),
newCreateAlias,
createAlias_routingConfig,
createAlias_description,
createAlias_functionName,
createAlias_name,
createAlias_functionVersion,
AliasConfiguration (..),
newAliasConfiguration,
aliasConfiguration_routingConfig,
aliasConfiguration_name,
aliasConfiguration_functionVersion,
aliasConfiguration_aliasArn,
aliasConfiguration_description,
aliasConfiguration_revisionId,
)
where
import qualified Amazonka.Core as Core
import Amazonka.Lambda.Types
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 CreateAlias = CreateAlias'
{
CreateAlias -> Maybe AliasRoutingConfiguration
routingConfig :: Prelude.Maybe AliasRoutingConfiguration,
CreateAlias -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreateAlias -> Text
functionName :: Prelude.Text,
CreateAlias -> Text
name :: Prelude.Text,
CreateAlias -> Text
functionVersion :: Prelude.Text
}
deriving (CreateAlias -> CreateAlias -> Bool
(CreateAlias -> CreateAlias -> Bool)
-> (CreateAlias -> CreateAlias -> Bool) -> Eq CreateAlias
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAlias -> CreateAlias -> Bool
$c/= :: CreateAlias -> CreateAlias -> Bool
== :: CreateAlias -> CreateAlias -> Bool
$c== :: CreateAlias -> CreateAlias -> Bool
Prelude.Eq, ReadPrec [CreateAlias]
ReadPrec CreateAlias
Int -> ReadS CreateAlias
ReadS [CreateAlias]
(Int -> ReadS CreateAlias)
-> ReadS [CreateAlias]
-> ReadPrec CreateAlias
-> ReadPrec [CreateAlias]
-> Read CreateAlias
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAlias]
$creadListPrec :: ReadPrec [CreateAlias]
readPrec :: ReadPrec CreateAlias
$creadPrec :: ReadPrec CreateAlias
readList :: ReadS [CreateAlias]
$creadList :: ReadS [CreateAlias]
readsPrec :: Int -> ReadS CreateAlias
$creadsPrec :: Int -> ReadS CreateAlias
Prelude.Read, Int -> CreateAlias -> ShowS
[CreateAlias] -> ShowS
CreateAlias -> String
(Int -> CreateAlias -> ShowS)
-> (CreateAlias -> String)
-> ([CreateAlias] -> ShowS)
-> Show CreateAlias
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAlias] -> ShowS
$cshowList :: [CreateAlias] -> ShowS
show :: CreateAlias -> String
$cshow :: CreateAlias -> String
showsPrec :: Int -> CreateAlias -> ShowS
$cshowsPrec :: Int -> CreateAlias -> ShowS
Prelude.Show, (forall x. CreateAlias -> Rep CreateAlias x)
-> (forall x. Rep CreateAlias x -> CreateAlias)
-> Generic CreateAlias
forall x. Rep CreateAlias x -> CreateAlias
forall x. CreateAlias -> Rep CreateAlias x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAlias x -> CreateAlias
$cfrom :: forall x. CreateAlias -> Rep CreateAlias x
Prelude.Generic)
newCreateAlias ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
CreateAlias
newCreateAlias :: Text -> Text -> Text -> CreateAlias
newCreateAlias
Text
pFunctionName_
Text
pName_
Text
pFunctionVersion_ =
CreateAlias' :: Maybe AliasRoutingConfiguration
-> Maybe Text -> Text -> Text -> Text -> CreateAlias
CreateAlias'
{ $sel:routingConfig:CreateAlias' :: Maybe AliasRoutingConfiguration
routingConfig = Maybe AliasRoutingConfiguration
forall a. Maybe a
Prelude.Nothing,
$sel:description:CreateAlias' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:functionName:CreateAlias' :: Text
functionName = Text
pFunctionName_,
$sel:name:CreateAlias' :: Text
name = Text
pName_,
$sel:functionVersion:CreateAlias' :: Text
functionVersion = Text
pFunctionVersion_
}
createAlias_routingConfig :: Lens.Lens' CreateAlias (Prelude.Maybe AliasRoutingConfiguration)
createAlias_routingConfig :: (Maybe AliasRoutingConfiguration
-> f (Maybe AliasRoutingConfiguration))
-> CreateAlias -> f CreateAlias
createAlias_routingConfig = (CreateAlias -> Maybe AliasRoutingConfiguration)
-> (CreateAlias -> Maybe AliasRoutingConfiguration -> CreateAlias)
-> Lens
CreateAlias
CreateAlias
(Maybe AliasRoutingConfiguration)
(Maybe AliasRoutingConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlias' {Maybe AliasRoutingConfiguration
routingConfig :: Maybe AliasRoutingConfiguration
$sel:routingConfig:CreateAlias' :: CreateAlias -> Maybe AliasRoutingConfiguration
routingConfig} -> Maybe AliasRoutingConfiguration
routingConfig) (\s :: CreateAlias
s@CreateAlias' {} Maybe AliasRoutingConfiguration
a -> CreateAlias
s {$sel:routingConfig:CreateAlias' :: Maybe AliasRoutingConfiguration
routingConfig = Maybe AliasRoutingConfiguration
a} :: CreateAlias)
createAlias_description :: Lens.Lens' CreateAlias (Prelude.Maybe Prelude.Text)
createAlias_description :: (Maybe Text -> f (Maybe Text)) -> CreateAlias -> f CreateAlias
createAlias_description = (CreateAlias -> Maybe Text)
-> (CreateAlias -> Maybe Text -> CreateAlias)
-> Lens CreateAlias CreateAlias (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlias' {Maybe Text
description :: Maybe Text
$sel:description:CreateAlias' :: CreateAlias -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateAlias
s@CreateAlias' {} Maybe Text
a -> CreateAlias
s {$sel:description:CreateAlias' :: Maybe Text
description = Maybe Text
a} :: CreateAlias)
createAlias_functionName :: Lens.Lens' CreateAlias Prelude.Text
createAlias_functionName :: (Text -> f Text) -> CreateAlias -> f CreateAlias
createAlias_functionName = (CreateAlias -> Text)
-> (CreateAlias -> Text -> CreateAlias)
-> Lens CreateAlias CreateAlias Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlias' {Text
functionName :: Text
$sel:functionName:CreateAlias' :: CreateAlias -> Text
functionName} -> Text
functionName) (\s :: CreateAlias
s@CreateAlias' {} Text
a -> CreateAlias
s {$sel:functionName:CreateAlias' :: Text
functionName = Text
a} :: CreateAlias)
createAlias_name :: Lens.Lens' CreateAlias Prelude.Text
createAlias_name :: (Text -> f Text) -> CreateAlias -> f CreateAlias
createAlias_name = (CreateAlias -> Text)
-> (CreateAlias -> Text -> CreateAlias)
-> Lens CreateAlias CreateAlias Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlias' {Text
name :: Text
$sel:name:CreateAlias' :: CreateAlias -> Text
name} -> Text
name) (\s :: CreateAlias
s@CreateAlias' {} Text
a -> CreateAlias
s {$sel:name:CreateAlias' :: Text
name = Text
a} :: CreateAlias)
createAlias_functionVersion :: Lens.Lens' CreateAlias Prelude.Text
createAlias_functionVersion :: (Text -> f Text) -> CreateAlias -> f CreateAlias
createAlias_functionVersion = (CreateAlias -> Text)
-> (CreateAlias -> Text -> CreateAlias)
-> Lens CreateAlias CreateAlias Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlias' {Text
functionVersion :: Text
$sel:functionVersion:CreateAlias' :: CreateAlias -> Text
functionVersion} -> Text
functionVersion) (\s :: CreateAlias
s@CreateAlias' {} Text
a -> CreateAlias
s {$sel:functionVersion:CreateAlias' :: Text
functionVersion = Text
a} :: CreateAlias)
instance Core.AWSRequest CreateAlias where
type AWSResponse CreateAlias = AliasConfiguration
request :: CreateAlias -> Request CreateAlias
request = Service -> CreateAlias -> Request CreateAlias
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateAlias)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateAlias))
-> Logger
-> Service
-> Proxy CreateAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateAlias)))
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 AliasConfiguration
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
instance Prelude.Hashable CreateAlias
instance Prelude.NFData CreateAlias
instance Core.ToHeaders CreateAlias where
toHeaders :: CreateAlias -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateAlias -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON CreateAlias where
toJSON :: CreateAlias -> Value
toJSON CreateAlias' {Maybe Text
Maybe AliasRoutingConfiguration
Text
functionVersion :: Text
name :: Text
functionName :: Text
description :: Maybe Text
routingConfig :: Maybe AliasRoutingConfiguration
$sel:functionVersion:CreateAlias' :: CreateAlias -> Text
$sel:name:CreateAlias' :: CreateAlias -> Text
$sel:functionName:CreateAlias' :: CreateAlias -> Text
$sel:description:CreateAlias' :: CreateAlias -> Maybe Text
$sel:routingConfig:CreateAlias' :: CreateAlias -> Maybe AliasRoutingConfiguration
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"RoutingConfig" Text -> AliasRoutingConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AliasRoutingConfiguration -> Pair)
-> Maybe AliasRoutingConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AliasRoutingConfiguration
routingConfig,
(Text
"Description" 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
description,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"FunctionVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
functionVersion)
]
)
instance Core.ToPath CreateAlias where
toPath :: CreateAlias -> ByteString
toPath CreateAlias' {Maybe Text
Maybe AliasRoutingConfiguration
Text
functionVersion :: Text
name :: Text
functionName :: Text
description :: Maybe Text
routingConfig :: Maybe AliasRoutingConfiguration
$sel:functionVersion:CreateAlias' :: CreateAlias -> Text
$sel:name:CreateAlias' :: CreateAlias -> Text
$sel:functionName:CreateAlias' :: CreateAlias -> Text
$sel:description:CreateAlias' :: CreateAlias -> Maybe Text
$sel:routingConfig:CreateAlias' :: CreateAlias -> Maybe AliasRoutingConfiguration
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/2015-03-31/functions/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
functionName,
ByteString
"/aliases"
]
instance Core.ToQuery CreateAlias where
toQuery :: CreateAlias -> QueryString
toQuery = QueryString -> CreateAlias -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty