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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SMS.Types.Server
import Amazonka.SMS.Types.ServerReplicationParameters

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

-- |
-- Create a value of 'ServerReplicationConfiguration' 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:
--
-- 'serverReplicationParameters', 'serverReplicationConfiguration_serverReplicationParameters' - The parameters for replicating the server.
--
-- 'server', 'serverReplicationConfiguration_server' - The ID of the server with which this replication configuration is
-- associated.
newServerReplicationConfiguration ::
  ServerReplicationConfiguration
newServerReplicationConfiguration :: ServerReplicationConfiguration
newServerReplicationConfiguration =
  ServerReplicationConfiguration' :: Maybe ServerReplicationParameters
-> Maybe Server -> ServerReplicationConfiguration
ServerReplicationConfiguration'
    { $sel:serverReplicationParameters:ServerReplicationConfiguration' :: Maybe ServerReplicationParameters
serverReplicationParameters =
        Maybe ServerReplicationParameters
forall a. Maybe a
Prelude.Nothing,
      $sel:server:ServerReplicationConfiguration' :: Maybe Server
server = Maybe Server
forall a. Maybe a
Prelude.Nothing
    }

-- | The parameters for replicating the server.
serverReplicationConfiguration_serverReplicationParameters :: Lens.Lens' ServerReplicationConfiguration (Prelude.Maybe ServerReplicationParameters)
serverReplicationConfiguration_serverReplicationParameters :: (Maybe ServerReplicationParameters
 -> f (Maybe ServerReplicationParameters))
-> ServerReplicationConfiguration
-> f ServerReplicationConfiguration
serverReplicationConfiguration_serverReplicationParameters = (ServerReplicationConfiguration
 -> Maybe ServerReplicationParameters)
-> (ServerReplicationConfiguration
    -> Maybe ServerReplicationParameters
    -> ServerReplicationConfiguration)
-> Lens
     ServerReplicationConfiguration
     ServerReplicationConfiguration
     (Maybe ServerReplicationParameters)
     (Maybe ServerReplicationParameters)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerReplicationConfiguration' {Maybe ServerReplicationParameters
serverReplicationParameters :: Maybe ServerReplicationParameters
$sel:serverReplicationParameters:ServerReplicationConfiguration' :: ServerReplicationConfiguration -> Maybe ServerReplicationParameters
serverReplicationParameters} -> Maybe ServerReplicationParameters
serverReplicationParameters) (\s :: ServerReplicationConfiguration
s@ServerReplicationConfiguration' {} Maybe ServerReplicationParameters
a -> ServerReplicationConfiguration
s {$sel:serverReplicationParameters:ServerReplicationConfiguration' :: Maybe ServerReplicationParameters
serverReplicationParameters = Maybe ServerReplicationParameters
a} :: ServerReplicationConfiguration)

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

instance Core.FromJSON ServerReplicationConfiguration where
  parseJSON :: Value -> Parser ServerReplicationConfiguration
parseJSON =
    String
-> (Object -> Parser ServerReplicationConfiguration)
-> Value
-> Parser ServerReplicationConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ServerReplicationConfiguration"
      ( \Object
x ->
          Maybe ServerReplicationParameters
-> Maybe Server -> ServerReplicationConfiguration
ServerReplicationConfiguration'
            (Maybe ServerReplicationParameters
 -> Maybe Server -> ServerReplicationConfiguration)
-> Parser (Maybe ServerReplicationParameters)
-> Parser (Maybe Server -> ServerReplicationConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ServerReplicationParameters)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"serverReplicationParameters")
            Parser (Maybe Server -> ServerReplicationConfiguration)
-> Parser (Maybe Server) -> Parser ServerReplicationConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Server)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"server")
      )

instance
  Prelude.Hashable
    ServerReplicationConfiguration

instance
  Prelude.NFData
    ServerReplicationConfiguration

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