{-# 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.CreateLoadBalancerListeners
-- 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 one or more listeners for the specified load balancer. If a
-- listener with the specified port does not already exist, it is created;
-- otherwise, the properties of the new listener must match the properties
-- of the existing listener.
--
-- 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/.
module Amazonka.ELB.CreateLoadBalancerListeners
  ( -- * Creating a Request
    CreateLoadBalancerListeners (..),
    newCreateLoadBalancerListeners,

    -- * Request Lenses
    createLoadBalancerListeners_loadBalancerName,
    createLoadBalancerListeners_listeners,

    -- * Destructuring the Response
    CreateLoadBalancerListenersResponse (..),
    newCreateLoadBalancerListenersResponse,

    -- * Response Lenses
    createLoadBalancerListenersResponse_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 CreateLoadBalancerListeners.
--
-- /See:/ 'newCreateLoadBalancerListeners' smart constructor.
data CreateLoadBalancerListeners = CreateLoadBalancerListeners'
  { -- | The name of the load balancer.
    CreateLoadBalancerListeners -> Text
loadBalancerName :: Prelude.Text,
    -- | The listeners.
    CreateLoadBalancerListeners -> [Listener]
listeners :: [Listener]
  }
  deriving (CreateLoadBalancerListeners -> CreateLoadBalancerListeners -> Bool
(CreateLoadBalancerListeners
 -> CreateLoadBalancerListeners -> Bool)
-> (CreateLoadBalancerListeners
    -> CreateLoadBalancerListeners -> Bool)
-> Eq CreateLoadBalancerListeners
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateLoadBalancerListeners -> CreateLoadBalancerListeners -> Bool
$c/= :: CreateLoadBalancerListeners -> CreateLoadBalancerListeners -> Bool
== :: CreateLoadBalancerListeners -> CreateLoadBalancerListeners -> Bool
$c== :: CreateLoadBalancerListeners -> CreateLoadBalancerListeners -> Bool
Prelude.Eq, ReadPrec [CreateLoadBalancerListeners]
ReadPrec CreateLoadBalancerListeners
Int -> ReadS CreateLoadBalancerListeners
ReadS [CreateLoadBalancerListeners]
(Int -> ReadS CreateLoadBalancerListeners)
-> ReadS [CreateLoadBalancerListeners]
-> ReadPrec CreateLoadBalancerListeners
-> ReadPrec [CreateLoadBalancerListeners]
-> Read CreateLoadBalancerListeners
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateLoadBalancerListeners]
$creadListPrec :: ReadPrec [CreateLoadBalancerListeners]
readPrec :: ReadPrec CreateLoadBalancerListeners
$creadPrec :: ReadPrec CreateLoadBalancerListeners
readList :: ReadS [CreateLoadBalancerListeners]
$creadList :: ReadS [CreateLoadBalancerListeners]
readsPrec :: Int -> ReadS CreateLoadBalancerListeners
$creadsPrec :: Int -> ReadS CreateLoadBalancerListeners
Prelude.Read, Int -> CreateLoadBalancerListeners -> ShowS
[CreateLoadBalancerListeners] -> ShowS
CreateLoadBalancerListeners -> String
(Int -> CreateLoadBalancerListeners -> ShowS)
-> (CreateLoadBalancerListeners -> String)
-> ([CreateLoadBalancerListeners] -> ShowS)
-> Show CreateLoadBalancerListeners
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateLoadBalancerListeners] -> ShowS
$cshowList :: [CreateLoadBalancerListeners] -> ShowS
show :: CreateLoadBalancerListeners -> String
$cshow :: CreateLoadBalancerListeners -> String
showsPrec :: Int -> CreateLoadBalancerListeners -> ShowS
$cshowsPrec :: Int -> CreateLoadBalancerListeners -> ShowS
Prelude.Show, (forall x.
 CreateLoadBalancerListeners -> Rep CreateLoadBalancerListeners x)
-> (forall x.
    Rep CreateLoadBalancerListeners x -> CreateLoadBalancerListeners)
-> Generic CreateLoadBalancerListeners
forall x.
Rep CreateLoadBalancerListeners x -> CreateLoadBalancerListeners
forall x.
CreateLoadBalancerListeners -> Rep CreateLoadBalancerListeners x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateLoadBalancerListeners x -> CreateLoadBalancerListeners
$cfrom :: forall x.
CreateLoadBalancerListeners -> Rep CreateLoadBalancerListeners x
Prelude.Generic)

-- |
-- Create a value of 'CreateLoadBalancerListeners' 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:
--
-- 'loadBalancerName', 'createLoadBalancerListeners_loadBalancerName' - The name of the load balancer.
--
-- 'listeners', 'createLoadBalancerListeners_listeners' - The listeners.
newCreateLoadBalancerListeners ::
  -- | 'loadBalancerName'
  Prelude.Text ->
  CreateLoadBalancerListeners
