{-# 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.SMS.StartAppReplication
-- 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)
--
-- Starts replicating the specified application by creating replication
-- jobs for each server in the application.
module Amazonka.SMS.StartAppReplication
  ( -- * Creating a Request
    StartAppReplication (..),
    newStartAppReplication,

    -- * Request Lenses
    startAppReplication_appId,

    -- * Destructuring the Response
    StartAppReplicationResponse (..),
    newStartAppReplicationResponse,

    -- * Response Lenses
    startAppReplicationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SMS.Types

-- | /See:/ 'newStartAppReplication' smart constructor.
data StartAppReplication = StartAppReplication'
  { -- | The ID of the application.
    StartAppReplication -> Maybe Text
appId :: Prelude.Maybe Prelude.Text
  }
  deriving (StartAppReplication -> StartAppReplication -> Bool
(StartAppReplication -> StartAppReplication -> Bool)
-> (StartAppReplication -> StartAppReplication -> Bool)
-> Eq StartAppReplication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartAppReplication -> StartAppReplication -> Bool
$c/= :: StartAppReplication -> StartAppReplication -> Bool
== :: StartAppReplication -> StartAppReplication -> Bool
$c== :: StartAppReplication -> StartAppReplication -> Bool
Prelude.Eq, ReadPrec [StartAppReplication]
ReadPrec StartAppReplication
Int -> ReadS StartAppReplication
ReadS [StartAppReplication]
(Int -> ReadS StartAppReplication)
-> ReadS [StartAppReplication]
-> ReadPrec StartAppReplication
-> ReadPrec [StartAppReplication]
-> Read StartAppReplication
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartAppReplication]
$creadListPrec :: ReadPrec [StartAppReplication]
readPrec :: ReadPrec StartAppReplication
$creadPrec :: ReadPrec StartAppReplication
readList :: ReadS [StartAppReplication]
$creadList :: ReadS [StartAppReplication]
readsPrec :: Int -> ReadS StartAppReplication
$creadsPrec :: Int -> ReadS StartAppReplication
Prelude.Read, Int -> StartAppReplication -> ShowS
[StartAppReplication] -> ShowS
StartAppReplication -> String
(Int -> StartAppReplication -> ShowS)
-> (StartAppReplication -> String)
-> ([StartAppReplication] -> ShowS)
-> Show StartAppReplication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartAppReplication] -> ShowS
$cshowList :: [StartAppReplication] -> ShowS
show :: StartAppReplication -> String
$cshow :: StartAppReplication -> String
showsPrec :: Int -> StartAppReplication -> ShowS
$cshowsPrec :: Int -> StartAppReplication -> ShowS
Prelude.Show, (forall x. StartAppReplication -> Rep StartAppReplication x)
-> (forall x. Rep StartAppReplication x -> StartAppReplication)
-> Generic StartAppReplication
forall x. Rep StartAppReplication x -> StartAppReplication
forall x. StartAppReplication -> Rep StartAppReplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartAppReplication x -> StartAppReplication
$cfrom :: forall x. StartAppReplication -> Rep StartAppReplication x
Prelude.Generic)

-- |
-- Create a value of 'StartAppReplication' 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:
--
-- 'appId', 'startAppReplication_appId' - The ID of the application.
newStartAppReplication ::
  StartAppReplication
newStartAppReplication :: StartAppReplication
newStartAppReplication =
  StartAppReplication' :: Maybe Text -> StartAppReplication
StartAppReplication' {$sel:appId:StartAppReplication' :: Maybe Text
appId = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The ID of the application.
startAppReplication_appId :: Lens.Lens' StartAppReplication (Prelude.Maybe Prelude.Text)
startAppReplication_appId :: (Maybe Text -> f (Maybe Text))
-> StartAppReplication -> f StartAppReplication
startAppReplication_appId = (StartAppReplication -> Maybe Text)
-> (StartAppReplication -> Maybe Text -> StartAppReplication)
-> Lens
     StartAppReplication StartAppReplication (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartAppReplication' {Maybe Text
appId :: Maybe Text
$sel:appId:StartAppReplication' :: StartAppReplication -> Maybe Text
appId} -> Maybe Text
appId) (\s :: StartAppReplication
s@StartAppReplication' {} Maybe Text
a -> StartAppReplication
s {$sel:appId:StartAppReplication' :: Maybe Text
appId = Maybe Text
a} :: StartAppReplication)

instance Core.AWSRequest StartAppReplication where
  type
    AWSResponse StartAppReplication =
      StartAppReplicationResponse
  request :: StartAppReplication -> Request StartAppReplication
request = Service -> StartAppReplication -> Request StartAppReplication
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartAppReplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartAppReplication)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StartAppReplication))
-> Logger
-> Service
-> Proxy StartAppReplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartAppReplication)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StartAppReplicationResponse
StartAppReplicationResponse'
            (Int -> StartAppReplicationResponse)
-> Either String Int -> Either String StartAppReplicationResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable StartAppReplication

instance Prelude.NFData StartAppReplication

instance Core.ToHeaders StartAppReplication where
  toHeaders :: StartAppReplication -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartAppReplication -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSServerMigrationService_V2016_10_24.StartAppReplication" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON StartAppReplication where
  toJSON :: StartAppReplication -> Value
toJSON StartAppReplication' {Maybe Text
appId :: Maybe Text
$sel:appId:StartAppReplication' :: StartAppReplication -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"appId" 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
appId]
      )

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

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

-- | /See:/ 'newStartAppReplicationResponse' smart constructor.
data StartAppReplicationResponse = StartAppReplicationResponse'
  { -- | The response's http status code.
    StartAppReplicationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartAppReplicationResponse -> StartAppReplicationResponse -> Bool
(StartAppReplicationResponse
 -> StartAppReplicationResponse -> Bool)
-> (StartAppReplicationResponse
    -> StartAppReplicationResponse -> Bool)
-> Eq StartAppReplicationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartAppReplicationResponse -> StartAppReplicationResponse -> Bool
$c/= :: StartAppReplicationResponse -> StartAppReplicationResponse -> Bool
== :: StartAppReplicationResponse -> StartAppReplicationResponse -> Bool
$c== :: StartAppReplicationResponse -> StartAppReplicationResponse -> Bool
Prelude.Eq, ReadPrec [StartAppReplicationResponse]
ReadPrec StartAppReplicationResponse
Int -> ReadS StartAppReplicationResponse
ReadS [StartAppReplicationResponse]
(Int -> ReadS StartAppReplicationResponse)
-> ReadS [StartAppReplicationResponse]
-> ReadPrec StartAppReplicationResponse
-> ReadPrec [StartAppReplicationResponse]
-> Read StartAppReplicationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartAppReplicationResponse]
$creadListPrec :: ReadPrec [StartAppReplicationResponse]
readPrec :: ReadPrec StartAppReplicationResponse
$creadPrec :: ReadPrec StartAppReplicationResponse
readList :: ReadS [StartAppReplicationResponse]
$creadList :: ReadS [StartAppReplicationResponse]
readsPrec :: Int -> ReadS StartAppReplicationResponse
$creadsPrec :: Int -> ReadS StartAppReplicationResponse
Prelude.Read, Int -> StartAppReplicationResponse -> ShowS
[StartAppReplicationResponse] -> ShowS
StartAppReplicationResponse -> String
(Int -> StartAppReplicationResponse -> ShowS)
-> (StartAppReplicationResponse -> String)
-> ([StartAppReplicationResponse] -> ShowS)
-> Show StartAppReplicationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartAppReplicationResponse] -> ShowS
$cshowList :: [StartAppReplicationResponse] -> ShowS
show :: StartAppReplicationResponse -> String
$cshow :: StartAppReplicationResponse -> String
showsPrec :: Int -> StartAppReplicationResponse -> ShowS
$cshowsPrec :: Int -> StartAppReplicationResponse -> ShowS
Prelude.Show, (forall x.
 StartAppReplicationResponse -> Rep StartAppReplicationResponse x)
-> (forall x.
    Rep StartAppReplicationResponse x -> StartAppReplicationResponse)
-> Generic StartAppReplicationResponse
forall x.
Rep StartAppReplicationResponse x -> StartAppReplicationResponse
forall x.
StartAppReplicationResponse -> Rep StartAppReplicationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartAppReplicationResponse x -> StartAppReplicationResponse
$cfrom :: forall x.
StartAppReplicationResponse -> Rep StartAppReplicationResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartAppReplicationResponse' 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:
--
-- 'httpStatus', 'startAppReplicationResponse_httpStatus' - The response's http status code.
newStartAppReplicationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartAppReplicationResponse
newStartAppReplicationResponse :: Int -> StartAppReplicationResponse
newStartAppReplicationResponse Int
pHttpStatus_ =
  StartAppReplicationResponse' :: Int -> StartAppReplicationResponse
StartAppReplicationResponse'
    { $sel:httpStatus:StartAppReplicationResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData StartAppReplicationResponse