{-# 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.OpsWorks.AttachElasticLoadBalancer
-- 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)
--
-- Attaches an Elastic Load Balancing load balancer to a specified layer.
-- AWS OpsWorks Stacks does not support Application Load Balancer. You can
-- only use Classic Load Balancer with AWS OpsWorks Stacks. For more
-- information, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/layers-elb.html Elastic Load Balancing>.
--
-- You must create the Elastic Load Balancing instance separately, by using
-- the Elastic Load Balancing console, API, or CLI. For more information,
-- see
-- <https://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/Welcome.html Elastic Load Balancing Developer Guide>.
--
-- __Required Permissions__: To use this action, an IAM user must have a
-- Manage permissions level for the stack, or an attached policy that
-- explicitly grants permissions. For more information on user permissions,
-- see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>.
module Amazonka.OpsWorks.AttachElasticLoadBalancer
  ( -- * Creating a Request
    AttachElasticLoadBalancer (..),
    newAttachElasticLoadBalancer,

    -- * Request Lenses
    attachElasticLoadBalancer_elasticLoadBalancerName,
    attachElasticLoadBalancer_layerId,

    -- * Destructuring the Response
    AttachElasticLoadBalancerResponse (..),
    newAttachElasticLoadBalancerResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorks.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newAttachElasticLoadBalancer' smart constructor.
data AttachElasticLoadBalancer = AttachElasticLoadBalancer'
  { -- | The Elastic Load Balancing instance\'s name.
    AttachElasticLoadBalancer -> Text
elasticLoadBalancerName :: Prelude.Text,
    -- | The ID of the layer to which the Elastic Load Balancing instance is to
    -- be attached.
    AttachElasticLoadBalancer -> Text
layerId :: Prelude.Text
  }
  deriving (AttachElasticLoadBalancer -> AttachElasticLoadBalancer -> Bool
(AttachElasticLoadBalancer -> AttachElasticLoadBalancer -> Bool)
-> (AttachElasticLoadBalancer -> AttachElasticLoadBalancer -> Bool)
-> Eq AttachElasticLoadBalancer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachElasticLoadBalancer -> AttachElasticLoadBalancer -> Bool
$c/= :: AttachElasticLoadBalancer -> AttachElasticLoadBalancer -> Bool
== :: AttachElasticLoadBalancer -> AttachElasticLoadBalancer -> Bool
$c== :: AttachElasticLoadBalancer -> AttachElasticLoadBalancer -> Bool
Prelude.Eq, ReadPrec [AttachElasticLoadBalancer]
ReadPrec AttachElasticLoadBalancer
Int -> ReadS AttachElasticLoadBalancer
ReadS [AttachElasticLoadBalancer]
(Int -> ReadS AttachElasticLoadBalancer)
-> ReadS [AttachElasticLoadBalancer]
-> ReadPrec AttachElasticLoadBalancer
-> ReadPrec [AttachElasticLoadBalancer]
-> Read AttachElasticLoadBalancer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachElasticLoadBalancer]
$creadListPrec :: ReadPrec [AttachElasticLoadBalancer]
readPrec :: ReadPrec AttachElasticLoadBalancer
$creadPrec :: ReadPrec AttachElasticLoadBalancer
readList :: ReadS [AttachElasticLoadBalancer]
$creadList :: ReadS [AttachElasticLoadBalancer]
readsPrec :: Int -> ReadS AttachElasticLoadBalancer
$creadsPrec :: Int -> ReadS AttachElasticLoadBalancer
Prelude.Read, Int -> AttachElasticLoadBalancer -> ShowS
[AttachElasticLoadBalancer] -> ShowS
AttachElasticLoadBalancer -> String
(Int -> AttachElasticLoadBalancer -> ShowS)
-> (AttachElasticLoadBalancer -> String)
-> ([AttachElasticLoadBalancer] -> ShowS)
-> Show AttachElasticLoadBalancer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachElasticLoadBalancer] -> ShowS
$cshowList :: [AttachElasticLoadBalancer] -> ShowS
show :: AttachElasticLoadBalancer -> String
$cshow :: AttachElasticLoadBalancer -> String
showsPrec :: Int -> AttachElasticLoadBalancer -> ShowS
$cshowsPrec :: Int -> AttachElasticLoadBalancer -> ShowS
Prelude.Show, (forall x.
 AttachElasticLoadBalancer -> Rep AttachElasticLoadBalancer x)
-> (forall x.
    Rep AttachElasticLoadBalancer x -> AttachElasticLoadBalancer)
-> Generic AttachElasticLoadBalancer
forall x.
Rep AttachElasticLoadBalancer x -> AttachElasticLoadBalancer
forall x.
AttachElasticLoadBalancer -> Rep AttachElasticLoadBalancer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AttachElasticLoadBalancer x -> AttachElasticLoadBalancer
$cfrom :: forall x.
AttachElasticLoadBalancer -> Rep AttachElasticLoadBalancer x
Prelude.Generic)

