{-# 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.DescribeTargetGroupAttributes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes the attributes for the specified target group.
--
-- For more information, see the following:
--
-- -   <https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html#target-group-attributes Target group attributes>
--     in the /Application Load Balancers Guide/
--
-- -   <https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-target-groups.html#target-group-attributes Target group attributes>
--     in the /Network Load Balancers Guide/
--
-- -   <https://docs.aws.amazon.com/elasticloadbalancing/latest/gateway/target-groups.html#target-group-attributes Target group attributes>
--     in the /Gateway Load Balancers Guide/
module Amazonka.ELBV2.DescribeTargetGroupAttributes
  ( -- * Creating a Request
    DescribeTargetGroupAttributes (..),
    newDescribeTargetGroupAttributes,

    -- * Request Lenses
    describeTargetGroupAttributes_targetGroupArn,

    -- * Destructuring the Response
    DescribeTargetGroupAttributesResponse (..),
    newDescribeTargetGroupAttributesResponse,

    -- * Response Lenses
    describeTargetGroupAttributesResponse_attributes,
    describeTargetGroupAttributesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeTargetGroupAttributes' smart constructor.
data DescribeTargetGroupAttributes = DescribeTargetGroupAttributes'
  { -- | The Amazon Resource Name (ARN) of the target group.
    DescribeTargetGroupAttributes -> Text
targetGroupArn :: Prelude.Text
  }
  deriving (DescribeTargetGroupAttributes
-> DescribeTargetGroupAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeTargetGroupAttributes
-> DescribeTargetGroupAttributes -> Bool
$c/= :: DescribeTargetGroupAttributes
-> DescribeTargetGroupAttributes -> Bool
== :: DescribeTargetGroupAttributes
-> DescribeTargetGroupAttributes -> Bool
$c== :: DescribeTargetGroupAttributes
-> DescribeTargetGroupAttributes -> Bool
Prelude.Eq, ReadPrec [DescribeTargetGroupAttributes]
ReadPrec DescribeTargetGroupAttributes
Int -> ReadS DescribeTargetGroupAttributes
ReadS [DescribeTargetGroupAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeTargetGroupAttributes]
$creadListPrec :: ReadPrec [DescribeTargetGroupAttributes]
readPrec :: ReadPrec DescribeTargetGroupAttributes
$creadPrec :: ReadPrec DescribeTargetGroupAttributes
readList :: ReadS [DescribeTargetGroupAttributes]
$creadList :: ReadS [DescribeTargetGroupAttributes]
readsPrec :: Int -> ReadS DescribeTargetGroupAttributes
$creadsPrec :: Int -> ReadS DescribeTargetGroupAttributes
Prelude.Read, Int -> DescribeTargetGroupAttributes -> ShowS
[DescribeTargetGroupAttributes] -> ShowS
DescribeTargetGroupAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeTargetGroupAttributes] -> ShowS
$cshowList :: [DescribeTargetGroupAttributes] -> ShowS
show :: DescribeTargetGroupAttributes -> String
$cshow :: DescribeTargetGroupAttributes -> String
showsPrec :: Int -> DescribeTargetGroupAttributes -> ShowS
$cshowsPrec :: Int -> DescribeTargetGroupAttributes -> ShowS
Prelude.Show, forall x.
Rep DescribeTargetGroupAttributes x
-> DescribeTargetGroupAttributes
forall x.
DescribeTargetGroupAttributes
-> Rep DescribeTargetGroupAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeTargetGroupAttributes x
-> DescribeTargetGroupAttributes
$cfrom :: forall x.
DescribeTargetGroupAttributes
-> Rep DescribeTargetGroupAttributes x
Prelude.Generic)

-- |
-- Create a value of 'DescribeTargetGroupAttributes' 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', 'describeTargetGroupAttributes_targetGroupArn' - The Amazon Resource Name (ARN) of the target group.
newDescribeTargetGroupAttributes ::
  -- | 'targetGroupArn'
  Prelude.Text ->
  DescribeTargetGroupAttributes
newDescribeTargetGroupAttributes :: Text -> DescribeTargetGroupAttributes
newDescribeTargetGroupAttributes Text
pTargetGroupArn_ =
  DescribeTargetGroupAttributes'
    { $sel:targetGroupArn:DescribeTargetGroupAttributes' :: Text
targetGroupArn =
        Text
pTargetGroupArn_
    }

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

instance
  Core.AWSRequest
    DescribeTargetGroupAttributes
  where
  type
    AWSResponse DescribeTargetGroupAttributes =
      DescribeTargetGroupAttributesResponse
  request :: (Service -> Service)
-> DescribeTargetGroupAttributes
-> Request DescribeTargetGroupAttributes
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 DescribeTargetGroupAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeTargetGroupAttributes)))
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
"DescribeTargetGroupAttributesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [TargetGroupAttribute]
-> Int -> DescribeTargetGroupAttributesResponse
DescribeTargetGroupAttributesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Attributes"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            forall (f :: * -> *) a b. Applicative f => 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
    DescribeTargetGroupAttributes
  where
  hashWithSalt :: Int -> DescribeTargetGroupAttributes -> Int
hashWithSalt Int
_salt DescribeTargetGroupAttributes' {Text
targetGroupArn :: Text
$sel:targetGroupArn:DescribeTargetGroupAttributes' :: DescribeTargetGroupAttributes -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
targetGroupArn

instance Prelude.NFData DescribeTargetGroupAttributes where
  rnf :: DescribeTargetGroupAttributes -> ()
rnf DescribeTargetGroupAttributes' {Text
targetGroupArn :: Text
$sel:targetGroupArn:DescribeTargetGroupAttributes' :: DescribeTargetGroupAttributes -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
targetGroupArn

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

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

instance Data.ToQuery DescribeTargetGroupAttributes where
  toQuery :: DescribeTargetGroupAttributes -> QueryString
toQuery DescribeTargetGroupAttributes' {Text
targetGroupArn :: Text
$sel:targetGroupArn:DescribeTargetGroupAttributes' :: DescribeTargetGroupAttributes -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ( ByteString
"DescribeTargetGroupAttributes" ::
                      Prelude.ByteString
                  ),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2015-12-01" :: Prelude.ByteString),
        ByteString
"TargetGroupArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
targetGroupArn
      ]

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

-- |
-- Create a value of 'DescribeTargetGroupAttributesResponse' 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:
--
-- 'attributes', 'describeTargetGroupAttributesResponse_attributes' - Information about the target group attributes
--
-- 'httpStatus', 'describeTargetGroupAttributesResponse_httpStatus' - The response's http status code.
newDescribeTargetGroupAttributesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeTargetGroupAttributesResponse
newDescribeTargetGroupAttributesResponse :: Int -> DescribeTargetGroupAttributesResponse
newDescribeTargetGroupAttributesResponse Int
pHttpStatus_ =
  DescribeTargetGroupAttributesResponse'
    { $sel:attributes:DescribeTargetGroupAttributesResponse' :: Maybe [TargetGroupAttribute]
attributes =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeTargetGroupAttributesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the target group attributes
describeTargetGroupAttributesResponse_attributes :: Lens.Lens' DescribeTargetGroupAttributesResponse (Prelude.Maybe [TargetGroupAttribute])
describeTargetGroupAttributesResponse_attributes :: Lens'
  DescribeTargetGroupAttributesResponse
  (Maybe [TargetGroupAttribute])
describeTargetGroupAttributesResponse_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTargetGroupAttributesResponse' {Maybe [TargetGroupAttribute]
attributes :: Maybe [TargetGroupAttribute]
$sel:attributes:DescribeTargetGroupAttributesResponse' :: DescribeTargetGroupAttributesResponse
-> Maybe [TargetGroupAttribute]
attributes} -> Maybe [TargetGroupAttribute]
attributes) (\s :: DescribeTargetGroupAttributesResponse
s@DescribeTargetGroupAttributesResponse' {} Maybe [TargetGroupAttribute]
a -> DescribeTargetGroupAttributesResponse
s {$sel:attributes:DescribeTargetGroupAttributesResponse' :: Maybe [TargetGroupAttribute]
attributes = Maybe [TargetGroupAttribute]
a} :: DescribeTargetGroupAttributesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DescribeTargetGroupAttributesResponse
  where
  rnf :: DescribeTargetGroupAttributesResponse -> ()
rnf DescribeTargetGroupAttributesResponse' {Int
Maybe [TargetGroupAttribute]
httpStatus :: Int
attributes :: Maybe [TargetGroupAttribute]
$sel:httpStatus:DescribeTargetGroupAttributesResponse' :: DescribeTargetGroupAttributesResponse -> Int
$sel:attributes:DescribeTargetGroupAttributesResponse' :: DescribeTargetGroupAttributesResponse
-> Maybe [TargetGroupAttribute]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [TargetGroupAttribute]
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus