{-# 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.DescribeLoadBalancerTargetGroups
-- 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)
--
-- Gets information about the load balancer target groups for the specified
-- Auto Scaling group.
--
-- To determine the availability of registered instances, use the @State@
-- element in the response. When you attach a target group to an Auto
-- Scaling group, the initial @State@ value is @Adding@. The state
-- transitions to @Added@ after all Auto Scaling instances are registered
-- with the target group. If Elastic Load Balancing health checks are
-- enabled for the Auto Scaling group, the state transitions to @InService@
-- after at least one Auto Scaling instance passes the health check. When
-- the target group is in the @InService@ state, Amazon EC2 Auto Scaling
-- can terminate and replace any instances that are reported as unhealthy.
-- If no registered instances pass the health checks, the target group
-- doesn\'t enter the @InService@ state.
--
-- Target groups also have an @InService@ state if you attach them in the
-- CreateAutoScalingGroup API call. If your target group state is
-- @InService@, but it is not working properly, check the scaling
-- activities by calling DescribeScalingActivities and take any corrective
-- actions necessary.
--
-- For help with failed health checks, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/ts-as-healthchecks.html Troubleshooting Amazon EC2 Auto Scaling: Health checks>
-- in the /Amazon EC2 Auto Scaling User Guide/. For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/autoscaling-load-balancer.html Elastic Load Balancing and Amazon EC2 Auto Scaling>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- This operation returns paginated results.
module Amazonka.AutoScaling.DescribeLoadBalancerTargetGroups
  ( -- * Creating a Request
    DescribeLoadBalancerTargetGroups (..),
    newDescribeLoadBalancerTargetGroups,

    -- * Request Lenses
    describeLoadBalancerTargetGroups_nextToken,
    describeLoadBalancerTargetGroups_maxRecords,
    describeLoadBalancerTargetGroups_autoScalingGroupName,

    -- * Destructuring the Response
    DescribeLoadBalancerTargetGroupsResponse (..),
    newDescribeLoadBalancerTargetGroupsResponse,

    -- * Response Lenses
    describeLoadBalancerTargetGroupsResponse_loadBalancerTargetGroups,
    describeLoadBalancerTargetGroupsResponse_nextToken,
    describeLoadBalancerTargetGroupsResponse_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:/ 'newDescribeLoadBalancerTargetGroups' smart constructor.
data DescribeLoadBalancerTargetGroups = DescribeLoadBalancerTargetGroups'
  { -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    DescribeLoadBalancerTargetGroups -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to return with this call. The default value
    -- is @100@ and the maximum value is @100@.
    DescribeLoadBalancerTargetGroups -> Maybe Int
maxRecords :: Prelude.Maybe Prelude.Int,
    -- | The name of the Auto Scaling group.
    DescribeLoadBalancerTargetGroups -> Text
autoScalingGroupName :: Prelude.Text
  }
  deriving (DescribeLoadBalancerTargetGroups
-> DescribeLoadBalancerTargetGroups -> Bool
(DescribeLoadBalancerTargetGroups
 -> DescribeLoadBalancerTargetGroups -> Bool)
-> (DescribeLoadBalancerTargetGroups
    -> DescribeLoadBalancerTargetGroups -> Bool)
-> Eq DescribeLoadBalancerTargetGroups
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLoadBalancerTargetGroups
-> DescribeLoadBalancerTargetGroups -> Bool
$c/= :: DescribeLoadBalancerTargetGroups
-> DescribeLoadBalancerTargetGroups -> Bool
== :: DescribeLoadBalancerTargetGroups
-> DescribeLoadBalancerTargetGroups -> Bool
$c== :: DescribeLoadBalancerTargetGroups
-> DescribeLoadBalancerTargetGroups -> Bool
Prelude.Eq, ReadPrec [DescribeLoadBalancerTargetGroups]
ReadPrec DescribeLoadBalancerTargetGroups
Int -> ReadS DescribeLoadBalancerTargetGroups
ReadS [DescribeLoadBalancerTargetGroups]
(Int -> ReadS DescribeLoadBalancerTargetGroups)
-> ReadS [DescribeLoadBalancerTargetGroups]
-> ReadPrec DescribeLoadBalancerTargetGroups
-> ReadPrec [DescribeLoadBalancerTargetGroups]
-> Read DescribeLoadBalancerTargetGroups
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLoadBalancerTargetGroups]
$creadListPrec :: ReadPrec [DescribeLoadBalancerTargetGroups]
readPrec :: ReadPrec DescribeLoadBalancerTargetGroups
$creadPrec :: ReadPrec DescribeLoadBalancerTargetGroups
readList :: ReadS [DescribeLoadBalancerTargetGroups]
$creadList :: ReadS [DescribeLoadBalancerTargetGroups]
readsPrec :: Int -> ReadS DescribeLoadBalancerTargetGroups
$creadsPrec :: Int -> ReadS DescribeLoadBalancerTargetGroups
Prelude.Read, Int -> DescribeLoadBalancerTargetGroups -> ShowS
[DescribeLoadBalancerTargetGroups] -> ShowS
DescribeLoadBalancerTargetGroups -> String
(Int -> DescribeLoadBalancerTargetGroups -> ShowS)
-> (DescribeLoadBalancerTargetGroups -> String)
-> ([DescribeLoadBalancerTargetGroups] -> ShowS)
-> Show DescribeLoadBalancerTargetGroups
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLoadBalancerTargetGroups] -> ShowS
$cshowList :: [DescribeLoadBalancerTargetGroups] -> ShowS
show :: DescribeLoadBalancerTargetGroups -> String
$cshow :: DescribeLoadBalancerTargetGroups -> String
showsPrec :: Int -> DescribeLoadBalancerTargetGroups -> ShowS
$cshowsPrec :: Int -> DescribeLoadBalancerTargetGroups -> ShowS
Prelude.Show, (forall x.
 DescribeLoadBalancerTargetGroups
 -> Rep DescribeLoadBalancerTargetGroups x)
-> (forall x.
    Rep DescribeLoadBalancerTargetGroups x
    -> DescribeLoadBalancerTargetGroups)
-> Generic DescribeLoadBalancerTargetGroups
forall x.
Rep DescribeLoadBalancerTargetGroups x
-> DescribeLoadBalancerTargetGroups
forall x.
DescribeLoadBalancerTargetGroups
-> Rep DescribeLoadBalancerTargetGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeLoadBalancerTargetGroups x
-> DescribeLoadBalancerTargetGroups
$cfrom :: forall x.
DescribeLoadBalancerTargetGroups
-> Rep DescribeLoadBalancerTargetGroups x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLoadBalancerTargetGroups' 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:
--
-- 'nextToken', 'describeLoadBalancerTargetGroups_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
--
-- 'maxRecords', 'describeLoadBalancerTargetGroups_maxRecords' - The maximum number of items to return with this call. The default value
-- is @100@ and the maximum value is @100@.
--
-- 'autoScalingGroupName', 'describeLoadBalancerTargetGroups_autoScalingGroupName' - The name of the Auto Scaling group.
newDescribeLoadBalancerTargetGroups ::
  -- | 'autoScalingGroupName'
  Prelude.Text ->
  DescribeLoadBalancerTargetGroups
newDescribeLoadBalancerTargetGroups :: Text -> DescribeLoadBalancerTargetGroups
newDescribeLoadBalancerTargetGroups
  Text
pAutoScalingGroupName_ =
    DescribeLoadBalancerTargetGroups' :: Maybe Text -> Maybe Int -> Text -> DescribeLoadBalancerTargetGroups
DescribeLoadBalancerTargetGroups'
      { $sel:nextToken:DescribeLoadBalancerTargetGroups' :: Maybe Text
nextToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:maxRecords:DescribeLoadBalancerTargetGroups' :: Maybe Int
maxRecords = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:autoScalingGroupName:DescribeLoadBalancerTargetGroups' :: Text
autoScalingGroupName =
          Text
pAutoScalingGroupName_
      }

-- | The token for the next set of items to return. (You received this token
-- from a previous call.)
describeLoadBalancerTargetGroups_nextToken :: Lens.Lens' DescribeLoadBalancerTargetGroups (Prelude.Maybe Prelude.Text)
describeLoadBalancerTargetGroups_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeLoadBalancerTargetGroups
-> f DescribeLoadBalancerTargetGroups
describeLoadBalancerTargetGroups_nextToken = (DescribeLoadBalancerTargetGroups -> Maybe Text)
-> (DescribeLoadBalancerTargetGroups
    -> Maybe Text -> DescribeLoadBalancerTargetGroups)