-- |
-- Create a value of 'AttachElasticLoadBalancer' 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:
--
-- 'elasticLoadBalancerName', 'attachElasticLoadBalancer_elasticLoadBalancerName' - The Elastic Load Balancing instance\'s name.
--
-- 'layerId', 'attachElasticLoadBalancer_layerId' - The ID of the layer to which the Elastic Load Balancing instance is to
-- be attached.
newAttachElasticLoadBalancer ::
  -- | 'elasticLoadBalancerName'
  Prelude.Text ->
  -- | 'layerId'
  Prelude.Text ->
  AttachElasticLoadBalancer
newAttachElasticLoadBalancer :: Text -> Text -> AttachElasticLoadBalancer
newAttachElasticLoadBalancer
  Text
pElasticLoadBalancerName_
  Text
pLayerId_ =
    AttachElasticLoadBalancer' :: Text -> Text -> AttachElasticLoadBalancer
AttachElasticLoadBalancer'
      { $sel:elasticLoadBalancerName:AttachElasticLoadBalancer' :: Text
elasticLoadBalancerName =
          Text
pElasticLoadBalancerName_,
        $sel:layerId:AttachElasticLoadBalancer' :: Text
layerId = Text
pLayerId_
      }

-- | The Elastic Load Balancing instance\'s name.
attachElasticLoadBalancer_elasticLoadBalancerName :: Lens.Lens' AttachElasticLoadBalancer Prelude.Text
attachElasticLoadBalancer_elasticLoadBalancerName :: (Text -> f Text)
-> AttachElasticLoadBalancer -> f AttachElasticLoadBalancer
attachElasticLoadBalancer_elasticLoadBalancerName = (AttachElasticLoadBalancer -> Text)
-> (AttachElasticLoadBalancer -> Text -> AttachElasticLoadBalancer)
-> Lens
     AttachElasticLoadBalancer AttachElasticLoadBalancer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachElasticLoadBalancer' {Text
elasticLoadBalancerName :: Text
$sel:elasticLoadBalancerName:AttachElasticLoadBalancer' :: AttachElasticLoadBalancer -> Text
elasticLoadBalancerName} -> Text
elasticLoadBalancerName) (\s :: AttachElasticLoadBalancer
s@AttachElasticLoadBalancer' {} Text
a -> AttachElasticLoadBalancer
s {$sel:elasticLoadBalancerName:AttachElasticLoadBalancer' :: Text
elasticLoadBalancerName = Text
a} :: AttachElasticLoadBalancer)

-- | The ID of the layer to which the Elastic Load Balancing instance is to
-- be attached.
attachElasticLoadBalancer_layerId :: Lens.Lens' AttachElasticLoadBalancer Prelude.Text
attachElasticLoadBalancer_layerId :: (Text -> f Text)
-> AttachElasticLoadBalancer -> f AttachElasticLoadBalancer
attachElasticLoadBalancer_layerId = (AttachElasticLoadBalancer -> Text)
-> (AttachElasticLoadBalancer -> Text -> AttachElasticLoadBalancer)
-> Lens
     AttachElasticLoadBalancer AttachElasticLoadBalancer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachElasticLoadBalancer' {Text
layerId :: Text
$sel:layerId:AttachElasticLoadBalancer' :: AttachElasticLoadBalancer -> Text
layerId} -> Text
layerId) (\s :: AttachElasticLoadBalancer
s@AttachElasticLoadBalancer' {} Text
a -> AttachElasticLoadBalancer
s {$sel:layerId:AttachElasticLoadBalancer' :: Text
layerId = Text
a} :: AttachElasticLoadBalancer)

instance Core.AWSRequest AttachElasticLoadBalancer where
  type
    AWSResponse AttachElasticLoadBalancer =
      AttachElasticLoadBalancerResponse
  request :: AttachElasticLoadBalancer -> Request AttachElasticLoadBalancer
request = Service
-> AttachElasticLoadBalancer -> Request AttachElasticLoadBalancer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AttachElasticLoadBalancer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AttachElasticLoadBalancer)))
response =
    AWSResponse AttachElasticLoadBalancer
-> Logger
-> Service
-> Proxy AttachElasticLoadBalancer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AttachElasticLoadBalancer)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse AttachElasticLoadBalancer
AttachElasticLoadBalancerResponse
AttachElasticLoadBalancerResponse'

instance Prelude.Hashable AttachElasticLoadBalancer

instance Prelude.NFData AttachElasticLoadBalancer

instance Core.ToHeaders AttachElasticLoadBalancer where
  toHeaders :: AttachElasticLoadBalancer -> [Header]
toHeaders =
    [Header] -> AttachElasticLoadBalancer -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"OpsWorks_20130218.AttachElasticLoadBalancer" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON AttachElasticLoadBalancer where
  toJSON :: AttachElasticLoadBalancer -> Value
