{-# 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 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.ProvisionedThroughput
import Amazonka.DynamoDB.Types.WriteRequest
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
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]
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
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. 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'
{ $sel:provisionedThroughput:GlobalSecondaryIndex' :: Maybe ProvisionedThroughput
provisionedThroughput =
forall a. Maybe a
Prelude.Nothing,
$sel:indexName:GlobalSecondaryIndex' :: Text
indexName = Text
pIndexName_,
$sel:keySchema:GlobalSecondaryIndex' :: NonEmpty KeySchemaElement
keySchema = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced 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 :: Lens' GlobalSecondaryIndex (Maybe ProvisionedThroughput)
globalSecondaryIndex_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 :: Lens' GlobalSecondaryIndex Text
globalSecondaryIndex_indexName = 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 :: Lens' GlobalSecondaryIndex (NonEmpty KeySchemaElement)
globalSecondaryIndex_keySchema = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 :: Lens' GlobalSecondaryIndex Projection
globalSecondaryIndex_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 Data.FromJSON GlobalSecondaryIndex where
parseJSON :: Value -> Parser GlobalSecondaryIndex
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"GlobalSecondaryIndex"
( \Object
x ->
Maybe ProvisionedThroughput
-> Text
-> NonEmpty KeySchemaElement
-> Projection
-> GlobalSecondaryIndex
GlobalSecondaryIndex'
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
"ProvisionedThroughput")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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 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 a
Data..: Key
"Projection")
)
instance Prelude.Hashable GlobalSecondaryIndex where
hashWithSalt :: Int -> GlobalSecondaryIndex -> Int
hashWithSalt Int
_salt 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
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ProvisionedThroughput
provisionedThroughput
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
indexName
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty KeySchemaElement
keySchema
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Projection
projection
instance Prelude.NFData GlobalSecondaryIndex where
rnf :: GlobalSecondaryIndex -> ()
rnf 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
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe ProvisionedThroughput
provisionedThroughput
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
indexName
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty KeySchemaElement
keySchema
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Projection
projection
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"ProvisionedThroughput" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ProvisionedThroughput
provisionedThroughput,
forall a. a -> Maybe a
Prelude.Just (Key
"IndexName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
indexName),
forall a. a -> Maybe a
Prelude.Just (Key
"KeySchema" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty KeySchemaElement
keySchema),
forall a. a -> Maybe a
Prelude.Just (Key
"Projection" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Projection
projection)
]
)