{-# 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.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 a stopped Source Server. This action would make
-- the Source Server protected again and restart billing for it.
module Amazonka.DrS.StartReplication
  ( -- * Creating a Request
    StartReplication (..),
    newStartReplication,

    -- * Request Lenses
    startReplication_sourceServerID,

    -- * Destructuring the Response
    StartReplicationResponse (..),
    newStartReplicationResponse,

    -- * Response Lenses
    startReplicationResponse_sourceServer,
    startReplicationResponse_httpStatus,
  )
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:/ 'newStartReplication' smart constructor.
data StartReplication = StartReplication'
  { -- | The ID of the Source Server to start replication for.
    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' - The ID of the Source Server to start replication for.
newStartReplication ::
  -- | 'sourceServerID'
  Prelude.Text ->
  StartReplication
newStartReplication :: Text -> StartReplication
newStartReplication Text
pSourceServerID_ =
  StartReplication'
    { $sel:sourceServerID:StartReplication' :: Text
sourceServerID =
        Text
pSourceServerID_
    }

-- | The ID of the Source Server to start replication for.
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 =
      StartReplicationResponse
  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 ->
          Maybe SourceServer -> Int -> StartReplicationResponse
StartReplicationResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"sourceServer")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

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

-- | /See:/ 'newStartReplicationResponse' smart constructor.
data StartReplicationResponse = StartReplicationResponse'
  { -- | The Source Server that this action was targeted on.
    StartReplicationResponse -> Maybe SourceServer
sourceServer :: Prelude.Maybe SourceServer,
    -- | The response's http status code.
    StartReplicationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartReplicationResponse -> StartReplicationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartReplicationResponse -> StartReplicationResponse -> Bool
$c/= :: StartReplicationResponse -> StartReplicationResponse -> Bool
== :: StartReplicationResponse -> StartReplicationResponse -> Bool
$c== :: StartReplicationResponse -> StartReplicationResponse -> Bool
Prelude.Eq, Int -> StartReplicationResponse -> ShowS
[StartReplicationResponse] -> ShowS
StartReplicationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartReplicationResponse] -> ShowS
$cshowList :: [StartReplicationResponse] -> ShowS
show :: StartReplicationResponse -> String
$cshow :: StartReplicationResponse -> String
showsPrec :: Int -> StartReplicationResponse -> ShowS
$cshowsPrec :: Int -> StartReplicationResponse -> ShowS
Prelude.Show, forall x.
Rep StartReplicationResponse x -> StartReplicationResponse
forall x.
StartReplicationResponse -> Rep StartReplicationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartReplicationResponse x -> StartReplicationResponse
$cfrom :: forall x.
StartReplicationResponse -> Rep StartReplicationResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartReplicationResponse' 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:
--
-- 'sourceServer', 'startReplicationResponse_sourceServer' - The Source Server that this action was targeted on.
--
-- 'httpStatus', 'startReplicationResponse_httpStatus' - The response's http status code.
newStartReplicationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartReplicationResponse
newStartReplicationResponse :: Int -> StartReplicationResponse
newStartReplicationResponse Int
pHttpStatus_ =
  StartReplicationResponse'
    { $sel:sourceServer:StartReplicationResponse' :: Maybe SourceServer
sourceServer =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartReplicationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Source Server that this action was targeted on.
startReplicationResponse_sourceServer :: Lens.Lens' StartReplicationResponse (Prelude.Maybe SourceServer)
startReplicationResponse_sourceServer :: Lens' StartReplicationResponse (Maybe SourceServer)
startReplicationResponse_sourceServer = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartReplicationResponse' {Maybe SourceServer
sourceServer :: Maybe SourceServer
$sel:sourceServer:StartReplicationResponse' :: StartReplicationResponse -> Maybe SourceServer
sourceServer} -> Maybe SourceServer
sourceServer) (\s :: StartReplicationResponse
s@StartReplicationResponse' {} Maybe SourceServer
a -> StartReplicationResponse
s {$sel:sourceServer:StartReplicationResponse' :: Maybe SourceServer
sourceServer = Maybe SourceServer
a} :: StartReplicationResponse)

-- | The response's http status code.
startReplicationResponse_httpStatus :: Lens.Lens' StartReplicationResponse Prelude.Int
startReplicationResponse_httpStatus :: Lens' StartReplicationResponse Int
startReplicationResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartReplicationResponse' {Int
httpStatus :: Int
$sel:httpStatus:StartReplicationResponse' :: StartReplicationResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: StartReplicationResponse
s@StartReplicationResponse' {} Int
a -> StartReplicationResponse
s {$sel:httpStatus:StartReplicationResponse' :: Int
httpStatus = Int
a} :: StartReplicationResponse)

instance Prelude.NFData StartReplicationResponse where
  rnf :: StartReplicationResponse -> ()
rnf StartReplicationResponse' {Int
Maybe SourceServer
httpStatus :: Int
sourceServer :: Maybe SourceServer
$sel:httpStatus:StartReplicationResponse' :: StartReplicationResponse -> Int
$sel:sourceServer:StartReplicationResponse' :: StartReplicationResponse -> Maybe SourceServer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SourceServer
sourceServer
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus