{-# 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.DescribeGlobalTable
-- 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 information about the specified global table.
--
-- This operation only applies to
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V1.html Version 2017.11.29>
-- of global tables. If you are using global tables
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V2.html Version 2019.11.21>
-- you can use
-- <https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html DescribeTable>
-- instead.
module Amazonka.DynamoDB.DescribeGlobalTable
  ( -- * Creating a Request
    DescribeGlobalTable (..),
    newDescribeGlobalTable,

    -- * Request Lenses
    describeGlobalTable_globalTableName,

    -- * Destructuring the Response
    DescribeGlobalTableResponse (..),
    newDescribeGlobalTableResponse,

    -- * Response Lenses
    describeGlobalTableResponse_globalTableDescription,
    describeGlobalTableResponse_httpStatus,
  )
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:/ 'newDescribeGlobalTable' smart constructor.
data DescribeGlobalTable = DescribeGlobalTable'
  { -- | The name of the global table.
    DescribeGlobalTable -> Text
globalTableName :: Prelude.Text
  }
  deriving (DescribeGlobalTable -> DescribeGlobalTable -> Bool
(DescribeGlobalTable -> DescribeGlobalTable -> Bool)
-> (DescribeGlobalTable -> DescribeGlobalTable -> Bool)
-> Eq DescribeGlobalTable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeGlobalTable -> DescribeGlobalTable -> Bool
$c/= :: DescribeGlobalTable -> DescribeGlobalTable -> Bool
== :: DescribeGlobalTable -> DescribeGlobalTable -> Bool
$c== :: DescribeGlobalTable -> DescribeGlobalTable -> Bool
Prelude.Eq, ReadPrec [DescribeGlobalTable]
ReadPrec DescribeGlobalTable
Int -> ReadS DescribeGlobalTable
ReadS [DescribeGlobalTable]
(Int -> ReadS DescribeGlobalTable)
-> ReadS [DescribeGlobalTable]
-> ReadPrec DescribeGlobalTable
-> ReadPrec [DescribeGlobalTable]
-> Read DescribeGlobalTable
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeGlobalTable]
$creadListPrec :: ReadPrec [DescribeGlobalTable]
readPrec :: ReadPrec DescribeGlobalTable
$creadPrec :: ReadPrec DescribeGlobalTable
readList :: ReadS [DescribeGlobalTable]
$creadList :: ReadS [DescribeGlobalTable]
readsPrec :: Int -> ReadS DescribeGlobalTable
$creadsPrec :: Int -> ReadS DescribeGlobalTable
Prelude.Read, Int -> DescribeGlobalTable -> ShowS
[DescribeGlobalTable] -> ShowS
DescribeGlobalTable -> String
(Int -> DescribeGlobalTable -> ShowS)
-> (DescribeGlobalTable -> String)
-> ([DescribeGlobalTable] -> ShowS)
-> Show DescribeGlobalTable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeGlobalTable] -> ShowS
$cshowList :: [DescribeGlobalTable] -> ShowS
show :: DescribeGlobalTable -> String
$cshow :: DescribeGlobalTable -> String
showsPrec :: Int -> DescribeGlobalTable -> ShowS
$cshowsPrec :: Int -> DescribeGlobalTable -> ShowS
Prelude.Show, (forall x. DescribeGlobalTable -> Rep DescribeGlobalTable x)
-> (forall x. Rep DescribeGlobalTable x -> DescribeGlobalTable)
-> Generic DescribeGlobalTable
forall x. Rep DescribeGlobalTable x -> DescribeGlobalTable
forall x. DescribeGlobalTable -> Rep DescribeGlobalTable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeGlobalTable x -> DescribeGlobalTable
$cfrom :: forall x. DescribeGlobalTable -> Rep DescribeGlobalTable x
Prelude.Generic)

-- |
-- Create a value of 'DescribeGlobalTable' 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:
--
-- 'globalTableName', 'describeGlobalTable_globalTableName' - The name of the global table.
newDescribeGlobalTable ::
  -- | 'globalTableName'
  Prelude.Text ->
  DescribeGlobalTable
newDescribeGlobalTable :: Text -> DescribeGlobalTable
newDescribeGlobalTable Text
pGlobalTableName_ =
  DescribeGlobalTable' :: Text -> DescribeGlobalTable
DescribeGlobalTable'
    { $sel:globalTableName:DescribeGlobalTable' :: Text
globalTableName =
        Text
pGlobalTableName_
    }

-- | The name of the global table.
describeGlobalTable_globalTableName :: Lens.Lens' DescribeGlobalTable Prelude.Text
describeGlobalTable_globalTableName :: (Text -> f Text) -> DescribeGlobalTable -> f DescribeGlobalTable
describeGlobalTable_globalTableName = (DescribeGlobalTable -> Text)
-> (DescribeGlobalTable -> Text -> DescribeGlobalTable)
-> Lens DescribeGlobalTable DescribeGlobalTable Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGlobalTable' {Text
globalTableName :: Text
$sel:globalTableName:DescribeGlobalTable' :: DescribeGlobalTable -> Text
globalTableName} -> Text
globalTableName) (\s :: DescribeGlobalTable
s@DescribeGlobalTable' {} Text
a -> DescribeGlobalTable
s {$sel:globalTableName:DescribeGlobalTable' :: Text
globalTableName = Text
a} :: DescribeGlobalTable)

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

instance Prelude.NFData DescribeGlobalTable

instance Core.ToHeaders DescribeGlobalTable where
  toHeaders :: DescribeGlobalTable -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeGlobalTable -> 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.DescribeGlobalTable" ::
                          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 DescribeGlobalTable where
  toJSON :: DescribeGlobalTable -> Value
toJSON DescribeGlobalTable' {Text
globalTableName :: Text
$sel:globalTableName:DescribeGlobalTable' :: DescribeGlobalTable -> 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
"GlobalTableName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
globalTableName)
          ]
      )

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

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

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

-- |
-- Create a value of 'DescribeGlobalTableResponse' 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:
--
-- 'globalTableDescription', 'describeGlobalTableResponse_globalTableDescription' - Contains the details of the global table.
--
-- 'httpStatus', 'describeGlobalTableResponse_httpStatus' - The response's http status code.
newDescribeGlobalTableResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeGlobalTableResponse
newDescribeGlobalTableResponse :: Int -> DescribeGlobalTableResponse
newDescribeGlobalTableResponse Int
pHttpStatus_ =
  DescribeGlobalTableResponse' :: Maybe GlobalTableDescription -> Int -> DescribeGlobalTableResponse
DescribeGlobalTableResponse'
    { $sel:globalTableDescription:DescribeGlobalTableResponse' :: Maybe GlobalTableDescription
globalTableDescription =
        Maybe GlobalTableDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeGlobalTableResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Contains the details of the global table.
describeGlobalTableResponse_globalTableDescription :: Lens.Lens' DescribeGlobalTableResponse (Prelude.Maybe GlobalTableDescription)
describeGlobalTableResponse_globalTableDescription :: (Maybe GlobalTableDescription -> f (Maybe GlobalTableDescription))
-> DescribeGlobalTableResponse -> f DescribeGlobalTableResponse
describeGlobalTableResponse_globalTableDescription = (DescribeGlobalTableResponse -> Maybe GlobalTableDescription)
-> (DescribeGlobalTableResponse
    -> Maybe GlobalTableDescription -> DescribeGlobalTableResponse)
-> Lens
     DescribeGlobalTableResponse
     DescribeGlobalTableResponse
     (Maybe GlobalTableDescription)
     (Maybe GlobalTableDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGlobalTableResponse' {Maybe GlobalTableDescription
globalTableDescription :: Maybe GlobalTableDescription
$sel:globalTableDescription:DescribeGlobalTableResponse' :: DescribeGlobalTableResponse -> Maybe GlobalTableDescription
globalTableDescription} -> Maybe GlobalTableDescription
globalTableDescription) (\s :: DescribeGlobalTableResponse
s@DescribeGlobalTableResponse' {} Maybe GlobalTableDescription
a -> DescribeGlobalTableResponse
s {$sel:globalTableDescription:DescribeGlobalTableResponse' :: Maybe GlobalTableDescription
globalTableDescription = Maybe GlobalTableDescription
a} :: DescribeGlobalTableResponse)

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

instance Prelude.NFData DescribeGlobalTableResponse