{-# 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.StartOnDemandAppReplication
-- 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 an on-demand replication run for the specified application.
module Amazonka.SMS.StartOnDemandAppReplication
  ( -- * Creating a Request
    StartOnDemandAppReplication (..),
    newStartOnDemandAppReplication,

    -- * Request Lenses
    startOnDemandAppReplication_description,
    startOnDemandAppReplication_appId,

    -- * Destructuring the Response
    StartOnDemandAppReplicationResponse (..),
    newStartOnDemandAppReplicationResponse,

    -- * Response Lenses
    startOnDemandAppReplicationResponse_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:/ 'newStartOnDemandAppReplication' smart constructor.
data StartOnDemandAppReplication = StartOnDemandAppReplication'
  { -- | The description of the replication run.
    StartOnDemandAppReplication -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The ID of the application.
    StartOnDemandAppReplication -> Text
appId :: Prelude.Text
  }
  deriving (StartOnDemandAppReplication -> StartOnDemandAppReplication -> Bool
(StartOnDemandAppReplication
 -> StartOnDemandAppReplication -> Bool)
-> (StartOnDemandAppReplication
    -> StartOnDemandAppReplication -> Bool)
-> Eq StartOnDemandAppReplication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartOnDemandAppReplication -> StartOnDemandAppReplication -> Bool
$c/= :: StartOnDemandAppReplication -> StartOnDemandAppReplication -> Bool
== :: StartOnDemandAppReplication -> StartOnDemandAppReplication -> Bool
$c== :: StartOnDemandAppReplication -> StartOnDemandAppReplication -> Bool
Prelude.Eq, ReadPrec [StartOnDemandAppReplication]
ReadPrec StartOnDemandAppReplication
Int -> ReadS StartOnDemandAppReplication
ReadS [StartOnDemandAppReplication]
(Int -> ReadS StartOnDemandAppReplication)
-> ReadS [StartOnDemandAppReplication]
-> ReadPrec StartOnDemandAppReplication
-> ReadPrec [StartOnDemandAppReplication]
-> Read StartOnDemandAppReplication
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartOnDemandAppReplication]
$creadListPrec :: ReadPrec [StartOnDemandAppReplication]
readPrec :: ReadPrec StartOnDemandAppReplication
$creadPrec :: ReadPrec StartOnDemandAppReplication
readList :: ReadS [StartOnDemandAppReplication]
$creadList :: ReadS [StartOnDemandAppReplication]
readsPrec :: Int -> ReadS StartOnDemandAppReplication
$creadsPrec :: Int -> ReadS StartOnDemandAppReplication
Prelude.Read, Int -> StartOnDemandAppReplication -> ShowS
[StartOnDemandAppReplication] -> ShowS
StartOnDemandAppReplication -> String
(Int -> StartOnDemandAppReplication -> ShowS)
-> (StartOnDemandAppReplication -> String)
-> ([StartOnDemandAppReplication] -> ShowS)
-> Show StartOnDemandAppReplication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartOnDemandAppReplication] -> ShowS
$cshowList :: [StartOnDemandAppReplication] -> ShowS
show :: StartOnDemandAppReplication -> String
$cshow :: StartOnDemandAppReplication -> String
showsPrec :: Int -> StartOnDemandAppReplication -> ShowS
$cshowsPrec :: Int -> StartOnDemandAppReplication -> ShowS
Prelude.Show, (forall x.
 StartOnDemandAppReplication -> Rep StartOnDemandAppReplication x)
-> (forall x.
    Rep StartOnDemandAppReplication x -> StartOnDemandAppReplication)
-> Generic StartOnDemandAppReplication
forall x.
Rep StartOnDemandAppReplication x -> StartOnDemandAppReplication
forall x.
StartOnDemandAppReplication -> Rep StartOnDemandAppReplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartOnDemandAppReplication x -> StartOnDemandAppReplication
$cfrom :: forall x.
StartOnDemandAppReplication -> Rep StartOnDemandAppReplication x
Prelude.Generic)

-- |
-- Create a value of 'StartOnDemandAppReplication' 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:
--
-- 'description', 'startOnDemandAppReplication_description' - The description of the replication run.
--
-- 'appId', 'startOnDemandAppReplication_appId' - The ID of the application.
newStartOnDemandAppReplication ::
  -- | 'appId'
  Prelude.Text ->
  StartOnDemandAppReplication
newStartOnDemandAppReplication :: Text -> StartOnDemandAppReplication
newStartOnDemandAppReplication Text
pAppId_ =
  StartOnDemandAppReplication' :: Maybe Text -> Text -> StartOnDemandAppReplication
StartOnDemandAppReplication'
    { $sel:description:StartOnDemandAppReplication' :: Maybe Text
description =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:appId:StartOnDemandAppReplication' :: Text
appId = Text
pAppId_
    }

-- | The description of the replication run.
startOnDemandAppReplication_description :: Lens.Lens' StartOnDemandAppReplication (Prelude.Maybe Prelude.Text)
startOnDemandAppReplication_description :: (Maybe Text -> f (Maybe Text))
-> StartOnDemandAppReplication -> f StartOnDemandAppReplication
startOnDemandAppReplication_description = (StartOnDemandAppReplication -> Maybe Text)
-> (StartOnDemandAppReplication
    -> Maybe Text -> StartOnDemandAppReplication)
-> Lens
     StartOnDemandAppReplication
     StartOnDemandAppReplication
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartOnDemandAppReplication' {Maybe Text
description :: Maybe Text
$sel:description:StartOnDemandAppReplication' :: StartOnDemandAppReplication -> Maybe Text
description} -> Maybe Text
description) (\s :: StartOnDemandAppReplication
s@StartOnDemandAppReplication' {} Maybe Text
a -> StartOnDemandAppReplication
s {$sel:description:StartOnDemandAppReplication' :: Maybe Text
description = Maybe Text
a} :: StartOnDemandAppReplication)

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

instance Core.AWSRequest StartOnDemandAppReplication where
  type
    AWSResponse StartOnDemandAppReplication =
      StartOnDemandAppReplicationResponse
  request :: StartOnDemandAppReplication -> Request StartOnDemandAppReplication
request = Service
-> StartOnDemandAppReplication
-> Request StartOnDemandAppReplication
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartOnDemandAppReplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartOnDemandAppReplication)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StartOnDemandAppReplication))
-> Logger
-> Service
-> Proxy StartOnDemandAppReplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartOnDemandAppReplication)))
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 -> StartOnDemandAppReplicationResponse
StartOnDemandAppReplicationResponse'
            (Int -> StartOnDemandAppReplicationResponse)
-> Either String Int
-> Either String StartOnDemandAppReplicationResponse
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 StartOnDemandAppReplication

instance Prelude.NFData StartOnDemandAppReplication

instance Core.ToHeaders StartOnDemandAppReplication where
  toHeaders :: StartOnDemandAppReplication -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartOnDemandAppReplication -> 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.StartOnDemandAppReplication" ::
                          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 StartOnDemandAppReplication where
  toJSON :: StartOnDemandAppReplication -> Value
toJSON StartOnDemandAppReplication' {Maybe Text
Text
appId :: Text
description :: Maybe Text
$sel:appId:StartOnDemandAppReplication' :: StartOnDemandAppReplication -> Text
$sel:description:StartOnDemandAppReplication' :: StartOnDemandAppReplication -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"description" 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
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"appId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
appId)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    StartOnDemandAppReplicationResponse