{-# 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.LocalSecondaryIndexDescription
-- 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.LocalSecondaryIndexDescription 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.KeySchemaElement
import Amazonka.DynamoDB.Types.Projection
import Amazonka.DynamoDB.Types.WriteRequest
import qualified Amazonka.Prelude as Prelude

-- | Represents the properties of a local secondary index.
--
-- /See:/ 'newLocalSecondaryIndexDescription' smart constructor.
data LocalSecondaryIndexDescription = LocalSecondaryIndexDescription'
  { -- | The Amazon Resource Name (ARN) that uniquely identifies the index.
    LocalSecondaryIndexDescription -> Maybe Text
indexArn :: Prelude.Maybe Prelude.Text,
    -- | Represents the name of the local secondary index.
    LocalSecondaryIndexDescription -> Maybe Text
indexName :: Prelude.Maybe Prelude.Text,
    -- | The total size of the specified index, in bytes. DynamoDB updates this
    -- value approximately every six hours. Recent changes might not be
    -- reflected in this value.
    LocalSecondaryIndexDescription -> Maybe Integer
indexSizeBytes :: Prelude.Maybe Prelude.Integer,
    -- | The number of items in the specified index. DynamoDB updates this value
    -- approximately every six hours. Recent changes might not be reflected in
    -- this value.
    LocalSecondaryIndexDescription -> Maybe Integer
itemCount :: Prelude.Maybe Prelude.Integer,
    -- | The complete key schema for the local secondary index, consisting of one
    -- or more pairs of attribute names and key types:
    --
    -- -   @HASH@ - partition key
    --
    -- -   @RANGE@ - sort key
    --
    -- The partition key of an item is also known as its /hash attribute/. The
    -- term \"hash attribute\" derives from DynamoDB\'s usage of an internal
    -- hash function to evenly distribute data items across partitions, based
    -- on their partition key values.
    --
    -- The sort key of an item is also known as its /range attribute/. The term
    -- \"range attribute\" derives from the way DynamoDB stores items with the
    -- same partition key physically close together, in sorted order by the
    -- sort key value.
    LocalSecondaryIndexDescription -> Maybe (NonEmpty KeySchemaElement)
keySchema :: Prelude.Maybe (Prelude.NonEmpty KeySchemaElement),
    -- | Represents attributes that are copied (projected) from the table into
    -- the global secondary index. These are in addition to the primary key
    -- attributes and index key attributes, which are automatically projected.
    LocalSecondaryIndexDescription -> Maybe Projection
projection :: Prelude.Maybe Projection
  }
  deriving (LocalSecondaryIndexDescription
-> LocalSecondaryIndexDescription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LocalSecondaryIndexDescription
-> LocalSecondaryIndexDescription -> Bool
$c/= :: LocalSecondaryIndexDescription
-> LocalSecondaryIndexDescription -> Bool
== :: LocalSecondaryIndexDescription
-> LocalSecondaryIndexDescription -> Bool
$c== :: LocalSecondaryIndexDescription
-> LocalSecondaryIndexDescription -> Bool
Prelude.Eq, ReadPrec [LocalSecondaryIndexDescription]
ReadPrec LocalSecondaryIndexDescription
Int -> ReadS LocalSecondaryIndexDescription
ReadS [LocalSecondaryIndexDescription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LocalSecondaryIndexDescription]
$creadListPrec :: ReadPrec [LocalSecondaryIndexDescription]
readPrec :: ReadPrec LocalSecondaryIndexDescription
$creadPrec :: ReadPrec LocalSecondaryIndexDescription
readList :: ReadS [LocalSecondaryIndexDescription]
$creadList :: ReadS [LocalSecondaryIndexDescription]
readsPrec :: Int -> ReadS LocalSecondaryIndexDescription
$creadsPrec :: Int -> ReadS LocalSecondaryIndexDescription
Prelude.Read, Int -> LocalSecondaryIndexDescription -> ShowS
[LocalSecondaryIndexDescription] -> ShowS
LocalSecondaryIndexDescription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LocalSecondaryIndexDescription] -> ShowS
$cshowList :: [LocalSecondaryIndexDescription] -> ShowS
show :: LocalSecondaryIndexDescription -> String
$cshow :: LocalSecondaryIndexDescription -> String
showsPrec :: Int -> LocalSecondaryIndexDescription -> ShowS
$cshowsPrec :: Int -> LocalSecondaryIndexDescription -> ShowS
Prelude.Show, forall x.
Rep LocalSecondaryIndexDescription x
-> LocalSecondaryIndexDescription
forall x.
LocalSecondaryIndexDescription
-> Rep LocalSecondaryIndexDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LocalSecondaryIndexDescription x
-> LocalSecondaryIndexDescription
$cfrom :: forall x.
LocalSecondaryIndexDescription
-> Rep LocalSecondaryIndexDescription x
Prelude.Generic)