newCreateLoadBalancerListeners :: Text -> CreateLoadBalancerListeners
newCreateLoadBalancerListeners Text
pLoadBalancerName_ =
  CreateLoadBalancerListeners' :: Text -> [Listener] -> CreateLoadBalancerListeners
CreateLoadBalancerListeners'
    { $sel:loadBalancerName:CreateLoadBalancerListeners' :: Text
loadBalancerName =
        Text
pLoadBalancerName_,
      $sel:listeners:CreateLoadBalancerListeners' :: [Listener]
listeners = [Listener]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the load balancer.
createLoadBalancerListeners_loadBalancerName :: Lens.Lens' CreateLoadBalancerListeners Prelude.Text
createLoadBalancerListeners_loadBalancerName :: (Text -> f Text)
-> CreateLoadBalancerListeners -> f CreateLoadBalancerListeners
createLoadBalancerListeners_loadBalancerName = (CreateLoadBalancerListeners -> Text)
-> (CreateLoadBalancerListeners
    -> Text -> CreateLoadBalancerListeners)
-> Lens
     CreateLoadBalancerListeners CreateLoadBalancerListeners Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancerListeners' {Text
loadBalancerName :: Text
$sel:loadBalancerName:CreateLoadBalancerListeners' :: CreateLoadBalancerListeners -> Text
loadBalancerName} -> Text
loadBalancerName) (\s :: CreateLoadBalancerListeners
s@CreateLoadBalancerListeners' {} Text
a -> CreateLoadBalancerListeners
s {$sel:loadBalancerName:CreateLoadBalancerListeners' :: Text
loadBalancerName = Text
a} :: CreateLoadBalancerListeners)

-- | The listeners.
createLoadBalancerListeners_listeners :: Lens.Lens' CreateLoadBalancerListeners [Listener]
createLoadBalancerListeners_listeners :: ([Listener] -> f [Listener])
-> CreateLoadBalancerListeners -> f CreateLoadBalancerListeners
createLoadBalancerListeners_listeners = (CreateLoadBalancerListeners -> [Listener])
-> (CreateLoadBalancerListeners
    -> [Listener] -> CreateLoadBalancerListeners)
-> Lens
     CreateLoadBalancerListeners
     CreateLoadBalancerListeners
     [Listener]
     [Listener]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancerListeners' {[Listener]
listeners :: [Listener]
$sel:listeners:CreateLoadBalancerListeners' :: CreateLoadBalancerListeners -> [Listener]
listeners} -> [Listener]
listeners) (\s :: CreateLoadBalancerListeners
s@CreateLoadBalancerListeners' {} [Listener]
a -> CreateLoadBalancerListeners
s {$sel:listeners:CreateLoadBalancerListeners' :: [Listener]
listeners = [Listener]
a} :: CreateLoadBalancerListeners) (([Listener] -> f [Listener])
 -> CreateLoadBalancerListeners -> f CreateLoadBalancerListeners)
-> (([Listener] -> f [Listener]) -> [Listener] -> f [Listener])
-> ([Listener] -> f [Listener])
-> CreateLoadBalancerListeners
-> f CreateLoadBalancerListeners
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 CreateLoadBalancerListeners where
  type
    AWSResponse CreateLoadBalancerListeners =
      CreateLoadBalancerListenersResponse
  request :: CreateLoadBalancerListeners -> Request CreateLoadBalancerListeners
request = Service
-> CreateLoadBalancerListeners
-> Request CreateLoadBalancerListeners
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateLoadBalancerListeners
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateLoadBalancerListeners)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse CreateLoadBalancerListeners))
-> Logger
-> Service
-> Proxy CreateLoadBalancerListeners
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateLoadBalancerListeners)))
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
"CreateLoadBalancerListenersResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> CreateLoadBalancerListenersResponse
CreateLoadBalancerListenersResponse'
            (Int -> CreateLoadBalancerListenersResponse)
-> Either String Int
-> Either String CreateLoadBalancerListenersResponse
forall (f :: * -> *) a b. Functor 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 CreateLoadBalancerListeners

instance Prelude.NFData CreateLoadBalancerListeners

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

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

instance Core.ToQuery CreateLoadBalancerListeners where
  toQuery :: CreateLoadBalancerListeners -> QueryString
toQuery CreateLoadBalancerListeners' {[Listener]
Text
listeners :: [Listener]
loadBalancerName :: Text
$sel:listeners:CreateLoadBalancerListeners' :: CreateLoadBalancerListeners -> [Listener]
$sel:loadBalancerName:CreateLoadBalancerListeners' :: CreateLoadBalancerListeners -> 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
"CreateLoadBalancerListeners" ::
                      Prelude.ByteString
                  ),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-06-01" :: Prelude.ByteString),
        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 parameters for CreateLoadBalancerListener.
