{-# 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.SSMIncidents.Types.AddRegionAction
-- 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.SSMIncidents.Types.AddRegionAction where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Defines the Region and KMS key to add to the replication set.
--
-- /See:/ 'newAddRegionAction' smart constructor.
data AddRegionAction = AddRegionAction'
  { -- | The KMS key ID to use to encrypt your replication set.
    AddRegionAction -> Maybe Text
sseKmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The Region name to add to the replication set.
    AddRegionAction -> Text
regionName :: Prelude.Text
  }
  deriving (AddRegionAction -> AddRegionAction -> Bool
(AddRegionAction -> AddRegionAction -> Bool)
-> (AddRegionAction -> AddRegionAction -> Bool)
-> Eq AddRegionAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddRegionAction -> AddRegionAction -> Bool
$c/= :: AddRegionAction -> AddRegionAction -> Bool
== :: AddRegionAction -> AddRegionAction -> Bool
$c== :: AddRegionAction -> AddRegionAction -> Bool
Prelude.Eq, ReadPrec [AddRegionAction]
ReadPrec AddRegionAction
Int -> ReadS AddRegionAction
ReadS [AddRegionAction]
(Int -> ReadS AddRegionAction)
-> ReadS [AddRegionAction]
-> ReadPrec AddRegionAction
-> ReadPrec [AddRegionAction]
-> Read AddRegionAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddRegionAction]
$creadListPrec :: ReadPrec [AddRegionAction]
readPrec :: ReadPrec AddRegionAction
$creadPrec :: ReadPrec AddRegionAction
readList :: ReadS [AddRegionAction]
$creadList :: ReadS [AddRegionAction]
readsPrec :: Int -> ReadS AddRegionAction
$creadsPrec :: Int -> ReadS AddRegionAction
Prelude.Read, Int -> AddRegionAction -> ShowS
[AddRegionAction] -> ShowS
AddRegionAction -> String
(Int -> AddRegionAction -> ShowS)
-> (AddRegionAction -> String)
-> ([AddRegionAction] -> ShowS)
-> Show AddRegionAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddRegionAction] -> ShowS
$cshowList :: [AddRegionAction] -> ShowS
show :: AddRegionAction -> String
$cshow :: AddRegionAction -> String
showsPrec :: Int -> AddRegionAction -> ShowS
$cshowsPrec :: Int -> AddRegionAction -> ShowS
Prelude.Show, (forall x. AddRegionAction -> Rep AddRegionAction x)
-> (forall x. Rep AddRegionAction x -> AddRegionAction)
-> Generic AddRegionAction
forall x. Rep AddRegionAction x -> AddRegionAction
forall x. AddRegionAction -> Rep AddRegionAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddRegionAction x -> AddRegionAction
$cfrom :: forall x. AddRegionAction -> Rep AddRegionAction x
Prelude.Generic)

-- |
-- Create a value of 'AddRegionAction' 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:
--
-- 'sseKmsKeyId', 'addRegionAction_sseKmsKeyId' - The KMS key ID to use to encrypt your replication set.
--
-- 'regionName', 'addRegionAction_regionName' - The Region name to add to the replication set.
newAddRegionAction ::
  -- | 'regionName'
  Prelude.Text ->
  AddRegionAction
newAddRegionAction :: Text -> AddRegionAction
newAddRegionAction Text
pRegionName_ =
  AddRegionAction' :: Maybe Text -> Text -> AddRegionAction
AddRegionAction'
    { $sel:sseKmsKeyId:AddRegionAction' :: Maybe Text
sseKmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:regionName:AddRegionAction' :: Text
regionName = Text
pRegionName_
    }

-- | The KMS key ID to use to encrypt your replication set.
addRegionAction_sseKmsKeyId :: Lens.Lens' AddRegionAction (Prelude.Maybe Prelude.Text)
addRegionAction_sseKmsKeyId :: (Maybe Text -> f (Maybe Text))
-> AddRegionAction -> f AddRegionAction
addRegionAction_sseKmsKeyId = (AddRegionAction -> Maybe Text)
-> (AddRegionAction -> Maybe Text -> AddRegionAction)
-> Lens AddRegionAction AddRegionAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddRegionAction' {Maybe Text
sseKmsKeyId :: Maybe Text
$sel:sseKmsKeyId:AddRegionAction' :: AddRegionAction -> Maybe Text
sseKmsKeyId} -> Maybe Text
sseKmsKeyId) (\s :: AddRegionAction
s@AddRegionAction' {} Maybe Text
a -> AddRegionAction
s {$sel:sseKmsKeyId:AddRegionAction' :: Maybe Text
sseKmsKeyId = Maybe Text
a} :: AddRegionAction)

-- | The Region name to add to the replication set.
addRegionAction_regionName :: Lens.Lens' AddRegionAction Prelude.Text
addRegionAction_regionName :: (Text -> f Text) -> AddRegionAction -> f AddRegionAction
addRegionAction_regionName = (AddRegionAction -> Text)
-> (AddRegionAction -> Text -> AddRegionAction)
-> Lens AddRegionAction AddRegionAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddRegionAction' {Text
regionName :: Text
$sel:regionName:AddRegionAction' :: AddRegionAction -> Text
regionName} -> Text
regionName) (\s :: AddRegionAction
s@AddRegionAction' {} Text
a -> AddRegionAction
s {$sel:regionName:AddRegionAction' :: Text
regionName = Text
a} :: AddRegionAction)

instance Prelude.Hashable AddRegionAction

instance Prelude.NFData AddRegionAction

instance Core.ToJSON AddRegionAction where
  toJSON :: AddRegionAction -> Value
toJSON AddRegionAction' {Maybe Text
Text
regionName :: Text
sseKmsKeyId :: Maybe Text
$sel:regionName:AddRegionAction' :: AddRegionAction -> Text
$sel:sseKmsKeyId:AddRegionAction' :: AddRegionAction -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"sseKmsKeyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sseKmsKeyId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"regionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
regionName)
          ]
      )