{-# 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.UpdateGlobalSecondaryIndexAction
-- 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.UpdateGlobalSecondaryIndexAction where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.ProvisionedThroughput
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the new provisioned throughput settings to be applied to a
-- global secondary index.
--
-- /See:/ 'newUpdateGlobalSecondaryIndexAction' smart constructor.
data UpdateGlobalSecondaryIndexAction = UpdateGlobalSecondaryIndexAction'
  { -- | The name of the global secondary index to be updated.
    UpdateGlobalSecondaryIndexAction -> Text
indexName :: Prelude.Text,
    -- | Represents the provisioned throughput settings for the specified global
    -- secondary index.
    --
    -- For current minimum and maximum provisioned throughput values, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html Service, Account, and Table Quotas>
    -- in the /Amazon DynamoDB Developer Guide/.
    UpdateGlobalSecondaryIndexAction -> ProvisionedThroughput
provisionedThroughput :: ProvisionedThroughput
  }
  deriving (UpdateGlobalSecondaryIndexAction
-> UpdateGlobalSecondaryIndexAction -> Bool
(UpdateGlobalSecondaryIndexAction
 -> UpdateGlobalSecondaryIndexAction -> Bool)
-> (UpdateGlobalSecondaryIndexAction
    -> UpdateGlobalSecondaryIndexAction -> Bool)
-> Eq UpdateGlobalSecondaryIndexAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateGlobalSecondaryIndexAction
-> UpdateGlobalSecondaryIndexAction -> Bool
$c/= :: UpdateGlobalSecondaryIndexAction
-> UpdateGlobalSecondaryIndexAction -> Bool
== :: UpdateGlobalSecondaryIndexAction
-> UpdateGlobalSecondaryIndexAction -> Bool
$c== :: UpdateGlobalSecondaryIndexAction
-> UpdateGlobalSecondaryIndexAction -> Bool
Prelude.Eq, ReadPrec [UpdateGlobalSecondaryIndexAction]
ReadPrec UpdateGlobalSecondaryIndexAction
Int -> ReadS UpdateGlobalSecondaryIndexAction
ReadS [UpdateGlobalSecondaryIndexAction]
(Int -> ReadS UpdateGlobalSecondaryIndexAction)
-> ReadS [UpdateGlobalSecondaryIndexAction]
-> ReadPrec UpdateGlobalSecondaryIndexAction
-> ReadPrec [UpdateGlobalSecondaryIndexAction]
-> Read UpdateGlobalSecondaryIndexAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateGlobalSecondaryIndexAction]
$creadListPrec :: ReadPrec [UpdateGlobalSecondaryIndexAction]
readPrec :: ReadPrec UpdateGlobalSecondaryIndexAction
$creadPrec :: ReadPrec UpdateGlobalSecondaryIndexAction
readList :: ReadS [UpdateGlobalSecondaryIndexAction]
$creadList :: ReadS [UpdateGlobalSecondaryIndexAction]
readsPrec :: Int -> ReadS UpdateGlobalSecondaryIndexAction
$creadsPrec :: Int -> ReadS UpdateGlobalSecondaryIndexAction
Prelude.Read, Int -> UpdateGlobalSecondaryIndexAction -> ShowS
[UpdateGlobalSecondaryIndexAction] -> ShowS
UpdateGlobalSecondaryIndexAction -> String
(Int -> UpdateGlobalSecondaryIndexAction -> ShowS)
-> (UpdateGlobalSecondaryIndexAction -> String)
-> ([UpdateGlobalSecondaryIndexAction] -> ShowS)
-> Show UpdateGlobalSecondaryIndexAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateGlobalSecondaryIndexAction] -> ShowS
$cshowList :: [UpdateGlobalSecondaryIndexAction] -> ShowS
show :: UpdateGlobalSecondaryIndexAction -> String
$cshow :: UpdateGlobalSecondaryIndexAction -> String
showsPrec :: Int -> UpdateGlobalSecondaryIndexAction -> ShowS
$cshowsPrec :: Int -> UpdateGlobalSecondaryIndexAction -> ShowS
Prelude.Show, (forall x.
 UpdateGlobalSecondaryIndexAction
 -> Rep UpdateGlobalSecondaryIndexAction x)
-> (forall x.
    Rep UpdateGlobalSecondaryIndexAction x
    -> UpdateGlobalSecondaryIndexAction)
-> Generic UpdateGlobalSecondaryIndexAction
forall x.
Rep UpdateGlobalSecondaryIndexAction x
-> UpdateGlobalSecondaryIndexAction
forall x.
UpdateGlobalSecondaryIndexAction
-> Rep UpdateGlobalSecondaryIndexAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateGlobalSecondaryIndexAction x
-> UpdateGlobalSecondaryIndexAction
$cfrom :: forall x.
UpdateGlobalSecondaryIndexAction
-> Rep UpdateGlobalSecondaryIndexAction x
Prelude.Generic)

-- |
-- Create a value of 'UpdateGlobalSecondaryIndexAction' 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', 'updateGlobalSecondaryIndexAction_indexName' - The name of the global secondary index to be updated.
--
-- 'provisionedThroughput', 'updateGlobalSecondaryIndexAction_provisionedThroughput' - Represents the provisioned throughput settings for the specified global
-- secondary index.
--
-- For current minimum and maximum provisioned throughput values, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html Service, Account, and Table Quotas>
-- in the /Amazon DynamoDB Developer Guide/.
newUpdateGlobalSecondaryIndexAction ::
  -- | 'indexName'
  Prelude.Text ->
  -- | 'provisionedThroughput'
  ProvisionedThroughput ->
  UpdateGlobalSecondaryIndexAction
