{-# 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.GlobalAccelerator.CreateListener
(
CreateListener (..),
newCreateListener,
createListener_clientAffinity,
createListener_acceleratorArn,
createListener_portRanges,
createListener_protocol,
createListener_idempotencyToken,
CreateListenerResponse (..),
newCreateListenerResponse,
createListenerResponse_listener,
createListenerResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.GlobalAccelerator.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 CreateListener = CreateListener'
{
CreateListener -> Maybe ClientAffinity
clientAffinity :: Prelude.Maybe ClientAffinity,
CreateListener -> Text
acceleratorArn :: Prelude.Text,
CreateListener -> NonEmpty PortRange
portRanges :: Prelude.NonEmpty PortRange,
CreateListener -> Protocol
protocol :: Protocol,
CreateListener -> Text
idempotencyToken :: Prelude.Text
}
deriving (CreateListener -> CreateListener -> Bool
(CreateListener -> CreateListener -> Bool)
-> (CreateListener -> CreateListener -> Bool) -> Eq CreateListener
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateListener -> CreateListener -> Bool
$c/= :: CreateListener -> CreateListener -> Bool
== :: CreateListener -> CreateListener -> Bool
$c== :: CreateListener -> CreateListener -> Bool
Prelude.Eq, ReadPrec [CreateListener]
ReadPrec CreateListener
Int -> ReadS CreateListener
ReadS [CreateListener]
(Int -> ReadS CreateListener)
-> ReadS [CreateListener]
-> ReadPrec CreateListener
-> ReadPrec [CreateListener]
-> Read CreateListener
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateListener]
$creadListPrec :: ReadPrec [CreateListener]
readPrec :: ReadPrec CreateListener
$creadPrec :: ReadPrec CreateListener
readList :: ReadS [CreateListener]
$creadList :: ReadS [CreateListener]
readsPrec :: Int -> ReadS CreateListener
$creadsPrec :: Int -> ReadS CreateListener
Prelude.Read, Int -> CreateListener -> ShowS
[CreateListener] -> ShowS
CreateListener -> String
(Int -> CreateListener -> ShowS)
-> (CreateListener -> String)
-> ([CreateListener] -> ShowS)
-> Show CreateListener
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateListener] -> ShowS
$cshowList :: [CreateListener] -> ShowS
show :: CreateListener -> String
$cshow :: CreateListener -> String
showsPrec :: Int -> CreateListener -> ShowS
$cshowsPrec :: Int -> CreateListener -> ShowS
Prelude.Show, (forall x. CreateListener -> Rep CreateListener x)
-> (forall x. Rep CreateListener x -> CreateListener)
-> Generic CreateListener
forall x. Rep CreateListener x -> CreateListener
forall x. CreateListener -> Rep CreateListener x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateListener x -> CreateListener
$cfrom :: forall x. CreateListener -> Rep CreateListener x
Prelude.Generic)
newCreateListener ::
Prelude.Text ->
Prelude.NonEmpty PortRange ->
Protocol ->
Prelude.Text ->
CreateListener
newCreateListener :: Text -> NonEmpty PortRange -> Protocol -> Text -> CreateListener
newCreateListener
Text
pAcceleratorArn_
NonEmpty PortRange
pPortRanges_
Protocol
pProtocol_
Text
pIdempotencyToken_ =
CreateListener' :: Maybe ClientAffinity
-> Text -> NonEmpty PortRange -> Protocol -> Text -> CreateListener
CreateListener'
{ $sel:clientAffinity:CreateListener' :: Maybe ClientAffinity
clientAffinity = Maybe ClientAffinity
forall a. Maybe a
Prelude.Nothing,
$sel:acceleratorArn:CreateListener' :: Text
acceleratorArn = Text
pAcceleratorArn_,
$sel:portRanges:CreateListener' :: NonEmpty PortRange
portRanges = Tagged (NonEmpty PortRange) (Identity (NonEmpty PortRange))
-> Tagged (NonEmpty PortRange) (Identity (NonEmpty PortRange))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty PortRange) (Identity (NonEmpty PortRange))
-> Tagged (NonEmpty PortRange) (Identity (NonEmpty PortRange)))
-> NonEmpty PortRange -> NonEmpty PortRange
forall t b. AReview t b -> b -> t
Lens.# NonEmpty PortRange
pPortRanges_,
$sel:protocol:CreateListener' :: Protocol
protocol = Protocol
pProtocol_,
$sel:idempotencyToken:CreateListener' :: Text
idempotencyToken = Text
pIdempotencyToken_
}
createListener_clientAffinity :: Lens.Lens' CreateListener (Prelude.Maybe ClientAffinity)
createListener_clientAffinity :: (Maybe ClientAffinity -> f (Maybe ClientAffinity))
-> CreateListener -> f CreateListener
createListener_clientAffinity = (CreateListener -> Maybe ClientAffinity)
-> (CreateListener -> Maybe ClientAffinity -> CreateListener)
-> Lens
CreateListener
CreateListener
(Maybe ClientAffinity)
(Maybe ClientAffinity)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListener' {Maybe ClientAffinity
clientAffinity :: Maybe ClientAffinity
$sel:clientAffinity:CreateListener' :: CreateListener -> Maybe ClientAffinity
clientAffinity} -> Maybe ClientAffinity
clientAffinity) (\s :: CreateListener
s@CreateListener' {} Maybe ClientAffinity
a -> CreateListener
s {$sel:clientAffinity:CreateListener' :: Maybe ClientAffinity
clientAffinity = Maybe ClientAffinity
a} :: CreateListener)
createListener_acceleratorArn :: Lens.Lens' CreateListener Prelude.Text
createListener_acceleratorArn :: (Text -> f Text) -> CreateListener -> f CreateListener
createListener_acceleratorArn = (CreateListener -> Text)
-> (CreateListener -> Text -> CreateListener)
-> Lens CreateListener CreateListener Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListener' {Text
acceleratorArn :: Text
$sel:acceleratorArn:CreateListener' :: CreateListener -> Text
acceleratorArn} -> Text
acceleratorArn) (\s :: CreateListener
s@CreateListener' {} Text
a -> CreateListener
s {$sel:acceleratorArn:CreateListener' :: Text
acceleratorArn = Text
a} :: CreateListener)
createListener_portRanges :: Lens.Lens' CreateListener (Prelude.NonEmpty PortRange)
createListener_portRanges :: (NonEmpty PortRange -> f (NonEmpty PortRange))
-> CreateListener -> f CreateListener
createListener_portRanges = (CreateListener -> NonEmpty PortRange)
-> (CreateListener -> NonEmpty PortRange -> CreateListener)
-> Lens
CreateListener
CreateListener
(NonEmpty PortRange)
(NonEmpty PortRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListener' {NonEmpty PortRange
portRanges :: NonEmpty PortRange
$sel:portRanges:CreateListener' :: CreateListener -> NonEmpty PortRange
portRanges} -> NonEmpty PortRange
portRanges) (\s :: CreateListener
s@CreateListener' {} NonEmpty PortRange
a -> CreateListener
s {$sel:portRanges:CreateListener' :: NonEmpty PortRange
portRanges = NonEmpty PortRange
a} :: CreateListener) ((NonEmpty PortRange -> f (NonEmpty PortRange))
-> CreateListener -> f CreateListener)
-> ((NonEmpty PortRange -> f (NonEmpty PortRange))
-> NonEmpty PortRange -> f (NonEmpty PortRange))
-> (NonEmpty PortRange -> f (NonEmpty PortRange))
-> CreateListener
-> f CreateListener
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty PortRange -> f (NonEmpty PortRange))
-> NonEmpty PortRange -> f (NonEmpty PortRange)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createListener_protocol :: Lens.Lens' CreateListener Protocol
createListener_protocol :: (Protocol -> f Protocol) -> CreateListener -> f CreateListener
createListener_protocol = (CreateListener -> Protocol)
-> (CreateListener -> Protocol -> CreateListener)
-> Lens CreateListener CreateListener Protocol Protocol
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListener' {Protocol
protocol :: Protocol
$sel:protocol:CreateListener' :: CreateListener -> Protocol
protocol} -> Protocol
protocol) (\s :: CreateListener
s@CreateListener' {} Protocol
a -> CreateListener
s {$sel:protocol:CreateListener' :: Protocol
protocol = Protocol
a} :: CreateListener)
createListener_idempotencyToken :: Lens.Lens' CreateListener Prelude.Text
createListener_idempotencyToken :: (Text -> f Text) -> CreateListener -> f CreateListener
createListener_idempotencyToken = (CreateListener -> Text)
-> (CreateListener -> Text -> CreateListener)
-> Lens CreateListener CreateListener Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListener' {Text
idempotencyToken :: Text
$sel:idempotencyToken:CreateListener' :: CreateListener -> Text
idempotencyToken} -> Text
idempotencyToken) (\s :: CreateListener
s@CreateListener' {} Text
a -> CreateListener
s {$sel:idempotencyToken:CreateListener' :: Text
idempotencyToken = Text
a} :: CreateListener)
instance Core.AWSRequest CreateListener where
type
AWSResponse CreateListener =
CreateListenerResponse
request :: CreateListener -> Request CreateListener
request = Service -> CreateListener -> Request CreateListener
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateListener
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateListener)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateListener))
-> Logger
-> Service
-> Proxy CreateListener
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateListener)))
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 ->
Maybe Listener -> Int -> CreateListenerResponse
CreateListenerResponse'
(Maybe Listener -> Int -> CreateListenerResponse)
-> Either String (Maybe Listener)
-> Either String (Int -> CreateListenerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Listener)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Listener")
Either String (Int -> CreateListenerResponse)
-> Either String Int -> Either String CreateListenerResponse
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 CreateListener
instance Prelude.NFData CreateListener
instance Core.ToHeaders CreateListener where
toHeaders :: CreateListener -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateListener -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"GlobalAccelerator_V20180706.CreateListener" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreateListener where
toJSON :: CreateListener -> Value
toJSON CreateListener' {Maybe ClientAffinity
NonEmpty PortRange
Text
Protocol
idempotencyToken :: Text
protocol :: Protocol
portRanges :: NonEmpty PortRange
acceleratorArn :: Text
clientAffinity :: Maybe ClientAffinity
$sel:idempotencyToken:CreateListener' :: CreateListener -> Text
$sel:protocol:CreateListener' :: CreateListener -> Protocol
$sel:portRanges:CreateListener' :: CreateListener -> NonEmpty PortRange
$sel:acceleratorArn:CreateListener' :: CreateListener -> Text
$sel:clientAffinity:CreateListener' :: CreateListener -> Maybe ClientAffinity
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ClientAffinity" Text -> ClientAffinity -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(ClientAffinity -> Pair) -> Maybe ClientAffinity -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ClientAffinity
clientAffinity,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"AcceleratorArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
acceleratorArn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PortRanges" Text -> NonEmpty PortRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty PortRange
portRanges),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Protocol" Text -> Protocol -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Protocol
protocol),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"IdempotencyToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
idempotencyToken)
]
)
instance Core.ToPath CreateListener where
toPath :: CreateListener -> ByteString
toPath = ByteString -> CreateListener -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateListener where
toQuery :: CreateListener -> QueryString
toQuery = QueryString -> CreateListener -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateListenerResponse = CreateListenerResponse'
{
CreateListenerResponse -> Maybe Listener
listener :: Prelude.Maybe Listener,
CreateListenerResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateListenerResponse -> CreateListenerResponse -> Bool
(CreateListenerResponse -> CreateListenerResponse -> Bool)
-> (CreateListenerResponse -> CreateListenerResponse -> Bool)
-> Eq CreateListenerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateListenerResponse -> CreateListenerResponse -> Bool
$c/= :: CreateListenerResponse -> CreateListenerResponse -> Bool
== :: CreateListenerResponse -> CreateListenerResponse -> Bool
$c== :: CreateListenerResponse -> CreateListenerResponse -> Bool
Prelude.Eq, ReadPrec [CreateListenerResponse]
ReadPrec CreateListenerResponse
Int -> ReadS CreateListenerResponse
ReadS [CreateListenerResponse]
(Int -> ReadS CreateListenerResponse)
-> ReadS [CreateListenerResponse]
-> ReadPrec CreateListenerResponse
-> ReadPrec [CreateListenerResponse]
-> Read CreateListenerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateListenerResponse]
$creadListPrec :: ReadPrec [CreateListenerResponse]
readPrec :: ReadPrec CreateListenerResponse
$creadPrec :: ReadPrec CreateListenerResponse
readList :: ReadS [CreateListenerResponse]
$creadList :: ReadS [CreateListenerResponse]
readsPrec :: Int -> ReadS CreateListenerResponse
$creadsPrec :: Int -> ReadS CreateListenerResponse
Prelude.Read, Int -> CreateListenerResponse -> ShowS
[CreateListenerResponse] -> ShowS
CreateListenerResponse -> String
(Int -> CreateListenerResponse -> ShowS)
-> (CreateListenerResponse -> String)
-> ([CreateListenerResponse] -> ShowS)
-> Show CreateListenerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateListenerResponse] -> ShowS
$cshowList :: [CreateListenerResponse] -> ShowS
show :: CreateListenerResponse -> String
$cshow :: CreateListenerResponse -> String
showsPrec :: Int -> CreateListenerResponse -> ShowS
$cshowsPrec :: Int -> CreateListenerResponse -> ShowS
Prelude.Show, (forall x. CreateListenerResponse -> Rep CreateListenerResponse x)
-> (forall x.
Rep CreateListenerResponse x -> CreateListenerResponse)
-> Generic CreateListenerResponse
forall x. Rep CreateListenerResponse x -> CreateListenerResponse
forall x. CreateListenerResponse -> Rep CreateListenerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateListenerResponse x -> CreateListenerResponse
$cfrom :: forall x. CreateListenerResponse -> Rep CreateListenerResponse x
Prelude.Generic)
newCreateListenerResponse ::
Prelude.Int ->
CreateListenerResponse
newCreateListenerResponse :: Int -> CreateListenerResponse
newCreateListenerResponse Int
pHttpStatus_ =
CreateListenerResponse' :: Maybe Listener -> Int -> CreateListenerResponse
CreateListenerResponse'
{ $sel:listener:CreateListenerResponse' :: Maybe Listener
listener = Maybe Listener
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateListenerResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createListenerResponse_listener :: Lens.Lens' CreateListenerResponse (Prelude.Maybe Listener)
createListenerResponse_listener :: (Maybe Listener -> f (Maybe Listener))
-> CreateListenerResponse -> f CreateListenerResponse
createListenerResponse_listener = (CreateListenerResponse -> Maybe Listener)
-> (CreateListenerResponse
-> Maybe Listener -> CreateListenerResponse)
-> Lens
CreateListenerResponse
CreateListenerResponse
(Maybe Listener)
(Maybe Listener)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListenerResponse' {Maybe Listener
listener :: Maybe Listener
$sel:listener:CreateListenerResponse' :: CreateListenerResponse -> Maybe Listener
listener} -> Maybe Listener
listener) (\s :: CreateListenerResponse
s@CreateListenerResponse' {} Maybe Listener
a -> CreateListenerResponse
s {$sel:listener:CreateListenerResponse' :: Maybe Listener
listener = Maybe Listener
a} :: CreateListenerResponse)
createListenerResponse_httpStatus :: Lens.Lens' CreateListenerResponse Prelude.Int
createListenerResponse_httpStatus :: (Int -> f Int)
-> CreateListenerResponse -> f CreateListenerResponse
createListenerResponse_httpStatus = (CreateListenerResponse -> Int)
-> (CreateListenerResponse -> Int -> CreateListenerResponse)
-> Lens CreateListenerResponse CreateListenerResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListenerResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateListenerResponse' :: CreateListenerResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateListenerResponse
s@CreateListenerResponse' {} Int
a -> CreateListenerResponse
s {$sel:httpStatus:CreateListenerResponse' :: Int
httpStatus = Int
a} :: CreateListenerResponse)
instance Prelude.NFData CreateListenerResponse