{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.ELBV2.CreateListener
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a listener for the specified Application Load Balancer, Network
-- Load Balancer, or Gateway Load Balancer.
--
-- For more information, see the following:
--
-- -   <https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html Listeners for your Application Load Balancers>
--
-- -   <https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-listeners.html Listeners for your Network Load Balancers>
--
-- -   <https://docs.aws.amazon.com/elasticloadbalancing/latest/gateway/gateway-listeners.html Listeners for your Gateway Load Balancers>
--
-- This operation is idempotent, which means that it completes at most one
-- time. If you attempt to create multiple listeners with the same
-- settings, each call succeeds.
module Amazonka.ELBV2.CreateListener
  ( -- * Creating a Request
    CreateListener (..),
    newCreateListener,

    -- * Request Lenses
    createListener_sslPolicy,
    createListener_protocol,
    createListener_certificates,
    createListener_alpnPolicy,
    createListener_tags,
    createListener_port,
    createListener_loadBalancerArn,
    createListener_defaultActions,

    -- * Destructuring the Response
    CreateListenerResponse (..),
    newCreateListenerResponse,

    -- * Response Lenses
    createListenerResponse_listeners,
    createListenerResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ELBV2.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

-- | /See:/ 'newCreateListener' smart constructor.
data CreateListener = CreateListener'
  { -- | [HTTPS and TLS listeners] The security policy that defines which
    -- protocols and ciphers are supported.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-https-listener.html#describe-ssl-policies Security policies>
    -- in the /Application Load Balancers Guide/ and
    -- <https://docs.aws.amazon.com/elasticloadbalancing/latest/network/create-tls-listener.html#describe-ssl-policies Security policies>
    -- in the /Network Load Balancers Guide/.
    CreateListener -> Maybe Text
sslPolicy :: Prelude.Maybe Prelude.Text,
    -- | The protocol for connections from clients to the load balancer. For
    -- Application Load Balancers, the supported protocols are HTTP and HTTPS.
    -- For Network Load Balancers, the supported protocols are TCP, TLS, UDP,
    -- and TCP_UDP. You can’t specify the UDP or TCP_UDP protocol if dual-stack
    -- mode is enabled. You cannot specify a protocol for a Gateway Load
    -- Balancer.
    CreateListener -> Maybe ProtocolEnum
protocol :: Prelude.Maybe ProtocolEnum,
    -- | [HTTPS and TLS listeners] The default certificate for the listener. You
    -- must provide exactly one certificate. Set @CertificateArn@ to the
    -- certificate ARN but do not set @IsDefault@.
    CreateListener -> Maybe [Certificate]
certificates :: Prelude.Maybe [Certificate],
    -- | [TLS listeners] The name of the Application-Layer Protocol Negotiation
    -- (ALPN) policy. You can specify one policy name. The following are the
    -- possible values:
    --
    -- -   @HTTP1Only@
    --
    -- -   @HTTP2Only@
    --
    -- -   @HTTP2Optional@
    --
    -- -   @HTTP2Preferred@
    --
    -- -   @None@
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/elasticloadbalancing/latest/network/create-tls-listener.html#alpn-policies ALPN policies>
    -- in the /Network Load Balancers Guide/.
    CreateListener -> Maybe [Text]
alpnPolicy :: Prelude.Maybe [Prelude.Text],
    -- | The tags to assign to the listener.
    CreateListener -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The port on which the load balancer is listening. You cannot specify a
    -- port for a Gateway Load Balancer.
    CreateListener -> Maybe Natural
port :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Name (ARN) of the load balancer.
    CreateListener -> Text
loadBalancerArn :: Prelude.Text,
    -- | The actions for the default rule.
    CreateListener -> [Action]
defaultActions :: [Action]
  }
  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)

-- |
-- Create a value of 'CreateListener' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'sslPolicy', 'createListener_sslPolicy' - [HTTPS and TLS listeners] The security policy that defines which
-- protocols and ciphers are supported.
--
-- For more information, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-https-listener.html#describe-ssl-policies Security policies>
-- in the /Application Load Balancers Guide/ and
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/network/create-tls-listener.html#describe-ssl-policies Security policies>
-- in the /Network Load Balancers Guide/.
--
-- 'protocol', 'createListener_protocol' - The protocol for connections from clients to the load balancer. For
-- Application Load Balancers, the supported protocols are HTTP and HTTPS.
-- For Network Load Balancers, the supported protocols are TCP, TLS, UDP,
-- and TCP_UDP. You can’t specify the UDP or TCP_UDP protocol if dual-stack
-- mode is enabled. You cannot specify a protocol for a Gateway Load
-- Balancer.
--
-- 'certificates', 'createListener_certificates' - [HTTPS and TLS listeners] The default certificate for the listener. You
-- must provide exactly one certificate. Set @CertificateArn@ to the
-- certificate ARN but do not set @IsDefault@.
--
-- 'alpnPolicy', 'createListener_alpnPolicy' - [TLS listeners] The name of the Application-Layer Protocol Negotiation
-- (ALPN) policy. You can specify one policy name. The following are the
-- possible values:
--
-- -   @HTTP1Only@
--
-- -   @HTTP2Only@
--
-- -   @HTTP2Optional@
--
-- -   @HTTP2Preferred@
--
-- -   @None@
--
-- For more information, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/network/create-tls-listener.html#alpn-policies ALPN policies>
-- in the /Network Load Balancers Guide/.
--
-- 'tags', 'createListener_tags' - The tags to assign to the listener.
--
-- 'port', 'createListener_port' - The port on which the load balancer is listening. You cannot specify a
-- port for a Gateway Load Balancer.
--
-- 'loadBalancerArn', 'createListener_loadBalancerArn' - The Amazon Resource Name (ARN) of the load balancer.
--
-- 'defaultActions', 'createListener_defaultActions' - The actions for the default rule.
newCreateListener ::
  -- | 'loadBalancerArn'
  Prelude.Text ->
  CreateListener
newCreateListener :: Text -> CreateListener
newCreateListener Text
pLoadBalancerArn_ =
  CreateListener' :: Maybe Text
-> Maybe ProtocolEnum
-> Maybe [Certificate]
-> Maybe [Text]
-> Maybe (NonEmpty Tag)
-> Maybe Natural
-> Text
-> [Action]
-> CreateListener
CreateListener'
    { $sel:sslPolicy:CreateListener' :: Maybe Text
sslPolicy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:CreateListener' :: Maybe ProtocolEnum
protocol = Maybe ProtocolEnum
forall a. Maybe a
Prelude.Nothing,
      $sel:certificates:CreateListener' :: Maybe [Certificate]
certificates = Maybe [Certificate]
forall a. Maybe a
Prelude.Nothing,
      $sel:alpnPolicy:CreateListener' :: Maybe [Text]
alpnPolicy = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateListener' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
      $sel:port:CreateListener' :: Maybe Natural
port = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:loadBalancerArn:CreateListener' :: Text
loadBalancerArn = Text
pLoadBalancerArn_,
      $sel:defaultActions:CreateListener' :: [Action]
defaultActions = [Action]
forall a. Monoid a => a
Prelude.mempty
    }

-- | [HTTPS and TLS listeners] The security policy that defines which
-- protocols and ciphers are supported.
--
-- For more information, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-https-listener.html#describe-ssl-policies Security policies>
-- in the /Application Load Balancers Guide/ and
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/network/create-tls-listener.html#describe-ssl-policies Security policies>
-- in the /Network Load Balancers Guide/.
createListener_sslPolicy :: Lens.Lens' CreateListener (Prelude.Maybe Prelude.Text)
createListener_sslPolicy :: (Maybe Text -> f (Maybe Text))
-> CreateListener -> f CreateListener
createListener_sslPolicy = (CreateListener -> Maybe Text)
-> (CreateListener -> Maybe Text -> CreateListener)
-> Lens CreateListener CreateListener (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListener' {Maybe Text
sslPolicy :: Maybe Text
$sel:sslPolicy:CreateListener' :: CreateListener -> Maybe Text
sslPolicy} -> Maybe Text
sslPolicy) (\s :: CreateListener
s@CreateListener' {} Maybe Text
a -> CreateListener
s {$sel:sslPolicy:CreateListener' :: Maybe Text
sslPolicy = Maybe Text
a} :: CreateListener)

