{-# 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.DescribeTargetGroups
-- 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)
--
-- Describes the specified target groups or all of your target groups. By
-- default, all target groups are described. Alternatively, you can specify
-- one of the following to filter the results: the ARN of the load
-- balancer, the names of one or more target groups, or the ARNs of one or
-- more target groups.
--
-- This operation returns paginated results.
module Amazonka.ELBV2.DescribeTargetGroups
  ( -- * Creating a Request
    DescribeTargetGroups (..),
    newDescribeTargetGroups,

    -- * Request Lenses
    describeTargetGroups_targetGroupArns,
    describeTargetGroups_names,
    describeTargetGroups_loadBalancerArn,
    describeTargetGroups_marker,
    describeTargetGroups_pageSize,

    -- * Destructuring the Response
    DescribeTargetGroupsResponse (..),
    newDescribeTargetGroupsResponse,

    -- * Response Lenses
    describeTargetGroupsResponse_nextMarker,
    describeTargetGroupsResponse_targetGroups,
    describeTargetGroupsResponse_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:/ 'newDescribeTargetGroups' smart constructor.
data DescribeTargetGroups = DescribeTargetGroups'
  { -- | The Amazon Resource Names (ARN) of the target groups.
    DescribeTargetGroups -> Maybe [Text]
targetGroupArns :: Prelude.Maybe [Prelude.Text],
    -- | The names of the target groups.
    DescribeTargetGroups -> Maybe [Text]
names :: Prelude.Maybe [Prelude.Text],
    -- | The Amazon Resource Name (ARN) of the load balancer.
    DescribeTargetGroups -> Maybe Text
loadBalancerArn :: Prelude.Maybe Prelude.Text,
    -- | The marker for the next set of results. (You received this marker from a
    -- previous call.)
    DescribeTargetGroups -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return with this call.
    DescribeTargetGroups -> Maybe Natural
pageSize :: Prelude.Maybe Prelude.Natural
  }
  deriving (DescribeTargetGroups -> DescribeTargetGroups -> Bool
(DescribeTargetGroups -> DescribeTargetGroups -> Bool)
-> (DescribeTargetGroups -> DescribeTargetGroups -> Bool)
-> Eq DescribeTargetGroups
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeTargetGroups -> DescribeTargetGroups -> Bool
$c/= :: DescribeTargetGroups -> DescribeTargetGroups -> Bool
== :: DescribeTargetGroups -> DescribeTargetGroups -> Bool
$c== :: DescribeTargetGroups -> DescribeTargetGroups -> Bool
Prelude.Eq, ReadPrec [DescribeTargetGroups]
ReadPrec DescribeTargetGroups
Int -> ReadS DescribeTargetGroups
ReadS [DescribeTargetGroups]
(Int -> ReadS DescribeTargetGroups)
-> ReadS [DescribeTargetGroups]
-> ReadPrec DescribeTargetGroups
-> ReadPrec [DescribeTargetGroups]
-> Read DescribeTargetGroups
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeTargetGroups]
$creadListPrec :: ReadPrec [DescribeTargetGroups]
readPrec :: ReadPrec DescribeTargetGroups
$creadPrec :: ReadPrec DescribeTargetGroups
readList :: ReadS [DescribeTargetGroups]
$creadList :: ReadS [DescribeTargetGroups]
readsPrec :: Int -> ReadS DescribeTargetGroups
$creadsPrec :: Int -> ReadS DescribeTargetGroups
Prelude.Read, Int -> DescribeTargetGroups -> ShowS
[DescribeTargetGroups] -> ShowS
DescribeTargetGroups -> String
(Int -> DescribeTargetGroups -> ShowS)
-> (DescribeTargetGroups -> String)
-> ([DescribeTargetGroups] -> ShowS)
-> Show DescribeTargetGroups
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeTargetGroups] -> ShowS
$cshowList :: [DescribeTargetGroups] -> ShowS
show :: DescribeTargetGroups -> String
$cshow :: DescribeTargetGroups -> String
showsPrec :: Int -> DescribeTargetGroups -> ShowS
$cshowsPrec :: Int -> DescribeTargetGroups -> ShowS
Prelude.Show, (forall x. DescribeTargetGroups -> Rep DescribeTargetGroups x)
-> (forall x. Rep DescribeTargetGroups x -> DescribeTargetGroups)
-> Generic DescribeTargetGroups
forall x. Rep DescribeTargetGroups x -> DescribeTargetGroups
forall x. DescribeTargetGroups -> Rep DescribeTargetGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeTargetGroups x -> DescribeTargetGroups
$cfrom :: forall x. DescribeTargetGroups -> Rep DescribeTargetGroups x
Prelude.Generic)

