{-# 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.DynamoDB.DescribeEndpoints
-- 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)
--
-- Returns the regional endpoint information.
module Amazonka.DynamoDB.DescribeEndpoints
  ( -- * Creating a Request
    DescribeEndpoints (..),
    newDescribeEndpoints,

    -- * Destructuring the Response
    DescribeEndpointsResponse (..),
    newDescribeEndpointsResponse,

    -- * Response Lenses
    describeEndpointsResponse_httpStatus,
    describeEndpointsResponse_endpoints,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.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:/ 'newDescribeEndpoints' smart constructor.
data DescribeEndpoints = DescribeEndpoints'
  {
  }
  deriving (DescribeEndpoints -> DescribeEndpoints -> Bool
(DescribeEndpoints -> DescribeEndpoints -> Bool)
-> (DescribeEndpoints -> DescribeEndpoints -> Bool)
-> Eq DescribeEndpoints
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeEndpoints -> DescribeEndpoints -> Bool
$c/= :: DescribeEndpoints -> DescribeEndpoints -> Bool
== :: DescribeEndpoints -> DescribeEndpoints -> Bool
$c== :: DescribeEndpoints -> DescribeEndpoints -> Bool
Prelude.Eq, ReadPrec [DescribeEndpoints]
ReadPrec DescribeEndpoints
Int -> ReadS DescribeEndpoints
ReadS [DescribeEndpoints]
(Int -> ReadS DescribeEndpoints)
-> ReadS [DescribeEndpoints]
-> ReadPrec DescribeEndpoints
-> ReadPrec [DescribeEndpoints]
-> Read DescribeEndpoints
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeEndpoints]
$creadListPrec :: ReadPrec [DescribeEndpoints]
readPrec :: ReadPrec DescribeEndpoints
$creadPrec :: ReadPrec DescribeEndpoints
readList :: ReadS [DescribeEndpoints]
$creadList :: ReadS [DescribeEndpoints]
readsPrec :: Int -> ReadS DescribeEndpoints
$creadsPrec :: Int -> ReadS DescribeEndpoints
Prelude.Read, Int -> DescribeEndpoints -> ShowS
[DescribeEndpoints] -> ShowS
DescribeEndpoints -> String
(Int -> DescribeEndpoints -> ShowS)
-> (DescribeEndpoints -> String)
-> ([DescribeEndpoints] -> ShowS)
-> Show DescribeEndpoints
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeEndpoints] -> ShowS
$cshowList :: [DescribeEndpoints] -> ShowS
show :: DescribeEndpoints -> String
$cshow :: DescribeEndpoints -> String
showsPrec :: Int -> DescribeEndpoints -> ShowS
$cshowsPrec :: Int -> DescribeEndpoints -> ShowS
Prelude.Show, (forall x. DescribeEndpoints -> Rep DescribeEndpoints x)
-> (forall x. Rep DescribeEndpoints x -> DescribeEndpoints)
-> Generic DescribeEndpoints
forall x. Rep DescribeEndpoints x -> DescribeEndpoints
forall x. DescribeEndpoints -> Rep DescribeEndpoints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeEndpoints x -> DescribeEndpoints
$cfrom :: forall x. DescribeEndpoints -> Rep DescribeEndpoints x
Prelude.Generic)

-- |
-- Create a value of 'DescribeEndpoints' 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.
newDescribeEndpoints ::
  DescribeEndpoints
newDescribeEndpoints :: DescribeEndpoints
newDescribeEndpoints = DescribeEndpoints
DescribeEndpoints'

instance Core.AWSRequest DescribeEndpoints where
  type
    AWSResponse DescribeEndpoints =
      DescribeEndpointsResponse
  request :: DescribeEndpoints -> Request DescribeEndpoints
request = Service -> DescribeEndpoints -> Request DescribeEndpoints
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeEndpoints
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeEndpoints)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeEndpoints))
-> Logger
-> Service
-> Proxy DescribeEndpoints
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeEndpoints)))
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 ->
          Int -> [Endpoint] -> DescribeEndpointsResponse
DescribeEndpointsResponse'
            (Int -> [Endpoint] -> DescribeEndpointsResponse)
-> Either String Int
-> Either String ([Endpoint] -> DescribeEndpointsResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String ([Endpoint] -> DescribeEndpointsResponse)
-> Either String [Endpoint]
-> Either String DescribeEndpointsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Key -> Either String (Maybe [Endpoint])
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"Endpoints" Either String (Maybe [Endpoint])
-> [Endpoint] -> Either String [Endpoint]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Endpoint]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable DescribeEndpoints

instance Prelude.NFData DescribeEndpoints

instance Core.ToHeaders DescribeEndpoints where
  toHeaders :: DescribeEndpoints -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeEndpoints -> 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
"DynamoDB_20120810.DescribeEndpoints" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeEndpoints where
  toJSON :: DescribeEndpoints -> Value
toJSON = Value -> DescribeEndpoints -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

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

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

-- |
-- Create a value of 'DescribeEndpointsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'httpStatus', 'describeEndpointsResponse_httpStatus' - The response's http status code.
--
-- 'endpoints', 'describeEndpointsResponse_endpoints' - List of endpoints.
newDescribeEndpointsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeEndpointsResponse
newDescribeEndpointsResponse :: Int -> DescribeEndpointsResponse
newDescribeEndpointsResponse Int
pHttpStatus_ =
  DescribeEndpointsResponse' :: Int -> [Endpoint] -> DescribeEndpointsResponse
DescribeEndpointsResponse'
    { $sel:httpStatus:DescribeEndpointsResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:endpoints:DescribeEndpointsResponse' :: [Endpoint]
endpoints = [Endpoint]
forall a. Monoid a => a
Prelude.mempty
    }

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

-- | List of endpoints.
describeEndpointsResponse_endpoints :: Lens.Lens' DescribeEndpointsResponse [Endpoint]
describeEndpointsResponse_endpoints :: ([Endpoint] -> f [Endpoint])
-> DescribeEndpointsResponse -> f DescribeEndpointsResponse
describeEndpointsResponse_endpoints = (DescribeEndpointsResponse -> [Endpoint])
-> (DescribeEndpointsResponse
    -> [Endpoint] -> DescribeEndpointsResponse)
-> Lens
     DescribeEndpointsResponse
     DescribeEndpointsResponse
     [Endpoint]
     [Endpoint]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEndpointsResponse' {[Endpoint]
endpoints :: [Endpoint]
$sel:endpoints:DescribeEndpointsResponse' :: DescribeEndpointsResponse -> [Endpoint]
endpoints} -> [Endpoint]
endpoints) (\s :: DescribeEndpointsResponse
s@DescribeEndpointsResponse' {} [Endpoint]
a -> DescribeEndpointsResponse
s {$sel:endpoints:DescribeEndpointsResponse' :: [Endpoint]
endpoints = [Endpoint]
a} :: DescribeEndpointsResponse) (([Endpoint] -> f [Endpoint])
 -> DescribeEndpointsResponse -> f DescribeEndpointsResponse)
-> (([Endpoint] -> f [Endpoint]) -> [Endpoint] -> f [Endpoint])
-> ([Endpoint] -> f [Endpoint])
-> DescribeEndpointsResponse
-> f DescribeEndpointsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Endpoint] -> f [Endpoint]) -> [Endpoint] -> f [Endpoint]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData DescribeEndpointsResponse