{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$sel:appId:StartAppReplication' :: Maybe Text
appId = forall a. Maybe a
Prelude.Nothing}

-- | The ID of the application.
startAppReplication_appId :: Lens.Lens' StartAppReplication (Prelude.Maybe Prelude.Text)
startAppReplication_appId :: Lens' StartAppReplication (Maybe Text)
startAppReplication_appId = 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 :: (Service -> Service)
-> StartAppReplication -> Request StartAppReplication
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 StartAppReplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartAppReplication)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StartAppReplicationResponse
StartAppReplicationResponse'
            forall (f :: * -> *) a b. Functor 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 StartAppReplication where
  hashWithSalt :: Int -> StartAppReplication -> Int
hashWithSalt Int
_salt StartAppReplication' {Maybe Text
appId :: Maybe Text
$sel:appId:StartAppReplication' :: StartAppReplication -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
appId

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

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

instance Data.ToJSON StartAppReplication where
  toJSON :: StartAppReplication -> Value
toJSON StartAppReplication' {Maybe Text
appId :: Maybe Text
$sel:appId:StartAppReplication' :: StartAppReplication -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"appId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
appId]
      )

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

instance Data.ToQuery StartAppReplication where
  toQuery :: StartAppReplication -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:httpStatus:StartAppReplicationResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
startAppReplicationResponse_httpStatus :: Lens.Lens' StartAppReplicationResponse Prelude.Int
startAppReplicationResponse_httpStatus :: Lens' StartAppReplicationResponse Int
startAppReplicationResponse_httpStatus = 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 where
  rnf :: StartAppReplicationResponse -> ()
rnf StartAppReplicationResponse' {Int
httpStatus :: Int
$sel:httpStatus:StartAppReplicationResponse' :: StartAppReplicationResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus