{-# 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.ELB.CreateLoadBalancer
-- 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 Classic Load Balancer.
--
-- You can add listeners, security groups, subnets, and tags when you
-- create your load balancer, or you can add them later using
-- CreateLoadBalancerListeners, ApplySecurityGroupsToLoadBalancer,
-- AttachLoadBalancerToSubnets, and AddTags.
--
-- To describe your current load balancers, see DescribeLoadBalancers. When
-- you are finished with a load balancer, you can delete it using
-- DeleteLoadBalancer.
--
-- You can create up to 20 load balancers per region per account. You can
-- request an increase for the number of load balancers for your account.
-- For more information, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-limits.html Limits for Your Classic Load Balancer>
-- in the /Classic Load Balancers Guide/.
module Amazonka.ELB.CreateLoadBalancer
  ( -- * Creating a Request
    CreateLoadBalancer (..),
    newCreateLoadBalancer,

    -- * Request Lenses
    createLoadBalancer_securityGroups,
    createLoadBalancer_subnets,
    createLoadBalancer_availabilityZones,
    createLoadBalancer_scheme,
    createLoadBalancer_tags,
    createLoadBalancer_loadBalancerName,
    createLoadBalancer_listeners,

    -- * Destructuring the Response
    CreateLoadBalancerResponse (..),
    newCreateLoadBalancerResponse,

    -- * Response Lenses
    createLoadBalancerResponse_dNSName,
    createLoadBalancerResponse_httpStatus,
  )
where

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

-- | Contains the parameters for CreateLoadBalancer.
--
-- /See:/ 'newCreateLoadBalancer' smart constructor.
data CreateLoadBalancer = CreateLoadBalancer'
  { -- | The IDs of the security groups to assign to the load balancer.
    CreateLoadBalancer -> Maybe [Text]
securityGroups :: Prelude.Maybe [Prelude.Text],
    -- | The IDs of the subnets in your VPC to attach to the load balancer.
    -- Specify one subnet per Availability Zone specified in
    -- @AvailabilityZones@.
    CreateLoadBalancer -> Maybe [Text]
subnets :: Prelude.Maybe [Prelude.Text],
    -- | One or more Availability Zones from the same region as the load
    -- balancer.
    --
    -- You must specify at least one Availability Zone.
    --
    -- You can add more Availability Zones after you create the load balancer
    -- using EnableAvailabilityZonesForLoadBalancer.
    CreateLoadBalancer -> Maybe [Text]
availabilityZones :: Prelude.Maybe [Prelude.Text],
    -- | The type of a load balancer. Valid only for load balancers in a VPC.
    --
    -- By default, Elastic Load Balancing creates an Internet-facing load
    -- balancer with a DNS name that resolves to public IP addresses. For more
    -- information about Internet-facing and Internal load balancers, see
    -- <https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/how-elastic-load-balancing-works.html#load-balancer-scheme Load Balancer Scheme>
    -- in the /Elastic Load Balancing User Guide/.
    --
    -- Specify @internal@ to create a load balancer with a DNS name that
    -- resolves to private IP addresses.
    CreateLoadBalancer -> Maybe Text
scheme :: Prelude.Maybe Prelude.Text,
    -- | A list of tags to assign to the load balancer.
    --
    -- For more information about tagging your load balancer, see
    -- <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/add-remove-tags.html Tag Your Classic Load Balancer>
    -- in the /Classic Load Balancers Guide/.
    CreateLoadBalancer -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The name of the load balancer.
    --
    -- This name must be unique within your set of load balancers for the
    -- region, must have a maximum of 32 characters, must contain only
    -- alphanumeric characters or hyphens, and cannot begin or end with a
    -- hyphen.
    CreateLoadBalancer -> Text
loadBalancerName :: Prelude.Text,
    -- | The listeners.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-listener-config.html Listeners for Your Classic Load Balancer>
    -- in the /Classic Load Balancers Guide/.
    CreateLoadBalancer -> [Listener]
listeners :: [Listener]
  }
  deriving (CreateLoadBalancer -> CreateLoadBalancer -> Bool
(CreateLoadBalancer -> CreateLoadBalancer -> Bool)
-> (CreateLoadBalancer -> CreateLoadBalancer -> Bool)
-> Eq CreateLoadBalancer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateLoadBalancer -> CreateLoadBalancer -> Bool
$c/= :: CreateLoadBalancer -> CreateLoadBalancer -> Bool
== :: CreateLoadBalancer -> CreateLoadBalancer -> Bool
$c== :: CreateLoadBalancer -> CreateLoadBalancer -> Bool
Prelude.Eq, ReadPrec [CreateLoadBalancer]
ReadPrec CreateLoadBalancer
Int -> ReadS CreateLoadBalancer
ReadS [CreateLoadBalancer]
(Int -> ReadS CreateLoadBalancer)
-> ReadS [CreateLoadBalancer]
-> ReadPrec CreateLoadBalancer
-> ReadPrec [CreateLoadBalancer]
-> Read CreateLoadBalancer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateLoadBalancer]
$creadListPrec :: ReadPrec [CreateLoadBalancer]
readPrec :: ReadPrec CreateLoadBalancer
$creadPrec :: ReadPrec CreateLoadBalancer
readList :: ReadS [CreateLoadBalancer]
$creadList :: ReadS [CreateLoadBalancer]
readsPrec :: Int -> ReadS CreateLoadBalancer
$creadsPrec :: Int -> ReadS CreateLoadBalancer
Prelude.Read, Int -> CreateLoadBalancer -> ShowS
[CreateLoadBalancer] -> ShowS
CreateLoadBalancer -> String
(Int -> CreateLoadBalancer -> ShowS)
-> (CreateLoadBalancer -> String)
-> ([CreateLoadBalancer] -> ShowS)
-> Show CreateLoadBalancer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateLoadBalancer] -> ShowS
$cshowList :: [CreateLoadBalancer] -> ShowS
show :: CreateLoadBalancer -> String
$cshow :: CreateLoadBalancer -> String
showsPrec :: Int -> CreateLoadBalancer -> ShowS
$cshowsPrec :: Int -> CreateLoadBalancer -> ShowS
Prelude.Show, (forall x. CreateLoadBalancer -> Rep CreateLoadBalancer x)
-> (forall x. Rep CreateLoadBalancer x -> CreateLoadBalancer)
-> Generic CreateLoadBalancer
forall x. Rep CreateLoadBalancer x -> CreateLoadBalancer
forall x. CreateLoadBalancer -> Rep CreateLoadBalancer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateLoadBalancer x -> CreateLoadBalancer
$cfrom :: forall x. CreateLoadBalancer -> Rep CreateLoadBalancer x
Prelude.Generic)

-- |
-- Create a value of 'CreateLoadBalancer' 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:
--
-- 'securityGroups', 'createLoadBalancer_securityGroups' - The IDs of the security groups to assign to the load balancer.
--
-- 'subnets', 'createLoadBalancer_subnets' - The IDs of the subnets in your VPC to attach to the load balancer.
-- Specify one subnet per Availability Zone specified in
-- @AvailabilityZones@.
--
-- 'availabilityZones', 'createLoadBalancer_availabilityZones' - One or more Availability Zones from the same region as the load
-- balancer.
--
-- You must specify at least one Availability Zone.
--
-- You can add more Availability Zones after you create the load balancer
-- using EnableAvailabilityZonesForLoadBalancer.
--
-- 'scheme', 'createLoadBalancer_scheme' - The type of a load balancer. Valid only for load balancers in a VPC.
--
-- By default, Elastic Load Balancing creates an Internet-facing load
-- balancer with a DNS name that resolves to public IP addresses. For more
-- information about Internet-facing and Internal load balancers, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/how-elastic-load-balancing-works.html#load-balancer-scheme Load Balancer Scheme>
-- in the /Elastic Load Balancing User Guide/.
--
-- Specify @internal@ to create a load balancer with a DNS name that
-- resolves to private IP addresses.
--
-- 'tags', 'createLoadBalancer_tags' - A list of tags to assign to the load balancer.
--
-- For more information about tagging your load balancer, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/add-remove-tags.html Tag Your Classic Load Balancer>
-- in the /Classic Load Balancers Guide/.
--
-- 'loadBalancerName', 'createLoadBalancer_loadBalancerName' - The name of the load balancer.
--
-- This name must be unique within your set of load balancers for the
-- region, must have a maximum of 32 characters, must contain only
-- alphanumeric characters or hyphens, and cannot begin or end with a
-- hyphen.
--
-- 'listeners', 'createLoadBalancer_listeners' - The listeners.
--
-- For more information, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-listener-config.html Listeners for Your Classic Load Balancer>
-- in the /Classic Load Balancers Guide/.
newCreateLoadBalancer ::
  -- | 'loadBalancerName'
  Prelude.Text ->
  CreateLoadBalancer
newCreateLoadBalancer :: Text -> CreateLoadBalancer
newCreateLoadBalancer Text
pLoadBalancerName_ =
  CreateLoadBalancer' :: Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Text
-> Maybe (NonEmpty Tag)
-> Text
-> [Listener]
-> CreateLoadBalancer
CreateLoadBalancer'
    { $sel:securityGroups:CreateLoadBalancer' :: Maybe [Text]
securityGroups =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:subnets:CreateLoadBalancer' :: Maybe [Text]
subnets = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:availabilityZones:CreateLoadBalancer' :: Maybe [Text]
availabilityZones = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:scheme:CreateLoadBalancer' :: Maybe Text
scheme = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateLoadBalancer' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
      $sel:loadBalancerName:CreateLoadBalancer' :: Text
loadBalancerName = Text
pLoadBalancerName_,
      $sel:listeners:CreateLoadBalancer' :: [Listener]
listeners = [Listener]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The IDs of the security groups to assign to the load balancer.
createLoadBalancer_securityGroups :: Lens.Lens' CreateLoadBalancer (Prelude.Maybe [Prelude.Text])
createLoadBalancer_securityGroups :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_securityGroups = (CreateLoadBalancer -> Maybe [Text])
-> (CreateLoadBalancer -> Maybe [Text] -> CreateLoadBalancer)
-> Lens
     CreateLoadBalancer CreateLoadBalancer (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Maybe [Text]
securityGroups :: Maybe [Text]
$sel:securityGroups:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe [Text]
securityGroups} -> Maybe [Text]
securityGroups) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Maybe [Text]
a -> CreateLoadBalancer
s {$sel:securityGroups:CreateLoadBalancer' :: Maybe [Text]
securityGroups = Maybe [Text]
a} :: CreateLoadBalancer) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateLoadBalancer -> f CreateLoadBalancer)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateLoadBalancer
-> f CreateLoadBalancer
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 IDs of the subnets in your VPC to attach to the load balancer.
-- Specify one subnet per Availability Zone specified in
-- @AvailabilityZones@.
createLoadBalancer_subnets :: Lens.Lens' CreateLoadBalancer (Prelude.Maybe [Prelude.Text])
createLoadBalancer_subnets :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_subnets = (CreateLoadBalancer -> Maybe [Text])
-> (CreateLoadBalancer -> Maybe [Text] -> CreateLoadBalancer)
-> Lens
     CreateLoadBalancer CreateLoadBalancer (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Maybe [Text]
subnets :: Maybe [Text]
$sel:subnets:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe [Text]
subnets} -> Maybe [Text]
subnets) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Maybe [Text]
a -> CreateLoadBalancer
s {$sel:subnets:CreateLoadBalancer' :: Maybe [Text]
subnets = Maybe [Text]
a} :: CreateLoadBalancer) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateLoadBalancer -> f CreateLoadBalancer)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateLoadBalancer
-> f CreateLoadBalancer
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

-- | One or more Availability Zones from the same region as the load
-- balancer.
--
-- You must specify at least one Availability Zone.
--
-- You can add more Availability Zones after you create the load balancer
-- using EnableAvailabilityZonesForLoadBalancer.
createLoadBalancer_availabilityZones :: Lens.Lens' CreateLoadBalancer (Prelude.Maybe [Prelude.Text])
createLoadBalancer_availabilityZones :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_availabilityZones = (CreateLoadBalancer -> Maybe [Text])
-> (CreateLoadBalancer -> Maybe [Text] -> CreateLoadBalancer)
-> Lens
     CreateLoadBalancer CreateLoadBalancer (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Maybe [Text]
availabilityZones :: Maybe [Text]
$sel:availabilityZones:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe [Text]
availabilityZones} -> Maybe [Text]
availabilityZones) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Maybe [Text]
a -> CreateLoadBalancer
s {$sel:availabilityZones:CreateLoadBalancer' :: Maybe [Text]
availabilityZones = Maybe [Text]
a} :: CreateLoadBalancer) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateLoadBalancer -> f CreateLoadBalancer)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateLoadBalancer
-> f CreateLoadBalancer
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 type of a load balancer. Valid only for load balancers in a VPC.
--
-- By default, Elastic Load Balancing creates an Internet-facing load
-- balancer with a DNS name that resolves to public IP addresses. For more
-- information about Internet-facing and Internal load balancers, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/how-elastic-load-balancing-works.html#load-balancer-scheme Load Balancer Scheme>
-- in the /Elastic Load Balancing User Guide/.
--
-- Specify @internal@ to create a load balancer with a DNS name that
-- resolves to private IP addresses.
createLoadBalancer_scheme :: Lens.Lens' CreateLoadBalancer (Prelude.Maybe Prelude.Text)
createLoadBalancer_scheme :: (Maybe Text -> f (Maybe Text))
-> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_scheme = (CreateLoadBalancer -> Maybe Text)
-> (CreateLoadBalancer -> Maybe Text -> CreateLoadBalancer)
-> Lens
     CreateLoadBalancer CreateLoadBalancer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Maybe Text
scheme :: Maybe Text
$sel:scheme:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe Text
scheme} -> Maybe Text
scheme) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Maybe Text
a -> CreateLoadBalancer
s {$sel:scheme:CreateLoadBalancer' :: Maybe Text
scheme = Maybe Text
a} :: CreateLoadBalancer)

-- | A list of tags to assign to the load balancer.
--
-- For more information about tagging your load balancer, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/add-remove-tags.html Tag Your Classic Load Balancer>
-- in the /Classic Load Balancers Guide/.
createLoadBalancer_tags :: Lens.Lens' CreateLoadBalancer (Prelude.Maybe (Prelude.NonEmpty Tag))
createLoadBalancer_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_tags = (CreateLoadBalancer -> Maybe (NonEmpty Tag))
-> (CreateLoadBalancer
    -> Maybe (NonEmpty Tag) -> CreateLoadBalancer)
-> Lens
     CreateLoadBalancer
     CreateLoadBalancer
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Maybe (NonEmpty Tag)
a -> CreateLoadBalancer
s {$sel:tags:CreateLoadBalancer' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateLoadBalancer) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> CreateLoadBalancer -> f CreateLoadBalancer)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateLoadBalancer
-> f CreateLoadBalancer
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 name of the load balancer.
--
-- This name must be unique within your set of load balancers for the
-- region, must have a maximum of 32 characters, must contain only
-- alphanumeric characters or hyphens, and cannot begin or end with a
-- hyphen.
createLoadBalancer_loadBalancerName :: Lens.Lens' CreateLoadBalancer Prelude.Text
createLoadBalancer_loadBalancerName :: (Text -> f Text) -> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_loadBalancerName = (CreateLoadBalancer -> Text)
-> (CreateLoadBalancer -> Text -> CreateLoadBalancer)
-> Lens CreateLoadBalancer CreateLoadBalancer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Text
loadBalancerName :: Text
$sel:loadBalancerName:CreateLoadBalancer' :: CreateLoadBalancer -> Text
loadBalancerName} -> Text
loadBalancerName) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Text
a -> CreateLoadBalancer
s {$sel:loadBalancerName:CreateLoadBalancer' :: Text
loadBalancerName = Text
a} :: CreateLoadBalancer)

-- | The listeners.
--
-- For more information, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-listener-config.html Listeners for Your Classic Load Balancer>
-- in the /Classic Load Balancers Guide/.
createLoadBalancer_listeners :: Lens.Lens' CreateLoadBalancer [Listener]
createLoadBalancer_listeners :: ([Listener] -> f [Listener])
-> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_listeners = (CreateLoadBalancer -> [Listener])
-> (CreateLoadBalancer -> [Listener] -> CreateLoadBalancer)
-> Lens CreateLoadBalancer CreateLoadBalancer [Listener] [Listener]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {[Listener]
listeners :: [Listener]
$sel:listeners:CreateLoadBalancer' :: CreateLoadBalancer -> [Listener]
listeners} -> [Listener]
listeners) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} [Listener]
a -> CreateLoadBalancer
s {$sel:listeners:CreateLoadBalancer' :: [Listener]
listeners = [Listener]
a} :: CreateLoadBalancer) (([Listener] -> f [Listener])
 -> CreateLoadBalancer -> f CreateLoadBalancer)
-> (([Listener] -> f [Listener]) -> [Listener] -> f [Listener])
-> ([Listener] -> f [Listener])
-> CreateLoadBalancer
-> f CreateLoadBalancer
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Listener] -> f [Listener]) -> [Listener] -> f [Listener]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateLoadBalancer where
  type
    AWSResponse CreateLoadBalancer =
      CreateLoadBalancerResponse
  request :: CreateLoadBalancer -> Request CreateLoadBalancer
request = Service -> CreateLoadBalancer -> Request CreateLoadBalancer
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateLoadBalancer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateLoadBalancer)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse CreateLoadBalancer))
-> Logger
-> Service
-> Proxy CreateLoadBalancer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateLoadBalancer)))
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
"CreateLoadBalancerResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Int -> CreateLoadBalancerResponse
CreateLoadBalancerResponse'
            (Maybe Text -> Int -> CreateLoadBalancerResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateLoadBalancerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DNSName")
            Either String (Int -> CreateLoadBalancerResponse)
-> Either String Int -> Either String CreateLoadBalancerResponse
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 CreateLoadBalancer

instance Prelude.NFData CreateLoadBalancer

instance Core.ToHeaders CreateLoadBalancer where
  toHeaders :: CreateLoadBalancer -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateLoadBalancer -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath CreateLoadBalancer where
  toPath :: CreateLoadBalancer -> ByteString
toPath = ByteString -> CreateLoadBalancer -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery CreateLoadBalancer where
  toQuery :: CreateLoadBalancer -> QueryString
toQuery CreateLoadBalancer' {[Listener]
Maybe [Text]
Maybe (NonEmpty Tag)
Maybe Text
Text
listeners :: [Listener]
loadBalancerName :: Text
tags :: Maybe (NonEmpty Tag)
scheme :: Maybe Text
availabilityZones :: Maybe [Text]
subnets :: Maybe [Text]
securityGroups :: Maybe [Text]
$sel:listeners:CreateLoadBalancer' :: CreateLoadBalancer -> [Listener]
$sel:loadBalancerName:CreateLoadBalancer' :: CreateLoadBalancer -> Text
$sel:tags:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe (NonEmpty Tag)
$sel:scheme:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe Text
$sel:availabilityZones:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe [Text]
$sel:subnets:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe [Text]
$sel:securityGroups:CreateLoadBalancer' :: CreateLoadBalancer -> 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
"CreateLoadBalancer" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-06-01" :: Prelude.ByteString),
        ByteString
"SecurityGroups"
          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]
securityGroups
            ),
        ByteString
"Subnets"
          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]
subnets),
        ByteString
"AvailabilityZones"
          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]
availabilityZones
            ),
        ByteString
"Scheme" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
scheme,
        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
"LoadBalancerName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
loadBalancerName,
        ByteString
"Listeners"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [Listener] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [Listener]
listeners
      ]

-- | Contains the output for CreateLoadBalancer.
--
-- /See:/ 'newCreateLoadBalancerResponse' smart constructor.
data CreateLoadBalancerResponse = CreateLoadBalancerResponse'
  { -- | The DNS name of the load balancer.
    CreateLoadBalancerResponse -> Maybe Text
dNSName :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateLoadBalancerResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateLoadBalancerResponse -> CreateLoadBalancerResponse -> Bool
(CreateLoadBalancerResponse -> CreateLoadBalancerResponse -> Bool)
-> (CreateLoadBalancerResponse
    -> CreateLoadBalancerResponse -> Bool)
-> Eq CreateLoadBalancerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateLoadBalancerResponse -> CreateLoadBalancerResponse -> Bool
$c/= :: CreateLoadBalancerResponse -> CreateLoadBalancerResponse -> Bool
== :: CreateLoadBalancerResponse -> CreateLoadBalancerResponse -> Bool
$c== :: CreateLoadBalancerResponse -> CreateLoadBalancerResponse -> Bool
Prelude.Eq, ReadPrec [CreateLoadBalancerResponse]
ReadPrec CreateLoadBalancerResponse
Int -> ReadS CreateLoadBalancerResponse
ReadS [CreateLoadBalancerResponse]
(Int -> ReadS CreateLoadBalancerResponse)
-> ReadS [CreateLoadBalancerResponse]
-> ReadPrec CreateLoadBalancerResponse
-> ReadPrec [CreateLoadBalancerResponse]
-> Read CreateLoadBalancerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateLoadBalancerResponse]
$creadListPrec :: ReadPrec [CreateLoadBalancerResponse]
readPrec :: ReadPrec CreateLoadBalancerResponse
$creadPrec :: ReadPrec CreateLoadBalancerResponse
readList :: ReadS [CreateLoadBalancerResponse]
$creadList :: ReadS [CreateLoadBalancerResponse]
readsPrec :: Int -> ReadS CreateLoadBalancerResponse
$creadsPrec :: Int -> ReadS CreateLoadBalancerResponse
Prelude.Read, Int -> CreateLoadBalancerResponse -> ShowS
[CreateLoadBalancerResponse] -> ShowS
CreateLoadBalancerResponse -> String
(Int -> CreateLoadBalancerResponse -> ShowS)
-> (CreateLoadBalancerResponse -> String)
-> ([CreateLoadBalancerResponse] -> ShowS)
-> Show CreateLoadBalancerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateLoadBalancerResponse] -> ShowS
$cshowList :: [CreateLoadBalancerResponse] -> ShowS
show :: CreateLoadBalancerResponse -> String
$cshow :: CreateLoadBalancerResponse -> String
showsPrec :: Int -> CreateLoadBalancerResponse -> ShowS
$cshowsPrec :: Int -> CreateLoadBalancerResponse -> ShowS
Prelude.Show, (forall x.
 CreateLoadBalancerResponse -> Rep CreateLoadBalancerResponse x)