-- |
-- Create a value of 'LocalSecondaryIndexDescription' 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:
--
-- 'indexArn', 'localSecondaryIndexDescription_indexArn' - The Amazon Resource Name (ARN) that uniquely identifies the index.
--
-- 'indexName', 'localSecondaryIndexDescription_indexName' - Represents the name of the local secondary index.
--
-- 'indexSizeBytes', 'localSecondaryIndexDescription_indexSizeBytes' - The total size of the specified index, in bytes. DynamoDB updates this
-- value approximately every six hours. Recent changes might not be
-- reflected in this value.
--
-- 'itemCount', 'localSecondaryIndexDescription_itemCount' - The number of items in the specified index. DynamoDB updates this value
-- approximately every six hours. Recent changes might not be reflected in
-- this value.
--
-- 'keySchema', 'localSecondaryIndexDescription_keySchema' - The complete key schema for the local secondary index, consisting of one
-- or more pairs of attribute names and key types:
--
-- -   @HASH@ - partition key
--
-- -   @RANGE@ - sort key
--
-- The partition key of an item is also known as its /hash attribute/. The
-- term \"hash attribute\" derives from DynamoDB\'s usage of an internal
-- hash function to evenly distribute data items across partitions, based
-- on their partition key values.
--
-- The sort key of an item is also known as its /range attribute/. The term
-- \"range attribute\" derives from the way DynamoDB stores items with the
-- same partition key physically close together, in sorted order by the
-- sort key value.
--
-- 'projection', 'localSecondaryIndexDescription_projection' - Represents attributes that are copied (projected) from the table into
-- the global secondary index. These are in addition to the primary key
-- attributes and index key attributes, which are automatically projected.
newLocalSecondaryIndexDescription ::
  LocalSecondaryIndexDescription
newLocalSecondaryIndexDescription :: LocalSecondaryIndexDescription
newLocalSecondaryIndexDescription =
  LocalSecondaryIndexDescription'
    { $sel:indexArn:LocalSecondaryIndexDescription' :: Maybe Text
indexArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:indexName:LocalSecondaryIndexDescription' :: Maybe Text
indexName = forall a. Maybe a
Prelude.Nothing,
      $sel:indexSizeBytes:LocalSecondaryIndexDescription' :: Maybe Integer
indexSizeBytes = forall a. Maybe a
Prelude.Nothing,
      $sel:itemCount:LocalSecondaryIndexDescription' :: Maybe Integer
itemCount = forall a. Maybe a
Prelude.Nothing,
      $sel:keySchema:LocalSecondaryIndexDescription' :: Maybe (NonEmpty KeySchemaElement)
keySchema = forall a. Maybe a
Prelude.Nothing,
      $sel:projection:LocalSecondaryIndexDescription' :: Maybe Projection
projection = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) that uniquely identifies the index.
localSecondaryIndexDescription_indexArn :: Lens.Lens' LocalSecondaryIndexDescription (Prelude.Maybe Prelude.Text)
localSecondaryIndexDescription_indexArn :: Lens' LocalSecondaryIndexDescription (Maybe Text)
localSecondaryIndexDescription_indexArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocalSecondaryIndexDescription' {Maybe Text
indexArn :: Maybe Text
$sel:indexArn:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Text
indexArn} -> Maybe Text
indexArn) (\s :: LocalSecondaryIndexDescription
s@LocalSecondaryIndexDescription' {} Maybe Text
a -> LocalSecondaryIndexDescription
s {$sel:indexArn:LocalSecondaryIndexDescription' :: Maybe Text
indexArn = Maybe Text
a} :: LocalSecondaryIndexDescription)

