{-# 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.DetachTrafficSources
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- __Reserved for use with Amazon VPC Lattice, which is in preview and
-- subject to change. Do not use this API for production workloads. This
-- API is also subject to change.__
--
-- Detaches one or more traffic sources from the specified Auto Scaling
-- group.
module Amazonka.AutoScaling.DetachTrafficSources
  ( -- * Creating a Request
    DetachTrafficSources (..),
    newDetachTrafficSources,

    -- * Request Lenses
    detachTrafficSources_autoScalingGroupName,
    detachTrafficSources_trafficSources,

    -- * Destructuring the Response
    DetachTrafficSourcesResponse (..),
    newDetachTrafficSourcesResponse,

    -- * Response Lenses
    detachTrafficSourcesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDetachTrafficSources' smart constructor.
data DetachTrafficSources = DetachTrafficSources'
  { -- | The name of the Auto Scaling group.
    DetachTrafficSources -> Text
autoScalingGroupName :: Prelude.Text,
    -- | The unique identifiers of one or more traffic sources you are detaching.
    -- You can specify up to 10 traffic sources.
    --
    -- Currently, you must specify an Amazon Resource Name (ARN) for an
    -- existing VPC Lattice target group. When you detach a target group, it
    -- enters the @Removing@ state while deregistering the instances in the
    -- group. When all instances are deregistered, then you can no longer
    -- describe the target group using the DescribeTrafficSources API call. The
    -- instances continue to run.
    DetachTrafficSources -> [TrafficSourceIdentifier]
trafficSources :: [TrafficSourceIdentifier]
  }
  deriving (DetachTrafficSources -> DetachTrafficSources -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetachTrafficSources -> DetachTrafficSources -> Bool
$c/= :: DetachTrafficSources -> DetachTrafficSources -> Bool
== :: DetachTrafficSources -> DetachTrafficSources -> Bool
$c== :: DetachTrafficSources -> DetachTrafficSources -> Bool
Prelude.Eq, ReadPrec [DetachTrafficSources]
ReadPrec DetachTrafficSources
Int -> ReadS DetachTrafficSources
ReadS [DetachTrafficSources]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetachTrafficSources]
$creadListPrec :: ReadPrec [DetachTrafficSources]
readPrec :: ReadPrec DetachTrafficSources
$creadPrec :: ReadPrec DetachTrafficSources
readList :: ReadS [DetachTrafficSources]
$creadList :: ReadS [DetachTrafficSources]
readsPrec :: Int -> ReadS DetachTrafficSources
$creadsPrec :: Int -> ReadS DetachTrafficSources
Prelude.Read, Int -> DetachTrafficSources -> ShowS
[DetachTrafficSources] -> ShowS
DetachTrafficSources -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetachTrafficSources] -> ShowS
$cshowList :: [DetachTrafficSources] -> ShowS
show :: DetachTrafficSources -> String
$cshow :: DetachTrafficSources -> String
showsPrec :: Int -> DetachTrafficSources -> ShowS
$cshowsPrec :: Int -> DetachTrafficSources -> ShowS
Prelude.Show, forall x. Rep DetachTrafficSources x -> DetachTrafficSources
forall x. DetachTrafficSources -> Rep DetachTrafficSources x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetachTrafficSources x -> DetachTrafficSources
$cfrom :: forall x. DetachTrafficSources -> Rep DetachTrafficSources x
Prelude.Generic)

-- |
-- Create a value of 'DetachTrafficSources' 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', 'detachTrafficSources_autoScalingGroupName' - The name of the Auto Scaling group.
--
-- 'trafficSources', 'detachTrafficSources_trafficSources' - The unique identifiers of one or more traffic sources you are detaching.
-- You can specify up to 10 traffic sources.
--
-- Currently, you must specify an Amazon Resource Name (ARN) for an
-- existing VPC Lattice target group. When you detach a target group, it
-- enters the @Removing@ state while deregistering the instances in the
-- group. When all instances are deregistered, then you can no longer
-- describe the target group using the DescribeTrafficSources API call. The
-- instances continue to run.
newDetachTrafficSources ::
  -- | 'autoScalingGroupName'
  Prelude.Text ->
  DetachTrafficSources