-- |
-- Create a value of 'DescribeTargetGroups' 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:
--
-- 'targetGroupArns', 'describeTargetGroups_targetGroupArns' - The Amazon Resource Names (ARN) of the target groups.
--
-- 'names', 'describeTargetGroups_names' - The names of the target groups.
--
-- 'loadBalancerArn', 'describeTargetGroups_loadBalancerArn' - The Amazon Resource Name (ARN) of the load balancer.
--
-- 'marker', 'describeTargetGroups_marker' - The marker for the next set of results. (You received this marker from a
-- previous call.)
--
-- 'pageSize', 'describeTargetGroups_pageSize' - The maximum number of results to return with this call.
newDescribeTargetGroups ::
  DescribeTargetGroups
newDescribeTargetGroups :: DescribeTargetGroups
newDescribeTargetGroups =
  DescribeTargetGroups' :: Maybe [Text]
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> DescribeTargetGroups
DescribeTargetGroups'
    { $sel:targetGroupArns:DescribeTargetGroups' :: Maybe [Text]
targetGroupArns =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:names:DescribeTargetGroups' :: Maybe [Text]
names = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:loadBalancerArn:DescribeTargetGroups' :: Maybe Text
loadBalancerArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:DescribeTargetGroups' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:DescribeTargetGroups' :: Maybe Natural
pageSize = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Names (ARN) of the target groups.
describeTargetGroups_targetGroupArns :: Lens.Lens' DescribeTargetGroups (Prelude.Maybe [Prelude.Text])
describeTargetGroups_targetGroupArns :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeTargetGroups -> f DescribeTargetGroups
describeTargetGroups_targetGroupArns = (DescribeTargetGroups -> Maybe [Text])
-> (DescribeTargetGroups -> Maybe [Text] -> DescribeTargetGroups)
-> Lens
     DescribeTargetGroups
     DescribeTargetGroups
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTargetGroups' {Maybe [Text]
targetGroupArns :: Maybe [Text]
$sel:targetGroupArns:DescribeTargetGroups' :: DescribeTargetGroups -> Maybe [Text]
targetGroupArns} -> Maybe [Text]
targetGroupArns) (\s :: DescribeTargetGroups
s@DescribeTargetGroups' {} Maybe [Text]
a -> DescribeTargetGroups
s {$sel:targetGroupArns:DescribeTargetGroups' :: Maybe [Text]
targetGroupArns = Maybe [Text]
a} :: DescribeTargetGroups) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeTargetGroups -> f DescribeTargetGroups)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeTargetGroups
-> f DescribeTargetGroups
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The names of the target groups.
describeTargetGroups_names :: Lens.Lens' DescribeTargetGroups (Prelude.Maybe [Prelude.Text])
describeTargetGroups_names :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeTargetGroups -> f DescribeTargetGroups
describeTargetGroups_names = (DescribeTargetGroups -> Maybe [Text])
-> (DescribeTargetGroups -> Maybe [Text] -> DescribeTargetGroups)
-> Lens
     DescribeTargetGroups
     DescribeTargetGroups
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTargetGroups' {Maybe [Text]
names :: Maybe [Text]
$sel:names:DescribeTargetGroups' :: DescribeTargetGroups -> Maybe [Text]
names} -> Maybe [Text]
names) (\s :: DescribeTargetGroups
s@DescribeTargetGroups' {} Maybe [Text]
a -> DescribeTargetGroups
s {$sel:names:DescribeTargetGroups' :: Maybe [Text]
names = Maybe [Text]
a} :: DescribeTargetGroups) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeTargetGroups -> f DescribeTargetGroups)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeTargetGroups
-> f DescribeTargetGroups
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the load balancer.
describeTargetGroups_loadBalancerArn :: Lens.Lens' DescribeTargetGroups (Prelude.Maybe Prelude.Text)
describeTargetGroups_loadBalancerArn :: (Maybe Text -> f (Maybe Text))
-> DescribeTargetGroups -> f DescribeTargetGroups
describeTargetGroups_loadBalancerArn = (DescribeTargetGroups -> Maybe Text)
-> (DescribeTargetGroups -> Maybe Text -> DescribeTargetGroups)
-> Lens
     DescribeTargetGroups DescribeTargetGroups (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTargetGroups' {Maybe Text
loadBalancerArn :: Maybe Text
$sel:loadBalancerArn:DescribeTargetGroups' :: DescribeTargetGroups -> Maybe Text
loadBalancerArn} -> Maybe Text
loadBalancerArn) (\s :: DescribeTargetGroups
s@DescribeTargetGroups' {} Maybe Text
a -> DescribeTargetGroups
s {$sel:loadBalancerArn:DescribeTargetGroups' :: Maybe Text
loadBalancerArn = Maybe Text
a} :: DescribeTargetGroups)

-- | The marker for the next set of results. (You received this marker from a
-- previous call.)
describeTargetGroups_marker :: Lens.Lens' DescribeTargetGroups (Prelude.Maybe Prelude.Text)
describeTargetGroups_marker :: (Maybe Text -> f (Maybe Text))
-> DescribeTargetGroups -> f DescribeTargetGroups
describeTargetGroups_marker = (DescribeTargetGroups -> Maybe Text)
-> (DescribeTargetGroups -> Maybe Text -> DescribeTargetGroups)
-> Lens
     DescribeTargetGroups DescribeTargetGroups (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTargetGroups' {Maybe Text
marker :: Maybe Text
$sel:marker:DescribeTargetGroups' :: DescribeTargetGroups -> Maybe Text
marker} -> Maybe Text
marker) (\s :: DescribeTargetGroups
s@DescribeTargetGroups' {} Maybe Text
a -> DescribeTargetGroups
s {$sel:marker:DescribeTargetGroups' :: Maybe Text
marker = Maybe Text
a} :: DescribeTargetGroups)

-- | The maximum number of results to return with this call.
describeTargetGroups_pageSize :: Lens.Lens' DescribeTargetGroups (Prelude.Maybe Prelude.Natural)
describeTargetGroups_pageSize :: (Maybe Natural -> f (Maybe Natural))
-> DescribeTargetGroups -> f DescribeTargetGroups
describeTargetGroups_pageSize = (DescribeTargetGroups -> Maybe Natural)
-> (DescribeTargetGroups -> Maybe Natural -> DescribeTargetGroups)
-> Lens
     DescribeTargetGroups
     DescribeTargetGroups
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTargetGroups' {Maybe Natural
pageSize :: Maybe Natural
$sel:pageSize:DescribeTargetGroups' :: DescribeTargetGroups -> Maybe Natural
pageSize} -> Maybe Natural
pageSize) (\s :: DescribeTargetGroups
s@DescribeTargetGroups' {} Maybe Natural
a -> DescribeTargetGroups
s {$sel:pageSize:DescribeTargetGroups' :: Maybe Natural
pageSize = Maybe Natural
a} :: DescribeTargetGroups)

instance Core.AWSPager DescribeTargetGroups where
  page :: DescribeTargetGroups
-> AWSResponse DescribeTargetGroups -> Maybe DescribeTargetGroups
page DescribeTargetGroups
rq AWSResponse DescribeTargetGroups
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeTargetGroups
DescribeTargetGroupsResponse
rs
            DescribeTargetGroupsResponse
-> Getting (First Text) DescribeTargetGroupsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeTargetGroupsResponse
-> Const (First Text) DescribeTargetGroupsResponse
Lens' DescribeTargetGroupsResponse (Maybe Text)
describeTargetGroupsResponse_nextMarker
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeTargetGroupsResponse
 -> Const (First Text) DescribeTargetGroupsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeTargetGroupsResponse 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 DescribeTargetGroups
forall a. Maybe a
Prelude.Nothing
    | Maybe [TargetGroup] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeTargetGroups
DescribeTargetGroupsResponse
rs
            DescribeTargetGroupsResponse
-> Getting
     (First [TargetGroup]) DescribeTargetGroupsResponse [TargetGroup]
-> Maybe [TargetGroup]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [TargetGroup]
 -> Const (First [TargetGroup]) (Maybe [TargetGroup]))
