{-# 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.CloudFront.CreateFunction
(
CreateFunction (..),
newCreateFunction,
createFunction_name,
createFunction_functionConfig,
createFunction_functionCode,
CreateFunctionResponse (..),
newCreateFunctionResponse,
createFunctionResponse_eTag,
createFunctionResponse_location,
createFunctionResponse_functionSummary,
createFunctionResponse_httpStatus,
)
where
import Amazonka.CloudFront.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 CreateFunction = CreateFunction'
{
CreateFunction -> Text
name :: Prelude.Text,
CreateFunction -> FunctionConfig
functionConfig :: FunctionConfig,
CreateFunction -> Sensitive Base64
functionCode :: Core.Sensitive Core.Base64
}
deriving (CreateFunction -> CreateFunction -> Bool
(CreateFunction -> CreateFunction -> Bool)
-> (CreateFunction -> CreateFunction -> Bool) -> Eq CreateFunction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFunction -> CreateFunction -> Bool
$c/= :: CreateFunction -> CreateFunction -> Bool
== :: CreateFunction -> CreateFunction -> Bool
$c== :: CreateFunction -> CreateFunction -> Bool
Prelude.Eq, Int -> CreateFunction -> ShowS
[CreateFunction] -> ShowS
CreateFunction -> String
(Int -> CreateFunction -> ShowS)
-> (CreateFunction -> String)
-> ([CreateFunction] -> ShowS)
-> Show CreateFunction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFunction] -> ShowS
$cshowList :: [CreateFunction] -> ShowS
show :: CreateFunction -> String
$cshow :: CreateFunction -> String
showsPrec :: Int -> CreateFunction -> ShowS
$cshowsPrec :: Int -> CreateFunction -> ShowS
Prelude.Show, (forall x. CreateFunction -> Rep CreateFunction x)
-> (forall x. Rep CreateFunction x -> CreateFunction)
-> Generic CreateFunction
forall x. Rep CreateFunction x -> CreateFunction
forall x. CreateFunction -> Rep CreateFunction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateFunction x -> CreateFunction
$cfrom :: forall x. CreateFunction -> Rep CreateFunction x
Prelude.Generic)
newCreateFunction ::
Prelude.Text ->
FunctionConfig ->
Prelude.ByteString ->
CreateFunction
newCreateFunction :: Text -> FunctionConfig -> ByteString -> CreateFunction
newCreateFunction
Text
pName_
FunctionConfig
pFunctionConfig_
ByteString
pFunctionCode_ =
CreateFunction' :: Text -> FunctionConfig -> Sensitive Base64 -> CreateFunction
CreateFunction'
{ $sel:name:CreateFunction' :: Text
name = Text
pName_,
$sel:functionConfig:CreateFunction' :: FunctionConfig
functionConfig = FunctionConfig
pFunctionConfig_,
$sel:functionCode:CreateFunction' :: Sensitive Base64
functionCode =
Tagged Base64 (Identity Base64)
-> Tagged (Sensitive Base64) (Identity (Sensitive Base64))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Base64 (Identity Base64)
-> Tagged (Sensitive Base64) (Identity (Sensitive Base64)))
-> (Tagged ByteString (Identity ByteString)
-> Tagged Base64 (Identity Base64))
-> Tagged ByteString (Identity ByteString)
-> Tagged (Sensitive Base64) (Identity (Sensitive Base64))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Tagged ByteString (Identity ByteString)
-> Tagged Base64 (Identity Base64)
Iso' Base64 ByteString
Core._Base64
(Tagged ByteString (Identity ByteString)
-> Tagged (Sensitive Base64) (Identity (Sensitive Base64)))
-> ByteString -> Sensitive Base64
forall t b. AReview t b -> b -> t
Lens.# ByteString
pFunctionCode_
}
createFunction_name :: Lens.Lens' CreateFunction Prelude.Text
createFunction_name :: (Text -> f Text) -> CreateFunction -> f CreateFunction
createFunction_name = (CreateFunction -> Text)
-> (CreateFunction -> Text -> CreateFunction)
-> Lens CreateFunction CreateFunction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFunction' {Text
name :: Text
$sel:name:CreateFunction' :: CreateFunction -> Text
name} -> Text
name) (\s :: CreateFunction
s@CreateFunction' {} Text
a -> CreateFunction
s {$sel:name:CreateFunction' :: Text
name = Text
a} :: CreateFunction)
createFunction_functionConfig :: Lens.Lens' CreateFunction FunctionConfig
createFunction_functionConfig :: (FunctionConfig -> f FunctionConfig)
-> CreateFunction -> f CreateFunction
createFunction_functionConfig = (CreateFunction -> FunctionConfig)
-> (CreateFunction -> FunctionConfig -> CreateFunction)
-> Lens CreateFunction CreateFunction FunctionConfig FunctionConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFunction' {FunctionConfig
functionConfig :: FunctionConfig
$sel:functionConfig:CreateFunction' :: CreateFunction -> FunctionConfig
functionConfig} -> FunctionConfig
functionConfig) (\s :: CreateFunction
s@CreateFunction' {} FunctionConfig
a -> CreateFunction
s {$sel:functionConfig:CreateFunction' :: FunctionConfig
functionConfig = FunctionConfig
a} :: CreateFunction)
createFunction_functionCode :: Lens.Lens' CreateFunction Prelude.ByteString
createFunction_functionCode :: (ByteString -> f ByteString) -> CreateFunction -> f CreateFunction
createFunction_functionCode = (CreateFunction -> Sensitive Base64)
-> (CreateFunction -> Sensitive Base64 -> CreateFunction)
-> Lens
CreateFunction CreateFunction (Sensitive Base64) (Sensitive Base64)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFunction' {Sensitive Base64
functionCode :: Sensitive Base64
$sel:functionCode:CreateFunction' :: CreateFunction -> Sensitive Base64
functionCode} -> Sensitive Base64
functionCode) (\s :: CreateFunction
s@CreateFunction' {} Sensitive Base64
a -> CreateFunction
s {$sel:functionCode:CreateFunction' :: Sensitive Base64
functionCode = Sensitive Base64
a} :: CreateFunction) ((Sensitive Base64 -> f (Sensitive Base64))
-> CreateFunction -> f CreateFunction)
-> ((ByteString -> f ByteString)
-> Sensitive Base64 -> f (Sensitive Base64))
-> (ByteString -> f ByteString)
-> CreateFunction
-> f CreateFunction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Base64 -> f Base64) -> Sensitive Base64 -> f (Sensitive Base64)
forall a. Iso' (Sensitive a) a
Core._Sensitive ((Base64 -> f Base64) -> Sensitive Base64 -> f (Sensitive Base64))
-> ((ByteString -> f ByteString) -> Base64 -> f Base64)
-> (ByteString -> f ByteString)
-> Sensitive Base64
-> f (Sensitive Base64)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ByteString -> f ByteString) -> Base64 -> f Base64
Iso' Base64 ByteString
Core._Base64
instance Core.AWSRequest CreateFunction where
type
AWSResponse CreateFunction =
CreateFunctionResponse
request :: CreateFunction -> Request CreateFunction
request = Service -> CreateFunction -> Request CreateFunction
forall a. (ToRequest a, ToElement a) => Service -> a -> Request a
Request.postXML Service
defaultService
response :: Logger
-> Service
-> Proxy CreateFunction
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateFunction)))
response =
(Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse CreateFunction))
-> Logger
-> Service
-> Proxy CreateFunction
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateFunction)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
( \Int
s ResponseHeaders
h [Node]
x ->
Maybe Text
-> Maybe Text
-> Maybe FunctionSummary
-> Int
-> CreateFunctionResponse
CreateFunctionResponse'
(Maybe Text
-> Maybe Text
-> Maybe FunctionSummary
-> Int
-> CreateFunctionResponse)
-> Either String (Maybe Text)
-> Either
String
(Maybe Text
-> Maybe FunctionSummary -> Int -> CreateFunctionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"ETag")
Either
String
(Maybe Text
-> Maybe FunctionSummary -> Int -> CreateFunctionResponse)
-> Either String (Maybe Text)
-> Either
String (Maybe FunctionSummary -> Int -> CreateFunctionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"Location")
Either
String (Maybe FunctionSummary -> Int -> CreateFunctionResponse)
-> Either String (Maybe FunctionSummary)
-> Either String (Int -> CreateFunctionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node] -> Either String (Maybe FunctionSummary)
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
Either String (Int -> CreateFunctionResponse)
-> Either String Int -> Either String CreateFunctionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable CreateFunction
instance Prelude.NFData CreateFunction
instance Core.ToElement CreateFunction where
toElement :: CreateFunction -> Element
toElement =
Name -> CreateFunction -> Element
forall a. ToXML a => Name -> a -> Element
Core.mkElement
Name
"{http://cloudfront.amazonaws.com/doc/2020-05-31/}CreateFunctionRequest"
instance Core.ToHeaders CreateFunction where
toHeaders :: CreateFunction -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateFunction -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath CreateFunction where
toPath :: CreateFunction -> ByteString
toPath = ByteString -> CreateFunction -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/2020-05-31/function"
instance Core.ToQuery CreateFunction where
toQuery :: CreateFunction -> QueryString
toQuery = QueryString -> CreateFunction -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
instance Core.ToXML CreateFunction where
toXML :: CreateFunction -> XML
toXML CreateFunction' {Text
Sensitive Base64
FunctionConfig
functionCode :: Sensitive Base64
functionConfig :: FunctionConfig
name :: Text
$sel:functionCode:CreateFunction' :: CreateFunction -> Sensitive Base64
$sel:functionConfig:CreateFunction' :: CreateFunction -> FunctionConfig
$sel:name:CreateFunction' :: CreateFunction -> Text
..} =
[XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ Name
"Name" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
name,
Name
"FunctionConfig" Name -> FunctionConfig -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= FunctionConfig
functionConfig,
Name
"FunctionCode" Name -> Sensitive Base64 -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Sensitive Base64
functionCode
]
data CreateFunctionResponse = CreateFunctionResponse'
{
CreateFunctionResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
CreateFunctionResponse -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
CreateFunctionResponse -> Maybe FunctionSummary
functionSummary :: Prelude.Maybe FunctionSummary,
CreateFunctionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateFunctionResponse -> CreateFunctionResponse -> Bool
(CreateFunctionResponse -> CreateFunctionResponse -> Bool)
-> (CreateFunctionResponse -> CreateFunctionResponse -> Bool)
-> Eq CreateFunctionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFunctionResponse -> CreateFunctionResponse -> Bool
$c/= :: CreateFunctionResponse -> CreateFunctionResponse -> Bool
== :: CreateFunctionResponse -> CreateFunctionResponse -> Bool
$c== :: CreateFunctionResponse -> CreateFunctionResponse -> Bool
Prelude.Eq, ReadPrec [CreateFunctionResponse]
ReadPrec CreateFunctionResponse
Int -> ReadS CreateFunctionResponse
ReadS [CreateFunctionResponse]
(Int -> ReadS CreateFunctionResponse)
-> ReadS [CreateFunctionResponse]
-> ReadPrec CreateFunctionResponse
-> ReadPrec [CreateFunctionResponse]
-> Read CreateFunctionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateFunctionResponse]
$creadListPrec :: ReadPrec [CreateFunctionResponse]
readPrec :: ReadPrec CreateFunctionResponse
$creadPrec :: ReadPrec CreateFunctionResponse
readList :: ReadS [CreateFunctionResponse]
$creadList :: ReadS [CreateFunctionResponse]
readsPrec :: Int -> ReadS CreateFunctionResponse
$creadsPrec :: Int -> ReadS CreateFunctionResponse
Prelude.Read, Int -> CreateFunctionResponse -> ShowS
[CreateFunctionResponse] -> ShowS
CreateFunctionResponse -> String
(Int -> CreateFunctionResponse -> ShowS)
-> (CreateFunctionResponse -> String)
-> ([CreateFunctionResponse] -> ShowS)
-> Show CreateFunctionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFunctionResponse] -> ShowS
$cshowList :: [CreateFunctionResponse] -> ShowS
show :: CreateFunctionResponse -> String
$cshow :: CreateFunctionResponse -> String
showsPrec :: Int -> CreateFunctionResponse -> ShowS
$cshowsPrec :: Int -> CreateFunctionResponse -> ShowS
Prelude.Show, (forall x. CreateFunctionResponse -> Rep CreateFunctionResponse x)
-> (forall x.
Rep CreateFunctionResponse x -> CreateFunctionResponse)
-> Generic CreateFunctionResponse
forall x. Rep CreateFunctionResponse x -> CreateFunctionResponse
forall x. CreateFunctionResponse -> Rep CreateFunctionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateFunctionResponse x -> CreateFunctionResponse
$cfrom :: forall x. CreateFunctionResponse -> Rep CreateFunctionResponse x
Prelude.Generic)
newCreateFunctionResponse ::
Prelude.Int ->
CreateFunctionResponse
newCreateFunctionResponse :: Int -> CreateFunctionResponse
newCreateFunctionResponse Int
pHttpStatus_ =
CreateFunctionResponse' :: Maybe Text
-> Maybe Text
-> Maybe FunctionSummary
-> Int
-> CreateFunctionResponse
CreateFunctionResponse'
{ $sel:eTag:CreateFunctionResponse' :: Maybe Text
eTag = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:location:CreateFunctionResponse' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:functionSummary:CreateFunctionResponse' :: Maybe FunctionSummary
functionSummary = Maybe FunctionSummary
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateFunctionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createFunctionResponse_eTag :: Lens.Lens' CreateFunctionResponse (Prelude.Maybe Prelude.Text)
createFunctionResponse_eTag :: (Maybe Text -> f (Maybe Text))
-> CreateFunctionResponse -> f CreateFunctionResponse
createFunctionResponse_eTag = (CreateFunctionResponse -> Maybe Text)
-> (CreateFunctionResponse -> Maybe Text -> CreateFunctionResponse)
-> Lens
CreateFunctionResponse
CreateFunctionResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFunctionResponse' {Maybe Text
eTag :: Maybe Text
$sel:eTag:CreateFunctionResponse' :: CreateFunctionResponse -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: CreateFunctionResponse
s@CreateFunctionResponse' {} Maybe Text
a -> CreateFunctionResponse
s {$sel:eTag:CreateFunctionResponse' :: Maybe Text
eTag = Maybe Text
a} :: CreateFunctionResponse)
createFunctionResponse_location :: Lens.Lens' CreateFunctionResponse (Prelude.Maybe Prelude.Text)
createFunctionResponse_location :: (Maybe Text -> f (Maybe Text))
-> CreateFunctionResponse -> f CreateFunctionResponse
createFunctionResponse_location = (CreateFunctionResponse -> Maybe Text)
-> (CreateFunctionResponse -> Maybe Text -> CreateFunctionResponse)
-> Lens
CreateFunctionResponse
CreateFunctionResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFunctionResponse' {Maybe Text
location :: Maybe Text
$sel:location:CreateFunctionResponse' :: CreateFunctionResponse -> Maybe Text
location} -> Maybe Text
location) (\s :: CreateFunctionResponse
s@CreateFunctionResponse' {} Maybe Text
a -> CreateFunctionResponse
s {$sel:location:CreateFunctionResponse' :: Maybe Text
location = Maybe Text
a} :: CreateFunctionResponse)
createFunctionResponse_functionSummary :: Lens.Lens' CreateFunctionResponse (Prelude.Maybe FunctionSummary)
createFunctionResponse_functionSummary :: (Maybe FunctionSummary -> f (Maybe FunctionSummary))
-> CreateFunctionResponse -> f CreateFunctionResponse
createFunctionResponse_functionSummary = (CreateFunctionResponse -> Maybe FunctionSummary)
-> (CreateFunctionResponse
-> Maybe FunctionSummary -> CreateFunctionResponse)
-> Lens
CreateFunctionResponse
CreateFunctionResponse
(Maybe FunctionSummary)
(Maybe FunctionSummary)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFunctionResponse' {Maybe FunctionSummary
functionSummary :: Maybe FunctionSummary
$sel:functionSummary:CreateFunctionResponse' :: CreateFunctionResponse -> Maybe FunctionSummary
functionSummary} -> Maybe FunctionSummary
functionSummary) (\s :: CreateFunctionResponse
s@CreateFunctionResponse' {} Maybe FunctionSummary
a -> CreateFunctionResponse
s {$sel:functionSummary:CreateFunctionResponse' :: Maybe FunctionSummary
functionSummary = Maybe FunctionSummary
a} :: CreateFunctionResponse)
createFunctionResponse_httpStatus :: Lens.Lens' CreateFunctionResponse Prelude.Int
createFunctionResponse_httpStatus :: (Int -> f Int)
-> CreateFunctionResponse -> f CreateFunctionResponse
createFunctionResponse_httpStatus = (CreateFunctionResponse -> Int)
-> (CreateFunctionResponse -> Int -> CreateFunctionResponse)
-> Lens CreateFunctionResponse CreateFunctionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFunctionResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateFunctionResponse' :: CreateFunctionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateFunctionResponse
s@CreateFunctionResponse' {} Int
a -> CreateFunctionResponse
s {$sel:httpStatus:CreateFunctionResponse' :: Int
httpStatus = Int
a} :: CreateFunctionResponse)
instance Prelude.NFData CreateFunctionResponse