{-# 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-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.UpdateGlobalSecondaryIndexAction 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.ProvisionedThroughput
import Amazonka.DynamoDB.Types.WriteRequest
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
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]
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
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.
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'
      { $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 :: Lens' UpdateGlobalSecondaryIndexAction Text
updateGlobalSecondaryIndexAction_indexName = 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 :: Lens' UpdateGlobalSecondaryIndexAction ProvisionedThroughput
updateGlobalSecondaryIndexAction_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
  where
  hashWithSalt :: Int -> UpdateGlobalSecondaryIndexAction -> Int
hashWithSalt
    Int
_salt
    UpdateGlobalSecondaryIndexAction' {Text
ProvisionedThroughput
provisionedThroughput :: ProvisionedThroughput
indexName :: Text
$sel:provisionedThroughput:UpdateGlobalSecondaryIndexAction' :: UpdateGlobalSecondaryIndexAction -> ProvisionedThroughput
$sel:indexName:UpdateGlobalSecondaryIndexAction' :: UpdateGlobalSecondaryIndexAction -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
indexName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ProvisionedThroughput
provisionedThroughput

instance
  Prelude.NFData
    UpdateGlobalSecondaryIndexAction
  where
  rnf :: UpdateGlobalSecondaryIndexAction -> ()
rnf UpdateGlobalSecondaryIndexAction' {Text
ProvisionedThroughput
provisionedThroughput :: ProvisionedThroughput
indexName :: Text
$sel:provisionedThroughput:UpdateGlobalSecondaryIndexAction' :: UpdateGlobalSecondaryIndexAction -> ProvisionedThroughput
$sel:indexName:UpdateGlobalSecondaryIndexAction' :: UpdateGlobalSecondaryIndexAction -> Text
..} =
    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 ProvisionedThroughput
provisionedThroughput

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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
"ProvisionedThroughput"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ProvisionedThroughput
provisionedThroughput
              )
          ]
      )