-> DescribeTargetGroupsResponse
-> Const (First [TargetGroup]) DescribeTargetGroupsResponse
Lens' DescribeTargetGroupsResponse (Maybe [TargetGroup])
describeTargetGroupsResponse_targetGroups
              ((Maybe [TargetGroup]
  -> Const (First [TargetGroup]) (Maybe [TargetGroup]))
 -> DescribeTargetGroupsResponse
 -> Const (First [TargetGroup]) DescribeTargetGroupsResponse)
-> (([TargetGroup] -> Const (First [TargetGroup]) [TargetGroup])
    -> Maybe [TargetGroup]
    -> Const (First [TargetGroup]) (Maybe [TargetGroup]))
-> Getting
     (First [TargetGroup]) DescribeTargetGroupsResponse [TargetGroup]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([TargetGroup] -> Const (First [TargetGroup]) [TargetGroup])
-> Maybe [TargetGroup]
-> Const (First [TargetGroup]) (Maybe [TargetGroup])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeTargetGroups
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeTargetGroups -> Maybe DescribeTargetGroups
forall a. a -> Maybe a
Prelude.Just (DescribeTargetGroups -> Maybe DescribeTargetGroups)
-> DescribeTargetGroups -> Maybe DescribeTargetGroups
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeTargetGroups
rq
          DescribeTargetGroups
-> (DescribeTargetGroups -> DescribeTargetGroups)
-> DescribeTargetGroups
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeTargetGroups -> Identity DescribeTargetGroups
Lens
  DescribeTargetGroups DescribeTargetGroups (Maybe Text) (Maybe Text)
describeTargetGroups_marker
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeTargetGroups -> Identity DescribeTargetGroups)
-> Maybe Text -> DescribeTargetGroups -> DescribeTargetGroups
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeTargetGroups
DescribeTargetGroupsResponse
rs
          DescribeTargetGroupsResponse
-> Getting (First Text) DescribeTargetGroupsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeTargetGroupsResponse
-> Const (First Text) DescribeTargetGroupsResponse
Lens' DescribeTargetGroupsResponse (Maybe Text)
describeTargetGroupsResponse_nextMarker
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeTargetGroupsResponse
 -> Const (First Text) DescribeTargetGroupsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeTargetGroupsResponse 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 DescribeTargetGroups where
  type
    AWSResponse DescribeTargetGroups =
      DescribeTargetGroupsResponse
  request :: DescribeTargetGroups -> Request DescribeTargetGroups
request = Service -> DescribeTargetGroups -> Request DescribeTargetGroups
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeTargetGroups
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeTargetGroups)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeTargetGroups))
-> Logger
-> Service
-> Proxy DescribeTargetGroups
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeTargetGroups)))
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
"DescribeTargetGroupsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text
-> Maybe [TargetGroup] -> Int -> DescribeTargetGroupsResponse
DescribeTargetGroupsResponse'
            (Maybe Text
 -> Maybe [TargetGroup] -> Int -> DescribeTargetGroupsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [TargetGroup] -> Int -> DescribeTargetGroupsResponse)
forall (f :: * -> *) a b. Functor 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
"NextMarker")
            Either
  String (Maybe [TargetGroup] -> Int -> DescribeTargetGroupsResponse)
-> Either String (Maybe [TargetGroup])
-> Either String (Int -> DescribeTargetGroupsResponse)
forall (f :: * -> *) a b. Applicative f => 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
"TargetGroups" 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 [TargetGroup]))
-> Either String (Maybe [TargetGroup])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [TargetGroup])
-> [Node] -> Either String (Maybe [TargetGroup])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [TargetGroup]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Int -> DescribeTargetGroupsResponse)
-> Either String Int -> Either String DescribeTargetGroupsResponse
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 DescribeTargetGroups

instance Prelude.NFData DescribeTargetGroups

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

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

instance Core.ToQuery DescribeTargetGroups where
  toQuery :: DescribeTargetGroups -> QueryString
toQuery DescribeTargetGroups' {Maybe Natural
Maybe [Text]
Maybe Text
pageSize :: Maybe Natural
marker :: Maybe Text
loadBalancerArn :: Maybe Text
names :: Maybe [Text]
targetGroupArns :: Maybe [Text]
$sel:pageSize:DescribeTargetGroups' :: DescribeTargetGroups -> Maybe Natural
$sel:marker:DescribeTargetGroups' :: DescribeTargetGroups -> Maybe Text
$sel:loadBalancerArn:DescribeTargetGroups' :: DescribeTargetGroups -> Maybe Text
$sel:names:DescribeTargetGroups' :: DescribeTargetGroups -> Maybe [Text]
$sel:targetGroupArns:DescribeTargetGroups' :: DescribeTargetGroups -> 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
"DescribeTargetGroups" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-12-01" :: Prelude.ByteString),
        ByteString