-- | The protocol for connections from clients to the load balancer. For
-- Application Load Balancers, the supported protocols are HTTP and HTTPS.
-- For Network Load Balancers, the supported protocols are TCP, TLS, UDP,
-- and TCP_UDP. You can’t specify the UDP or TCP_UDP protocol if dual-stack
-- mode is enabled. You cannot specify a protocol for a Gateway Load
-- Balancer.
createListener_protocol :: Lens.Lens' CreateListener (Prelude.Maybe ProtocolEnum)
createListener_protocol :: (Maybe ProtocolEnum -> f (Maybe ProtocolEnum))
-> CreateListener -> f CreateListener
createListener_protocol = (CreateListener -> Maybe ProtocolEnum)
-> (CreateListener -> Maybe ProtocolEnum -> CreateListener)
-> Lens
     CreateListener
     CreateListener
     (Maybe ProtocolEnum)
     (Maybe ProtocolEnum)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListener' {Maybe ProtocolEnum
protocol :: Maybe ProtocolEnum
$sel:protocol:CreateListener' :: CreateListener -> Maybe ProtocolEnum
protocol} -> Maybe ProtocolEnum
protocol) (\s :: CreateListener
s@CreateListener' {} Maybe ProtocolEnum
a -> CreateListener
s {$sel:protocol:CreateListener' :: Maybe ProtocolEnum
protocol = Maybe ProtocolEnum
a} :: CreateListener)