newDetachTrafficSources :: Text -> DetachTrafficSources
newDetachTrafficSources Text
pAutoScalingGroupName_ =
  DetachTrafficSources'
    { $sel:autoScalingGroupName:DetachTrafficSources' :: Text
autoScalingGroupName =
        Text
pAutoScalingGroupName_,
      $sel:trafficSources:DetachTrafficSources' :: [TrafficSourceIdentifier]
trafficSources = forall a. Monoid a => a
Prelude.mempty
    }

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

-- | The unique identifiers of one or more traffic sources you are detaching.
-- You can specify up to 10 traffic sources.
--
-- Currently, you must specify an Amazon Resource Name (ARN) for an
-- existing VPC Lattice target group. When you detach a target group, it
-- enters the @Removing@ state while deregistering the instances in the
-- group. When all instances are deregistered, then you can no longer
-- describe the target group using the DescribeTrafficSources API call. The
-- instances continue to run.
detachTrafficSources_trafficSources :: Lens.Lens' DetachTrafficSources [TrafficSourceIdentifier]
detachTrafficSources_trafficSources :: Lens' DetachTrafficSources [TrafficSourceIdentifier]
detachTrafficSources_trafficSources = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachTrafficSources' {[TrafficSourceIdentifier]
trafficSources :: [TrafficSourceIdentifier]
$sel:trafficSources:DetachTrafficSources' :: DetachTrafficSources -> [TrafficSourceIdentifier]
trafficSources} -> [TrafficSourceIdentifier]
trafficSources) (\s :: DetachTrafficSources
s@DetachTrafficSources' {} [TrafficSourceIdentifier]
a -> DetachTrafficSources
s {$sel:trafficSources:DetachTrafficSources' :: [TrafficSourceIdentifier]
trafficSources = [TrafficSourceIdentifier]
a} :: DetachTrafficSources) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest DetachTrafficSources where
  type
    AWSResponse DetachTrafficSources =
      DetachTrafficSourcesResponse
  request :: (Service -> Service)
-> DetachTrafficSources -> Request DetachTrafficSources
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DetachTrafficSources
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DetachTrafficSources)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DetachTrafficSourcesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> DetachTrafficSourcesResponse
DetachTrafficSourcesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DetachTrafficSources where
  hashWithSalt :: Int -> DetachTrafficSources -> Int
hashWithSalt Int
_salt DetachTrafficSources' {[TrafficSourceIdentifier]
Text
trafficSources :: [TrafficSourceIdentifier]
autoScalingGroupName :: Text
$sel:trafficSources:DetachTrafficSources' :: DetachTrafficSources -> [TrafficSourceIdentifier]
$sel:autoScalingGroupName:DetachTrafficSources' :: DetachTrafficSources -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
autoScalingGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [TrafficSourceIdentifier]
trafficSources

instance Prelude.NFData DetachTrafficSources where
  rnf :: DetachTrafficSources -> ()
rnf DetachTrafficSources' {[TrafficSourceIdentifier]
Text
trafficSources :: [TrafficSourceIdentifier]
autoScalingGroupName :: Text
$sel:trafficSources:DetachTrafficSources' :: DetachTrafficSources -> [TrafficSourceIdentifier]
$sel:autoScalingGroupName:DetachTrafficSources' :: DetachTrafficSources -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
autoScalingGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [TrafficSourceIdentifier]
trafficSources

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

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

instance Data.ToQuery DetachTrafficSources where
  toQuery :: DetachTrafficSources -> QueryString
toQuery DetachTrafficSources' {[TrafficSourceIdentifier]
Text
trafficSources :: [TrafficSourceIdentifier]
autoScalingGroupName :: Text
$sel:trafficSources:DetachTrafficSources' :: DetachTrafficSources -> [TrafficSourceIdentifier]
$sel:autoScalingGroupName:DetachTrafficSources' :: DetachTrafficSources -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DetachTrafficSources" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"AutoScalingGroupName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
autoScalingGroupName,
        ByteString
"TrafficSources"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" [TrafficSourceIdentifier]
trafficSources
      ]

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

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

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

instance Prelude.NFData DetachTrafficSourcesResponse where
  rnf :: DetachTrafficSourcesResponse -> ()
rnf DetachTrafficSourcesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DetachTrafficSourcesResponse' :: DetachTrafficSourcesResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus