{-# 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.LocalSecondaryIndexInfo
-- 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.LocalSecondaryIndexInfo 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 for the table when
-- the backup was created.
--
-- /See:/ 'newLocalSecondaryIndexInfo' smart constructor.
data LocalSecondaryIndexInfo = LocalSecondaryIndexInfo'
  { -- | Represents the name of the local secondary index.
    LocalSecondaryIndexInfo -> Maybe Text
indexName :: Prelude.Maybe Prelude.Text,
    -- | The complete key schema for a local secondary index, which consists 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.
    LocalSecondaryIndexInfo -> 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.
    LocalSecondaryIndexInfo -> Maybe Projection
projection :: Prelude.Maybe Projection
  }
  deriving (LocalSecondaryIndexInfo -> LocalSecondaryIndexInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LocalSecondaryIndexInfo -> LocalSecondaryIndexInfo -> Bool
$c/= :: LocalSecondaryIndexInfo -> LocalSecondaryIndexInfo -> Bool
== :: LocalSecondaryIndexInfo -> LocalSecondaryIndexInfo -> Bool
$c== :: LocalSecondaryIndexInfo -> LocalSecondaryIndexInfo -> Bool
Prelude.Eq, ReadPrec [LocalSecondaryIndexInfo]
ReadPrec LocalSecondaryIndexInfo
Int -> ReadS LocalSecondaryIndexInfo
ReadS [LocalSecondaryIndexInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LocalSecondaryIndexInfo]
$creadListPrec :: ReadPrec [LocalSecondaryIndexInfo]
readPrec :: ReadPrec LocalSecondaryIndexInfo
$creadPrec :: ReadPrec LocalSecondaryIndexInfo
readList :: ReadS [LocalSecondaryIndexInfo]
$creadList :: ReadS [LocalSecondaryIndexInfo]
readsPrec :: Int -> ReadS LocalSecondaryIndexInfo
$creadsPrec :: Int -> ReadS LocalSecondaryIndexInfo
Prelude.Read, Int -> LocalSecondaryIndexInfo -> ShowS
[LocalSecondaryIndexInfo] -> ShowS
LocalSecondaryIndexInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LocalSecondaryIndexInfo] -> ShowS
$cshowList :: [LocalSecondaryIndexInfo] -> ShowS
show :: LocalSecondaryIndexInfo -> String
$cshow :: LocalSecondaryIndexInfo -> String
showsPrec :: Int -> LocalSecondaryIndexInfo -> ShowS
$cshowsPrec :: Int -> LocalSecondaryIndexInfo -> ShowS
Prelude.Show, forall x. Rep LocalSecondaryIndexInfo x -> LocalSecondaryIndexInfo
forall x. LocalSecondaryIndexInfo -> Rep LocalSecondaryIndexInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LocalSecondaryIndexInfo x -> LocalSecondaryIndexInfo
$cfrom :: forall x. LocalSecondaryIndexInfo -> Rep LocalSecondaryIndexInfo x
Prelude.Generic)

-- |
-- Create a value of 'LocalSecondaryIndexInfo' 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:
--
-- 'indexName', 'localSecondaryIndexInfo_indexName' - Represents the name of the local secondary index.
--
-- 'keySchema', 'localSecondaryIndexInfo_keySchema' - The complete key schema for a local secondary index, which consists 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', 'localSecondaryIndexInfo_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.
newLocalSecondaryIndexInfo ::
  LocalSecondaryIndexInfo
newLocalSecondaryIndexInfo :: LocalSecondaryIndexInfo
newLocalSecondaryIndexInfo =
  LocalSecondaryIndexInfo'
    { $sel:indexName:LocalSecondaryIndexInfo' :: Maybe Text
indexName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:keySchema:LocalSecondaryIndexInfo' :: Maybe (NonEmpty KeySchemaElement)
keySchema = forall a. Maybe a
Prelude.Nothing,
      $sel:projection:LocalSecondaryIndexInfo' :: Maybe Projection
projection = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The complete key schema for a local secondary index, which consists 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.
localSecondaryIndexInfo_keySchema :: Lens.Lens' LocalSecondaryIndexInfo (Prelude.Maybe (Prelude.NonEmpty KeySchemaElement))
localSecondaryIndexInfo_keySchema :: Lens' LocalSecondaryIndexInfo (Maybe (NonEmpty KeySchemaElement))
localSecondaryIndexInfo_keySchema = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocalSecondaryIndexInfo' {Maybe (NonEmpty KeySchemaElement)
keySchema :: Maybe (NonEmpty KeySchemaElement)
$sel:keySchema:LocalSecondaryIndexInfo' :: LocalSecondaryIndexInfo -> Maybe (NonEmpty KeySchemaElement)
keySchema} -> Maybe (NonEmpty KeySchemaElement)
keySchema) (\s :: LocalSecondaryIndexInfo
s@LocalSecondaryIndexInfo' {} Maybe (NonEmpty KeySchemaElement)
a -> LocalSecondaryIndexInfo
s {$sel:keySchema:LocalSecondaryIndexInfo' :: Maybe (NonEmpty KeySchemaElement)
keySchema = Maybe (NonEmpty KeySchemaElement)
a} :: LocalSecondaryIndexInfo) 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.
localSecondaryIndexInfo_projection :: Lens.Lens' LocalSecondaryIndexInfo (Prelude.Maybe Projection)
localSecondaryIndexInfo_projection :: Lens' LocalSecondaryIndexInfo (Maybe Projection)
localSecondaryIndexInfo_projection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocalSecondaryIndexInfo' {Maybe Projection
projection :: Maybe Projection
$sel:projection:LocalSecondaryIndexInfo' :: LocalSecondaryIndexInfo -> Maybe Projection
projection} -> Maybe Projection
projection) (\s :: LocalSecondaryIndexInfo
s@LocalSecondaryIndexInfo' {} Maybe Projection
a -> LocalSecondaryIndexInfo
s {$sel:projection:LocalSecondaryIndexInfo' :: Maybe Projection
projection = Maybe Projection
a} :: LocalSecondaryIndexInfo)

instance Data.FromJSON LocalSecondaryIndexInfo where
  parseJSON :: Value -> Parser LocalSecondaryIndexInfo
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LocalSecondaryIndexInfo"
      ( \Object
x ->
          Maybe Text
-> Maybe (NonEmpty KeySchemaElement)
-> Maybe Projection
-> LocalSecondaryIndexInfo
LocalSecondaryIndexInfo'
            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
"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
"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 LocalSecondaryIndexInfo where
  hashWithSalt :: Int -> LocalSecondaryIndexInfo -> Int
hashWithSalt Int
_salt LocalSecondaryIndexInfo' {Maybe (NonEmpty KeySchemaElement)
Maybe Text
Maybe Projection
projection :: Maybe Projection
keySchema :: Maybe (NonEmpty KeySchemaElement)
indexName :: Maybe Text
$sel:projection:LocalSecondaryIndexInfo' :: LocalSecondaryIndexInfo -> Maybe Projection
$sel:keySchema:LocalSecondaryIndexInfo' :: LocalSecondaryIndexInfo -> Maybe (NonEmpty KeySchemaElement)
$sel:indexName:LocalSecondaryIndexInfo' :: LocalSecondaryIndexInfo -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
indexName
      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 LocalSecondaryIndexInfo where
  rnf :: LocalSecondaryIndexInfo -> ()
rnf LocalSecondaryIndexInfo' {Maybe (NonEmpty KeySchemaElement)
Maybe Text
Maybe Projection
projection :: Maybe Projection
keySchema :: Maybe (NonEmpty KeySchemaElement)
indexName :: Maybe Text
$sel:projection:LocalSecondaryIndexInfo' :: LocalSecondaryIndexInfo -> Maybe Projection
$sel:keySchema:LocalSecondaryIndexInfo' :: LocalSecondaryIndexInfo -> Maybe (NonEmpty KeySchemaElement)
$sel:indexName:LocalSecondaryIndexInfo' :: LocalSecondaryIndexInfo -> Maybe Text
..} =
    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 (NonEmpty KeySchemaElement)
keySchema
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Projection
projection