-- | [HTTPS and TLS listeners] The default certificate for the listener. You
-- must provide exactly one certificate. Set @CertificateArn@ to the
-- certificate ARN but do not set @IsDefault@.
createListener_certificates :: Lens.Lens' CreateListener (Prelude.Maybe [Certificate])
createListener_certificates :: (Maybe [Certificate] -> f (Maybe [Certificate]))
-> CreateListener -> f CreateListener
createListener_certificates = (CreateListener -> Maybe [Certificate])
-> (CreateListener -> Maybe [Certificate] -> CreateListener)
-> Lens
     CreateListener
     CreateListener
     (Maybe [Certificate])
     (Maybe [Certificate])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListener' {Maybe [Certificate]
certificates :: Maybe [Certificate]
$sel:certificates:CreateListener' :: CreateListener -> Maybe [Certificate]
certificates} -> Maybe [Certificate]
certificates) (\s :: CreateListener
s@CreateListener' {} Maybe [Certificate]
a -> CreateListener
s {$sel:certificates:CreateListener' :: Maybe [Certificate]
certificates = Maybe [Certificate]
a} :: CreateListener) ((Maybe [Certificate] -> f (Maybe [Certificate]))
 -> CreateListener -> f CreateListener)
-> ((Maybe [Certificate] -> f (Maybe [Certificate]))
    -> Maybe [Certificate] -> f (Maybe [Certificate]))
