{-# 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.AutoScaling.DetachLoadBalancers
-- 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 one or more Classic Load Balancers from the specified Auto
-- Scaling group.
--
-- This operation detaches only Classic Load Balancers. If you have
-- Application Load Balancers, Network Load Balancers, or Gateway Load
-- Balancers, use the DetachLoadBalancerTargetGroups API instead.
--
-- When you detach a load balancer, it enters the @Removing@ state while
-- deregistering the instances in the group. When all instances are
-- deregistered, then you can no longer describe the load balancer using
-- the DescribeLoadBalancers API call. The instances remain running.
module Amazonka.AutoScaling.DetachLoadBalancers
  ( -- * Creating a Request
    DetachLoadBalancers (..),
    newDetachLoadBalancers,

    -- * Request Lenses
    detachLoadBalancers_autoScalingGroupName,
    detachLoadBalancers_loadBalancerNames,

    -- * Destructuring the Response
    DetachLoadBalancersResponse (..),
    newDetachLoadBalancersResponse,

    -- * Response Lenses
    detachLoadBalancersResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDetachLoadBalancers' smart constructor.
data DetachLoadBalancers = DetachLoadBalancers'
  { -- | The name of the Auto Scaling group.
    DetachLoadBalancers -> Text
autoScalingGroupName :: Prelude.Text,
    -- | The names of the load balancers. You can specify up to 10 load
    -- balancers.
    DetachLoadBalancers -> [Text]
loadBalancerNames :: [Prelude.Text]
  }
  deriving (DetachLoadBalancers -> DetachLoadBalancers -> Bool
(DetachLoadBalancers -> DetachLoadBalancers -> Bool)
-> (DetachLoadBalancers -> DetachLoadBalancers -> Bool)
-> Eq DetachLoadBalancers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetachLoadBalancers -> DetachLoadBalancers -> Bool
$c/= :: DetachLoadBalancers -> DetachLoadBalancers -> Bool
== :: DetachLoadBalancers -> DetachLoadBalancers -> Bool
$c== :: DetachLoadBalancers -> DetachLoadBalancers -> Bool
Prelude.Eq, ReadPrec [DetachLoadBalancers]
ReadPrec DetachLoadBalancers
Int -> ReadS DetachLoadBalancers
ReadS [DetachLoadBalancers]
(Int -> ReadS DetachLoadBalancers)
-> ReadS [DetachLoadBalancers]
-> ReadPrec DetachLoadBalancers
-> ReadPrec [DetachLoadBalancers]
-> Read DetachLoadBalancers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetachLoadBalancers]
$creadListPrec :: ReadPrec [DetachLoadBalancers]
readPrec :: ReadPrec DetachLoadBalancers
$creadPrec :: ReadPrec DetachLoadBalancers
readList :: ReadS [DetachLoadBalancers]
$creadList :: ReadS [DetachLoadBalancers]
readsPrec :: Int -> ReadS DetachLoadBalancers
$creadsPrec :: Int -> ReadS DetachLoadBalancers
Prelude.Read, Int -> DetachLoadBalancers -> ShowS
[DetachLoadBalancers] -> ShowS
DetachLoadBalancers -> String
(Int -> DetachLoadBalancers -> ShowS)
-> (DetachLoadBalancers -> String)
-> ([DetachLoadBalancers] -> ShowS)
-> Show DetachLoadBalancers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetachLoadBalancers] -> ShowS
$cshowList :: [DetachLoadBalancers] -> ShowS
show :: DetachLoadBalancers -> String
$cshow :: DetachLoadBalancers -> String
showsPrec :: Int -> DetachLoadBalancers -> ShowS
$cshowsPrec :: Int -> DetachLoadBalancers -> ShowS
Prelude.Show, (forall x. DetachLoadBalancers -> Rep DetachLoadBalancers x)
-> (forall x. Rep DetachLoadBalancers x -> DetachLoadBalancers)
-> Generic DetachLoadBalancers
forall x. Rep DetachLoadBalancers x -> DetachLoadBalancers
forall x. DetachLoadBalancers -> Rep DetachLoadBalancers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetachLoadBalancers x -> DetachLoadBalancers
$cfrom :: forall x. DetachLoadBalancers -> Rep DetachLoadBalancers x
Prelude.Generic)

-- |
-- Create a value of 'DetachLoadBalancers' 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:
--
-- 'autoScalingGroupName', 'detachLoadBalancers_autoScalingGroupName' - The name of the Auto Scaling group.
--
-- 'loadBalancerNames', 'detachLoadBalancers_loadBalancerNames' - The names of the load balancers. You can specify up to 10 load
-- balancers.
newDetachLoadBalancers ::
  -- | 'autoScalingGroupName'
  Prelude.Text ->
  DetachLoadBalancers
newDetachLoadBalancers :: Text -> DetachLoadBalancers
newDetachLoadBalancers Text
pAutoScalingGroupName_ =
  DetachLoadBalancers' :: Text -> [Text] -> DetachLoadBalancers
DetachLoadBalancers'
    { $sel:autoScalingGroupName:DetachLoadBalancers' :: Text
autoScalingGroupName =
        Text
pAutoScalingGroupName_,
      $sel:loadBalancerNames:DetachLoadBalancers' :: [Text]
loadBalancerNames = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the Auto Scaling group.
detachLoadBalancers_autoScalingGroupName :: Lens.Lens' DetachLoadBalancers Prelude.Text
detachLoadBalancers_autoScalingGroupName :: (Text -> f Text) -> DetachLoadBalancers -> f DetachLoadBalancers
detachLoadBalancers_autoScalingGroupName = (DetachLoadBalancers -> Text)
-> (DetachLoadBalancers -> Text -> DetachLoadBalancers)
-> Lens DetachLoadBalancers DetachLoadBalancers Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachLoadBalancers' {Text
autoScalingGroupName :: Text
$sel:autoScalingGroupName:DetachLoadBalancers' :: DetachLoadBalancers -> Text
autoScalingGroupName} -> Text
autoScalingGroupName) (\s :: DetachLoadBalancers
s@DetachLoadBalancers' {} Text
a -> DetachLoadBalancers
s {$sel:autoScalingGroupName:DetachLoadBalancers' :: Text
autoScalingGroupName = Text
a} :: DetachLoadBalancers)

-- | The names of the load balancers. You can specify up to 10 load
-- balancers.
detachLoadBalancers_loadBalancerNames :: Lens.Lens' DetachLoadBalancers [Prelude.Text]
detachLoadBalancers_loadBalancerNames :: ([Text] -> f [Text])
-> DetachLoadBalancers -> f DetachLoadBalancers
detachLoadBalancers_loadBalancerNames = (DetachLoadBalancers -> [Text])
-> (DetachLoadBalancers -> [Text] -> DetachLoadBalancers)
-> Lens DetachLoadBalancers DetachLoadBalancers [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachLoadBalancers' {[Text]
loadBalancerNames :: [Text]
$sel:loadBalancerNames:DetachLoadBalancers' :: DetachLoadBalancers -> [Text]
loadBalancerNames} -> [Text]
loadBalancerNames) (\s :: DetachLoadBalancers
s@DetachLoadBalancers' {} [Text]
a -> DetachLoadBalancers
s {$sel:loadBalancerNames:DetachLoadBalancers' :: [Text]
loadBalancerNames = [Text]
a} :: DetachLoadBalancers) (([Text] -> f [Text])
 -> DetachLoadBalancers -> f DetachLoadBalancers)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DetachLoadBalancers
-> f DetachLoadBalancers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest DetachLoadBalancers where
  type
    AWSResponse DetachLoadBalancers =
      DetachLoadBalancersResponse
  request :: DetachLoadBalancers -> Request DetachLoadBalancers
request = Service -> DetachLoadBalancers -> Request DetachLoadBalancers
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DetachLoadBalancers
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DetachLoadBalancers)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DetachLoadBalancers))
-> Logger
-> Service
-> Proxy DetachLoadBalancers
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DetachLoadBalancers)))
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
"DetachLoadBalancersResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> DetachLoadBalancersResponse
DetachLoadBalancersResponse'
            (Int -> DetachLoadBalancersResponse)
-> Either String Int -> Either String DetachLoadBalancersResponse
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 DetachLoadBalancers

instance Prelude.NFData DetachLoadBalancers

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

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

instance Core.ToQuery DetachLoadBalancers where
  toQuery :: DetachLoadBalancers -> QueryString
toQuery DetachLoadBalancers' {[Text]
Text
loadBalancerNames :: [Text]
autoScalingGroupName :: Text
$sel:loadBalancerNames:DetachLoadBalancers' :: DetachLoadBalancers -> [Text]
$sel:autoScalingGroupName:DetachLoadBalancers' :: DetachLoadBalancers -> 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
"DetachLoadBalancers" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"AutoScalingGroupName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
autoScalingGroupName,
        ByteString
"LoadBalancerNames"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [Text]
loadBalancerNames
      ]

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

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

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

instance Prelude.NFData DetachLoadBalancersResponse