toJSON AttachElasticLoadBalancer' {Text
layerId :: Text
elasticLoadBalancerName :: Text
$sel:layerId:AttachElasticLoadBalancer' :: AttachElasticLoadBalancer -> Text
$sel:elasticLoadBalancerName:AttachElasticLoadBalancer' :: AttachElasticLoadBalancer -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ElasticLoadBalancerName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
elasticLoadBalancerName
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LayerId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
layerId)
          ]
      )

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

instance Core.ToQuery AttachElasticLoadBalancer where
  toQuery :: AttachElasticLoadBalancer -> QueryString
toQuery = QueryString -> AttachElasticLoadBalancer -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newAttachElasticLoadBalancerResponse' smart constructor.
data AttachElasticLoadBalancerResponse = AttachElasticLoadBalancerResponse'
  {
  }
  deriving (AttachElasticLoadBalancerResponse
-> AttachElasticLoadBalancerResponse -> Bool
(AttachElasticLoadBalancerResponse
 -> AttachElasticLoadBalancerResponse -> Bool)
-> (AttachElasticLoadBalancerResponse
    -> AttachElasticLoadBalancerResponse -> Bool)
-> Eq AttachElasticLoadBalancerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachElasticLoadBalancerResponse
-> AttachElasticLoadBalancerResponse -> Bool
$c/= :: AttachElasticLoadBalancerResponse
-> AttachElasticLoadBalancerResponse -> Bool
== :: AttachElasticLoadBalancerResponse
-> AttachElasticLoadBalancerResponse -> Bool
$c== :: AttachElasticLoadBalancerResponse
-> AttachElasticLoadBalancerResponse -> Bool
Prelude.Eq, ReadPrec [AttachElasticLoadBalancerResponse]
ReadPrec AttachElasticLoadBalancerResponse
Int -> ReadS AttachElasticLoadBalancerResponse
ReadS [AttachElasticLoadBalancerResponse]
(Int -> ReadS AttachElasticLoadBalancerResponse)
-> ReadS [AttachElasticLoadBalancerResponse]
-> ReadPrec AttachElasticLoadBalancerResponse
-> ReadPrec [AttachElasticLoadBalancerResponse]
-> Read AttachElasticLoadBalancerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachElasticLoadBalancerResponse]
$creadListPrec :: ReadPrec [AttachElasticLoadBalancerResponse]
readPrec :: ReadPrec AttachElasticLoadBalancerResponse
$creadPrec :: ReadPrec AttachElasticLoadBalancerResponse
readList :: ReadS [AttachElasticLoadBalancerResponse]
$creadList :: ReadS [AttachElasticLoadBalancerResponse]
readsPrec :: Int -> ReadS AttachElasticLoadBalancerResponse
$creadsPrec :: Int -> ReadS AttachElasticLoadBalancerResponse
Prelude.Read, Int -> AttachElasticLoadBalancerResponse -> ShowS
[AttachElasticLoadBalancerResponse] -> ShowS
AttachElasticLoadBalancerResponse -> String
(Int -> AttachElasticLoadBalancerResponse -> ShowS)
-> (AttachElasticLoadBalancerResponse -> String)
-> ([AttachElasticLoadBalancerResponse] -> ShowS)
-> Show AttachElasticLoadBalancerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachElasticLoadBalancerResponse] -> ShowS
$cshowList :: [AttachElasticLoadBalancerResponse] -> ShowS
show :: AttachElasticLoadBalancerResponse -> String
$cshow :: AttachElasticLoadBalancerResponse -> String
showsPrec :: Int -> AttachElasticLoadBalancerResponse -> ShowS
$cshowsPrec :: Int -> AttachElasticLoadBalancerResponse -> ShowS
Prelude.Show, (forall x.
 AttachElasticLoadBalancerResponse
 -> Rep AttachElasticLoadBalancerResponse x)
-> (forall x.
    Rep AttachElasticLoadBalancerResponse x
    -> AttachElasticLoadBalancerResponse)
-> Generic AttachElasticLoadBalancerResponse
forall x.
Rep AttachElasticLoadBalancerResponse x
-> AttachElasticLoadBalancerResponse
forall x.
AttachElasticLoadBalancerResponse
-> Rep AttachElasticLoadBalancerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AttachElasticLoadBalancerResponse x
-> AttachElasticLoadBalancerResponse
$cfrom :: forall x.
AttachElasticLoadBalancerResponse
-> Rep AttachElasticLoadBalancerResponse x
Prelude.Generic)

-- |
-- Create a value of 'AttachElasticLoadBalancerResponse' 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.
newAttachElasticLoadBalancerResponse ::
  AttachElasticLoadBalancerResponse
newAttachElasticLoadBalancerResponse :: AttachElasticLoadBalancerResponse
newAttachElasticLoadBalancerResponse =
  AttachElasticLoadBalancerResponse
AttachElasticLoadBalancerResponse'

instance
  Prelude.NFData
    AttachElasticLoadBalancerResponse