{-# 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.SMS.Types.ServerGroupReplicationConfiguration
-- 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.SMS.Types.ServerGroupReplicationConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SMS.Types.ServerReplicationConfiguration

-- | Replication configuration for a server group.
--
-- /See:/ 'newServerGroupReplicationConfiguration' smart constructor.
data ServerGroupReplicationConfiguration = ServerGroupReplicationConfiguration'
  { -- | The ID of the server group with which this replication configuration is
    -- associated.
    ServerGroupReplicationConfiguration -> Maybe Text
serverGroupId :: Prelude.Maybe Prelude.Text,
    -- | The replication configuration for servers in the server group.
    ServerGroupReplicationConfiguration
-> Maybe [ServerReplicationConfiguration]
serverReplicationConfigurations :: Prelude.Maybe [ServerReplicationConfiguration]
  }
  deriving (ServerGroupReplicationConfiguration
-> ServerGroupReplicationConfiguration -> Bool
(ServerGroupReplicationConfiguration
 -> ServerGroupReplicationConfiguration -> Bool)
-> (ServerGroupReplicationConfiguration
    -> ServerGroupReplicationConfiguration -> Bool)
-> Eq ServerGroupReplicationConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServerGroupReplicationConfiguration
-> ServerGroupReplicationConfiguration -> Bool
$c/= :: ServerGroupReplicationConfiguration
-> ServerGroupReplicationConfiguration -> Bool
== :: ServerGroupReplicationConfiguration
-> ServerGroupReplicationConfiguration -> Bool
$c== :: ServerGroupReplicationConfiguration
-> ServerGroupReplicationConfiguration -> Bool
Prelude.Eq, ReadPrec [ServerGroupReplicationConfiguration]
ReadPrec ServerGroupReplicationConfiguration
Int -> ReadS ServerGroupReplicationConfiguration
ReadS [ServerGroupReplicationConfiguration]
(Int -> ReadS ServerGroupReplicationConfiguration)
-> ReadS [ServerGroupReplicationConfiguration]
-> ReadPrec ServerGroupReplicationConfiguration
-> ReadPrec [ServerGroupReplicationConfiguration]
-> Read ServerGroupReplicationConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServerGroupReplicationConfiguration]
$creadListPrec :: ReadPrec [ServerGroupReplicationConfiguration]
readPrec :: ReadPrec ServerGroupReplicationConfiguration
$creadPrec :: ReadPrec ServerGroupReplicationConfiguration
readList :: ReadS [ServerGroupReplicationConfiguration]
$creadList :: ReadS [ServerGroupReplicationConfiguration]
readsPrec :: Int -> ReadS ServerGroupReplicationConfiguration
$creadsPrec :: Int -> ReadS ServerGroupReplicationConfiguration
Prelude.Read, Int -> ServerGroupReplicationConfiguration -> ShowS
[ServerGroupReplicationConfiguration] -> ShowS
ServerGroupReplicationConfiguration -> String
(Int -> ServerGroupReplicationConfiguration -> ShowS)
-> (ServerGroupReplicationConfiguration -> String)
-> ([ServerGroupReplicationConfiguration] -> ShowS)
-> Show ServerGroupReplicationConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServerGroupReplicationConfiguration] -> ShowS
$cshowList :: [ServerGroupReplicationConfiguration] -> ShowS
show :: ServerGroupReplicationConfiguration -> String
$cshow :: ServerGroupReplicationConfiguration -> String
showsPrec :: Int -> ServerGroupReplicationConfiguration -> ShowS
$cshowsPrec :: Int -> ServerGroupReplicationConfiguration -> ShowS
Prelude.Show, (forall x.
 ServerGroupReplicationConfiguration
 -> Rep ServerGroupReplicationConfiguration x)
-> (forall x.
    Rep ServerGroupReplicationConfiguration x
    -> ServerGroupReplicationConfiguration)
-> Generic ServerGroupReplicationConfiguration
forall x.
Rep ServerGroupReplicationConfiguration x
-> ServerGroupReplicationConfiguration
forall x.
ServerGroupReplicationConfiguration
-> Rep ServerGroupReplicationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ServerGroupReplicationConfiguration x
-> ServerGroupReplicationConfiguration
$cfrom :: forall x.
ServerGroupReplicationConfiguration
-> Rep ServerGroupReplicationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ServerGroupReplicationConfiguration' 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:
--
-- 'serverGroupId', 'serverGroupReplicationConfiguration_serverGroupId' - The ID of the server group with which this replication configuration is
-- associated.
--
-- 'serverReplicationConfigurations', 'serverGroupReplicationConfiguration_serverReplicationConfigurations' - The replication configuration for servers in the server group.
newServerGroupReplicationConfiguration ::
  ServerGroupReplicationConfiguration
newServerGroupReplicationConfiguration :: ServerGroupReplicationConfiguration
newServerGroupReplicationConfiguration =
  ServerGroupReplicationConfiguration' :: Maybe Text
-> Maybe [ServerReplicationConfiguration]
-> ServerGroupReplicationConfiguration
ServerGroupReplicationConfiguration'
    { $sel:serverGroupId:ServerGroupReplicationConfiguration' :: Maybe Text
serverGroupId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:serverReplicationConfigurations:ServerGroupReplicationConfiguration' :: Maybe [ServerReplicationConfiguration]
serverReplicationConfigurations =
        Maybe [ServerReplicationConfiguration]
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the server group with which this replication configuration is
-- associated.
serverGroupReplicationConfiguration_serverGroupId :: Lens.Lens' ServerGroupReplicationConfiguration (Prelude.Maybe Prelude.Text)
serverGroupReplicationConfiguration_serverGroupId :: (Maybe Text -> f (Maybe Text))
-> ServerGroupReplicationConfiguration
-> f ServerGroupReplicationConfiguration
serverGroupReplicationConfiguration_serverGroupId = (ServerGroupReplicationConfiguration -> Maybe Text)
-> (ServerGroupReplicationConfiguration
    -> Maybe Text -> ServerGroupReplicationConfiguration)
-> Lens
     ServerGroupReplicationConfiguration
     ServerGroupReplicationConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerGroupReplicationConfiguration' {Maybe Text
serverGroupId :: Maybe Text
$sel:serverGroupId:ServerGroupReplicationConfiguration' :: ServerGroupReplicationConfiguration -> Maybe Text
serverGroupId} -> Maybe Text
serverGroupId) (\s :: ServerGroupReplicationConfiguration
s@ServerGroupReplicationConfiguration' {} Maybe Text
a -> ServerGroupReplicationConfiguration
s {$sel:serverGroupId:ServerGroupReplicationConfiguration' :: Maybe Text
serverGroupId = Maybe Text
a} :: ServerGroupReplicationConfiguration)

-- | The replication configuration for servers in the server group.
serverGroupReplicationConfiguration_serverReplicationConfigurations :: Lens.Lens' ServerGroupReplicationConfiguration (Prelude.Maybe [ServerReplicationConfiguration])
serverGroupReplicationConfiguration_serverReplicationConfigurations :: (Maybe [ServerReplicationConfiguration]
 -> f (Maybe [ServerReplicationConfiguration]))
-> ServerGroupReplicationConfiguration
-> f ServerGroupReplicationConfiguration
serverGroupReplicationConfiguration_serverReplicationConfigurations = (ServerGroupReplicationConfiguration
 -> Maybe [ServerReplicationConfiguration])
-> (ServerGroupReplicationConfiguration
    -> Maybe [ServerReplicationConfiguration]
    -> ServerGroupReplicationConfiguration)
-> Lens
     ServerGroupReplicationConfiguration
     ServerGroupReplicationConfiguration
     (Maybe [ServerReplicationConfiguration])
     (Maybe [ServerReplicationConfiguration])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerGroupReplicationConfiguration' {Maybe [ServerReplicationConfiguration]
serverReplicationConfigurations :: Maybe [ServerReplicationConfiguration]
$sel:serverReplicationConfigurations:ServerGroupReplicationConfiguration' :: ServerGroupReplicationConfiguration
-> Maybe [ServerReplicationConfiguration]
serverReplicationConfigurations} -> Maybe [ServerReplicationConfiguration]
serverReplicationConfigurations) (\s :: ServerGroupReplicationConfiguration
s@ServerGroupReplicationConfiguration' {} Maybe [ServerReplicationConfiguration]
a -> ServerGroupReplicationConfiguration
s {$sel:serverReplicationConfigurations:ServerGroupReplicationConfiguration' :: Maybe [ServerReplicationConfiguration]
serverReplicationConfigurations = Maybe [ServerReplicationConfiguration]
a} :: ServerGroupReplicationConfiguration) ((Maybe [ServerReplicationConfiguration]
  -> f (Maybe [ServerReplicationConfiguration]))
 -> ServerGroupReplicationConfiguration
 -> f ServerGroupReplicationConfiguration)
-> ((Maybe [ServerReplicationConfiguration]
     -> f (Maybe [ServerReplicationConfiguration]))
    -> Maybe [ServerReplicationConfiguration]
    -> f (Maybe [ServerReplicationConfiguration]))
-> (Maybe [ServerReplicationConfiguration]
    -> f (Maybe [ServerReplicationConfiguration]))
-> ServerGroupReplicationConfiguration
-> f ServerGroupReplicationConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ServerReplicationConfiguration]
  [ServerReplicationConfiguration]
  [ServerReplicationConfiguration]
  [ServerReplicationConfiguration]
-> Iso
     (Maybe [ServerReplicationConfiguration])
     (Maybe [ServerReplicationConfiguration])
     (Maybe [ServerReplicationConfiguration])
     (Maybe [ServerReplicationConfiguration])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ServerReplicationConfiguration]
  [ServerReplicationConfiguration]
  [ServerReplicationConfiguration]
  [ServerReplicationConfiguration]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Core.FromJSON
    ServerGroupReplicationConfiguration
  where
  parseJSON :: Value -> Parser ServerGroupReplicationConfiguration
parseJSON =
    String
-> (Object -> Parser ServerGroupReplicationConfiguration)
-> Value
-> Parser ServerGroupReplicationConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ServerGroupReplicationConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe [ServerReplicationConfiguration]
-> ServerGroupReplicationConfiguration
ServerGroupReplicationConfiguration'
            (Maybe Text
 -> Maybe [ServerReplicationConfiguration]
 -> ServerGroupReplicationConfiguration)
-> Parser (Maybe Text)
-> Parser
     (Maybe [ServerReplicationConfiguration]
      -> ServerGroupReplicationConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"serverGroupId")
            Parser
  (Maybe [ServerReplicationConfiguration]
   -> ServerGroupReplicationConfiguration)
-> Parser (Maybe [ServerReplicationConfiguration])
-> Parser ServerGroupReplicationConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [ServerReplicationConfiguration]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"serverReplicationConfigurations"
                            Parser (Maybe (Maybe [ServerReplicationConfiguration]))
-> Maybe [ServerReplicationConfiguration]
-> Parser (Maybe [ServerReplicationConfiguration])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ServerReplicationConfiguration]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance
  Prelude.Hashable
    ServerGroupReplicationConfiguration

instance
  Prelude.NFData
    ServerGroupReplicationConfiguration

instance
  Core.ToJSON
    ServerGroupReplicationConfiguration
  where
  toJSON :: ServerGroupReplicationConfiguration -> Value
toJSON ServerGroupReplicationConfiguration' {Maybe [ServerReplicationConfiguration]
Maybe Text
serverReplicationConfigurations :: Maybe [ServerReplicationConfiguration]
serverGroupId :: Maybe Text
$sel:serverReplicationConfigurations:ServerGroupReplicationConfiguration' :: ServerGroupReplicationConfiguration
-> Maybe [ServerReplicationConfiguration]
$sel:serverGroupId:ServerGroupReplicationConfiguration' :: ServerGroupReplicationConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"serverGroupId" 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
serverGroupId,
            (Text
"serverReplicationConfigurations" Text -> [ServerReplicationConfiguration] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ServerReplicationConfiguration] -> Pair)
-> Maybe [ServerReplicationConfiguration] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ServerReplicationConfiguration]
serverReplicationConfigurations
          ]
      )