{-# 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.GlobalSecondaryIndexUpdate
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DynamoDB.Types.GlobalSecondaryIndexUpdate where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.CreateGlobalSecondaryIndexAction
import Amazonka.DynamoDB.Types.DeleteGlobalSecondaryIndexAction
import Amazonka.DynamoDB.Types.UpdateGlobalSecondaryIndexAction
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents one of the following:
--
-- -   A new global secondary index to be added to an existing table.
--
-- -   New provisioned throughput parameters for an existing global
--     secondary index.
--
-- -   An existing global secondary index to be removed from an existing
--     table.
--
-- /See:/ 'newGlobalSecondaryIndexUpdate' smart constructor.
data GlobalSecondaryIndexUpdate = GlobalSecondaryIndexUpdate'
  { -- | The parameters required for creating a global secondary index on an
    -- existing table:
    --
    -- -   @IndexName @
    --
    -- -   @KeySchema @
    --
    -- -   @AttributeDefinitions @
    --
    -- -   @Projection @
    --
    -- -   @ProvisionedThroughput @
    GlobalSecondaryIndexUpdate
-> Maybe CreateGlobalSecondaryIndexAction
create :: Prelude.Maybe CreateGlobalSecondaryIndexAction,
    -- | The name of an existing global secondary index to be removed.
    GlobalSecondaryIndexUpdate
-> Maybe DeleteGlobalSecondaryIndexAction
delete' :: Prelude.Maybe DeleteGlobalSecondaryIndexAction,
    -- | The name of an existing global secondary index, along with new
    -- provisioned throughput settings to be applied to that index.
    GlobalSecondaryIndexUpdate
-> Maybe UpdateGlobalSecondaryIndexAction
update :: Prelude.Maybe UpdateGlobalSecondaryIndexAction
  }
  deriving (GlobalSecondaryIndexUpdate -> GlobalSecondaryIndexUpdate -> Bool
(GlobalSecondaryIndexUpdate -> GlobalSecondaryIndexUpdate -> Bool)
-> (GlobalSecondaryIndexUpdate
    -> GlobalSecondaryIndexUpdate -> Bool)
-> Eq GlobalSecondaryIndexUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlobalSecondaryIndexUpdate -> GlobalSecondaryIndexUpdate -> Bool
$c/= :: GlobalSecondaryIndexUpdate -> GlobalSecondaryIndexUpdate -> Bool
== :: GlobalSecondaryIndexUpdate -> GlobalSecondaryIndexUpdate -> Bool
$c== :: GlobalSecondaryIndexUpdate -> GlobalSecondaryIndexUpdate -> Bool
Prelude.Eq, ReadPrec [GlobalSecondaryIndexUpdate]
ReadPrec GlobalSecondaryIndexUpdate
Int -> ReadS GlobalSecondaryIndexUpdate
ReadS [GlobalSecondaryIndexUpdate]
(Int -> ReadS GlobalSecondaryIndexUpdate)
-> ReadS [GlobalSecondaryIndexUpdate]
-> ReadPrec GlobalSecondaryIndexUpdate
-> ReadPrec [GlobalSecondaryIndexUpdate]
-> Read GlobalSecondaryIndexUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GlobalSecondaryIndexUpdate]
$creadListPrec :: ReadPrec [GlobalSecondaryIndexUpdate]
readPrec :: ReadPrec GlobalSecondaryIndexUpdate
$creadPrec :: ReadPrec GlobalSecondaryIndexUpdate
readList :: ReadS [GlobalSecondaryIndexUpdate]
$creadList :: ReadS [GlobalSecondaryIndexUpdate]
readsPrec :: Int -> ReadS GlobalSecondaryIndexUpdate
$creadsPrec :: Int -> ReadS GlobalSecondaryIndexUpdate
Prelude.Read, Int -> GlobalSecondaryIndexUpdate -> ShowS
[GlobalSecondaryIndexUpdate] -> ShowS
GlobalSecondaryIndexUpdate -> String
(Int -> GlobalSecondaryIndexUpdate -> ShowS)
-> (GlobalSecondaryIndexUpdate -> String)
-> ([GlobalSecondaryIndexUpdate] -> ShowS)
-> Show GlobalSecondaryIndexUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GlobalSecondaryIndexUpdate] -> ShowS
$cshowList :: [GlobalSecondaryIndexUpdate] -> ShowS
show :: GlobalSecondaryIndexUpdate -> String
$cshow :: GlobalSecondaryIndexUpdate -> String
showsPrec :: Int -> GlobalSecondaryIndexUpdate -> ShowS
$cshowsPrec :: Int -> GlobalSecondaryIndexUpdate -> ShowS
Prelude.Show, (forall x.
 GlobalSecondaryIndexUpdate -> Rep GlobalSecondaryIndexUpdate x)
-> (forall x.
    Rep GlobalSecondaryIndexUpdate x -> GlobalSecondaryIndexUpdate)
