{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.MGN.StartReplication
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Starts replication for SNAPSHOT_SHIPPING agents.
module Amazonka.MGN.StartReplication
  ( -- * Creating a Request
    StartReplication (..),
    newStartReplication,

    -- * Request Lenses
    startReplication_sourceServerID,

    -- * Destructuring the Response
    SourceServer (..),
    newSourceServer,

    -- * Response Lenses
    sourceServer_applicationID,
    sourceServer_arn,
    sourceServer_dataReplicationInfo,
    sourceServer_isArchived,
    sourceServer_launchedInstance,
    sourceServer_lifeCycle,
    sourceServer_replicationType,
    sourceServer_sourceProperties,
    sourceServer_sourceServerID,
    sourceServer_tags,
    sourceServer_vcenterClientID,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MGN.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newStartReplication' smart constructor.
data StartReplication = StartReplication'
  { -- | ID of source server on which to start replication.
    StartReplication -> Text
sourceServerID :: Prelude.Text
  }
  deriving (StartReplication -> StartReplication -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartReplication -> StartReplication -> Bool
$c/= :: StartReplication -> StartReplication -> Bool
== :: StartReplication -> StartReplication -> Bool
$c== :: StartReplication -> StartReplication -> Bool
Prelude.Eq, ReadPrec [StartReplication]
ReadPrec StartReplication
Int -> ReadS StartReplication
ReadS [StartReplication]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartReplication]
$creadListPrec :: ReadPrec [StartReplication]
readPrec :: ReadPrec StartReplication
$creadPrec :: ReadPrec StartReplication
readList :: ReadS [StartReplication]
$creadList :: ReadS [StartReplication]
readsPrec :: Int -> ReadS StartReplication
$creadsPrec :: Int -> ReadS StartReplication
Prelude.Read, Int -> StartReplication -> ShowS
[StartReplication] -> ShowS
StartReplication -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartReplication] -> ShowS
$cshowList :: [StartReplication] -> ShowS
show :: StartReplication -> String
$cshow :: StartReplication -> String
showsPrec :: Int -> StartReplication -> ShowS
$cshowsPrec :: Int -> StartReplication -> ShowS
Prelude.Show, forall x. Rep StartReplication x -> StartReplication
forall x. StartReplication -> Rep StartReplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartReplication x -> StartReplication
$cfrom :: forall x. StartReplication -> Rep StartReplication x
Prelude.Generic)

-- |
-- Create a value of 'StartReplication' 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:
--
-- 'sourceServerID', 'startReplication_sourceServerID' - ID of source server on which to start replication.
newStartReplication ::
  -- | 'sourceServerID'
  Prelude.Text ->
  StartReplication
newStartReplication :: Text -> StartReplication
newStartReplication Text
pSourceServerID_ =
  StartReplication'
    { $sel:sourceServerID:StartReplication' :: Text
sourceServerID =
        Text
pSourceServerID_
    }

-- | ID of source server on which to start replication.
startReplication_sourceServerID :: Lens.Lens' StartReplication Prelude.Text
startReplication_sourceServerID :: Lens' StartReplication Text
startReplication_sourceServerID = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartReplication' {Text
sourceServerID :: Text
$sel:sourceServerID:StartReplication' :: StartReplication -> Text
sourceServerID} -> Text
sourceServerID) (\s :: StartReplication
s@StartReplication' {} Text
a -> StartReplication
s {$sel:sourceServerID:StartReplication' :: Text
sourceServerID = Text
a} :: StartReplication)

instance Core.AWSRequest StartReplication where
  type AWSResponse StartReplication = SourceServer
  request :: (Service -> Service)
-> StartReplication -> Request StartReplication
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StartReplication
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartReplication)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable StartReplication where
  hashWithSalt :: Int -> StartReplication -> Int
hashWithSalt Int
_salt StartReplication' {Text
sourceServerID :: Text
$sel:sourceServerID:StartReplication' :: StartReplication -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sourceServerID

instance Prelude.NFData StartReplication where
  rnf :: StartReplication -> ()
rnf StartReplication' {Text
sourceServerID :: Text
$sel:sourceServerID:StartReplication' :: StartReplication -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
sourceServerID

instance Data.ToHeaders StartReplication where
  toHeaders :: StartReplication -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StartReplication where
  toJSON :: StartReplication -> Value
toJSON StartReplication' {Text
sourceServerID :: Text
$sel:sourceServerID:StartReplication' :: StartReplication -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"sourceServerID" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
sourceServerID)
          ]
      )

instance Data.ToPath StartReplication where
  toPath :: StartReplication -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/StartReplication"

instance Data.ToQuery StartReplication where
  toQuery :: StartReplication -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty