{-# 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.TestFunction
(
TestFunction (..),
newTestFunction,
testFunction_stage,
testFunction_name,
testFunction_ifMatch,
testFunction_eventObject,
TestFunctionResponse (..),
newTestFunctionResponse,
testFunctionResponse_testResult,
testFunctionResponse_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 TestFunction = TestFunction'
{
TestFunction -> Maybe FunctionStage
stage :: Prelude.Maybe FunctionStage,
TestFunction -> Text
name :: Prelude.Text,
TestFunction -> Text
ifMatch :: Prelude.Text,
TestFunction -> Sensitive Base64
eventObject :: Core.Sensitive Core.Base64
}
deriving (TestFunction -> TestFunction -> Bool
(TestFunction -> TestFunction -> Bool)
-> (TestFunction -> TestFunction -> Bool) -> Eq TestFunction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestFunction -> TestFunction -> Bool
$c/= :: TestFunction -> TestFunction -> Bool
== :: TestFunction -> TestFunction -> Bool
$c== :: TestFunction -> TestFunction -> Bool
Prelude.Eq, Int -> TestFunction -> ShowS
[TestFunction] -> ShowS
TestFunction -> String
(Int -> TestFunction -> ShowS)
-> (TestFunction -> String)
-> ([TestFunction] -> ShowS)
-> Show TestFunction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestFunction] -> ShowS
$cshowList :: [TestFunction] -> ShowS
show :: TestFunction -> String
$cshow :: TestFunction -> String
showsPrec :: Int -> TestFunction -> ShowS
$cshowsPrec :: Int -> TestFunction -> ShowS
Prelude.Show, (forall x. TestFunction -> Rep TestFunction x)
-> (forall x. Rep TestFunction x -> TestFunction)
-> Generic TestFunction
forall x. Rep TestFunction x -> TestFunction
forall x. TestFunction -> Rep TestFunction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestFunction x -> TestFunction
$cfrom :: forall x. TestFunction -> Rep TestFunction x
Prelude.Generic)
newTestFunction ::
Prelude.Text ->
Prelude.Text ->
Prelude.ByteString ->
TestFunction
newTestFunction :: Text -> Text -> ByteString -> TestFunction
newTestFunction Text
pName_ Text
pIfMatch_ ByteString
pEventObject_ =
TestFunction' :: Maybe FunctionStage
-> Text -> Text -> Sensitive Base64 -> TestFunction
TestFunction'
{ $sel:stage:TestFunction' :: Maybe FunctionStage
stage = Maybe FunctionStage
forall a. Maybe a
Prelude.Nothing,
$sel:name:TestFunction' :: Text
name = Text
pName_,
$sel:ifMatch:TestFunction' :: Text
ifMatch = Text
pIfMatch_,
$sel:eventObject:TestFunction' :: Sensitive Base64
eventObject =
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
pEventObject_
}
testFunction_stage :: Lens.Lens' TestFunction (Prelude.Maybe FunctionStage)
testFunction_stage :: (Maybe FunctionStage -> f (Maybe FunctionStage))
-> TestFunction -> f TestFunction
testFunction_stage = (TestFunction -> Maybe FunctionStage)
-> (TestFunction -> Maybe FunctionStage -> TestFunction)
-> Lens
TestFunction
TestFunction
(Maybe FunctionStage)
(Maybe FunctionStage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestFunction' {Maybe FunctionStage
stage :: Maybe FunctionStage
$sel:stage:TestFunction' :: TestFunction -> Maybe FunctionStage
stage} -> Maybe FunctionStage
stage) (\s :: TestFunction
s@TestFunction' {} Maybe FunctionStage
a -> TestFunction
s {$sel:stage:TestFunction' :: Maybe FunctionStage
stage = Maybe FunctionStage
a} :: TestFunction)
testFunction_name :: Lens.Lens' TestFunction Prelude.Text
testFunction_name :: (Text -> f Text) -> TestFunction -> f TestFunction
testFunction_name = (TestFunction -> Text)
-> (TestFunction -> Text -> TestFunction)
-> Lens TestFunction TestFunction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestFunction' {Text
name :: Text
$sel:name:TestFunction' :: TestFunction -> Text
name} -> Text
name) (\s :: TestFunction
s@TestFunction' {} Text
a -> TestFunction
s {$sel:name:TestFunction' :: Text
name = Text
a} :: TestFunction)
testFunction_ifMatch :: Lens.Lens' TestFunction Prelude.Text
testFunction_ifMatch :: (Text -> f Text) -> TestFunction -> f TestFunction
testFunction_ifMatch = (TestFunction -> Text)
-> (TestFunction -> Text -> TestFunction)
-> Lens TestFunction TestFunction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestFunction' {Text
ifMatch :: Text
$sel:ifMatch:TestFunction' :: TestFunction -> Text
ifMatch} -> Text
ifMatch) (\s :: TestFunction
s@TestFunction' {} Text
a -> TestFunction
s {$sel:ifMatch:TestFunction' :: Text
ifMatch = Text
a} :: TestFunction)
testFunction_eventObject :: Lens.Lens' TestFunction Prelude.ByteString
testFunction_eventObject :: (ByteString -> f ByteString) -> TestFunction -> f TestFunction
testFunction_eventObject = (TestFunction -> Sensitive Base64)
-> (TestFunction -> Sensitive Base64 -> TestFunction)
-> Lens
TestFunction TestFunction (Sensitive Base64) (Sensitive Base64)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestFunction' {Sensitive Base64
eventObject :: Sensitive Base64
$sel:eventObject:TestFunction' :: TestFunction -> Sensitive Base64
eventObject} -> Sensitive Base64
eventObject) (\s :: TestFunction
s@TestFunction' {} Sensitive Base64
a -> TestFunction
s {$sel:eventObject:TestFunction' :: Sensitive Base64
eventObject = Sensitive Base64
a} :: TestFunction) ((Sensitive Base64 -> f (Sensitive Base64))
-> TestFunction -> f TestFunction)
-> ((ByteString -> f ByteString)
-> Sensitive Base64 -> f (Sensitive Base64))
-> (ByteString -> f ByteString)
-> TestFunction
-> f TestFunction
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 TestFunction where
type AWSResponse TestFunction = TestFunctionResponse
request :: TestFunction -> Request TestFunction
request = Service -> TestFunction -> Request TestFunction
forall a. (ToRequest a, ToElement a) => Service -> a -> Request a
Request.postXML Service
defaultService
response :: Logger
-> Service
-> Proxy TestFunction
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TestFunction)))
response =
(Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse TestFunction))
-> Logger
-> Service
-> Proxy TestFunction
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TestFunction)))
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 TestResult -> Int -> TestFunctionResponse
TestFunctionResponse'
(Maybe TestResult -> Int -> TestFunctionResponse)
-> Either String (Maybe TestResult)
-> Either String (Int -> TestFunctionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node] -> Either String (Maybe TestResult)
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
Either String (Int -> TestFunctionResponse)
-> Either String Int -> Either String TestFunctionResponse
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 TestFunction
instance Prelude.NFData TestFunction
instance Core.ToElement TestFunction where
toElement :: TestFunction -> Element
toElement =
Name -> TestFunction -> Element
forall a. ToXML a => Name -> a -> Element
Core.mkElement
Name
"{http://cloudfront.amazonaws.com/doc/2020-05-31/}TestFunctionRequest"
instance Core.ToHeaders TestFunction where
toHeaders :: TestFunction -> ResponseHeaders
toHeaders TestFunction' {Maybe FunctionStage
Text
Sensitive Base64
eventObject :: Sensitive Base64
ifMatch :: Text
name :: Text
stage :: Maybe FunctionStage
$sel:eventObject:TestFunction' :: TestFunction -> Sensitive Base64
$sel:ifMatch:TestFunction' :: TestFunction -> Text
$sel:name:TestFunction' :: TestFunction -> Text
$sel:stage:TestFunction' :: TestFunction -> Maybe FunctionStage
..} =
[ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat [HeaderName
"If-Match" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
ifMatch]
instance Core.ToPath TestFunction where
toPath :: TestFunction -> ByteString
toPath TestFunction' {Maybe FunctionStage
Text
Sensitive Base64
eventObject :: Sensitive Base64
ifMatch :: Text
name :: Text
stage :: Maybe FunctionStage
$sel:eventObject:TestFunction' :: TestFunction -> Sensitive Base64
$sel:ifMatch:TestFunction' :: TestFunction -> Text
$sel:name:TestFunction' :: TestFunction -> Text
$sel:stage:TestFunction' :: TestFunction -> Maybe FunctionStage
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/2020-05-31/function/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name, ByteString
"/test"]
instance Core.ToQuery TestFunction where
toQuery :: TestFunction -> QueryString
toQuery = QueryString -> TestFunction -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
instance Core.ToXML TestFunction where
toXML :: TestFunction -> XML
toXML TestFunction' {Maybe FunctionStage
Text
Sensitive Base64
eventObject :: Sensitive Base64
ifMatch :: Text
name :: Text
stage :: Maybe FunctionStage
$sel:eventObject:TestFunction' :: TestFunction -> Sensitive Base64
$sel:ifMatch:TestFunction' :: TestFunction -> Text
$sel:name:TestFunction' :: TestFunction -> Text
$sel:stage:TestFunction' :: TestFunction -> Maybe FunctionStage
..} =
[XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ Name
"Stage" Name -> Maybe FunctionStage -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe FunctionStage
stage,
Name
"EventObject" Name -> Sensitive Base64 -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Sensitive Base64
eventObject
]
data TestFunctionResponse = TestFunctionResponse'
{
TestFunctionResponse -> Maybe TestResult
testResult :: Prelude.Maybe TestResult,
TestFunctionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (TestFunctionResponse -> TestFunctionResponse -> Bool
(TestFunctionResponse -> TestFunctionResponse -> Bool)
-> (TestFunctionResponse -> TestFunctionResponse -> Bool)
-> Eq TestFunctionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestFunctionResponse -> TestFunctionResponse -> Bool
$c/= :: TestFunctionResponse -> TestFunctionResponse -> Bool
== :: TestFunctionResponse -> TestFunctionResponse -> Bool
$c== :: TestFunctionResponse -> TestFunctionResponse -> Bool
Prelude.Eq, ReadPrec [TestFunctionResponse]
ReadPrec TestFunctionResponse
Int -> ReadS TestFunctionResponse
ReadS [TestFunctionResponse]
(Int -> ReadS TestFunctionResponse)
-> ReadS [TestFunctionResponse]
-> ReadPrec TestFunctionResponse
-> ReadPrec [TestFunctionResponse]
-> Read TestFunctionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestFunctionResponse]
$creadListPrec :: ReadPrec [TestFunctionResponse]
readPrec :: ReadPrec TestFunctionResponse
$creadPrec :: ReadPrec TestFunctionResponse
readList :: ReadS [TestFunctionResponse]
$creadList :: ReadS [TestFunctionResponse]
readsPrec :: Int -> ReadS TestFunctionResponse
$creadsPrec :: Int -> ReadS TestFunctionResponse
Prelude.Read, Int -> TestFunctionResponse -> ShowS
[TestFunctionResponse] -> ShowS
TestFunctionResponse -> String
(Int -> TestFunctionResponse -> ShowS)
-> (TestFunctionResponse -> String)
-> ([TestFunctionResponse] -> ShowS)
-> Show TestFunctionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestFunctionResponse] -> ShowS
$cshowList :: [TestFunctionResponse] -> ShowS
show :: TestFunctionResponse -> String
$cshow :: TestFunctionResponse -> String
showsPrec :: Int -> TestFunctionResponse -> ShowS
$cshowsPrec :: Int -> TestFunctionResponse -> ShowS
Prelude.Show, (forall x. TestFunctionResponse -> Rep TestFunctionResponse x)
-> (forall x. Rep TestFunctionResponse x -> TestFunctionResponse)
-> Generic TestFunctionResponse
forall x. Rep TestFunctionResponse x -> TestFunctionResponse
forall x. TestFunctionResponse -> Rep TestFunctionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestFunctionResponse x -> TestFunctionResponse
$cfrom :: forall x. TestFunctionResponse -> Rep TestFunctionResponse x
Prelude.Generic)
newTestFunctionResponse ::
Prelude.Int ->
TestFunctionResponse
newTestFunctionResponse :: Int -> TestFunctionResponse
newTestFunctionResponse Int
pHttpStatus_ =
TestFunctionResponse' :: Maybe TestResult -> Int -> TestFunctionResponse
TestFunctionResponse'
{ $sel:testResult:TestFunctionResponse' :: Maybe TestResult
testResult = Maybe TestResult
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:TestFunctionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
testFunctionResponse_testResult :: Lens.Lens' TestFunctionResponse (Prelude.Maybe TestResult)
testFunctionResponse_testResult :: (Maybe TestResult -> f (Maybe TestResult))
-> TestFunctionResponse -> f TestFunctionResponse
testFunctionResponse_testResult = (TestFunctionResponse -> Maybe TestResult)
-> (TestFunctionResponse
-> Maybe TestResult -> TestFunctionResponse)
-> Lens
TestFunctionResponse
TestFunctionResponse
(Maybe TestResult)
(Maybe TestResult)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestFunctionResponse' {Maybe TestResult
testResult :: Maybe TestResult
$sel:testResult:TestFunctionResponse' :: TestFunctionResponse -> Maybe TestResult
testResult} -> Maybe TestResult
testResult) (\s :: TestFunctionResponse
s@TestFunctionResponse' {} Maybe TestResult
a -> TestFunctionResponse
s {$sel:testResult:TestFunctionResponse' :: Maybe TestResult
testResult = Maybe TestResult
a} :: TestFunctionResponse)
testFunctionResponse_httpStatus :: Lens.Lens' TestFunctionResponse Prelude.Int
testFunctionResponse_httpStatus :: (Int -> f Int) -> TestFunctionResponse -> f TestFunctionResponse
testFunctionResponse_httpStatus = (TestFunctionResponse -> Int)
-> (TestFunctionResponse -> Int -> TestFunctionResponse)
-> Lens TestFunctionResponse TestFunctionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestFunctionResponse' {Int
httpStatus :: Int
$sel:httpStatus:TestFunctionResponse' :: TestFunctionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: TestFunctionResponse
s@TestFunctionResponse' {} Int
a -> TestFunctionResponse
s {$sel:httpStatus:TestFunctionResponse' :: Int
httpStatus = Int
a} :: TestFunctionResponse)
instance Prelude.NFData TestFunctionResponse