{-# 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-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- 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: -- -- - -- -- - -- -- - -- -- 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_alpnPolicy, createListener_certificates, createListener_port, createListener_protocol, createListener_sslPolicy, createListener_tags, createListener_loadBalancerArn, createListener_defaultActions, -- * Destructuring the Response CreateListenerResponse (..), newCreateListenerResponse, -- * Response Lenses createListenerResponse_listeners, createListenerResponse_httpStatus, ) where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import Amazonka.ELBV2.Types 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' { -- | [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 -- -- in the /Network Load Balancers Guide/. alpnPolicy :: Prelude.Maybe [Prelude.Text], -- | [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@. certificates :: Prelude.Maybe [Certificate], -- | The port on which the load balancer is listening. You cannot specify a -- port for a Gateway Load Balancer. port :: Prelude.Maybe Prelude.Natural, -- | 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. protocol :: Prelude.Maybe ProtocolEnum, -- | [HTTPS and TLS listeners] The security policy that defines which -- protocols and ciphers are supported. -- -- For more information, see -- -- in the /Application Load Balancers Guide/ and -- -- in the /Network Load Balancers Guide/. sslPolicy :: Prelude.Maybe Prelude.Text, -- | The tags to assign to the listener. tags :: Prelude.Maybe (Prelude.NonEmpty Tag), -- | The Amazon Resource Name (ARN) of the load balancer. loadBalancerArn :: Prelude.Text, -- | The actions for the default rule. defaultActions :: [Action] } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'CreateListener' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- '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 -- -- in the /Network Load Balancers Guide/. -- -- '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@. -- -- 'port', 'createListener_port' - The port on which the load balancer is listening. You cannot specify a -- port for a Gateway Load Balancer. -- -- '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. -- -- 'sslPolicy', 'createListener_sslPolicy' - [HTTPS and TLS listeners] The security policy that defines which -- protocols and ciphers are supported. -- -- For more information, see -- -- in the /Application Load Balancers Guide/ and -- -- in the /Network Load Balancers Guide/. -- -- 'tags', 'createListener_tags' - The tags to assign to the listener. -- -- '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 pLoadBalancerArn_ = CreateListener' { alpnPolicy = Prelude.Nothing, certificates = Prelude.Nothing, port = Prelude.Nothing, protocol = Prelude.Nothing, sslPolicy = Prelude.Nothing, tags = Prelude.Nothing, loadBalancerArn = pLoadBalancerArn_, defaultActions = Prelude.mempty } -- | [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 -- -- in the /Network Load Balancers Guide/. createListener_alpnPolicy :: Lens.Lens' CreateListener (Prelude.Maybe [Prelude.Text]) createListener_alpnPolicy = Lens.lens (\CreateListener' {alpnPolicy} -> alpnPolicy) (\s@CreateListener' {} a -> s {alpnPolicy = a} :: CreateListener) Prelude.. Lens.mapping Lens.coerced -- | [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 = Lens.lens (\CreateListener' {certificates} -> certificates) (\s@CreateListener' {} a -> s {certificates = a} :: CreateListener) Prelude.. Lens.mapping 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 = Lens.lens (\CreateListener' {port} -> port) (\s@CreateListener' {} a -> s {port = 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 = Lens.lens (\CreateListener' {protocol} -> protocol) (\s@CreateListener' {} a -> s {protocol = a} :: CreateListener) -- | [HTTPS and TLS listeners] The security policy that defines which -- protocols and ciphers are supported. -- -- For more information, see -- -- in the /Application Load Balancers Guide/ and -- -- in the /Network Load Balancers Guide/. createListener_sslPolicy :: Lens.Lens' CreateListener (Prelude.Maybe Prelude.Text) createListener_sslPolicy = Lens.lens (\CreateListener' {sslPolicy} -> sslPolicy) (\s@CreateListener' {} a -> s {sslPolicy = a} :: CreateListener) -- | The tags to assign to the listener. createListener_tags :: Lens.Lens' CreateListener (Prelude.Maybe (Prelude.NonEmpty Tag)) createListener_tags = Lens.lens (\CreateListener' {tags} -> tags) (\s@CreateListener' {} a -> s {tags = a} :: CreateListener) Prelude.. Lens.mapping Lens.coerced -- | The Amazon Resource Name (ARN) of the load balancer. createListener_loadBalancerArn :: Lens.Lens' CreateListener Prelude.Text createListener_loadBalancerArn = Lens.lens (\CreateListener' {loadBalancerArn} -> loadBalancerArn) (\s@CreateListener' {} a -> s {loadBalancerArn = a} :: CreateListener) -- | The actions for the default rule. createListener_defaultActions :: Lens.Lens' CreateListener [Action] createListener_defaultActions = Lens.lens (\CreateListener' {defaultActions} -> defaultActions) (\s@CreateListener' {} a -> s {defaultActions = a} :: CreateListener) Prelude.. Lens.coerced instance Core.AWSRequest CreateListener where type AWSResponse CreateListener = CreateListenerResponse request overrides = Request.postQuery (overrides defaultService) response = Response.receiveXMLWrapper "CreateListenerResult" ( \s h x -> CreateListenerResponse' Prelude.<$> ( x Data..@? "Listeners" Core..!@ Prelude.mempty Prelude.>>= Core.may (Data.parseXMLList "member") ) Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable CreateListener where hashWithSalt _salt CreateListener' {..} = _salt `Prelude.hashWithSalt` alpnPolicy `Prelude.hashWithSalt` certificates `Prelude.hashWithSalt` port `Prelude.hashWithSalt` protocol `Prelude.hashWithSalt` sslPolicy `Prelude.hashWithSalt` tags `Prelude.hashWithSalt` loadBalancerArn `Prelude.hashWithSalt` defaultActions instance Prelude.NFData CreateListener where rnf CreateListener' {..} = Prelude.rnf alpnPolicy `Prelude.seq` Prelude.rnf certificates `Prelude.seq` Prelude.rnf port `Prelude.seq` Prelude.rnf protocol `Prelude.seq` Prelude.rnf sslPolicy `Prelude.seq` Prelude.rnf tags `Prelude.seq` Prelude.rnf loadBalancerArn `Prelude.seq` Prelude.rnf defaultActions instance Data.ToHeaders CreateListener where toHeaders = Prelude.const Prelude.mempty instance Data.ToPath CreateListener where toPath = Prelude.const "/" instance Data.ToQuery CreateListener where toQuery CreateListener' {..} = Prelude.mconcat [ "Action" Data.=: ("CreateListener" :: Prelude.ByteString), "Version" Data.=: ("2015-12-01" :: Prelude.ByteString), "AlpnPolicy" Data.=: Data.toQuery (Data.toQueryList "member" Prelude.<$> alpnPolicy), "Certificates" Data.=: Data.toQuery (Data.toQueryList "member" Prelude.<$> certificates), "Port" Data.=: port, "Protocol" Data.=: protocol, "SslPolicy" Data.=: sslPolicy, "Tags" Data.=: Data.toQuery (Data.toQueryList "member" Prelude.<$> tags), "LoadBalancerArn" Data.=: loadBalancerArn, "DefaultActions" Data.=: Data.toQueryList "member" defaultActions ] -- | /See:/ 'newCreateListenerResponse' smart constructor. data CreateListenerResponse = CreateListenerResponse' { -- | Information about the listener. listeners :: Prelude.Maybe [Listener], -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'CreateListenerResponse' with all optional fields omitted. -- -- Use or 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 pHttpStatus_ = CreateListenerResponse' { listeners = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | Information about the listener. createListenerResponse_listeners :: Lens.Lens' CreateListenerResponse (Prelude.Maybe [Listener]) createListenerResponse_listeners = Lens.lens (\CreateListenerResponse' {listeners} -> listeners) (\s@CreateListenerResponse' {} a -> s {listeners = a} :: CreateListenerResponse) Prelude.. Lens.mapping Lens.coerced -- | The response's http status code. createListenerResponse_httpStatus :: Lens.Lens' CreateListenerResponse Prelude.Int createListenerResponse_httpStatus = Lens.lens (\CreateListenerResponse' {httpStatus} -> httpStatus) (\s@CreateListenerResponse' {} a -> s {httpStatus = a} :: CreateListenerResponse) instance Prelude.NFData CreateListenerResponse where rnf CreateListenerResponse' {..} = Prelude.rnf listeners `Prelude.seq` Prelude.rnf httpStatus