-> (Maybe [Certificate] -> f (Maybe [Certificate]))
-> CreateListener
-> f CreateListener
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Certificate] [Certificate] [Certificate] [Certificate]
-> Iso
     (Maybe [Certificate])
     (Maybe [Certificate])
     (Maybe [Certificate])
     (Maybe [Certificate])
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 [Certificate] [Certificate] [Certificate] [Certificate]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | [TLS listeners] The name of the Application-Layer Protocol Negotiation
-- (ALPN) policy. You can specify one policy name. The following are the
-- possible values:
--
-- -   @HTTP1Only@
--
-- -   @HTTP2Only@
--
-- -   @HTTP2Optional@
--
-- -   @HTTP2Preferred@
--
-- -   @None@
--
-- For more information, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/network/create-tls-listener.html#alpn-policies ALPN policies>
-- in the /Network Load Balancers Guide/.
createListener_alpnPolicy :: Lens.Lens' CreateListener (Prelude.Maybe [Prelude.Text])
createListener_alpnPolicy :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateListener -> f CreateListener
createListener_alpnPolicy = (CreateListener -> Maybe [Text])
-> (CreateListener -> Maybe [Text] -> CreateListener)
-> Lens CreateListener CreateListener (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListener' {Maybe [Text]
alpnPolicy :: Maybe [Text]
$sel:alpnPolicy:CreateListener' :: CreateListener -> Maybe [Text]
alpnPolicy} -> Maybe [Text]
alpnPolicy) (\s :: CreateListener
s@CreateListener' {} Maybe [Text]
a -> CreateListener
s {$sel:alpnPolicy:CreateListener' :: Maybe [Text]
alpnPolicy = Maybe [Text]
a} :: CreateListener) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateListener -> f CreateListener)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateListener
-> f CreateListener
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The tags to assign to the listener.
createListener_tags :: Lens.Lens' CreateListener (Prelude.Maybe (Prelude.NonEmpty Tag))
createListener_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateListener -> f CreateListener
createListener_tags = (CreateListener -> Maybe (NonEmpty Tag))
-> (CreateListener -> Maybe (NonEmpty Tag) -> CreateListener)
-> Lens
     CreateListener
     CreateListener
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListener' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateListener' :: CreateListener -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateListener
s@CreateListener' {} Maybe (NonEmpty Tag)
a -> CreateListener
s {$sel:tags:CreateListener' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateListener) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> CreateListener -> f CreateListener)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateListener
-> f CreateListener
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
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 (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The port on which the load balancer is listening. You cannot specify a
-- port for a Gateway Load Balancer.
createListener_port :: Lens.Lens' CreateListener (Prelude.Maybe Prelude.Natural)
createListener_port :: (Maybe Natural -> f (Maybe Natural))
-> CreateListener -> f CreateListener
createListener_port = (CreateListener -> Maybe Natural)
-> (CreateListener -> Maybe Natural -> CreateListener)
-> Lens
     CreateListener CreateListener (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListener' {Maybe Natural
port :: Maybe Natural
$sel:port:CreateListener' :: CreateListener -> Maybe Natural
port} -> Maybe Natural
port) (\s :: CreateListener
s@CreateListener' {} Maybe Natural
a -> CreateListener
s {$sel:port:CreateListener' :: Maybe Natural
port = Maybe Natural
a} :: CreateListener)

-- | The Amazon Resource Name (ARN) of the load balancer.
createListener_loadBalancerArn :: Lens.Lens' CreateListener Prelude.Text
createListener_loadBalancerArn :: (Text -> f Text) -> CreateListener -> f CreateListener
createListener_loadBalancerArn = (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
loadBalancerArn :: Text
$sel:loadBalancerArn:CreateListener' :: CreateListener -> Text
loadBalancerArn} -> Text
loadBalancerArn) (\s :: CreateListener
s@CreateListener' {} Text
a -> CreateListener
s {$sel:loadBalancerArn:CreateListener' :: Text
loadBalancerArn = Text
a} :: CreateListener)

-- | The actions for the default rule.
createListener_defaultActions :: Lens.Lens' CreateListener [Action]
createListener_defaultActions :: ([Action] -> f [Action]) -> CreateListener -> f CreateListener
createListener_defaultActions = (CreateListener -> [Action])
-> (CreateListener -> [Action] -> CreateListener)
-> Lens CreateListener CreateListener [Action] [Action]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateListener' {[Action]
defaultActions :: [Action]
$sel:defaultActions:CreateListener' :: CreateListener -> [Action]
defaultActions} -> [Action]
defaultActions) (\s :: CreateListener
s@CreateListener' {} [Action]
a -> CreateListener
s {$sel:defaultActions:CreateListener' :: [Action]
defaultActions = [Action]
a} :: CreateListener) (([Action] -> f [Action]) -> CreateListener -> f CreateListener)
-> (([Action] -> f [Action]) -> [Action] -> f [Action])
-> ([Action] -> f [Action])
-> CreateListener
-> f CreateListener
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Action] -> f [Action]) -> [Action] -> f [Action]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateListener where
  type
    AWSResponse CreateListener =
      CreateListenerResponse
  request :: CreateListener -> Request CreateListener
