{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.GlobalTableDescription
-- 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)
module Amazonka.DynamoDB.Types.GlobalTableDescription where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.GlobalTableStatus
import Amazonka.DynamoDB.Types.ReplicaDescription
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains details about the global table.
--
-- /See:/ 'newGlobalTableDescription' smart constructor.
data GlobalTableDescription = GlobalTableDescription'
  { -- | The current state of the global table:
    --
    -- -   @CREATING@ - The global table is being created.
    --
    -- -   @UPDATING@ - The global table is being updated.
    --
    -- -   @DELETING@ - The global table is being deleted.
    --
    -- -   @ACTIVE@ - The global table is ready for use.
    GlobalTableDescription -> Maybe GlobalTableStatus
globalTableStatus :: Prelude.Maybe GlobalTableStatus,
    -- | The global table name.
    GlobalTableDescription -> Maybe Text
globalTableName :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier of the global table.
    GlobalTableDescription -> Maybe Text
globalTableArn :: Prelude.Maybe Prelude.Text,
    -- | The creation time of the global table.
    GlobalTableDescription -> Maybe POSIX
creationDateTime :: Prelude.Maybe Core.POSIX,
    -- | The Regions where the global table has replicas.
    GlobalTableDescription -> Maybe [ReplicaDescription]
replicationGroup :: Prelude.Maybe [ReplicaDescription]
  }
  deriving (GlobalTableDescription -> GlobalTableDescription -> Bool
(GlobalTableDescription -> GlobalTableDescription -> Bool)
-> (GlobalTableDescription -> GlobalTableDescription -> Bool)
-> Eq GlobalTableDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlobalTableDescription -> GlobalTableDescription -> Bool
$c/= :: GlobalTableDescription -> GlobalTableDescription -> Bool
== :: GlobalTableDescription -> GlobalTableDescription -> Bool
$c== :: GlobalTableDescription -> GlobalTableDescription -> Bool
Prelude.Eq, ReadPrec [GlobalTableDescription]
ReadPrec GlobalTableDescription
Int -> ReadS GlobalTableDescription
ReadS [GlobalTableDescription]
(Int -> ReadS GlobalTableDescription)
-> ReadS [GlobalTableDescription]
-> ReadPrec GlobalTableDescription
-> ReadPrec [GlobalTableDescription]
-> Read GlobalTableDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GlobalTableDescription]
$creadListPrec :: ReadPrec [GlobalTableDescription]
readPrec :: ReadPrec GlobalTableDescription
$creadPrec :: ReadPrec GlobalTableDescription
readList :: ReadS [GlobalTableDescription]
$creadList :: ReadS [GlobalTableDescription]
readsPrec :: Int -> ReadS GlobalTableDescription
$creadsPrec :: Int -> ReadS GlobalTableDescription
Prelude.Read, Int -> GlobalTableDescription -> ShowS
[GlobalTableDescription] -> ShowS
GlobalTableDescription -> String
(Int -> GlobalTableDescription -> ShowS)
-> (GlobalTableDescription -> String)
-> ([GlobalTableDescription] -> ShowS)
-> Show GlobalTableDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GlobalTableDescription] -> ShowS
$cshowList :: [GlobalTableDescription] -> ShowS
show :: GlobalTableDescription -> String
$cshow :: GlobalTableDescription -> String
showsPrec :: Int -> GlobalTableDescription -> ShowS
$cshowsPrec :: Int -> GlobalTableDescription -> ShowS
Prelude.Show, (forall x. GlobalTableDescription -> Rep GlobalTableDescription x)
-> (forall x.
    Rep GlobalTableDescription x -> GlobalTableDescription)
-> Generic GlobalTableDescription
forall x. Rep GlobalTableDescription x -> GlobalTableDescription
forall x. GlobalTableDescription -> Rep GlobalTableDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GlobalTableDescription x -> GlobalTableDescription
$cfrom :: forall x. GlobalTableDescription -> Rep GlobalTableDescription x
Prelude.Generic)

-- |
-- Create a value of 'GlobalTableDescription' 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:
--
-- 'globalTableStatus', 'globalTableDescription_globalTableStatus' - The current state of the global table:
--
-- -   @CREATING@ - The global table is being created.
--
-- -   @UPDATING@ - The global table is being updated.
--
-- -   @DELETING@ - The global table is being deleted.
--
-- -   @ACTIVE@ - The global table is ready for use.
--
-- 'globalTableName', 'globalTableDescription_globalTableName' - The global table name.
--
-- 'globalTableArn', 'globalTableDescription_globalTableArn' - The unique identifier of the global table.
--
-- 'creationDateTime', 'globalTableDescription_creationDateTime' - The creation time of the global table.
--
-- 'replicationGroup', 'globalTableDescription_replicationGroup' - The Regions where the global table has replicas.
newGlobalTableDescription ::
  GlobalTableDescription
newGlobalTableDescription :: GlobalTableDescription
newGlobalTableDescription =
  GlobalTableDescription' :: Maybe GlobalTableStatus
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe [ReplicaDescription]
-> GlobalTableDescription
GlobalTableDescription'
    { $sel:globalTableStatus:GlobalTableDescription' :: Maybe GlobalTableStatus
globalTableStatus =
        Maybe GlobalTableStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:globalTableName:GlobalTableDescription' :: Maybe Text
globalTableName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:globalTableArn:GlobalTableDescription' :: Maybe Text
globalTableArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDateTime:GlobalTableDescription' :: Maybe POSIX
creationDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:replicationGroup:GlobalTableDescription' :: Maybe [ReplicaDescription]
replicationGroup = Maybe [ReplicaDescription]
forall a. Maybe a
Prelude.Nothing
    }

-- | The current state of the global table:
--
-- -   @CREATING@ - The global table is being created.
--
-- -   @UPDATING@ - The global table is being updated.
--
-- -   @DELETING@ - The global table is being deleted.
--
-- -   @ACTIVE@ - The global table is ready for use.
globalTableDescription_globalTableStatus :: Lens.Lens' GlobalTableDescription (Prelude.Maybe GlobalTableStatus)
globalTableDescription_globalTableStatus :: (Maybe GlobalTableStatus -> f (Maybe GlobalTableStatus))
-> GlobalTableDescription -> f GlobalTableDescription
globalTableDescription_globalTableStatus = (GlobalTableDescription -> Maybe GlobalTableStatus)
-> (GlobalTableDescription
    -> Maybe GlobalTableStatus -> GlobalTableDescription)
-> Lens
     GlobalTableDescription
     GlobalTableDescription
     (Maybe GlobalTableStatus)
     (Maybe GlobalTableStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalTableDescription' {Maybe GlobalTableStatus
globalTableStatus :: Maybe GlobalTableStatus
$sel:globalTableStatus:GlobalTableDescription' :: GlobalTableDescription -> Maybe GlobalTableStatus
globalTableStatus} -> Maybe GlobalTableStatus
globalTableStatus) (\s :: GlobalTableDescription
s@GlobalTableDescription' {} Maybe GlobalTableStatus
a -> GlobalTableDescription
s {$sel:globalTableStatus:GlobalTableDescription' :: Maybe GlobalTableStatus
globalTableStatus = Maybe GlobalTableStatus
a} :: GlobalTableDescription)

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

-- | The unique identifier of the global table.
globalTableDescription_globalTableArn :: Lens.Lens' GlobalTableDescription (Prelude.Maybe Prelude.Text)
globalTableDescription_globalTableArn :: (Maybe Text -> f (Maybe Text))
-> GlobalTableDescription -> f GlobalTableDescription
globalTableDescription_globalTableArn = (GlobalTableDescription -> Maybe Text)
-> (GlobalTableDescription -> Maybe Text -> GlobalTableDescription)
-> Lens
     GlobalTableDescription
     GlobalTableDescription
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalTableDescription' {Maybe Text
globalTableArn :: Maybe Text
$sel:globalTableArn:GlobalTableDescription' :: GlobalTableDescription -> Maybe Text
globalTableArn} -> Maybe Text
globalTableArn) (\s :: GlobalTableDescription
s@GlobalTableDescription' {} Maybe Text
a -> GlobalTableDescription
s {$sel:globalTableArn:GlobalTableDescription' :: Maybe Text
globalTableArn = Maybe Text
a} :: GlobalTableDescription)

-- | The creation time of the global table.
globalTableDescription_creationDateTime :: Lens.Lens' GlobalTableDescription (Prelude.Maybe Prelude.UTCTime)
globalTableDescription_creationDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GlobalTableDescription -> f GlobalTableDescription
globalTableDescription_creationDateTime = (GlobalTableDescription -> Maybe POSIX)
-> (GlobalTableDescription
    -> Maybe POSIX -> GlobalTableDescription)
-> Lens
     GlobalTableDescription
     GlobalTableDescription
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalTableDescription' {Maybe POSIX
creationDateTime :: Maybe POSIX
$sel:creationDateTime:GlobalTableDescription' :: GlobalTableDescription -> Maybe POSIX
creationDateTime} -> Maybe POSIX
creationDateTime) (\s :: GlobalTableDescription
s@GlobalTableDescription' {} Maybe POSIX
a -> GlobalTableDescription
s {$sel:creationDateTime:GlobalTableDescription' :: Maybe POSIX
creationDateTime = Maybe POSIX
a} :: GlobalTableDescription) ((Maybe POSIX -> f (Maybe POSIX))
 -> GlobalTableDescription -> f GlobalTableDescription)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GlobalTableDescription
-> f GlobalTableDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The Regions where the global table has replicas.
globalTableDescription_replicationGroup :: Lens.Lens' GlobalTableDescription (Prelude.Maybe [ReplicaDescription])
globalTableDescription_replicationGroup :: (Maybe [ReplicaDescription] -> f (Maybe [ReplicaDescription]))
-> GlobalTableDescription -> f GlobalTableDescription
globalTableDescription_replicationGroup = (GlobalTableDescription -> Maybe [ReplicaDescription])
-> (GlobalTableDescription
    -> Maybe [ReplicaDescription] -> GlobalTableDescription)
-> Lens
     GlobalTableDescription
     GlobalTableDescription
     (Maybe [ReplicaDescription])
     (Maybe [ReplicaDescription])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalTableDescription' {Maybe [ReplicaDescription]
replicationGroup :: Maybe [ReplicaDescription]
$sel:replicationGroup:GlobalTableDescription' :: GlobalTableDescription -> Maybe [ReplicaDescription]
replicationGroup} -> Maybe [ReplicaDescription]
replicationGroup) (\s :: GlobalTableDescription
s@GlobalTableDescription' {} Maybe [ReplicaDescription]
a -> GlobalTableDescription
s {$sel:replicationGroup:GlobalTableDescription' :: Maybe [ReplicaDescription]
replicationGroup = Maybe [ReplicaDescription]
a} :: GlobalTableDescription) ((Maybe [ReplicaDescription] -> f (Maybe [ReplicaDescription]))
 -> GlobalTableDescription -> f GlobalTableDescription)
-> ((Maybe [ReplicaDescription] -> f (Maybe [ReplicaDescription]))
    -> Maybe [ReplicaDescription] -> f (Maybe [ReplicaDescription]))
-> (Maybe [ReplicaDescription] -> f (Maybe [ReplicaDescription]))
-> GlobalTableDescription
-> f GlobalTableDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ReplicaDescription]
  [ReplicaDescription]
  [ReplicaDescription]
  [ReplicaDescription]
-> Iso
     (Maybe [ReplicaDescription])
     (Maybe [ReplicaDescription])
     (Maybe [ReplicaDescription])
     (Maybe [ReplicaDescription])
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
  [ReplicaDescription]
  [ReplicaDescription]
  [ReplicaDescription]
  [ReplicaDescription]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON GlobalTableDescription where
  parseJSON :: Value -> Parser GlobalTableDescription
parseJSON =
    String
-> (Object -> Parser GlobalTableDescription)
-> Value
-> Parser GlobalTableDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GlobalTableDescription"
      ( \Object
x ->
          Maybe GlobalTableStatus
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe [ReplicaDescription]
-> GlobalTableDescription
GlobalTableDescription'
            (Maybe GlobalTableStatus
 -> Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe [ReplicaDescription]
 -> GlobalTableDescription)
-> Parser (Maybe GlobalTableStatus)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe [ReplicaDescription]
      -> GlobalTableDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe GlobalTableStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GlobalTableStatus")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe [ReplicaDescription]
   -> GlobalTableDescription)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe [ReplicaDescription]
      -> GlobalTableDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GlobalTableName")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe [ReplicaDescription]
   -> GlobalTableDescription)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe [ReplicaDescription] -> GlobalTableDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GlobalTableArn")
            Parser
  (Maybe POSIX
   -> Maybe [ReplicaDescription] -> GlobalTableDescription)
-> Parser (Maybe POSIX)
-> Parser (Maybe [ReplicaDescription] -> GlobalTableDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreationDateTime")
            Parser (Maybe [ReplicaDescription] -> GlobalTableDescription)
-> Parser (Maybe [ReplicaDescription])
-> Parser GlobalTableDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [ReplicaDescription]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReplicationGroup"
                            Parser (Maybe (Maybe [ReplicaDescription]))
-> Maybe [ReplicaDescription]
-> Parser (Maybe [ReplicaDescription])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ReplicaDescription]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable GlobalTableDescription

instance Prelude.NFData GlobalTableDescription