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

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.CreateReplicationGroupMemberAction
import Amazonka.DynamoDB.Types.DeleteReplicationGroupMemberAction
import Amazonka.DynamoDB.Types.UpdateReplicationGroupMemberAction
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents one of the following:
--
-- -   A new replica to be added to an existing regional table or global
--     table. This request invokes the @CreateTableReplica@ action in the
--     destination Region.
--
-- -   New parameters for an existing replica. This request invokes the
--     @UpdateTable@ action in the destination Region.
--
-- -   An existing replica to be deleted. The request invokes the
--     @DeleteTableReplica@ action in the destination Region, deleting the
--     replica and all if its items in the destination Region.
--
-- /See:/ 'newReplicationGroupUpdate' smart constructor.
data ReplicationGroupUpdate = ReplicationGroupUpdate'
  { -- | The parameters required for creating a replica for the table.
    ReplicationGroupUpdate -> Maybe CreateReplicationGroupMemberAction
create :: Prelude.Maybe CreateReplicationGroupMemberAction,
    -- | The parameters required for deleting a replica for the table.
    ReplicationGroupUpdate -> Maybe DeleteReplicationGroupMemberAction
delete' :: Prelude.Maybe DeleteReplicationGroupMemberAction,
    -- | The parameters required for updating a replica for the table.
    ReplicationGroupUpdate -> Maybe UpdateReplicationGroupMemberAction
update :: Prelude.Maybe UpdateReplicationGroupMemberAction
  }
  deriving (ReplicationGroupUpdate -> ReplicationGroupUpdate -> Bool
(ReplicationGroupUpdate -> ReplicationGroupUpdate -> Bool)
-> (ReplicationGroupUpdate -> ReplicationGroupUpdate -> Bool)
-> Eq ReplicationGroupUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReplicationGroupUpdate -> ReplicationGroupUpdate -> Bool
$c/= :: ReplicationGroupUpdate -> ReplicationGroupUpdate -> Bool
== :: ReplicationGroupUpdate -> ReplicationGroupUpdate -> Bool
$c== :: ReplicationGroupUpdate -> ReplicationGroupUpdate -> Bool
Prelude.Eq, ReadPrec [ReplicationGroupUpdate]
ReadPrec ReplicationGroupUpdate
Int -> ReadS ReplicationGroupUpdate
ReadS [ReplicationGroupUpdate]
(Int -> ReadS ReplicationGroupUpdate)
-> ReadS [ReplicationGroupUpdate]
-> ReadPrec ReplicationGroupUpdate
-> ReadPrec [ReplicationGroupUpdate]
-> Read ReplicationGroupUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReplicationGroupUpdate]
$creadListPrec :: ReadPrec [ReplicationGroupUpdate]
readPrec :: ReadPrec ReplicationGroupUpdate
$creadPrec :: ReadPrec ReplicationGroupUpdate
readList :: ReadS [ReplicationGroupUpdate]
$creadList :: ReadS [ReplicationGroupUpdate]
readsPrec :: Int -> ReadS ReplicationGroupUpdate
$creadsPrec :: Int -> ReadS ReplicationGroupUpdate
Prelude.Read, Int -> ReplicationGroupUpdate -> ShowS
[ReplicationGroupUpdate] -> ShowS
ReplicationGroupUpdate -> String
(Int -> ReplicationGroupUpdate -> ShowS)
-> (ReplicationGroupUpdate -> String)
-> ([ReplicationGroupUpdate] -> ShowS)
-> Show ReplicationGroupUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReplicationGroupUpdate] -> ShowS
$cshowList :: [ReplicationGroupUpdate] -> ShowS
show :: ReplicationGroupUpdate -> String
$cshow :: ReplicationGroupUpdate -> String
showsPrec :: Int -> ReplicationGroupUpdate -> ShowS
$cshowsPrec :: Int -> ReplicationGroupUpdate -> ShowS
Prelude.Show, (forall x. ReplicationGroupUpdate -> Rep ReplicationGroupUpdate x)
-> (forall x.
    Rep ReplicationGroupUpdate x -> ReplicationGroupUpdate)
-> Generic ReplicationGroupUpdate
forall x. Rep ReplicationGroupUpdate x -> ReplicationGroupUpdate
forall x. ReplicationGroupUpdate -> Rep ReplicationGroupUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReplicationGroupUpdate x -> ReplicationGroupUpdate
$cfrom :: forall x. ReplicationGroupUpdate -> Rep ReplicationGroupUpdate x
Prelude.Generic)

-- |
-- Create a value of 'ReplicationGroupUpdate' 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', 'replicationGroupUpdate_create' - The parameters required for creating a replica for the table.
--
-- 'delete'', 'replicationGroupUpdate_delete' - The parameters required for deleting a replica for the table.
--
-- 'update', 'replicationGroupUpdate_update' - The parameters required for updating a replica for the table.
newReplicationGroupUpdate ::
  ReplicationGroupUpdate
newReplicationGroupUpdate :: ReplicationGroupUpdate
newReplicationGroupUpdate =
  ReplicationGroupUpdate' :: Maybe CreateReplicationGroupMemberAction
-> Maybe DeleteReplicationGroupMemberAction
-> Maybe UpdateReplicationGroupMemberAction
-> ReplicationGroupUpdate
ReplicationGroupUpdate'
    { $sel:create:ReplicationGroupUpdate' :: Maybe CreateReplicationGroupMemberAction
create = Maybe CreateReplicationGroupMemberAction
forall a. Maybe a
Prelude.Nothing,
      $sel:delete':ReplicationGroupUpdate' :: Maybe DeleteReplicationGroupMemberAction
delete' = Maybe DeleteReplicationGroupMemberAction
forall a. Maybe a
Prelude.Nothing,
      $sel:update:ReplicationGroupUpdate' :: Maybe UpdateReplicationGroupMemberAction
update = Maybe UpdateReplicationGroupMemberAction
forall a. Maybe a
Prelude.Nothing
    }

-- | The parameters required for creating a replica for the table.
replicationGroupUpdate_create :: Lens.Lens' ReplicationGroupUpdate (Prelude.Maybe CreateReplicationGroupMemberAction)
replicationGroupUpdate_create :: (Maybe CreateReplicationGroupMemberAction
 -> f (Maybe CreateReplicationGroupMemberAction))
-> ReplicationGroupUpdate -> f ReplicationGroupUpdate
replicationGroupUpdate_create = (ReplicationGroupUpdate
 -> Maybe CreateReplicationGroupMemberAction)
-> (ReplicationGroupUpdate
    -> Maybe CreateReplicationGroupMemberAction
    -> ReplicationGroupUpdate)
-> Lens
     ReplicationGroupUpdate
     ReplicationGroupUpdate
     (Maybe CreateReplicationGroupMemberAction)
     (Maybe CreateReplicationGroupMemberAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationGroupUpdate' {Maybe CreateReplicationGroupMemberAction
create :: Maybe CreateReplicationGroupMemberAction
$sel:create:ReplicationGroupUpdate' :: ReplicationGroupUpdate -> Maybe CreateReplicationGroupMemberAction
create} -> Maybe CreateReplicationGroupMemberAction
create) (\s :: ReplicationGroupUpdate
s@ReplicationGroupUpdate' {} Maybe CreateReplicationGroupMemberAction
a -> ReplicationGroupUpdate
s {$sel:create:ReplicationGroupUpdate' :: Maybe CreateReplicationGroupMemberAction
create = Maybe CreateReplicationGroupMemberAction
a} :: ReplicationGroupUpdate)

-- | The parameters required for deleting a replica for the table.
replicationGroupUpdate_delete :: Lens.Lens' ReplicationGroupUpdate (Prelude.Maybe DeleteReplicationGroupMemberAction)
replicationGroupUpdate_delete :: (Maybe DeleteReplicationGroupMemberAction
 -> f (Maybe DeleteReplicationGroupMemberAction))
-> ReplicationGroupUpdate -> f ReplicationGroupUpdate
replicationGroupUpdate_delete = (ReplicationGroupUpdate
 -> Maybe DeleteReplicationGroupMemberAction)
-> (ReplicationGroupUpdate
    -> Maybe DeleteReplicationGroupMemberAction
    -> ReplicationGroupUpdate)
-> Lens
     ReplicationGroupUpdate
     ReplicationGroupUpdate
     (Maybe DeleteReplicationGroupMemberAction)
     (Maybe DeleteReplicationGroupMemberAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationGroupUpdate' {Maybe DeleteReplicationGroupMemberAction
delete' :: Maybe DeleteReplicationGroupMemberAction
$sel:delete':ReplicationGroupUpdate' :: ReplicationGroupUpdate -> Maybe DeleteReplicationGroupMemberAction
delete'} -> Maybe DeleteReplicationGroupMemberAction
delete') (\s :: ReplicationGroupUpdate
s@ReplicationGroupUpdate' {} Maybe DeleteReplicationGroupMemberAction
a -> ReplicationGroupUpdate
s {$sel:delete':ReplicationGroupUpdate' :: Maybe DeleteReplicationGroupMemberAction
delete' = Maybe DeleteReplicationGroupMemberAction
a} :: ReplicationGroupUpdate)

-- | The parameters required for updating a replica for the table.
replicationGroupUpdate_update :: Lens.Lens' ReplicationGroupUpdate (Prelude.Maybe UpdateReplicationGroupMemberAction)
replicationGroupUpdate_update :: (Maybe UpdateReplicationGroupMemberAction
 -> f (Maybe UpdateReplicationGroupMemberAction))
-> ReplicationGroupUpdate -> f ReplicationGroupUpdate
replicationGroupUpdate_update = (ReplicationGroupUpdate
 -> Maybe UpdateReplicationGroupMemberAction)
-> (ReplicationGroupUpdate
    -> Maybe UpdateReplicationGroupMemberAction
    -> ReplicationGroupUpdate)
-> Lens
     ReplicationGroupUpdate
     ReplicationGroupUpdate
     (Maybe UpdateReplicationGroupMemberAction)
     (Maybe UpdateReplicationGroupMemberAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationGroupUpdate' {Maybe UpdateReplicationGroupMemberAction
update :: Maybe UpdateReplicationGroupMemberAction
$sel:update:ReplicationGroupUpdate' :: ReplicationGroupUpdate -> Maybe UpdateReplicationGroupMemberAction
update} -> Maybe UpdateReplicationGroupMemberAction
update) (\s :: ReplicationGroupUpdate
s@ReplicationGroupUpdate' {} Maybe UpdateReplicationGroupMemberAction
a -> ReplicationGroupUpdate
s {$sel:update:ReplicationGroupUpdate' :: Maybe UpdateReplicationGroupMemberAction
update = Maybe UpdateReplicationGroupMemberAction
a} :: ReplicationGroupUpdate)

instance Prelude.Hashable ReplicationGroupUpdate

instance Prelude.NFData ReplicationGroupUpdate

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