{-# 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.GlobalAccelerator.DescribeEndpointGroup
-- 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)
--
-- Describe an endpoint group.
module Amazonka.GlobalAccelerator.DescribeEndpointGroup
  ( -- * Creating a Request
    DescribeEndpointGroup (..),
    newDescribeEndpointGroup,

    -- * Request Lenses
    describeEndpointGroup_endpointGroupArn,

    -- * Destructuring the Response
    DescribeEndpointGroupResponse (..),
    newDescribeEndpointGroupResponse,

    -- * Response Lenses
    describeEndpointGroupResponse_endpointGroup,
    describeEndpointGroupResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GlobalAccelerator.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:/ 'newDescribeEndpointGroup' smart constructor.
data DescribeEndpointGroup = DescribeEndpointGroup'
  { -- | The Amazon Resource Name (ARN) of the endpoint group to describe.
    DescribeEndpointGroup -> Text
endpointGroupArn :: Prelude.Text
  }
  deriving (DescribeEndpointGroup -> DescribeEndpointGroup -> Bool
(DescribeEndpointGroup -> DescribeEndpointGroup -> Bool)
-> (DescribeEndpointGroup -> DescribeEndpointGroup -> Bool)
-> Eq DescribeEndpointGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeEndpointGroup -> DescribeEndpointGroup -> Bool
$c/= :: DescribeEndpointGroup -> DescribeEndpointGroup -> Bool
== :: DescribeEndpointGroup -> DescribeEndpointGroup -> Bool
$c== :: DescribeEndpointGroup -> DescribeEndpointGroup -> Bool
Prelude.Eq, ReadPrec [DescribeEndpointGroup]
ReadPrec DescribeEndpointGroup
Int -> ReadS DescribeEndpointGroup
ReadS [DescribeEndpointGroup]
(Int -> ReadS DescribeEndpointGroup)
-> ReadS [DescribeEndpointGroup]
-> ReadPrec DescribeEndpointGroup
-> ReadPrec [DescribeEndpointGroup]
-> Read DescribeEndpointGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeEndpointGroup]
$creadListPrec :: ReadPrec [DescribeEndpointGroup]
readPrec :: ReadPrec DescribeEndpointGroup
$creadPrec :: ReadPrec DescribeEndpointGroup
readList :: ReadS [DescribeEndpointGroup]
$creadList :: ReadS [DescribeEndpointGroup]
readsPrec :: Int -> ReadS DescribeEndpointGroup
$creadsPrec :: Int -> ReadS DescribeEndpointGroup
Prelude.Read, Int -> DescribeEndpointGroup -> ShowS
[DescribeEndpointGroup] -> ShowS
DescribeEndpointGroup -> String
(Int -> DescribeEndpointGroup -> ShowS)
-> (DescribeEndpointGroup -> String)
-> ([DescribeEndpointGroup] -> ShowS)
-> Show DescribeEndpointGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeEndpointGroup] -> ShowS
$cshowList :: [DescribeEndpointGroup] -> ShowS
show :: DescribeEndpointGroup -> String
$cshow :: DescribeEndpointGroup -> String
showsPrec :: Int -> DescribeEndpointGroup -> ShowS
$cshowsPrec :: Int -> DescribeEndpointGroup -> ShowS
Prelude.Show, (forall x. DescribeEndpointGroup -> Rep DescribeEndpointGroup x)
-> (forall x. Rep DescribeEndpointGroup x -> DescribeEndpointGroup)
-> Generic DescribeEndpointGroup
forall x. Rep DescribeEndpointGroup x -> DescribeEndpointGroup
forall x. DescribeEndpointGroup -> Rep DescribeEndpointGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeEndpointGroup x -> DescribeEndpointGroup
$cfrom :: forall x. DescribeEndpointGroup -> Rep DescribeEndpointGroup x
Prelude.Generic)

-- |
-- Create a value of 'DescribeEndpointGroup' 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:
--
-- 'endpointGroupArn', 'describeEndpointGroup_endpointGroupArn' - The Amazon Resource Name (ARN) of the endpoint group to describe.
newDescribeEndpointGroup ::
  -- | 'endpointGroupArn'
  Prelude.Text ->
  DescribeEndpointGroup
newDescribeEndpointGroup :: Text -> DescribeEndpointGroup
newDescribeEndpointGroup Text
pEndpointGroupArn_ =
  DescribeEndpointGroup' :: Text -> DescribeEndpointGroup
DescribeEndpointGroup'
    { $sel:endpointGroupArn:DescribeEndpointGroup' :: Text
endpointGroupArn =
        Text
pEndpointGroupArn_
    }

-- | The Amazon Resource Name (ARN) of the endpoint group to describe.
describeEndpointGroup_endpointGroupArn :: Lens.Lens' DescribeEndpointGroup Prelude.Text
describeEndpointGroup_endpointGroupArn :: (Text -> f Text)
-> DescribeEndpointGroup -> f DescribeEndpointGroup
describeEndpointGroup_endpointGroupArn = (DescribeEndpointGroup -> Text)
-> (DescribeEndpointGroup -> Text -> DescribeEndpointGroup)
-> Lens DescribeEndpointGroup DescribeEndpointGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEndpointGroup' {Text
endpointGroupArn :: Text
$sel:endpointGroupArn:DescribeEndpointGroup' :: DescribeEndpointGroup -> Text
endpointGroupArn} -> Text
endpointGroupArn) (\s :: DescribeEndpointGroup
s@DescribeEndpointGroup' {} Text
a -> DescribeEndpointGroup
s {$sel:endpointGroupArn:DescribeEndpointGroup' :: Text
endpointGroupArn = Text
a} :: DescribeEndpointGroup)

instance Core.AWSRequest DescribeEndpointGroup where
  type
    AWSResponse DescribeEndpointGroup =
      DescribeEndpointGroupResponse
  request :: DescribeEndpointGroup -> Request DescribeEndpointGroup
request = Service -> DescribeEndpointGroup -> Request DescribeEndpointGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeEndpointGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeEndpointGroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeEndpointGroup))
-> Logger
-> Service
-> Proxy DescribeEndpointGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeEndpointGroup)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe EndpointGroup -> Int -> DescribeEndpointGroupResponse
DescribeEndpointGroupResponse'
            (Maybe EndpointGroup -> Int -> DescribeEndpointGroupResponse)
-> Either String (Maybe EndpointGroup)
-> Either String (Int -> DescribeEndpointGroupResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe EndpointGroup)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"EndpointGroup")
            Either String (Int -> DescribeEndpointGroupResponse)
-> Either String Int -> Either String DescribeEndpointGroupResponse
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 DescribeEndpointGroup

instance Prelude.NFData DescribeEndpointGroup

instance Core.ToHeaders DescribeEndpointGroup where
  toHeaders :: DescribeEndpointGroup -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeEndpointGroup -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"GlobalAccelerator_V20180706.DescribeEndpointGroup" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeEndpointGroup where
  toJSON :: DescribeEndpointGroup -> Value
toJSON DescribeEndpointGroup' {Text
endpointGroupArn :: Text
$sel:endpointGroupArn:DescribeEndpointGroup' :: DescribeEndpointGroup -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"EndpointGroupArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
endpointGroupArn)
          ]
      )

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

instance Core.ToQuery DescribeEndpointGroup where
  toQuery :: DescribeEndpointGroup -> QueryString
toQuery = QueryString -> DescribeEndpointGroup -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'DescribeEndpointGroupResponse' 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:
--
-- 'endpointGroup', 'describeEndpointGroupResponse_endpointGroup' - The description of an endpoint group.
--
-- 'httpStatus', 'describeEndpointGroupResponse_httpStatus' - The response's http status code.
newDescribeEndpointGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeEndpointGroupResponse
newDescribeEndpointGroupResponse :: Int -> DescribeEndpointGroupResponse
newDescribeEndpointGroupResponse Int
pHttpStatus_ =
  DescribeEndpointGroupResponse' :: Maybe EndpointGroup -> Int -> DescribeEndpointGroupResponse
DescribeEndpointGroupResponse'
    { $sel:endpointGroup:DescribeEndpointGroupResponse' :: Maybe EndpointGroup
endpointGroup =
        Maybe EndpointGroup
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeEndpointGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The description of an endpoint group.
describeEndpointGroupResponse_endpointGroup :: Lens.Lens' DescribeEndpointGroupResponse (Prelude.Maybe EndpointGroup)
describeEndpointGroupResponse_endpointGroup :: (Maybe EndpointGroup -> f (Maybe EndpointGroup))
-> DescribeEndpointGroupResponse -> f DescribeEndpointGroupResponse
describeEndpointGroupResponse_endpointGroup = (DescribeEndpointGroupResponse -> Maybe EndpointGroup)
-> (DescribeEndpointGroupResponse
    -> Maybe EndpointGroup -> DescribeEndpointGroupResponse)
-> Lens
     DescribeEndpointGroupResponse
     DescribeEndpointGroupResponse
     (Maybe EndpointGroup)
     (Maybe EndpointGroup)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEndpointGroupResponse' {Maybe EndpointGroup
endpointGroup :: Maybe EndpointGroup
$sel:endpointGroup:DescribeEndpointGroupResponse' :: DescribeEndpointGroupResponse -> Maybe EndpointGroup
endpointGroup} -> Maybe EndpointGroup
endpointGroup) (\s :: DescribeEndpointGroupResponse
s@DescribeEndpointGroupResponse' {} Maybe EndpointGroup
a -> DescribeEndpointGroupResponse
s {$sel:endpointGroup:DescribeEndpointGroupResponse' :: Maybe EndpointGroup
endpointGroup = Maybe EndpointGroup
a} :: DescribeEndpointGroupResponse)

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

instance Prelude.NFData DescribeEndpointGroupResponse