--
-- /See:/ 'newCreateLoadBalancerListenersResponse' smart constructor.
data CreateLoadBalancerListenersResponse = CreateLoadBalancerListenersResponse'
  { -- | The response's http status code.
    CreateLoadBalancerListenersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateLoadBalancerListenersResponse
-> CreateLoadBalancerListenersResponse -> Bool
(CreateLoadBalancerListenersResponse
 -> CreateLoadBalancerListenersResponse -> Bool)
-> (CreateLoadBalancerListenersResponse
    -> CreateLoadBalancerListenersResponse -> Bool)
-> Eq CreateLoadBalancerListenersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateLoadBalancerListenersResponse
-> CreateLoadBalancerListenersResponse -> Bool
$c/= :: CreateLoadBalancerListenersResponse
-> CreateLoadBalancerListenersResponse -> Bool
== :: CreateLoadBalancerListenersResponse
-> CreateLoadBalancerListenersResponse -> Bool
$c== :: CreateLoadBalancerListenersResponse
-> CreateLoadBalancerListenersResponse -> Bool
Prelude.Eq, ReadPrec [CreateLoadBalancerListenersResponse]
ReadPrec CreateLoadBalancerListenersResponse
Int -> ReadS CreateLoadBalancerListenersResponse
ReadS [CreateLoadBalancerListenersResponse]
(Int -> ReadS CreateLoadBalancerListenersResponse)
-> ReadS [CreateLoadBalancerListenersResponse]
-> ReadPrec CreateLoadBalancerListenersResponse
-> ReadPrec [CreateLoadBalancerListenersResponse]
-> Read CreateLoadBalancerListenersResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateLoadBalancerListenersResponse]
$creadListPrec :: ReadPrec [CreateLoadBalancerListenersResponse]
readPrec :: ReadPrec CreateLoadBalancerListenersResponse
$creadPrec :: ReadPrec CreateLoadBalancerListenersResponse
readList :: ReadS [CreateLoadBalancerListenersResponse]
$creadList :: ReadS [CreateLoadBalancerListenersResponse]
readsPrec :: Int -> ReadS CreateLoadBalancerListenersResponse
$creadsPrec :: Int -> ReadS CreateLoadBalancerListenersResponse
Prelude.Read, Int -> CreateLoadBalancerListenersResponse -> ShowS
[CreateLoadBalancerListenersResponse] -> ShowS
CreateLoadBalancerListenersResponse -> String
(Int -> CreateLoadBalancerListenersResponse -> ShowS)
-> (CreateLoadBalancerListenersResponse -> String)
-> ([CreateLoadBalancerListenersResponse] -> ShowS)
-> Show CreateLoadBalancerListenersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateLoadBalancerListenersResponse] -> ShowS
$cshowList :: [CreateLoadBalancerListenersResponse] -> ShowS
show :: CreateLoadBalancerListenersResponse -> String
$cshow :: CreateLoadBalancerListenersResponse -> String
showsPrec :: Int -> CreateLoadBalancerListenersResponse -> ShowS
$cshowsPrec :: Int -> CreateLoadBalancerListenersResponse -> ShowS
Prelude.Show, (forall x.
 CreateLoadBalancerListenersResponse
 -> Rep CreateLoadBalancerListenersResponse x)
-> (forall x.
    Rep CreateLoadBalancerListenersResponse x
    -> CreateLoadBalancerListenersResponse)
-> Generic CreateLoadBalancerListenersResponse
forall x.
Rep CreateLoadBalancerListenersResponse x
-> CreateLoadBalancerListenersResponse
forall x.
CreateLoadBalancerListenersResponse
-> Rep CreateLoadBalancerListenersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateLoadBalancerListenersResponse x
-> CreateLoadBalancerListenersResponse
$cfrom :: forall x.
CreateLoadBalancerListenersResponse
-> Rep CreateLoadBalancerListenersResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateLoadBalancerListenersResponse' 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:
--
-- 'httpStatus', 'createLoadBalancerListenersResponse_httpStatus' - The response's http status code.
newCreateLoadBalancerListenersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateLoadBalancerListenersResponse
newCreateLoadBalancerListenersResponse :: Int -> CreateLoadBalancerListenersResponse
newCreateLoadBalancerListenersResponse Int
pHttpStatus_ =
  CreateLoadBalancerListenersResponse' :: Int -> CreateLoadBalancerListenersResponse
CreateLoadBalancerListenersResponse'
    { $sel:httpStatus:CreateLoadBalancerListenersResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    CreateLoadBalancerListenersResponse