-> Lens
     DescribeLoadBalancerTargetGroups
     DescribeLoadBalancerTargetGroups
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLoadBalancerTargetGroups' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeLoadBalancerTargetGroups' :: DescribeLoadBalancerTargetGroups -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeLoadBalancerTargetGroups
s@DescribeLoadBalancerTargetGroups' {} Maybe Text
a -> DescribeLoadBalancerTargetGroups
s {$sel:nextToken:DescribeLoadBalancerTargetGroups' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeLoadBalancerTargetGroups)

-- | The maximum number of items to return with this call. The default value
-- is @100@ and the maximum value is @100@.
describeLoadBalancerTargetGroups_maxRecords :: Lens.Lens' DescribeLoadBalancerTargetGroups (Prelude.Maybe Prelude.Int)
describeLoadBalancerTargetGroups_maxRecords :: (Maybe Int -> f (Maybe Int))
-> DescribeLoadBalancerTargetGroups
-> f DescribeLoadBalancerTargetGroups
describeLoadBalancerTargetGroups_maxRecords = (DescribeLoadBalancerTargetGroups -> Maybe Int)
-> (DescribeLoadBalancerTargetGroups
    -> Maybe Int -> DescribeLoadBalancerTargetGroups)
-> Lens
     DescribeLoadBalancerTargetGroups
     DescribeLoadBalancerTargetGroups
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLoadBalancerTargetGroups' {Maybe Int
maxRecords :: Maybe Int
$sel:maxRecords:DescribeLoadBalancerTargetGroups' :: DescribeLoadBalancerTargetGroups -> Maybe Int
maxRecords} -> Maybe Int
maxRecords) (\s :: DescribeLoadBalancerTargetGroups
s@DescribeLoadBalancerTargetGroups' {} Maybe Int
a -> DescribeLoadBalancerTargetGroups
s {$sel:maxRecords:DescribeLoadBalancerTargetGroups' :: Maybe Int
maxRecords = Maybe Int
a} :: DescribeLoadBalancerTargetGroups)

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

instance
  Core.AWSPager
    DescribeLoadBalancerTargetGroups
  where
  page :: DescribeLoadBalancerTargetGroups
-> AWSResponse DescribeLoadBalancerTargetGroups
-> Maybe DescribeLoadBalancerTargetGroups
page DescribeLoadBalancerTargetGroups
rq AWSResponse DescribeLoadBalancerTargetGroups
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeLoadBalancerTargetGroups
DescribeLoadBalancerTargetGroupsResponse
rs
            DescribeLoadBalancerTargetGroupsResponse
-> Getting
     (First Text) DescribeLoadBalancerTargetGroupsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeLoadBalancerTargetGroupsResponse
-> Const (First Text) DescribeLoadBalancerTargetGroupsResponse
Lens' DescribeLoadBalancerTargetGroupsResponse (Maybe Text)
describeLoadBalancerTargetGroupsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeLoadBalancerTargetGroupsResponse
 -> Const (First Text) DescribeLoadBalancerTargetGroupsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) DescribeLoadBalancerTargetGroupsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeLoadBalancerTargetGroups
forall a. Maybe a
Prelude.Nothing
    | Maybe [LoadBalancerTargetGroupState] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeLoadBalancerTargetGroups
DescribeLoadBalancerTargetGroupsResponse
rs
            DescribeLoadBalancerTargetGroupsResponse
-> Getting
     (First [LoadBalancerTargetGroupState])
     DescribeLoadBalancerTargetGroupsResponse
     [LoadBalancerTargetGroupState]
-> Maybe [LoadBalancerTargetGroupState]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [LoadBalancerTargetGroupState]
 -> Const
      (First [LoadBalancerTargetGroupState])
      (Maybe [LoadBalancerTargetGroupState]))
-> DescribeLoadBalancerTargetGroupsResponse
-> Const
     (First [LoadBalancerTargetGroupState])
     DescribeLoadBalancerTargetGroupsResponse
Lens'
  DescribeLoadBalancerTargetGroupsResponse
  (Maybe [LoadBalancerTargetGroupState])
describeLoadBalancerTargetGroupsResponse_loadBalancerTargetGroups
              ((Maybe [LoadBalancerTargetGroupState]
  -> Const
       (First [LoadBalancerTargetGroupState])
       (Maybe [LoadBalancerTargetGroupState]))
 -> DescribeLoadBalancerTargetGroupsResponse
 -> Const
      (First [LoadBalancerTargetGroupState])
      DescribeLoadBalancerTargetGroupsResponse)
-> (([LoadBalancerTargetGroupState]
     -> Const
          (First [LoadBalancerTargetGroupState])
          [LoadBalancerTargetGroupState])
    -> Maybe [LoadBalancerTargetGroupState]
    -> Const
         (First [LoadBalancerTargetGroupState])
         (Maybe [LoadBalancerTargetGroupState]))
-> Getting
     (First [LoadBalancerTargetGroupState])
     DescribeLoadBalancerTargetGroupsResponse
     [LoadBalancerTargetGroupState]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([LoadBalancerTargetGroupState]
 -> Const
      (First [LoadBalancerTargetGroupState])
      [LoadBalancerTargetGroupState])
-> Maybe [LoadBalancerTargetGroupState]
-> Const
     (First [LoadBalancerTargetGroupState])
     (Maybe [LoadBalancerTargetGroupState])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeLoadBalancerTargetGroups
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeLoadBalancerTargetGroups
-> Maybe DescribeLoadBalancerTargetGroups
forall a. a -> Maybe a
Prelude.Just (DescribeLoadBalancerTargetGroups
 -> Maybe DescribeLoadBalancerTargetGroups)
-> DescribeLoadBalancerTargetGroups
-> Maybe DescribeLoadBalancerTargetGroups
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeLoadBalancerTargetGroups
rq
          DescribeLoadBalancerTargetGroups
-> (DescribeLoadBalancerTargetGroups
    -> DescribeLoadBalancerTargetGroups)
-> DescribeLoadBalancerTargetGroups
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeLoadBalancerTargetGroups
-> Identity DescribeLoadBalancerTargetGroups
Lens
  DescribeLoadBalancerTargetGroups
  DescribeLoadBalancerTargetGroups
  (Maybe Text)
  (Maybe Text)
describeLoadBalancerTargetGroups_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeLoadBalancerTargetGroups
 -> Identity DescribeLoadBalancerTargetGroups)
-> Maybe Text
-> DescribeLoadBalancerTargetGroups
-> DescribeLoadBalancerTargetGroups
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeLoadBalancerTargetGroups
DescribeLoadBalancerTargetGroupsResponse
rs
          DescribeLoadBalancerTargetGroupsResponse
-> Getting
     (First Text) DescribeLoadBalancerTargetGroupsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeLoadBalancerTargetGroupsResponse
-> Const (First Text) DescribeLoadBalancerTargetGroupsResponse
Lens' DescribeLoadBalancerTargetGroupsResponse (Maybe Text)
describeLoadBalancerTargetGroupsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeLoadBalancerTargetGroupsResponse
 -> Const (First Text) DescribeLoadBalancerTargetGroupsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) DescribeLoadBalancerTargetGroupsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance
  Core.AWSRequest
    DescribeLoadBalancerTargetGroups
  where
  type
    AWSResponse DescribeLoadBalancerTargetGroups =
      DescribeLoadBalancerTargetGroupsResponse
  request :: DescribeLoadBalancerTargetGroups
-> Request DescribeLoadBalancerTargetGroups
request = Service
-> DescribeLoadBalancerTargetGroups
-> Request DescribeLoadBalancerTargetGroups
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeLoadBalancerTargetGroups
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeLoadBalancerTargetGroups)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeLoadBalancerTargetGroups))
-> Logger
-> Service
-> Proxy DescribeLoadBalancerTargetGroups
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeLoadBalancerTargetGroups)))
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
"DescribeLoadBalancerTargetGroupsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [LoadBalancerTargetGroupState]
-> Maybe Text -> Int -> DescribeLoadBalancerTargetGroupsResponse
DescribeLoadBalancerTargetGroupsResponse'
            (Maybe [LoadBalancerTargetGroupState]
 -> Maybe Text -> Int -> DescribeLoadBalancerTargetGroupsResponse)
-> Either String (Maybe [LoadBalancerTargetGroupState])
-> Either
     String
     (Maybe Text -> Int -> DescribeLoadBalancerTargetGroupsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LoadBalancerTargetGroups"
                            Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [LoadBalancerTargetGroupState]))
-> Either String (Maybe [LoadBalancerTargetGroupState])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [LoadBalancerTargetGroupState])
-> [Node] -> Either String (Maybe [LoadBalancerTargetGroupState])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [LoadBalancerTargetGroupState]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either
  String
  (Maybe Text -> Int -> DescribeLoadBalancerTargetGroupsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeLoadBalancerTargetGroupsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"NextToken")
            Either String (Int -> DescribeLoadBalancerTargetGroupsResponse)
-> Either String Int
-> Either String DescribeLoadBalancerTargetGroupsResponse
forall (f :: * -> *) a b. Applicative f => 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
    DescribeLoadBalancerTargetGroups

instance
  Prelude.NFData
    DescribeLoadBalancerTargetGroups

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

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

instance
  Core.ToQuery
    DescribeLoadBalancerTargetGroups
  where
  toQuery :: DescribeLoadBalancerTargetGroups -> QueryString
toQuery DescribeLoadBalancerTargetGroups' {Maybe Int
Maybe Text
Text
autoScalingGroupName :: Text
maxRecords :: Maybe Int
nextToken :: Maybe Text
$sel:autoScalingGroupName:DescribeLoadBalancerTargetGroups' :: DescribeLoadBalancerTargetGroups -> Text
$sel:maxRecords:DescribeLoadBalancerTargetGroups' :: DescribeLoadBalancerTargetGroups -> Maybe Int
$sel:nextToken:DescribeLoadBalancerTargetGroups' :: DescribeLoadBalancerTargetGroups -> Maybe 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
"DescribeLoadBalancerTargetGroups" ::
                      Prelude.ByteString
                  ),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"NextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"MaxRecords" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
maxRecords,
        ByteString
"AutoScalingGroupName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
autoScalingGroupName
      ]

-- | /See:/ 'newDescribeLoadBalancerTargetGroupsResponse' smart constructor.
data DescribeLoadBalancerTargetGroupsResponse = DescribeLoadBalancerTargetGroupsResponse'
  { -- | Information about the target groups.
    DescribeLoadBalancerTargetGroupsResponse
-> Maybe [LoadBalancerTargetGroupState]
loadBalancerTargetGroups :: Prelude.Maybe [LoadBalancerTargetGroupState],
    -- | A string that indicates that the response contains more items than can
    -- be returned in a single response. To receive additional items, specify
    -- this string for the @NextToken@ value when requesting the next set of
    -- items. This value is null when there are no more items to return.
    DescribeLoadBalancerTargetGroupsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeLoadBalancerTargetGroupsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeLoadBalancerTargetGroupsResponse
-> DescribeLoadBalancerTargetGroupsResponse -> Bool
(DescribeLoadBalancerTargetGroupsResponse
 -> DescribeLoadBalancerTargetGroupsResponse -> Bool)
-> (DescribeLoadBalancerTargetGroupsResponse
    -> DescribeLoadBalancerTargetGroupsResponse -> Bool)
-> Eq DescribeLoadBalancerTargetGroupsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLoadBalancerTargetGroupsResponse
-> DescribeLoadBalancerTargetGroupsResponse -> Bool
$c/= :: DescribeLoadBalancerTargetGroupsResponse
-> DescribeLoadBalancerTargetGroupsResponse -> Bool
== :: DescribeLoadBalancerTargetGroupsResponse
-> DescribeLoadBalancerTargetGroupsResponse -> Bool
$c== :: DescribeLoadBalancerTargetGroupsResponse
-> DescribeLoadBalancerTargetGroupsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeLoadBalancerTargetGroupsResponse]
ReadPrec DescribeLoadBalancerTargetGroupsResponse
Int -> ReadS DescribeLoadBalancerTargetGroupsResponse
ReadS [DescribeLoadBalancerTargetGroupsResponse]
(Int -> ReadS DescribeLoadBalancerTargetGroupsResponse)
-> ReadS [DescribeLoadBalancerTargetGroupsResponse]
-> ReadPrec DescribeLoadBalancerTargetGroupsResponse
-> ReadPrec [DescribeLoadBalancerTargetGroupsResponse]
-> Read DescribeLoadBalancerTargetGroupsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLoadBalancerTargetGroupsResponse]
$creadListPrec :: ReadPrec [DescribeLoadBalancerTargetGroupsResponse]
readPrec :: ReadPrec DescribeLoadBalancerTargetGroupsResponse
$creadPrec :: ReadPrec DescribeLoadBalancerTargetGroupsResponse
readList :: ReadS [DescribeLoadBalancerTargetGroupsResponse]
$creadList :: ReadS [DescribeLoadBalancerTargetGroupsResponse]
readsPrec :: Int -> ReadS DescribeLoadBalancerTargetGroupsResponse
$creadsPrec :: Int -> ReadS DescribeLoadBalancerTargetGroupsResponse
Prelude.Read, Int -> DescribeLoadBalancerTargetGroupsResponse -> ShowS
[DescribeLoadBalancerTargetGroupsResponse] -> ShowS
DescribeLoadBalancerTargetGroupsResponse -> String
(Int -> DescribeLoadBalancerTargetGroupsResponse -> ShowS)
-> (DescribeLoadBalancerTargetGroupsResponse -> String)
-> ([DescribeLoadBalancerTargetGroupsResponse] -> ShowS)
-> Show DescribeLoadBalancerTargetGroupsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLoadBalancerTargetGroupsResponse] -> ShowS
$cshowList :: [DescribeLoadBalancerTargetGroupsResponse] -> ShowS
show :: DescribeLoadBalancerTargetGroupsResponse -> String
$cshow :: DescribeLoadBalancerTargetGroupsResponse -> String
showsPrec :: Int -> DescribeLoadBalancerTargetGroupsResponse -> ShowS
$cshowsPrec :: Int -> DescribeLoadBalancerTargetGroupsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeLoadBalancerTargetGroupsResponse
 -> Rep DescribeLoadBalancerTargetGroupsResponse x)
-> (forall x.
    Rep DescribeLoadBalancerTargetGroupsResponse x
    -> DescribeLoadBalancerTargetGroupsResponse)
-> Generic DescribeLoadBalancerTargetGroupsResponse
forall x.
Rep DescribeLoadBalancerTargetGroupsResponse x
-> DescribeLoadBalancerTargetGroupsResponse
forall x.
DescribeLoadBalancerTargetGroupsResponse
-> Rep DescribeLoadBalancerTargetGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeLoadBalancerTargetGroupsResponse x
-> DescribeLoadBalancerTargetGroupsResponse
$cfrom :: forall x.
DescribeLoadBalancerTargetGroupsResponse
-> Rep DescribeLoadBalancerTargetGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLoadBalancerTargetGroupsResponse' 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:
--
-- 'loadBalancerTargetGroups', 'describeLoadBalancerTargetGroupsResponse_loadBalancerTargetGroups' - Information about the target groups.
--
-- 'nextToken', 'describeLoadBalancerTargetGroupsResponse_nextToken' - A string that indicates that the response contains more items than can
-- be returned in a single response. To receive additional items, specify
-- this string for the @NextToken@ value when requesting the next set of
-- items. This value is null when there are no more items to return.
--
-- 'httpStatus', 'describeLoadBalancerTargetGroupsResponse_httpStatus' - The response's http status code.
newDescribeLoadBalancerTargetGroupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeLoadBalancerTargetGroupsResponse
newDescribeLoadBalancerTargetGroupsResponse :: Int -> DescribeLoadBalancerTargetGroupsResponse
newDescribeLoadBalancerTargetGroupsResponse
  Int
pHttpStatus_ =
    DescribeLoadBalancerTargetGroupsResponse' :: Maybe [LoadBalancerTargetGroupState]
-> Maybe Text -> Int -> DescribeLoadBalancerTargetGroupsResponse
DescribeLoadBalancerTargetGroupsResponse'
      { $sel:loadBalancerTargetGroups:DescribeLoadBalancerTargetGroupsResponse' :: Maybe [LoadBalancerTargetGroupState]
loadBalancerTargetGroups =
          Maybe [LoadBalancerTargetGroupState]
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:DescribeLoadBalancerTargetGroupsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeLoadBalancerTargetGroupsResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | Information about the target groups.
describeLoadBalancerTargetGroupsResponse_loadBalancerTargetGroups :: Lens.Lens' DescribeLoadBalancerTargetGroupsResponse (Prelude.Maybe [LoadBalancerTargetGroupState])
describeLoadBalancerTargetGroupsResponse_loadBalancerTargetGroups :: (Maybe [LoadBalancerTargetGroupState]
 -> f (Maybe [LoadBalancerTargetGroupState]))
-> DescribeLoadBalancerTargetGroupsResponse
-> f DescribeLoadBalancerTargetGroupsResponse
describeLoadBalancerTargetGroupsResponse_loadBalancerTargetGroups = (DescribeLoadBalancerTargetGroupsResponse
 -> Maybe [LoadBalancerTargetGroupState])
-> (DescribeLoadBalancerTargetGroupsResponse
    -> Maybe [LoadBalancerTargetGroupState]
    -> DescribeLoadBalancerTargetGroupsResponse)
-> Lens'
     DescribeLoadBalancerTargetGroupsResponse
     (Maybe [LoadBalancerTargetGroupState])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLoadBalancerTargetGroupsResponse' {Maybe [LoadBalancerTargetGroupState]
loadBalancerTargetGroups :: Maybe [LoadBalancerTargetGroupState]
$sel:loadBalancerTargetGroups:DescribeLoadBalancerTargetGroupsResponse' :: DescribeLoadBalancerTargetGroupsResponse
-> Maybe [LoadBalancerTargetGroupState]
loadBalancerTargetGroups} -> Maybe [LoadBalancerTargetGroupState]
loadBalancerTargetGroups) (\s :: DescribeLoadBalancerTargetGroupsResponse
s@DescribeLoadBalancerTargetGroupsResponse' {} Maybe [LoadBalancerTargetGroupState]
a -> DescribeLoadBalancerTargetGroupsResponse
s {$sel:loadBalancerTargetGroups:DescribeLoadBalancerTargetGroupsResponse' :: Maybe [LoadBalancerTargetGroupState]
loadBalancerTargetGroups = Maybe [LoadBalancerTargetGroupState]
a} :: DescribeLoadBalancerTargetGroupsResponse) ((Maybe [LoadBalancerTargetGroupState]
  -> f (Maybe [LoadBalancerTargetGroupState]))
 -> DescribeLoadBalancerTargetGroupsResponse
 -> f DescribeLoadBalancerTargetGroupsResponse)
-> ((Maybe [LoadBalancerTargetGroupState]
     -> f (Maybe [LoadBalancerTargetGroupState]))
    -> Maybe [LoadBalancerTargetGroupState]
    -> f (Maybe [LoadBalancerTargetGroupState]))
-> (Maybe [LoadBalancerTargetGroupState]
    -> f (Maybe [LoadBalancerTargetGroupState]))
-> DescribeLoadBalancerTargetGroupsResponse
-> f DescribeLoadBalancerTargetGroupsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [LoadBalancerTargetGroupState]
  [LoadBalancerTargetGroupState]
  [LoadBalancerTargetGroupState]
  [LoadBalancerTargetGroupState]
-> Iso
     (Maybe [LoadBalancerTargetGroupState])
     (Maybe [LoadBalancerTargetGroupState])
     (Maybe [LoadBalancerTargetGroupState])
     (Maybe [LoadBalancerTargetGroupState])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [LoadBalancerTargetGroupState]
  [LoadBalancerTargetGroupState]
  [LoadBalancerTargetGroupState]
  [LoadBalancerTargetGroupState]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A string that indicates that the response contains more items than can
-- be returned in a single response. To receive additional items, specify
-- this string for the @NextToken@ value when requesting the next set of
-- items. This value is null when there are no more items to return.
describeLoadBalancerTargetGroupsResponse_nextToken :: Lens.Lens' DescribeLoadBalancerTargetGroupsResponse (Prelude.Maybe Prelude.Text)
describeLoadBalancerTargetGroupsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeLoadBalancerTargetGroupsResponse
-> f DescribeLoadBalancerTargetGroupsResponse
describeLoadBalancerTargetGroupsResponse_nextToken = (DescribeLoadBalancerTargetGroupsResponse -> Maybe Text)
-> (DescribeLoadBalancerTargetGroupsResponse
    -> Maybe Text -> DescribeLoadBalancerTargetGroupsResponse)
-> Lens' DescribeLoadBalancerTargetGroupsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLoadBalancerTargetGroupsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeLoadBalancerTargetGroupsResponse' :: DescribeLoadBalancerTargetGroupsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeLoadBalancerTargetGroupsResponse
s@DescribeLoadBalancerTargetGroupsResponse' {} Maybe Text
a -> DescribeLoadBalancerTargetGroupsResponse
s {$sel:nextToken:DescribeLoadBalancerTargetGroupsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeLoadBalancerTargetGroupsResponse)

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

instance
  Prelude.NFData
    DescribeLoadBalancerTargetGroupsResponse