{-# 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.DetachElasticLoadBalancer
-- 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)
--
-- Detaches a specified Elastic Load Balancing instance from its layer.
--
-- __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.DetachElasticLoadBalancer
  ( -- * Creating a Request
    DetachElasticLoadBalancer (..),
    newDetachElasticLoadBalancer,

    -- * Request Lenses
    detachElasticLoadBalancer_elasticLoadBalancerName,
    detachElasticLoadBalancer_layerId,

    -- * Destructuring the Response
    DetachElasticLoadBalancerResponse (..),
    newDetachElasticLoadBalancerResponse,
  )
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:/ 'newDetachElasticLoadBalancer' smart constructor.
data DetachElasticLoadBalancer = DetachElasticLoadBalancer'
  { -- | The Elastic Load Balancing instance\'s name.
    DetachElasticLoadBalancer -> Text
elasticLoadBalancerName :: Prelude.Text,
    -- | The ID of the layer that the Elastic Load Balancing instance is attached
    -- to.
    DetachElasticLoadBalancer -> Text
layerId :: Prelude.Text
  }
  deriving (DetachElasticLoadBalancer -> DetachElasticLoadBalancer -> Bool
(DetachElasticLoadBalancer -> DetachElasticLoadBalancer -> Bool)
-> (DetachElasticLoadBalancer -> DetachElasticLoadBalancer -> Bool)
-> Eq DetachElasticLoadBalancer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetachElasticLoadBalancer -> DetachElasticLoadBalancer -> Bool
$c/= :: DetachElasticLoadBalancer -> DetachElasticLoadBalancer -> Bool
== :: DetachElasticLoadBalancer -> DetachElasticLoadBalancer -> Bool
$c== :: DetachElasticLoadBalancer -> DetachElasticLoadBalancer -> Bool
Prelude.Eq, ReadPrec [DetachElasticLoadBalancer]
ReadPrec DetachElasticLoadBalancer
Int -> ReadS DetachElasticLoadBalancer
ReadS [DetachElasticLoadBalancer]
(Int -> ReadS DetachElasticLoadBalancer)
-> ReadS [DetachElasticLoadBalancer]
-> ReadPrec DetachElasticLoadBalancer
-> ReadPrec [DetachElasticLoadBalancer]
-> Read DetachElasticLoadBalancer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetachElasticLoadBalancer]
$creadListPrec :: ReadPrec [DetachElasticLoadBalancer]
readPrec :: ReadPrec DetachElasticLoadBalancer
$creadPrec :: ReadPrec DetachElasticLoadBalancer
readList :: ReadS [DetachElasticLoadBalancer]
$creadList :: ReadS [DetachElasticLoadBalancer]
readsPrec :: Int -> ReadS DetachElasticLoadBalancer
$creadsPrec :: Int -> ReadS DetachElasticLoadBalancer
Prelude.Read, Int -> DetachElasticLoadBalancer -> ShowS
[DetachElasticLoadBalancer] -> ShowS
DetachElasticLoadBalancer -> String
(Int -> DetachElasticLoadBalancer -> ShowS)
-> (DetachElasticLoadBalancer -> String)
-> ([DetachElasticLoadBalancer] -> ShowS)
-> Show DetachElasticLoadBalancer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetachElasticLoadBalancer] -> ShowS
$cshowList :: [DetachElasticLoadBalancer] -> ShowS
show :: DetachElasticLoadBalancer -> String
$cshow :: DetachElasticLoadBalancer -> String
showsPrec :: Int -> DetachElasticLoadBalancer -> ShowS
$cshowsPrec :: Int -> DetachElasticLoadBalancer -> ShowS
Prelude.Show, (forall x.
 DetachElasticLoadBalancer -> Rep DetachElasticLoadBalancer x)
-> (forall x.
    Rep DetachElasticLoadBalancer x -> DetachElasticLoadBalancer)
-> Generic DetachElasticLoadBalancer
forall x.
Rep DetachElasticLoadBalancer x -> DetachElasticLoadBalancer
forall x.
DetachElasticLoadBalancer -> Rep DetachElasticLoadBalancer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DetachElasticLoadBalancer x -> DetachElasticLoadBalancer
$cfrom :: forall x.
DetachElasticLoadBalancer -> Rep DetachElasticLoadBalancer x
Prelude.Generic)

-- |
-- Create a value of 'DetachElasticLoadBalancer' 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', 'detachElasticLoadBalancer_elasticLoadBalancerName' - The Elastic Load Balancing instance\'s name.
--
-- 'layerId', 'detachElasticLoadBalancer_layerId' - The ID of the layer that the Elastic Load Balancing instance is attached
-- to.
newDetachElasticLoadBalancer ::
  -- | 'elasticLoadBalancerName'
  Prelude.Text ->
  -- | 'layerId'
  Prelude.Text ->
  DetachElasticLoadBalancer
newDetachElasticLoadBalancer :: Text -> Text -> DetachElasticLoadBalancer
newDetachElasticLoadBalancer
  Text
pElasticLoadBalancerName_
  Text
pLayerId_ =
    DetachElasticLoadBalancer' :: Text -> Text -> DetachElasticLoadBalancer
DetachElasticLoadBalancer'
      { $sel:elasticLoadBalancerName:DetachElasticLoadBalancer' :: Text
elasticLoadBalancerName =
          Text
pElasticLoadBalancerName_,
        $sel:layerId:DetachElasticLoadBalancer' :: Text
layerId = Text
pLayerId_
      }

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

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

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

instance Prelude.Hashable DetachElasticLoadBalancer

instance Prelude.NFData DetachElasticLoadBalancer

instance Core.ToHeaders DetachElasticLoadBalancer where
  toHeaders :: DetachElasticLoadBalancer -> [Header]
toHeaders =
    [Header] -> DetachElasticLoadBalancer -> [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.DetachElasticLoadBalancer" ::
                          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 DetachElasticLoadBalancer where
  toJSON :: DetachElasticLoadBalancer -> Value
toJSON DetachElasticLoadBalancer' {Text
layerId :: Text
elasticLoadBalancerName :: Text
$sel:layerId:DetachElasticLoadBalancer' :: DetachElasticLoadBalancer -> Text
$sel:elasticLoadBalancerName:DetachElasticLoadBalancer' :: DetachElasticLoadBalancer -> 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 DetachElasticLoadBalancer where
  toPath :: DetachElasticLoadBalancer -> ByteString
toPath = ByteString -> DetachElasticLoadBalancer -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

instance
  Prelude.NFData
    DetachElasticLoadBalancerResponse