{-# 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.ELBV2.DeregisterTargets
-- 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)
--
-- Deregisters the specified targets from the specified target group. After
-- the targets are deregistered, they no longer receive traffic from the
-- load balancer.
module Amazonka.ELBV2.DeregisterTargets
  ( -- * Creating a Request
    DeregisterTargets (..),
    newDeregisterTargets,

    -- * Request Lenses
    deregisterTargets_targetGroupArn,
    deregisterTargets_targets,

    -- * Destructuring the Response
    DeregisterTargetsResponse (..),
    newDeregisterTargetsResponse,

    -- * Response Lenses
    deregisterTargetsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeregisterTargets' smart constructor.
data DeregisterTargets = DeregisterTargets'
  { -- | The Amazon Resource Name (ARN) of the target group.
    DeregisterTargets -> Text
targetGroupArn :: Prelude.Text,
    -- | The targets. If you specified a port override when you registered a
    -- target, you must specify both the target ID and the port when you
    -- deregister it.
    DeregisterTargets -> [TargetDescription]
targets :: [TargetDescription]
  }
  deriving (DeregisterTargets -> DeregisterTargets -> Bool
(DeregisterTargets -> DeregisterTargets -> Bool)
-> (DeregisterTargets -> DeregisterTargets -> Bool)
-> Eq DeregisterTargets
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterTargets -> DeregisterTargets -> Bool
$c/= :: DeregisterTargets -> DeregisterTargets -> Bool
== :: DeregisterTargets -> DeregisterTargets -> Bool
$c== :: DeregisterTargets -> DeregisterTargets -> Bool
Prelude.Eq, ReadPrec [DeregisterTargets]
ReadPrec DeregisterTargets
Int -> ReadS DeregisterTargets
ReadS [DeregisterTargets]
(Int -> ReadS DeregisterTargets)
-> ReadS [DeregisterTargets]
-> ReadPrec DeregisterTargets
-> ReadPrec [DeregisterTargets]
-> Read DeregisterTargets
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterTargets]
$creadListPrec :: ReadPrec [DeregisterTargets]
readPrec :: ReadPrec DeregisterTargets
$creadPrec :: ReadPrec DeregisterTargets
readList :: ReadS [DeregisterTargets]
$creadList :: ReadS [DeregisterTargets]
readsPrec :: Int -> ReadS DeregisterTargets
$creadsPrec :: Int -> ReadS DeregisterTargets
Prelude.Read, Int -> DeregisterTargets -> ShowS
[DeregisterTargets] -> ShowS
DeregisterTargets -> String
(Int -> DeregisterTargets -> ShowS)
-> (DeregisterTargets -> String)
-> ([DeregisterTargets] -> ShowS)
-> Show DeregisterTargets
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterTargets] -> ShowS
$cshowList :: [DeregisterTargets] -> ShowS
show :: DeregisterTargets -> String
$cshow :: DeregisterTargets -> String
showsPrec :: Int -> DeregisterTargets -> ShowS
$cshowsPrec :: Int -> DeregisterTargets -> ShowS
Prelude.Show, (forall x. DeregisterTargets -> Rep DeregisterTargets x)
-> (forall x. Rep DeregisterTargets x -> DeregisterTargets)
-> Generic DeregisterTargets
forall x. Rep DeregisterTargets x -> DeregisterTargets
forall x. DeregisterTargets -> Rep DeregisterTargets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeregisterTargets x -> DeregisterTargets
$cfrom :: forall x. DeregisterTargets -> Rep DeregisterTargets x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterTargets' 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:
--
-- 'targetGroupArn', 'deregisterTargets_targetGroupArn' - The Amazon Resource Name (ARN) of the target group.
--
-- 'targets', 'deregisterTargets_targets' - The targets. If you specified a port override when you registered a
-- target, you must specify both the target ID and the port when you
-- deregister it.
newDeregisterTargets ::
  -- | 'targetGroupArn'
  Prelude.Text ->
  DeregisterTargets
newDeregisterTargets :: Text -> DeregisterTargets
newDeregisterTargets Text
pTargetGroupArn_ =
  DeregisterTargets' :: Text -> [TargetDescription] -> DeregisterTargets
DeregisterTargets'
    { $sel:targetGroupArn:DeregisterTargets' :: Text
targetGroupArn =
        Text
pTargetGroupArn_,
      $sel:targets:DeregisterTargets' :: [TargetDescription]
targets = [TargetDescription]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The Amazon Resource Name (ARN) of the target group.
deregisterTargets_targetGroupArn :: Lens.Lens' DeregisterTargets Prelude.Text
deregisterTargets_targetGroupArn :: (Text -> f Text) -> DeregisterTargets -> f DeregisterTargets
deregisterTargets_targetGroupArn = (DeregisterTargets -> Text)
-> (DeregisterTargets -> Text -> DeregisterTargets)
-> Lens DeregisterTargets DeregisterTargets Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterTargets' {Text
targetGroupArn :: Text
$sel:targetGroupArn:DeregisterTargets' :: DeregisterTargets -> Text
targetGroupArn} -> Text
targetGroupArn) (\s :: DeregisterTargets
s@DeregisterTargets' {} Text
a -> DeregisterTargets
s {$sel:targetGroupArn:DeregisterTargets' :: Text
targetGroupArn = Text
a} :: DeregisterTargets)

-- | The targets. If you specified a port override when you registered a
-- target, you must specify both the target ID and the port when you
-- deregister it.
deregisterTargets_targets :: Lens.Lens' DeregisterTargets [TargetDescription]
deregisterTargets_targets :: ([TargetDescription] -> f [TargetDescription])
-> DeregisterTargets -> f DeregisterTargets
deregisterTargets_targets = (DeregisterTargets -> [TargetDescription])
-> (DeregisterTargets -> [TargetDescription] -> DeregisterTargets)
-> Lens
     DeregisterTargets
     DeregisterTargets
     [TargetDescription]
     [TargetDescription]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterTargets' {[TargetDescription]
targets :: [TargetDescription]
$sel:targets:DeregisterTargets' :: DeregisterTargets -> [TargetDescription]
targets} -> [TargetDescription]
targets) (\s :: DeregisterTargets
s@DeregisterTargets' {} [TargetDescription]
a -> DeregisterTargets
s {$sel:targets:DeregisterTargets' :: [TargetDescription]
targets = [TargetDescription]
a} :: DeregisterTargets) (([TargetDescription] -> f [TargetDescription])
 -> DeregisterTargets -> f DeregisterTargets)
-> (([TargetDescription] -> f [TargetDescription])
    -> [TargetDescription] -> f [TargetDescription])
-> ([TargetDescription] -> f [TargetDescription])
-> DeregisterTargets
-> f DeregisterTargets
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([TargetDescription] -> f [TargetDescription])
-> [TargetDescription] -> f [TargetDescription]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DeregisterTargets

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

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

instance Core.ToQuery DeregisterTargets where
  toQuery :: DeregisterTargets -> QueryString
toQuery DeregisterTargets' {[TargetDescription]
Text
targets :: [TargetDescription]
targetGroupArn :: Text
$sel:targets:DeregisterTargets' :: DeregisterTargets -> [TargetDescription]
$sel:targetGroupArn:DeregisterTargets' :: DeregisterTargets -> 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
"DeregisterTargets" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-12-01" :: Prelude.ByteString),
        ByteString
"TargetGroupArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
targetGroupArn,
        ByteString
"Targets" ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [TargetDescription] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [TargetDescription]
targets
      ]

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

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

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

instance Prelude.NFData DeregisterTargetsResponse