{-# 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.DrS.RetryDataReplication
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Causes the data replication initiation sequence to begin immediately
-- upon next Handshake for the specified Source Server ID, regardless of
-- when the previous initiation started. This command will work only if the
-- Source Server is stalled or is in a DISCONNECTED or STOPPED state.
module Amazonka.DrS.RetryDataReplication
  ( -- * Creating a Request
    RetryDataReplication (..),
    newRetryDataReplication,

    -- * Request Lenses
    retryDataReplication_sourceServerID,

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

    -- * Response Lenses
    sourceServer_arn,
    sourceServer_dataReplicationInfo,
    sourceServer_lastLaunchResult,
    sourceServer_lifeCycle,
    sourceServer_recoveryInstanceId,
    sourceServer_replicationDirection,
    sourceServer_reversedDirectionSourceServerArn,
    sourceServer_sourceCloudProperties,
    sourceServer_sourceProperties,
    sourceServer_sourceServerID,
    sourceServer_stagingArea,
    sourceServer_tags,
  )
where

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

-- | /See:/ 'newRetryDataReplication' smart constructor.
data RetryDataReplication = RetryDataReplication'
  { -- | The ID of the Source Server whose data replication should be retried.
    RetryDataReplication -> Text
sourceServerID :: Prelude.Text
  }
  deriving (RetryDataReplication -> RetryDataReplication -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetryDataReplication -> RetryDataReplication -> Bool
$c/= :: RetryDataReplication -> RetryDataReplication -> Bool
== :: RetryDataReplication -> RetryDataReplication -> Bool
$c== :: RetryDataReplication -> RetryDataReplication -> Bool
Prelude.Eq, ReadPrec [RetryDataReplication]
ReadPrec RetryDataReplication
Int -> ReadS RetryDataReplication
ReadS [RetryDataReplication]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RetryDataReplication]
$creadListPrec :: ReadPrec [RetryDataReplication]
readPrec :: ReadPrec RetryDataReplication
$creadPrec :: ReadPrec RetryDataReplication
readList :: ReadS [RetryDataReplication]
$creadList :: ReadS [RetryDataReplication]
readsPrec :: Int -> ReadS RetryDataReplication
$creadsPrec :: Int -> ReadS RetryDataReplication
Prelude.Read, Int -> RetryDataReplication -> ShowS
[RetryDataReplication] -> ShowS
RetryDataReplication -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetryDataReplication] -> ShowS
$cshowList :: [RetryDataReplication] -> ShowS
show :: RetryDataReplication -> String
$cshow :: RetryDataReplication -> String
showsPrec :: Int -> RetryDataReplication -> ShowS
$cshowsPrec :: Int -> RetryDataReplication -> ShowS
Prelude.Show, forall x. Rep RetryDataReplication x -> RetryDataReplication
forall x. RetryDataReplication -> Rep RetryDataReplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RetryDataReplication x -> RetryDataReplication
$cfrom :: forall x. RetryDataReplication -> Rep RetryDataReplication x
Prelude.Generic)

-- |
-- Create a value of 'RetryDataReplication' 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', 'retryDataReplication_sourceServerID' - The ID of the Source Server whose data replication should be retried.
newRetryDataReplication ::
  -- | 'sourceServerID'
  Prelude.Text ->
  RetryDataReplication
newRetryDataReplication :: Text -> RetryDataReplication
newRetryDataReplication Text
pSourceServerID_ =
  RetryDataReplication'
    { $sel:sourceServerID:RetryDataReplication' :: Text
sourceServerID =
        Text
pSourceServerID_
    }

-- | The ID of the Source Server whose data replication should be retried.
retryDataReplication_sourceServerID :: Lens.Lens' RetryDataReplication Prelude.Text
retryDataReplication_sourceServerID :: Lens' RetryDataReplication Text
retryDataReplication_sourceServerID = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetryDataReplication' {Text
sourceServerID :: Text
$sel:sourceServerID:RetryDataReplication' :: RetryDataReplication -> Text
sourceServerID} -> Text
sourceServerID) (\s :: RetryDataReplication
s@RetryDataReplication' {} Text
a -> RetryDataReplication
s {$sel:sourceServerID:RetryDataReplication' :: Text
sourceServerID = Text
a} :: RetryDataReplication)

instance Core.AWSRequest RetryDataReplication where
  type AWSResponse RetryDataReplication = SourceServer
  request :: (Service -> Service)
-> RetryDataReplication -> Request RetryDataReplication
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 RetryDataReplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RetryDataReplication)))
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 RetryDataReplication where
  hashWithSalt :: Int -> RetryDataReplication -> Int
hashWithSalt Int
_salt RetryDataReplication' {Text
sourceServerID :: Text
$sel:sourceServerID:RetryDataReplication' :: RetryDataReplication -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sourceServerID

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

instance Data.ToHeaders RetryDataReplication where
  toHeaders :: RetryDataReplication -> 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 RetryDataReplication where
  toJSON :: RetryDataReplication -> Value
toJSON RetryDataReplication' {Text
sourceServerID :: Text
$sel:sourceServerID:RetryDataReplication' :: RetryDataReplication -> 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 RetryDataReplication where
  toPath :: RetryDataReplication -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/RetryDataReplication"

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