{-# 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 #-}
module Amazonka.DynamoDB.Types.GlobalSecondaryIndex where
import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.KeySchemaElement
import Amazonka.DynamoDB.Types.Projection
import Amazonka.DynamoDB.Types.ProvisionedThroughput
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data GlobalSecondaryIndex = GlobalSecondaryIndex'
{
GlobalSecondaryIndex -> Maybe ProvisionedThroughput
provisionedThroughput :: Prelude.Maybe ProvisionedThroughput,
GlobalSecondaryIndex -> Text
indexName :: Prelude.Text,
GlobalSecondaryIndex -> NonEmpty KeySchemaElement
keySchema :: Prelude.NonEmpty KeySchemaElement,
GlobalSecondaryIndex -> Projection
projection :: Projection
}
deriving (GlobalSecondaryIndex -> GlobalSecondaryIndex -> Bool
(GlobalSecondaryIndex -> GlobalSecondaryIndex -> Bool)
-> (GlobalSecondaryIndex -> GlobalSecondaryIndex -> Bool)
-> Eq GlobalSecondaryIndex
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlobalSecondaryIndex -> GlobalSecondaryIndex -> Bool
$c/= :: GlobalSecondaryIndex -> GlobalSecondaryIndex -> Bool
== :: GlobalSecondaryIndex -> GlobalSecondaryIndex -> Bool
$c== :: GlobalSecondaryIndex -> GlobalSecondaryIndex -> Bool
Prelude.Eq, ReadPrec [GlobalSecondaryIndex]
ReadPrec GlobalSecondaryIndex
Int -> ReadS GlobalSecondaryIndex
ReadS [GlobalSecondaryIndex]
(Int -> ReadS GlobalSecondaryIndex)
-> ReadS [GlobalSecondaryIndex]
-> ReadPrec GlobalSecondaryIndex
-> ReadPrec [GlobalSecondaryIndex]
-> Read GlobalSecondaryIndex
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GlobalSecondaryIndex]
$creadListPrec :: ReadPrec [GlobalSecondaryIndex]
readPrec :: ReadPrec GlobalSecondaryIndex
$creadPrec :: ReadPrec GlobalSecondaryIndex
readList :: ReadS [GlobalSecondaryIndex]
$creadList :: ReadS [GlobalSecondaryIndex]
readsPrec :: Int -> ReadS GlobalSecondaryIndex
$creadsPrec :: Int -> ReadS GlobalSecondaryIndex
Prelude.Read, Int -> GlobalSecondaryIndex -> ShowS
[GlobalSecondaryIndex] -> ShowS
GlobalSecondaryIndex -> String
(Int -> GlobalSecondaryIndex -> ShowS)
-> (GlobalSecondaryIndex -> String)
-> ([GlobalSecondaryIndex] -> ShowS)
-> Show GlobalSecondaryIndex
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GlobalSecondaryIndex] -> ShowS
$cshowList :: [GlobalSecondaryIndex] -> ShowS
show :: GlobalSecondaryIndex -> String
$cshow :: GlobalSecondaryIndex -> String
showsPrec :: Int -> GlobalSecondaryIndex -> ShowS
$cshowsPrec :: Int -> GlobalSecondaryIndex -> ShowS
Prelude.Show, (forall x. GlobalSecondaryIndex -> Rep GlobalSecondaryIndex x)
-> (forall x. Rep GlobalSecondaryIndex x -> GlobalSecondaryIndex)
-> Generic GlobalSecondaryIndex
forall x. Rep GlobalSecondaryIndex x -> GlobalSecondaryIndex
forall x. GlobalSecondaryIndex -> Rep GlobalSecondaryIndex x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GlobalSecondaryIndex x -> GlobalSecondaryIndex
$cfrom :: forall x. GlobalSecondaryIndex -> Rep GlobalSecondaryIndex x
Prelude.Generic)
newGlobalSecondaryIndex ::
Prelude.Text ->
Prelude.NonEmpty KeySchemaElement ->
Projection ->
GlobalSecondaryIndex
newGlobalSecondaryIndex :: Text
-> NonEmpty KeySchemaElement -> Projection -> GlobalSecondaryIndex
newGlobalSecondaryIndex
Text
pIndexName_
NonEmpty KeySchemaElement
pKeySchema_
Projection
pProjection_ =
GlobalSecondaryIndex' :: Maybe ProvisionedThroughput
-> Text
-> NonEmpty KeySchemaElement
-> Projection
-> GlobalSecondaryIndex
GlobalSecondaryIndex'
{ $sel:provisionedThroughput:GlobalSecondaryIndex' :: Maybe ProvisionedThroughput
provisionedThroughput =
Maybe ProvisionedThroughput
forall a. Maybe a
Prelude.Nothing,
$sel:indexName:GlobalSecondaryIndex' :: Text
indexName = Text
pIndexName_,
$sel:keySchema:GlobalSecondaryIndex' :: NonEmpty KeySchemaElement
keySchema = Tagged
(NonEmpty KeySchemaElement) (Identity (NonEmpty KeySchemaElement))
-> Tagged
(NonEmpty KeySchemaElement) (Identity (NonEmpty KeySchemaElement))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty KeySchemaElement) (Identity (NonEmpty KeySchemaElement))
-> Tagged
(NonEmpty KeySchemaElement) (Identity (NonEmpty KeySchemaElement)))
-> NonEmpty KeySchemaElement -> NonEmpty KeySchemaElement
forall t b. AReview t b -> b -> t
Lens.# NonEmpty KeySchemaElement
pKeySchema_,
$sel:projection:GlobalSecondaryIndex' :: Projection
projection = Projection
pProjection_
}
globalSecondaryIndex_provisionedThroughput :: Lens.Lens' GlobalSecondaryIndex (Prelude.Maybe ProvisionedThroughput)
globalSecondaryIndex_provisionedThroughput :: (Maybe ProvisionedThroughput -> f (Maybe ProvisionedThroughput))
-> GlobalSecondaryIndex -> f GlobalSecondaryIndex
globalSecondaryIndex_provisionedThroughput = (GlobalSecondaryIndex -> Maybe ProvisionedThroughput)
-> (GlobalSecondaryIndex
-> Maybe ProvisionedThroughput -> GlobalSecondaryIndex)
-> Lens
GlobalSecondaryIndex
GlobalSecondaryIndex
(Maybe ProvisionedThroughput)
(Maybe ProvisionedThroughput)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalSecondaryIndex' {Maybe ProvisionedThroughput
provisionedThroughput :: Maybe ProvisionedThroughput
$sel:provisionedThroughput:GlobalSecondaryIndex' :: GlobalSecondaryIndex -> Maybe ProvisionedThroughput
provisionedThroughput} -> Maybe ProvisionedThroughput
provisionedThroughput) (\s :: GlobalSecondaryIndex
s@GlobalSecondaryIndex' {} Maybe ProvisionedThroughput
a -> GlobalSecondaryIndex
s {$sel:provisionedThroughput:GlobalSecondaryIndex' :: Maybe ProvisionedThroughput
provisionedThroughput = Maybe ProvisionedThroughput
a} :: GlobalSecondaryIndex)
globalSecondaryIndex_indexName :: Lens.Lens' GlobalSecondaryIndex Prelude.Text
globalSecondaryIndex_indexName :: (Text -> f Text) -> GlobalSecondaryIndex -> f GlobalSecondaryIndex
globalSecondaryIndex_indexName = (GlobalSecondaryIndex -> Text)
-> (GlobalSecondaryIndex -> Text -> GlobalSecondaryIndex)
-> Lens GlobalSecondaryIndex GlobalSecondaryIndex Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalSecondaryIndex' {Text
indexName :: Text
$sel:indexName:GlobalSecondaryIndex' :: GlobalSecondaryIndex -> Text
indexName} -> Text
indexName) (\s :: GlobalSecondaryIndex
s@GlobalSecondaryIndex' {} Text
a -> GlobalSecondaryIndex
s {$sel:indexName:GlobalSecondaryIndex' :: Text
indexName = Text
a} :: GlobalSecondaryIndex)
globalSecondaryIndex_keySchema :: Lens.Lens' GlobalSecondaryIndex (Prelude.NonEmpty KeySchemaElement)
globalSecondaryIndex_keySchema :: (NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement))
-> GlobalSecondaryIndex -> f GlobalSecondaryIndex
globalSecondaryIndex_keySchema = (GlobalSecondaryIndex -> NonEmpty KeySchemaElement)
-> (GlobalSecondaryIndex
-> NonEmpty KeySchemaElement -> GlobalSecondaryIndex)
-> Lens
GlobalSecondaryIndex
GlobalSecondaryIndex
(NonEmpty KeySchemaElement)
(NonEmpty KeySchemaElement)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalSecondaryIndex' {NonEmpty KeySchemaElement
keySchema :: NonEmpty KeySchemaElement
$sel:keySchema:GlobalSecondaryIndex' :: GlobalSecondaryIndex -> NonEmpty KeySchemaElement
keySchema} -> NonEmpty KeySchemaElement
keySchema) (\s :: GlobalSecondaryIndex
s@GlobalSecondaryIndex' {} NonEmpty KeySchemaElement
a -> GlobalSecondaryIndex
s {$sel:keySchema:GlobalSecondaryIndex' :: NonEmpty KeySchemaElement
keySchema = NonEmpty KeySchemaElement
a} :: GlobalSecondaryIndex) ((NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement))
-> GlobalSecondaryIndex -> f GlobalSecondaryIndex)
-> ((NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement))
-> NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement))
-> (NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement))
-> GlobalSecondaryIndex
-> f GlobalSecondaryIndex
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement))
-> NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
globalSecondaryIndex_projection :: Lens.Lens' GlobalSecondaryIndex Projection
globalSecondaryIndex_projection :: (Projection -> f Projection)
-> GlobalSecondaryIndex -> f GlobalSecondaryIndex
globalSecondaryIndex_projection = (GlobalSecondaryIndex -> Projection)
-> (GlobalSecondaryIndex -> Projection -> GlobalSecondaryIndex)
-> Lens
GlobalSecondaryIndex GlobalSecondaryIndex Projection Projection
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalSecondaryIndex' {Projection
projection :: Projection
$sel:projection:GlobalSecondaryIndex' :: GlobalSecondaryIndex -> Projection
projection} -> Projection
projection) (\s :: GlobalSecondaryIndex
s@GlobalSecondaryIndex' {} Projection
a -> GlobalSecondaryIndex
s {$sel:projection:GlobalSecondaryIndex' :: Projection
projection = Projection
a} :: GlobalSecondaryIndex)
instance Prelude.Hashable GlobalSecondaryIndex
instance Prelude.NFData GlobalSecondaryIndex
instance Core.ToJSON GlobalSecondaryIndex where
toJSON :: GlobalSecondaryIndex -> Value
toJSON GlobalSecondaryIndex' {Maybe ProvisionedThroughput
NonEmpty KeySchemaElement
Text
Projection
projection :: Projection
keySchema :: NonEmpty KeySchemaElement
indexName :: Text
provisionedThroughput :: Maybe ProvisionedThroughput
$sel:projection:GlobalSecondaryIndex' :: GlobalSecondaryIndex -> Projection
$sel:keySchema:GlobalSecondaryIndex' :: GlobalSecondaryIndex -> NonEmpty KeySchemaElement
$sel:indexName:GlobalSecondaryIndex' :: GlobalSecondaryIndex -> Text
$sel:provisionedThroughput:GlobalSecondaryIndex' :: GlobalSecondaryIndex -> Maybe ProvisionedThroughput
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ProvisionedThroughput" Text -> ProvisionedThroughput -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(ProvisionedThroughput -> Pair)
-> Maybe ProvisionedThroughput -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ProvisionedThroughput
provisionedThroughput,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"IndexName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
indexName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"KeySchema" Text -> NonEmpty KeySchemaElement -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty KeySchemaElement
keySchema),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Projection" Text -> Projection -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Projection
projection)
]
)