"TargetGroupArns"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
                ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
targetGroupArns
            ),
        ByteString
"Names"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
names),
        ByteString
"LoadBalancerArn" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
loadBalancerArn,
        ByteString
"Marker" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
marker,
        ByteString
"PageSize" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
pageSize
      ]

-- | /See:/ 'newDescribeTargetGroupsResponse' smart constructor.
data DescribeTargetGroupsResponse = DescribeTargetGroupsResponse'
  { -- | If there are additional results, this is the marker for the next set of
    -- results. Otherwise, this is null.
    DescribeTargetGroupsResponse -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    -- | Information about the target groups.
    DescribeTargetGroupsResponse -> Maybe [TargetGroup]
targetGroups :: Prelude.Maybe [TargetGroup],
    -- | The response's http status code.
    DescribeTargetGroupsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeTargetGroupsResponse
-> DescribeTargetGroupsResponse -> Bool
(DescribeTargetGroupsResponse
 -> DescribeTargetGroupsResponse -> Bool)
-> (DescribeTargetGroupsResponse
    -> DescribeTargetGroupsResponse -> Bool)
-> Eq DescribeTargetGroupsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeTargetGroupsResponse
-> DescribeTargetGroupsResponse -> Bool
$c/= :: DescribeTargetGroupsResponse
-> DescribeTargetGroupsResponse -> Bool
== :: DescribeTargetGroupsResponse
-> DescribeTargetGroupsResponse -> Bool
$c== :: DescribeTargetGroupsResponse
-> DescribeTargetGroupsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeTargetGroupsResponse]
ReadPrec DescribeTargetGroupsResponse
Int -> ReadS DescribeTargetGroupsResponse
ReadS [DescribeTargetGroupsResponse]
(Int -> ReadS DescribeTargetGroupsResponse)
-> ReadS [DescribeTargetGroupsResponse]
-> ReadPrec DescribeTargetGroupsResponse
-> ReadPrec [DescribeTargetGroupsResponse]
-> Read DescribeTargetGroupsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeTargetGroupsResponse]
$creadListPrec :: ReadPrec [DescribeTargetGroupsResponse]
readPrec :: ReadPrec DescribeTargetGroupsResponse
$creadPrec :: ReadPrec DescribeTargetGroupsResponse
readList :: ReadS [DescribeTargetGroupsResponse]
$creadList :: ReadS [DescribeTargetGroupsResponse]
readsPrec :: Int -> ReadS DescribeTargetGroupsResponse
$creadsPrec :: Int -> ReadS DescribeTargetGroupsResponse
Prelude.Read, Int -> DescribeTargetGroupsResponse -> ShowS
[DescribeTargetGroupsResponse] -> ShowS
DescribeTargetGroupsResponse -> String
(Int -> DescribeTargetGroupsResponse -> ShowS)
-> (DescribeTargetGroupsResponse -> String)
-> ([DescribeTargetGroupsResponse] -> ShowS)
-> Show DescribeTargetGroupsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeTargetGroupsResponse] -> ShowS
$cshowList :: [DescribeTargetGroupsResponse] -> ShowS
show :: DescribeTargetGroupsResponse -> String
$cshow :: DescribeTargetGroupsResponse -> String
showsPrec :: Int -> DescribeTargetGroupsResponse -> ShowS
$cshowsPrec :: Int -> DescribeTargetGroupsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeTargetGroupsResponse -> Rep DescribeTargetGroupsResponse x)
-> (forall x.
    Rep DescribeTargetGroupsResponse x -> DescribeTargetGroupsResponse)
-> Generic DescribeTargetGroupsResponse
forall x.
Rep DescribeTargetGroupsResponse x -> DescribeTargetGroupsResponse
forall x.
DescribeTargetGroupsResponse -> Rep DescribeTargetGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeTargetGroupsResponse x -> DescribeTargetGroupsResponse
$cfrom :: forall x.
DescribeTargetGroupsResponse -> Rep DescribeTargetGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeTargetGroupsResponse' 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:
--
-- 'nextMarker', 'describeTargetGroupsResponse_nextMarker' - If there are additional results, this is the marker for the next set of
-- results. Otherwise, this is null.
--
-- 'targetGroups', 'describeTargetGroupsResponse_targetGroups' - Information about the target groups.
--
-- 'httpStatus', 'describeTargetGroupsResponse_httpStatus' - The response's http status code.
newDescribeTargetGroupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeTargetGroupsResponse
newDescribeTargetGroupsResponse :: Int -> DescribeTargetGroupsResponse
newDescribeTargetGroupsResponse Int
pHttpStatus_ =
  DescribeTargetGroupsResponse' :: Maybe Text
-> Maybe [TargetGroup] -> Int -> DescribeTargetGroupsResponse
DescribeTargetGroupsResponse'
    { $sel:nextMarker:DescribeTargetGroupsResponse' :: Maybe Text
nextMarker =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetGroups:DescribeTargetGroupsResponse' :: Maybe [TargetGroup]
targetGroups = Maybe [TargetGroup]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeTargetGroupsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If there are additional results, this is the marker for the next set of
-- results. Otherwise, this is null.
describeTargetGroupsResponse_nextMarker :: Lens.Lens' DescribeTargetGroupsResponse (Prelude.Maybe Prelude.Text)
describeTargetGroupsResponse_nextMarker :: (Maybe Text -> f (Maybe Text))
-> DescribeTargetGroupsResponse -> f DescribeTargetGroupsResponse
describeTargetGroupsResponse_nextMarker = (DescribeTargetGroupsResponse -> Maybe Text)
-> (DescribeTargetGroupsResponse
    -> Maybe Text -> DescribeTargetGroupsResponse)
-> Lens' DescribeTargetGroupsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTargetGroupsResponse' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:DescribeTargetGroupsResponse' :: DescribeTargetGroupsResponse -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: DescribeTargetGroupsResponse
s@DescribeTargetGroupsResponse' {} Maybe Text
a -> DescribeTargetGroupsResponse
s {$sel:nextMarker:DescribeTargetGroupsResponse' :: Maybe Text
nextMarker = Maybe Text
a} :: DescribeTargetGroupsResponse)

-- | Information about the target groups.
describeTargetGroupsResponse_targetGroups :: Lens.Lens' DescribeTargetGroupsResponse (Prelude.Maybe [TargetGroup])
describeTargetGroupsResponse_targetGroups :: (Maybe [TargetGroup] -> f (Maybe [TargetGroup]))
-> DescribeTargetGroupsResponse -> f DescribeTargetGroupsResponse
describeTargetGroupsResponse_targetGroups = (DescribeTargetGroupsResponse -> Maybe [TargetGroup])
-> (DescribeTargetGroupsResponse
    -> Maybe [TargetGroup] -> DescribeTargetGroupsResponse)
-> Lens' DescribeTargetGroupsResponse (Maybe [TargetGroup])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTargetGroupsResponse' {Maybe [TargetGroup]
targetGroups :: Maybe [TargetGroup]
$sel:targetGroups:DescribeTargetGroupsResponse' :: DescribeTargetGroupsResponse -> Maybe [TargetGroup]
targetGroups} -> Maybe [TargetGroup]
targetGroups) (\s :: DescribeTargetGroupsResponse
s@DescribeTargetGroupsResponse' {} Maybe [TargetGroup]
a -> DescribeTargetGroupsResponse
s {$sel:targetGroups:DescribeTargetGroupsResponse' :: Maybe [TargetGroup]
targetGroups = Maybe [TargetGroup]
a} :: DescribeTargetGroupsResponse) ((Maybe [TargetGroup] -> f (Maybe [TargetGroup]))
 -> DescribeTargetGroupsResponse -> f DescribeTargetGroupsResponse)
-> ((Maybe [TargetGroup] -> f (Maybe [TargetGroup]))
    -> Maybe [TargetGroup] -> f (Maybe [TargetGroup]))
-> (Maybe [TargetGroup] -> f (Maybe [TargetGroup]))
-> DescribeTargetGroupsResponse
-> f DescribeTargetGroupsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [TargetGroup] [TargetGroup] [TargetGroup] [TargetGroup]
-> Iso
     (Maybe [TargetGroup])
     (Maybe [TargetGroup])
     (Maybe [TargetGroup])
     (Maybe [TargetGroup])
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 [TargetGroup] [TargetGroup] [TargetGroup] [TargetGroup]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeTargetGroupsResponse