{-# 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.TableAutoScalingDescription
-- 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.TableAutoScalingDescription where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.ReplicaAutoScalingDescription
import Amazonka.DynamoDB.Types.TableStatus
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the auto scaling configuration for a global table.
--
-- /See:/ 'newTableAutoScalingDescription' smart constructor.
data TableAutoScalingDescription = TableAutoScalingDescription'
  { -- | The current state of the table:
    --
    -- -   @CREATING@ - The table is being created.
    --
    -- -   @UPDATING@ - The table is being updated.
    --
    -- -   @DELETING@ - The table is being deleted.
    --
    -- -   @ACTIVE@ - The table is ready for use.
    TableAutoScalingDescription -> Maybe TableStatus
tableStatus :: Prelude.Maybe TableStatus,
    -- | Represents replicas of the global table.
    TableAutoScalingDescription
-> Maybe [ReplicaAutoScalingDescription]
replicas :: Prelude.Maybe [ReplicaAutoScalingDescription],
    -- | The name of the table.
    TableAutoScalingDescription -> Maybe Text
tableName :: Prelude.Maybe Prelude.Text
  }
  deriving (TableAutoScalingDescription -> TableAutoScalingDescription -> Bool
(TableAutoScalingDescription
 -> TableAutoScalingDescription -> Bool)
-> (TableAutoScalingDescription
    -> TableAutoScalingDescription -> Bool)
-> Eq TableAutoScalingDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TableAutoScalingDescription -> TableAutoScalingDescription -> Bool
$c/= :: TableAutoScalingDescription -> TableAutoScalingDescription -> Bool
== :: TableAutoScalingDescription -> TableAutoScalingDescription -> Bool
$c== :: TableAutoScalingDescription -> TableAutoScalingDescription -> Bool
Prelude.Eq, ReadPrec [TableAutoScalingDescription]
ReadPrec TableAutoScalingDescription
Int -> ReadS TableAutoScalingDescription
ReadS [TableAutoScalingDescription]
(Int -> ReadS TableAutoScalingDescription)
-> ReadS [TableAutoScalingDescription]
-> ReadPrec TableAutoScalingDescription
-> ReadPrec [TableAutoScalingDescription]
-> Read TableAutoScalingDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TableAutoScalingDescription]
$creadListPrec :: ReadPrec [TableAutoScalingDescription]
readPrec :: ReadPrec TableAutoScalingDescription
$creadPrec :: ReadPrec TableAutoScalingDescription
readList :: ReadS [TableAutoScalingDescription]
$creadList :: ReadS [TableAutoScalingDescription]
readsPrec :: Int -> ReadS TableAutoScalingDescription
$creadsPrec :: Int -> ReadS TableAutoScalingDescription
Prelude.Read, Int -> TableAutoScalingDescription -> ShowS
[TableAutoScalingDescription] -> ShowS
TableAutoScalingDescription -> String
(Int -> TableAutoScalingDescription -> ShowS)
-> (TableAutoScalingDescription -> String)
-> ([TableAutoScalingDescription] -> ShowS)
-> Show TableAutoScalingDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TableAutoScalingDescription] -> ShowS
$cshowList :: [TableAutoScalingDescription] -> ShowS
show :: TableAutoScalingDescription -> String
$cshow :: TableAutoScalingDescription -> String
showsPrec :: Int -> TableAutoScalingDescription -> ShowS
$cshowsPrec :: Int -> TableAutoScalingDescription -> ShowS
Prelude.Show, (forall x.
 TableAutoScalingDescription -> Rep TableAutoScalingDescription x)
-> (forall x.
    Rep TableAutoScalingDescription x -> TableAutoScalingDescription)
-> Generic TableAutoScalingDescription
forall x.
Rep TableAutoScalingDescription x -> TableAutoScalingDescription
forall x.
TableAutoScalingDescription -> Rep TableAutoScalingDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TableAutoScalingDescription x -> TableAutoScalingDescription
$cfrom :: forall x.
TableAutoScalingDescription -> Rep TableAutoScalingDescription x
Prelude.Generic)

-- |
-- Create a value of 'TableAutoScalingDescription' 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:
--
-- 'tableStatus', 'tableAutoScalingDescription_tableStatus' - The current state of the table:
--
-- -   @CREATING@ - The table is being created.
--
-- -   @UPDATING@ - The table is being updated.
--
-- -   @DELETING@ - The table is being deleted.
--
-- -   @ACTIVE@ - The table is ready for use.
--
-- 'replicas', 'tableAutoScalingDescription_replicas' - Represents replicas of the global table.
--
-- 'tableName', 'tableAutoScalingDescription_tableName' - The name of the table.
newTableAutoScalingDescription ::
  TableAutoScalingDescription
newTableAutoScalingDescription :: TableAutoScalingDescription
newTableAutoScalingDescription =
  TableAutoScalingDescription' :: Maybe TableStatus
