{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DynamoDB.Types.TableAutoScalingDescription where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DynamoDB.Types.AttributeValue
import Amazonka.DynamoDB.Types.ReplicaAutoScalingDescription
import Amazonka.DynamoDB.Types.TableStatus
import Amazonka.DynamoDB.Types.WriteRequest
import qualified Amazonka.Prelude as Prelude

-- | Represents the auto scaling configuration for a global table.
--
-- /See:/ 'newTableAutoScalingDescription' smart constructor.
data TableAutoScalingDescription = TableAutoScalingDescription'
  { -- | 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,
    -- | 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
  }
  deriving (TableAutoScalingDescription -> TableAutoScalingDescription -> Bool
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]
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
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.
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:
--
-- 'replicas', 'tableAutoScalingDescription_replicas' - Represents replicas of the global table.
--
-- 'tableName', 'tableAutoScalingDescription_tableName' - The name of the table.
--
-- '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.
newTableAutoScalingDescription ::
  TableAutoScalingDescription
newTableAutoScalingDescription :: TableAutoScalingDescription
newTableAutoScalingDescription =
  TableAutoScalingDescription'
    { $sel:replicas:TableAutoScalingDescription' :: Maybe [ReplicaAutoScalingDescription]
replicas =
        forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:TableAutoScalingDescription' :: Maybe Text
tableName = forall a. Maybe a
Prelude.Nothing,
      $sel:tableStatus:TableAutoScalingDescription' :: Maybe TableStatus
tableStatus = forall a. Maybe a
Prelude.Nothing
    }

-- | Represents replicas of the global table.
tableAutoScalingDescription_replicas :: Lens.Lens' TableAutoScalingDescription (Prelude.Maybe [ReplicaAutoScalingDescription])
tableAutoScalingDescription_replicas :: Lens'
  TableAutoScalingDescription (Maybe [ReplicaAutoScalingDescription])
tableAutoScalingDescription_replicas = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' TableAutoScalingDescription (Maybe Text)
tableAutoScalingDescription_tableName = 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)

-- | 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 :: Lens' TableAutoScalingDescription (Maybe TableStatus)
tableAutoScalingDescription_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)

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

instance Prelude.Hashable TableAutoScalingDescription where
  hashWithSalt :: Int -> TableAutoScalingDescription -> Int
hashWithSalt Int
_salt TableAutoScalingDescription' {Maybe [ReplicaAutoScalingDescription]
Maybe Text
Maybe TableStatus
tableStatus :: Maybe TableStatus
tableName :: Maybe Text
replicas :: Maybe [ReplicaAutoScalingDescription]
$sel:tableStatus:TableAutoScalingDescription' :: TableAutoScalingDescription -> Maybe TableStatus
$sel:tableName:TableAutoScalingDescription' :: TableAutoScalingDescription -> Maybe Text
$sel:replicas:TableAutoScalingDescription' :: TableAutoScalingDescription
-> Maybe [ReplicaAutoScalingDescription]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ReplicaAutoScalingDescription]
replicas
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
tableName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TableStatus
tableStatus

instance Prelude.NFData TableAutoScalingDescription where
  rnf :: TableAutoScalingDescription -> ()
rnf TableAutoScalingDescription' {Maybe [ReplicaAutoScalingDescription]
Maybe Text
Maybe TableStatus
tableStatus :: Maybe TableStatus
tableName :: Maybe Text
replicas :: Maybe [ReplicaAutoScalingDescription]
$sel:tableStatus:TableAutoScalingDescription' :: TableAutoScalingDescription -> Maybe TableStatus
$sel:tableName:TableAutoScalingDescription' :: TableAutoScalingDescription -> Maybe Text
$sel:replicas:TableAutoScalingDescription' :: TableAutoScalingDescription
-> Maybe [ReplicaAutoScalingDescription]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ReplicaAutoScalingDescription]
replicas
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
tableName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TableStatus
tableStatus