newUpdateGlobalSecondaryIndexAction :: Text -> ProvisionedThroughput -> UpdateGlobalSecondaryIndexAction
newUpdateGlobalSecondaryIndexAction
  Text
pIndexName_
  ProvisionedThroughput
pProvisionedThroughput_ =
    UpdateGlobalSecondaryIndexAction' :: Text -> ProvisionedThroughput -> UpdateGlobalSecondaryIndexAction
UpdateGlobalSecondaryIndexAction'
      { $sel:indexName:UpdateGlobalSecondaryIndexAction' :: Text
indexName =
          Text
pIndexName_,
        $sel:provisionedThroughput:UpdateGlobalSecondaryIndexAction' :: ProvisionedThroughput
provisionedThroughput =
          ProvisionedThroughput
pProvisionedThroughput_
      }

-- | The name of the global secondary index to be updated.
updateGlobalSecondaryIndexAction_indexName :: Lens.Lens' UpdateGlobalSecondaryIndexAction Prelude.Text
updateGlobalSecondaryIndexAction_indexName :: (Text -> f Text)
-> UpdateGlobalSecondaryIndexAction
-> f UpdateGlobalSecondaryIndexAction
updateGlobalSecondaryIndexAction_indexName = (UpdateGlobalSecondaryIndexAction -> Text)
-> (UpdateGlobalSecondaryIndexAction
    -> Text -> UpdateGlobalSecondaryIndexAction)
-> Lens
     UpdateGlobalSecondaryIndexAction
     UpdateGlobalSecondaryIndexAction
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGlobalSecondaryIndexAction' {Text
indexName :: Text
$sel:indexName:UpdateGlobalSecondaryIndexAction' :: UpdateGlobalSecondaryIndexAction -> Text
indexName} -> Text
indexName) (\s :: UpdateGlobalSecondaryIndexAction
s@UpdateGlobalSecondaryIndexAction' {} Text
a -> UpdateGlobalSecondaryIndexAction
s {$sel:indexName:UpdateGlobalSecondaryIndexAction' :: Text
indexName = Text
a} :: UpdateGlobalSecondaryIndexAction)

-- | Represents the provisioned throughput settings for the specified global
-- secondary index.
--
-- For current minimum and maximum provisioned throughput values, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html Service, Account, and Table Quotas>
-- in the /Amazon DynamoDB Developer Guide/.
updateGlobalSecondaryIndexAction_provisionedThroughput :: Lens.Lens' UpdateGlobalSecondaryIndexAction ProvisionedThroughput
updateGlobalSecondaryIndexAction_provisionedThroughput :: (ProvisionedThroughput -> f ProvisionedThroughput)
-> UpdateGlobalSecondaryIndexAction
-> f UpdateGlobalSecondaryIndexAction
updateGlobalSecondaryIndexAction_provisionedThroughput = (UpdateGlobalSecondaryIndexAction -> ProvisionedThroughput)
-> (UpdateGlobalSecondaryIndexAction
    -> ProvisionedThroughput -> UpdateGlobalSecondaryIndexAction)
-> Lens
     UpdateGlobalSecondaryIndexAction
     UpdateGlobalSecondaryIndexAction
     ProvisionedThroughput
     ProvisionedThroughput
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGlobalSecondaryIndexAction' {ProvisionedThroughput
provisionedThroughput :: ProvisionedThroughput
$sel:provisionedThroughput:UpdateGlobalSecondaryIndexAction' :: UpdateGlobalSecondaryIndexAction -> ProvisionedThroughput
provisionedThroughput} -> ProvisionedThroughput
provisionedThroughput) (\s :: UpdateGlobalSecondaryIndexAction
s@UpdateGlobalSecondaryIndexAction' {} ProvisionedThroughput
a -> UpdateGlobalSecondaryIndexAction
s {$sel:provisionedThroughput:UpdateGlobalSecondaryIndexAction' :: ProvisionedThroughput
provisionedThroughput = ProvisionedThroughput
a} :: UpdateGlobalSecondaryIndexAction)

instance
  Prelude.Hashable
    UpdateGlobalSecondaryIndexAction

instance
  Prelude.NFData
    UpdateGlobalSecondaryIndexAction

instance Core.ToJSON UpdateGlobalSecondaryIndexAction where
  toJSON :: UpdateGlobalSecondaryIndexAction -> Value
toJSON UpdateGlobalSecondaryIndexAction' {Text
ProvisionedThroughput
provisionedThroughput :: ProvisionedThroughput
indexName :: Text
$sel:provisionedThroughput:UpdateGlobalSecondaryIndexAction' :: UpdateGlobalSecondaryIndexAction -> ProvisionedThroughput
$sel:indexName:UpdateGlobalSecondaryIndexAction' :: UpdateGlobalSecondaryIndexAction -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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
"ProvisionedThroughput"
                  Text -> ProvisionedThroughput -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ProvisionedThroughput
provisionedThroughput
              )
          ]
      )