-> Maybe [ReplicaAutoScalingDescription]
-> Maybe Text
-> TableAutoScalingDescription
TableAutoScalingDescription'
    { $sel:tableStatus:TableAutoScalingDescription' :: Maybe TableStatus
tableStatus =
        Maybe TableStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:replicas:TableAutoScalingDescription' :: Maybe [ReplicaAutoScalingDescription]
replicas = Maybe [ReplicaAutoScalingDescription]
forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:TableAutoScalingDescription' :: Maybe Text
tableName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | Represents replicas of the global table.
tableAutoScalingDescription_replicas :: Lens.Lens' TableAutoScalingDescription (Prelude.Maybe [ReplicaAutoScalingDescription])
tableAutoScalingDescription_replicas :: (Maybe [ReplicaAutoScalingDescription]
 -> f (Maybe [ReplicaAutoScalingDescription]))
-> TableAutoScalingDescription -> f TableAutoScalingDescription
tableAutoScalingDescription_replicas = (TableAutoScalingDescription
 -> Maybe [ReplicaAutoScalingDescription])
-> (TableAutoScalingDescription
    -> Maybe [ReplicaAutoScalingDescription]
    -> TableAutoScalingDescription)
-> Lens
     TableAutoScalingDescription
     TableAutoScalingDescription
     (Maybe [ReplicaAutoScalingDescription])
     (Maybe [ReplicaAutoScalingDescription])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TableAutoScalingDescription' {Maybe [ReplicaAutoScalingDescription]
replicas :: Maybe [ReplicaAutoScalingDescription]
$sel:replicas:TableAutoScalingDescription' :: TableAutoScalingDescription
-> Maybe [ReplicaAutoScalingDescription]
replicas} -> Maybe [ReplicaAutoScalingDescription]
replicas) (\s :: TableAutoScalingDescription
s@TableAutoScalingDescription' {} Maybe [ReplicaAutoScalingDescription]
a -> TableAutoScalingDescription
s {$sel:replicas:TableAutoScalingDescription' :: Maybe [ReplicaAutoScalingDescription]
replicas = Maybe [ReplicaAutoScalingDescription]
a} :: TableAutoScalingDescription) ((Maybe [ReplicaAutoScalingDescription]
  -> f (Maybe [ReplicaAutoScalingDescription]))
 -> TableAutoScalingDescription -> f TableAutoScalingDescription)
-> ((Maybe [ReplicaAutoScalingDescription]
     -> f (Maybe [ReplicaAutoScalingDescription]))
    -> Maybe [ReplicaAutoScalingDescription]
    -> f (Maybe [ReplicaAutoScalingDescription]))
-> (Maybe [ReplicaAutoScalingDescription]
    -> f (Maybe [ReplicaAutoScalingDescription]))
-> TableAutoScalingDescription
-> f TableAutoScalingDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ReplicaAutoScalingDescription]
  [ReplicaAutoScalingDescription]
  [ReplicaAutoScalingDescription]
  [ReplicaAutoScalingDescription]
-> Iso
     (Maybe [ReplicaAutoScalingDescription])
     (Maybe [ReplicaAutoScalingDescription])
     (Maybe [ReplicaAutoScalingDescription])
     (Maybe [ReplicaAutoScalingDescription])
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
  [ReplicaAutoScalingDescription]
  [ReplicaAutoScalingDescription]
  [ReplicaAutoScalingDescription]
  [ReplicaAutoScalingDescription]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the table.
tableAutoScalingDescription_tableName :: Lens.Lens' TableAutoScalingDescription (Prelude.Maybe Prelude.Text)
tableAutoScalingDescription_tableName :: (Maybe Text -> f (Maybe Text))
-> TableAutoScalingDescription -> f TableAutoScalingDescription
tableAutoScalingDescription_tableName = (TableAutoScalingDescription -> Maybe Text)
-> (TableAutoScalingDescription
    -> Maybe Text -> TableAutoScalingDescription)
-> Lens
     TableAutoScalingDescription
     TableAutoScalingDescription
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TableAutoScalingDescription' {Maybe Text
tableName :: Maybe Text
$sel:tableName:TableAutoScalingDescription' :: TableAutoScalingDescription -> Maybe Text
tableName} -> Maybe Text
tableName) (\s :: TableAutoScalingDescription
s@TableAutoScalingDescription' {} Maybe Text
a -> TableAutoScalingDescription
s {$sel:tableName:TableAutoScalingDescription' :: Maybe Text
tableName = Maybe Text
a} :: TableAutoScalingDescription)

instance Core.FromJSON TableAutoScalingDescription where
  parseJSON :: Value -> Parser TableAutoScalingDescription
parseJSON =
    String
-> (Object -> Parser TableAutoScalingDescription)
-> Value
-> Parser TableAutoScalingDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TableAutoScalingDescription"
      ( \Object
x ->
          Maybe TableStatus
-> Maybe [ReplicaAutoScalingDescription]
-> Maybe Text
-> TableAutoScalingDescription
TableAutoScalingDescription'
            (Maybe TableStatus
 -> Maybe [ReplicaAutoScalingDescription]
 -> Maybe Text
 -> TableAutoScalingDescription)
-> Parser (Maybe TableStatus)
-> Parser
     (Maybe [ReplicaAutoScalingDescription]
      -> Maybe Text -> TableAutoScalingDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TableStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TableStatus")
            Parser
  (Maybe [ReplicaAutoScalingDescription]
   -> Maybe Text -> TableAutoScalingDescription)
-> Parser (Maybe [ReplicaAutoScalingDescription])
-> Parser (Maybe Text -> TableAutoScalingDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (Maybe [ReplicaAutoScalingDescription]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Replicas" Parser (Maybe (Maybe [ReplicaAutoScalingDescription]))
-> Maybe [ReplicaAutoScalingDescription]
-> Parser (Maybe [ReplicaAutoScalingDescription])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ReplicaAutoScalingDescription]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> TableAutoScalingDescription)
-> Parser (Maybe Text) -> Parser TableAutoScalingDescription
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
"TableName")
      )

instance Prelude.Hashable TableAutoScalingDescription

instance Prelude.NFData TableAutoScalingDescription