-> (forall x.
    Rep CreateLoadBalancerResponse x -> CreateLoadBalancerResponse)
-> Generic CreateLoadBalancerResponse
forall x.
Rep CreateLoadBalancerResponse x -> CreateLoadBalancerResponse
forall x.
CreateLoadBalancerResponse -> Rep CreateLoadBalancerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateLoadBalancerResponse x -> CreateLoadBalancerResponse
$cfrom :: forall x.
CreateLoadBalancerResponse -> Rep CreateLoadBalancerResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateLoadBalancerResponse' 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:
--
-- 'dNSName', 'createLoadBalancerResponse_dNSName' - The DNS name of the load balancer.
--
-- 'httpStatus', 'createLoadBalancerResponse_httpStatus' - The response's http status code.
newCreateLoadBalancerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateLoadBalancerResponse
newCreateLoadBalancerResponse :: Int -> CreateLoadBalancerResponse
newCreateLoadBalancerResponse Int
pHttpStatus_ =
  CreateLoadBalancerResponse' :: Maybe Text -> Int -> CreateLoadBalancerResponse
CreateLoadBalancerResponse'
    { $sel:dNSName:CreateLoadBalancerResponse' :: Maybe Text
dNSName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateLoadBalancerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The DNS name of the load balancer.
createLoadBalancerResponse_dNSName :: Lens.Lens' CreateLoadBalancerResponse (Prelude.Maybe Prelude.Text)
createLoadBalancerResponse_dNSName :: (Maybe Text -> f (Maybe Text))
-> CreateLoadBalancerResponse -> f CreateLoadBalancerResponse
createLoadBalancerResponse_dNSName = (CreateLoadBalancerResponse -> Maybe Text)
-> (CreateLoadBalancerResponse
    -> Maybe Text -> CreateLoadBalancerResponse)
-> Lens
     CreateLoadBalancerResponse
     CreateLoadBalancerResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancerResponse' {Maybe Text
dNSName :: Maybe Text
$sel:dNSName:CreateLoadBalancerResponse' :: CreateLoadBalancerResponse -> Maybe Text
dNSName} -> Maybe Text
dNSName) (\s :: CreateLoadBalancerResponse
s@CreateLoadBalancerResponse' {} Maybe Text
a -> CreateLoadBalancerResponse
s {$sel:dNSName:CreateLoadBalancerResponse' :: Maybe Text
dNSName = Maybe Text
a} :: CreateLoadBalancerResponse)

-- | The response's http status code.
createLoadBalancerResponse_httpStatus :: Lens.Lens' CreateLoadBalancerResponse Prelude.Int
createLoadBalancerResponse_httpStatus :: (Int -> f Int)
-> CreateLoadBalancerResponse -> f CreateLoadBalancerResponse
createLoadBalancerResponse_httpStatus = (CreateLoadBalancerResponse -> Int)
-> (CreateLoadBalancerResponse
    -> Int -> CreateLoadBalancerResponse)
-> Lens
     CreateLoadBalancerResponse CreateLoadBalancerResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancerResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateLoadBalancerResponse' :: CreateLoadBalancerResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateLoadBalancerResponse
s@CreateLoadBalancerResponse' {} Int
a -> CreateLoadBalancerResponse
s {$sel:httpStatus:CreateLoadBalancerResponse' :: Int
httpStatus = Int
a} :: CreateLoadBalancerResponse)

instance Prelude.NFData CreateLoadBalancerResponse