-> Generic GlobalSecondaryIndexUpdate
forall x.
Rep GlobalSecondaryIndexUpdate x -> GlobalSecondaryIndexUpdate
forall x.
GlobalSecondaryIndexUpdate -> Rep GlobalSecondaryIndexUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GlobalSecondaryIndexUpdate x -> GlobalSecondaryIndexUpdate
$cfrom :: forall x.
GlobalSecondaryIndexUpdate -> Rep GlobalSecondaryIndexUpdate x
Prelude.Generic)

-- |
-- Create a value of 'GlobalSecondaryIndexUpdate' 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:
--
-- 'create', 'globalSecondaryIndexUpdate_create' - The parameters required for creating a global secondary index on an
-- existing table:
--
-- -   @IndexName @
--
-- -   @KeySchema @
--
-- -   @AttributeDefinitions @
--
-- -   @Projection @
--
-- -   @ProvisionedThroughput @
--
-- 'delete'', 'globalSecondaryIndexUpdate_delete' - The name of an existing global secondary index to be removed.
--
-- 'update', 'globalSecondaryIndexUpdate_update' - The name of an existing global secondary index, along with new
-- provisioned throughput settings to be applied to that index.
newGlobalSecondaryIndexUpdate ::
  GlobalSecondaryIndexUpdate
newGlobalSecondaryIndexUpdate :: GlobalSecondaryIndexUpdate
newGlobalSecondaryIndexUpdate =
  GlobalSecondaryIndexUpdate' :: Maybe CreateGlobalSecondaryIndexAction
-> Maybe DeleteGlobalSecondaryIndexAction
-> Maybe UpdateGlobalSecondaryIndexAction
-> GlobalSecondaryIndexUpdate
GlobalSecondaryIndexUpdate'
    { $sel:create:GlobalSecondaryIndexUpdate' :: Maybe CreateGlobalSecondaryIndexAction
create =
        Maybe CreateGlobalSecondaryIndexAction
forall a. Maybe a
Prelude.Nothing,
      $sel:delete':GlobalSecondaryIndexUpdate' :: Maybe DeleteGlobalSecondaryIndexAction
delete' = Maybe DeleteGlobalSecondaryIndexAction
forall a. Maybe a
Prelude.Nothing,
      $sel:update:GlobalSecondaryIndexUpdate' :: Maybe UpdateGlobalSecondaryIndexAction
update = Maybe UpdateGlobalSecondaryIndexAction
forall a. Maybe a
Prelude.Nothing
    }

-- | The parameters required for creating a global secondary index on an
-- existing table:
--
-- -   @IndexName @
--
-- -   @KeySchema @
--
-- -   @AttributeDefinitions @
--
-- -   @Projection @
--
-- -   @ProvisionedThroughput @
globalSecondaryIndexUpdate_create :: Lens.Lens' GlobalSecondaryIndexUpdate (Prelude.Maybe CreateGlobalSecondaryIndexAction)
globalSecondaryIndexUpdate_create :: (Maybe CreateGlobalSecondaryIndexAction
 -> f (Maybe CreateGlobalSecondaryIndexAction))
-> GlobalSecondaryIndexUpdate -> f GlobalSecondaryIndexUpdate
globalSecondaryIndexUpdate_create = (GlobalSecondaryIndexUpdate
 -> Maybe CreateGlobalSecondaryIndexAction)
-> (GlobalSecondaryIndexUpdate
    -> Maybe CreateGlobalSecondaryIndexAction
    -> GlobalSecondaryIndexUpdate)
-> Lens
     GlobalSecondaryIndexUpdate
     GlobalSecondaryIndexUpdate
     (Maybe CreateGlobalSecondaryIndexAction)
     (Maybe CreateGlobalSecondaryIndexAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalSecondaryIndexUpdate' {Maybe CreateGlobalSecondaryIndexAction
create :: Maybe CreateGlobalSecondaryIndexAction
$sel:create:GlobalSecondaryIndexUpdate' :: GlobalSecondaryIndexUpdate
-> Maybe CreateGlobalSecondaryIndexAction
create} -> Maybe CreateGlobalSecondaryIndexAction
create) (\s :: GlobalSecondaryIndexUpdate
s@GlobalSecondaryIndexUpdate' {} Maybe CreateGlobalSecondaryIndexAction
a -> GlobalSecondaryIndexUpdate
s {$sel:create:GlobalSecondaryIndexUpdate' :: Maybe CreateGlobalSecondaryIndexAction
create = Maybe CreateGlobalSecondaryIndexAction
a} :: GlobalSecondaryIndexUpdate)

-- | The name of an existing global secondary index to be removed.
globalSecondaryIndexUpdate_delete :: Lens.Lens' GlobalSecondaryIndexUpdate (Prelude.Maybe DeleteGlobalSecondaryIndexAction)
globalSecondaryIndexUpdate_delete :: (Maybe DeleteGlobalSecondaryIndexAction
 -> f (Maybe DeleteGlobalSecondaryIndexAction))
-> GlobalSecondaryIndexUpdate -> f GlobalSecondaryIndexUpdate
globalSecondaryIndexUpdate_delete = (GlobalSecondaryIndexUpdate
 -> Maybe DeleteGlobalSecondaryIndexAction)
-> (GlobalSecondaryIndexUpdate
    -> Maybe DeleteGlobalSecondaryIndexAction
    -> GlobalSecondaryIndexUpdate)
-> Lens
     GlobalSecondaryIndexUpdate
     GlobalSecondaryIndexUpdate
     (Maybe DeleteGlobalSecondaryIndexAction)
     (Maybe DeleteGlobalSecondaryIndexAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalSecondaryIndexUpdate' {Maybe DeleteGlobalSecondaryIndexAction
delete' :: Maybe DeleteGlobalSecondaryIndexAction
$sel:delete':GlobalSecondaryIndexUpdate' :: GlobalSecondaryIndexUpdate
-> Maybe DeleteGlobalSecondaryIndexAction
delete'} -> Maybe DeleteGlobalSecondaryIndexAction
delete') (\s :: GlobalSecondaryIndexUpdate
s@GlobalSecondaryIndexUpdate' {} Maybe DeleteGlobalSecondaryIndexAction
a -> GlobalSecondaryIndexUpdate
s {$sel:delete':GlobalSecondaryIndexUpdate' :: Maybe DeleteGlobalSecondaryIndexAction
delete' = Maybe DeleteGlobalSecondaryIndexAction
a} :: GlobalSecondaryIndexUpdate)

-- | The name of an existing global secondary index, along with new
-- provisioned throughput settings to be applied to that index.
globalSecondaryIndexUpdate_update :: Lens.Lens' GlobalSecondaryIndexUpdate (Prelude.Maybe UpdateGlobalSecondaryIndexAction)
globalSecondaryIndexUpdate_update :: (Maybe UpdateGlobalSecondaryIndexAction
 -> f (Maybe UpdateGlobalSecondaryIndexAction))
-> GlobalSecondaryIndexUpdate -> f GlobalSecondaryIndexUpdate
globalSecondaryIndexUpdate_update = (GlobalSecondaryIndexUpdate
 -> Maybe UpdateGlobalSecondaryIndexAction)
-> (GlobalSecondaryIndexUpdate
    -> Maybe UpdateGlobalSecondaryIndexAction
    -> GlobalSecondaryIndexUpdate)
-> Lens
     GlobalSecondaryIndexUpdate
     GlobalSecondaryIndexUpdate
     (Maybe UpdateGlobalSecondaryIndexAction)
     (Maybe UpdateGlobalSecondaryIndexAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalSecondaryIndexUpdate' {Maybe UpdateGlobalSecondaryIndexAction
update :: Maybe UpdateGlobalSecondaryIndexAction
$sel:update:GlobalSecondaryIndexUpdate' :: GlobalSecondaryIndexUpdate
-> Maybe UpdateGlobalSecondaryIndexAction
update} -> Maybe UpdateGlobalSecondaryIndexAction
update) (\s :: GlobalSecondaryIndexUpdate
s@GlobalSecondaryIndexUpdate' {} Maybe UpdateGlobalSecondaryIndexAction
a -> GlobalSecondaryIndexUpdate
s {$sel:update:GlobalSecondaryIndexUpdate' :: Maybe UpdateGlobalSecondaryIndexAction
update = Maybe UpdateGlobalSecondaryIndexAction
a} :: GlobalSecondaryIndexUpdate)

instance Prelude.Hashable GlobalSecondaryIndexUpdate

instance Prelude.NFData GlobalSecondaryIndexUpdate

instance Core.ToJSON GlobalSecondaryIndexUpdate where
  toJSON :: GlobalSecondaryIndexUpdate -> Value
toJSON GlobalSecondaryIndexUpdate' {Maybe DeleteGlobalSecondaryIndexAction
Maybe CreateGlobalSecondaryIndexAction
Maybe UpdateGlobalSecondaryIndexAction
update :: Maybe UpdateGlobalSecondaryIndexAction
delete' :: Maybe DeleteGlobalSecondaryIndexAction
create :: Maybe CreateGlobalSecondaryIndexAction
$sel:update:GlobalSecondaryIndexUpdate' :: GlobalSecondaryIndexUpdate
-> Maybe UpdateGlobalSecondaryIndexAction
$sel:delete':GlobalSecondaryIndexUpdate' :: GlobalSecondaryIndexUpdate
-> Maybe DeleteGlobalSecondaryIndexAction
$sel:create:GlobalSecondaryIndexUpdate' :: GlobalSecondaryIndexUpdate
-> Maybe CreateGlobalSecondaryIndexAction
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Create" Text -> CreateGlobalSecondaryIndexAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CreateGlobalSecondaryIndexAction -> Pair)
-> Maybe CreateGlobalSecondaryIndexAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CreateGlobalSecondaryIndexAction
create,
            (Text
"Delete" Text -> DeleteGlobalSecondaryIndexAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DeleteGlobalSecondaryIndexAction -> Pair)
-> Maybe DeleteGlobalSecondaryIndexAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeleteGlobalSecondaryIndexAction
delete',
            (Text
"Update" Text -> UpdateGlobalSecondaryIndexAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (UpdateGlobalSecondaryIndexAction -> Pair)
-> Maybe UpdateGlobalSecondaryIndexAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UpdateGlobalSecondaryIndexAction
update
          ]
      )