request = Service -> CreateListener -> Request CreateListener
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateListener
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateListener)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse CreateListener))
-> Logger
-> Service
-> Proxy CreateListener
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateListener)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"CreateListenerResult"
      ( \Int
s ResponseHeaders
h [Node]
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.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Listeners" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [Listener]))
-> Either String (Maybe [Listener])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Listener])
-> [Node] -> Either String (Maybe [Listener])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Listener]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            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
forall a. Monoid a => a
Prelude.mempty

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 CreateListener' {[Action]
Maybe Natural
Maybe [Text]
Maybe [Certificate]
Maybe (NonEmpty Tag)
Maybe Text
Maybe ProtocolEnum
Text
defaultActions :: [Action]
loadBalancerArn :: Text
port :: Maybe Natural
tags :: Maybe (NonEmpty Tag)
alpnPolicy :: Maybe [Text]
certificates :: Maybe [Certificate]
protocol :: Maybe ProtocolEnum
sslPolicy :: Maybe Text
$sel:defaultActions:CreateListener' :: CreateListener -> [Action]
$sel:loadBalancerArn:CreateListener' :: CreateListener -> Text
$sel:port:CreateListener' :: CreateListener -> Maybe Natural
$sel:tags:CreateListener' :: CreateListener -> Maybe (NonEmpty Tag)
$sel:alpnPolicy:CreateListener' :: CreateListener -> Maybe [Text]
$sel:certificates:CreateListener' :: CreateListener -> Maybe [Certificate]
$sel:protocol:CreateListener' :: CreateListener -> Maybe ProtocolEnum
$sel:sslPolicy:CreateListener' :: CreateListener -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"CreateListener" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-12-01" :: Prelude.ByteString),
        ByteString
"SslPolicy" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
sslPolicy,
        ByteString
"Protocol" ByteString -> Maybe ProtocolEnum -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe ProtocolEnum
protocol,
        ByteString
"Certificates"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Certificate] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Certificate] -> QueryString)
-> Maybe [Certificate] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Certificate]
certificates),
        ByteString
"AlpnPolicy"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
alpnPolicy),
        ByteString
"Tags"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> NonEmpty Tag -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" (NonEmpty Tag -> QueryString)
-> Maybe (NonEmpty Tag) -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags),
        ByteString
"Port" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
port,
        ByteString
"LoadBalancerArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
loadBalancerArn,
        ByteString
"DefaultActions"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [Action] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [Action]
defaultActions
      ]

-- | /See:/ 'newCreateListenerResponse' smart constructor.
data CreateListenerResponse = CreateListenerResponse'
  { -- | Information about the listener.
    CreateListenerResponse -> Maybe [Listener]
listeners :: Prelude.Maybe [Listener],
    -- | The response's http status code.
    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)

-- |
-- Create a value of 'CreateListenerResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'listeners', 'createListenerResponse_listeners' - Information about the listener.
--
-- 'httpStatus', 'createListenerResponse_httpStatus' - The response's http status code.
newCreateListenerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateListenerResponse
newCreateListenerResponse :: Int -> CreateListenerResponse
newCreateListenerResponse Int
pHttpStatus_ =
  CreateListenerResponse' :: Maybe [Listener] -> Int -> CreateListenerResponse
CreateListenerResponse'
    { $sel:listeners:CreateListenerResponse' :: Maybe [Listener]
listeners =
        Maybe [Listener]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateListenerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the listener.
createListenerResponse_listeners :: Lens.Lens' CreateListenerResponse (Prelude.Maybe [Listener])
createListenerResponse_listeners :: (Maybe [Listener] -> f (Maybe [Listener]))
-> CreateListenerResponse -> f CreateListenerResponse
createListenerResponse_listeners = (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]
listeners :: Maybe [Listener]
$sel:listeners:CreateListenerResponse' :: CreateListenerResponse -> Maybe [Listener]
listeners} -> Maybe [Listener]
listeners) (\s :: CreateListenerResponse
s@CreateListenerResponse' {} Maybe [Listener]
a -> CreateListenerResponse
s {$sel:listeners:CreateListenerResponse' :: Maybe [Listener]
listeners = Maybe [Listener]
a} :: CreateListenerResponse) ((Maybe [Listener] -> f (Maybe [Listener]))
 -> CreateListenerResponse -> f CreateListenerResponse)
-> ((Maybe [Listener] -> f (Maybe [Listener]))
    -> Maybe [Listener] -> f (Maybe [Listener]))
-> (Maybe [Listener] -> f (Maybe [Listener]))
-> CreateListenerResponse
-> f CreateListenerResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Listener] [Listener] [Listener] [Listener]
-> Iso
     (Maybe [Listener])
     (Maybe [Listener])
     (Maybe [Listener])
     (Maybe [Listener])
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 [Listener] [Listener] [Listener] [Listener]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
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