-- | Represents the name of the local secondary index.
localSecondaryIndexDescription_indexName :: Lens.Lens' LocalSecondaryIndexDescription (Prelude.Maybe Prelude.Text)
localSecondaryIndexDescription_indexName :: Lens' LocalSecondaryIndexDescription (Maybe Text)
localSecondaryIndexDescription_indexName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocalSecondaryIndexDescription' {Maybe Text
indexName :: Maybe Text
$sel:indexName:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Text
indexName} -> Maybe Text
indexName) (\s :: LocalSecondaryIndexDescription
s@LocalSecondaryIndexDescription' {} Maybe Text
a -> LocalSecondaryIndexDescription
s {$sel:indexName:LocalSecondaryIndexDescription' :: Maybe Text
indexName = Maybe Text
a} :: LocalSecondaryIndexDescription)

-- | The total size of the specified index, in bytes. DynamoDB updates this
-- value approximately every six hours. Recent changes might not be
-- reflected in this value.
localSecondaryIndexDescription_indexSizeBytes :: Lens.Lens' LocalSecondaryIndexDescription (Prelude.Maybe Prelude.Integer)
localSecondaryIndexDescription_indexSizeBytes :: Lens' LocalSecondaryIndexDescription (Maybe Integer)
localSecondaryIndexDescription_indexSizeBytes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocalSecondaryIndexDescription' {Maybe Integer
indexSizeBytes :: Maybe Integer
$sel:indexSizeBytes:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Integer
indexSizeBytes} -> Maybe Integer
indexSizeBytes) (\s :: LocalSecondaryIndexDescription
s@LocalSecondaryIndexDescription' {} Maybe Integer
a -> LocalSecondaryIndexDescription
s {$sel:indexSizeBytes:LocalSecondaryIndexDescription' :: Maybe Integer
indexSizeBytes = Maybe Integer
a} :: LocalSecondaryIndexDescription)

-- | The number of items in the specified index. DynamoDB updates this value
-- approximately every six hours. Recent changes might not be reflected in
-- this value.
localSecondaryIndexDescription_itemCount :: Lens.Lens' LocalSecondaryIndexDescription (Prelude.Maybe Prelude.Integer)
localSecondaryIndexDescription_itemCount :: Lens' LocalSecondaryIndexDescription (Maybe Integer)
localSecondaryIndexDescription_itemCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocalSecondaryIndexDescription' {Maybe Integer
itemCount :: Maybe Integer
$sel:itemCount:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Integer
itemCount} -> Maybe Integer
itemCount) (\s :: LocalSecondaryIndexDescription
s@LocalSecondaryIndexDescription' {} Maybe Integer
a -> LocalSecondaryIndexDescription
s {$sel:itemCount:LocalSecondaryIndexDescription' :: Maybe Integer
itemCount = Maybe Integer
a} :: LocalSecondaryIndexDescription)

-- | The complete key schema for the local secondary index, consisting of one
-- or more pairs of attribute names and key types:
--
-- -   @HASH@ - partition key
--
-- -   @RANGE@ - sort key
--
-- The partition key of an item is also known as its /hash attribute/. The
-- term \"hash attribute\" derives from DynamoDB\'s usage of an internal
-- hash function to evenly distribute data items across partitions, based
-- on their partition key values.
--
-- The sort key of an item is also known as its /range attribute/. The term
-- \"range attribute\" derives from the way DynamoDB stores items with the
-- same partition key physically close together, in sorted order by the
-- sort key value.
localSecondaryIndexDescription_keySchema :: Lens.Lens' LocalSecondaryIndexDescription (Prelude.Maybe (Prelude.NonEmpty KeySchemaElement))
localSecondaryIndexDescription_keySchema :: Lens'
  LocalSecondaryIndexDescription (Maybe (NonEmpty KeySchemaElement))
localSecondaryIndexDescription_keySchema = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocalSecondaryIndexDescription' {Maybe (NonEmpty KeySchemaElement)
keySchema :: Maybe (NonEmpty KeySchemaElement)
$sel:keySchema:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe (NonEmpty KeySchemaElement)
keySchema} -> Maybe (NonEmpty KeySchemaElement)
keySchema) (\s :: LocalSecondaryIndexDescription
s@LocalSecondaryIndexDescription' {} Maybe (NonEmpty KeySchemaElement)
a -> LocalSecondaryIndexDescription
s {$sel:keySchema:LocalSecondaryIndexDescription' :: Maybe (NonEmpty KeySchemaElement)
keySchema = Maybe (NonEmpty KeySchemaElement)
a} :: LocalSecondaryIndexDescription) 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

-- | Represents attributes that are copied (projected) from the table into
-- the global secondary index. These are in addition to the primary key
-- attributes and index key attributes, which are automatically projected.
localSecondaryIndexDescription_projection :: Lens.Lens' LocalSecondaryIndexDescription (Prelude.Maybe Projection)
localSecondaryIndexDescription_projection :: Lens' LocalSecondaryIndexDescription (Maybe Projection)
localSecondaryIndexDescription_projection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocalSecondaryIndexDescription' {Maybe Projection
projection :: Maybe Projection
$sel:projection:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Projection
projection} -> Maybe Projection
projection) (\s :: LocalSecondaryIndexDescription
s@LocalSecondaryIndexDescription' {} Maybe Projection
a -> LocalSecondaryIndexDescription
s {$sel:projection:LocalSecondaryIndexDescription' :: Maybe Projection
projection = Maybe Projection
a} :: LocalSecondaryIndexDescription)

instance Data.FromJSON LocalSecondaryIndexDescription where
  parseJSON :: Value -> Parser LocalSecondaryIndexDescription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LocalSecondaryIndexDescription"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Integer
-> Maybe Integer
-> Maybe (NonEmpty KeySchemaElement)
-> Maybe Projection
-> LocalSecondaryIndexDescription
LocalSecondaryIndexDescription'
            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
"IndexArn")
            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
"IndexName")
            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
"IndexSizeBytes")
            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
"ItemCount")
            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
"KeySchema")
            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
"Projection")
      )

instance
  Prelude.Hashable
    LocalSecondaryIndexDescription
  where
  hashWithSalt :: Int -> LocalSecondaryIndexDescription -> Int
hashWithSalt
    Int
_salt
    LocalSecondaryIndexDescription' {Maybe Integer
Maybe (NonEmpty KeySchemaElement)
Maybe Text
Maybe Projection
projection :: Maybe Projection
keySchema :: Maybe (NonEmpty KeySchemaElement)
itemCount :: Maybe Integer
indexSizeBytes :: Maybe Integer
indexName :: Maybe Text
indexArn :: Maybe Text
$sel:projection:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Projection
$sel:keySchema:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe (NonEmpty KeySchemaElement)
$sel:itemCount:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Integer
$sel:indexSizeBytes:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Integer
$sel:indexName:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Text
$sel:indexArn:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
indexArn
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
indexName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
indexSizeBytes
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
itemCount
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty KeySchemaElement)
keySchema
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Projection
projection

instance
  Prelude.NFData
    LocalSecondaryIndexDescription
  where
  rnf :: LocalSecondaryIndexDescription -> ()
rnf LocalSecondaryIndexDescription' {Maybe Integer
Maybe (NonEmpty KeySchemaElement)
Maybe Text
Maybe Projection
projection :: Maybe Projection
keySchema :: Maybe (NonEmpty KeySchemaElement)
itemCount :: Maybe Integer
indexSizeBytes :: Maybe Integer
indexName :: Maybe Text
indexArn :: Maybe Text
$sel:projection:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Projection
$sel:keySchema:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe (NonEmpty KeySchemaElement)
$sel:itemCount:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Integer
$sel:indexSizeBytes:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Integer
$sel:indexName:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Text
$sel:indexArn:LocalSecondaryIndexDescription' :: LocalSecondaryIndexDescription -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
indexArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
indexName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
indexSizeBytes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
itemCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty KeySchemaElement)
keySchema
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Projection
projection