{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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:/ '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
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]
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
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.
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'
    { $sel:description:StartOnDemandAppReplication' :: Maybe Text
description =
        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 :: Lens' StartOnDemandAppReplication (Maybe Text)
startOnDemandAppReplication_description = 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 :: Lens' StartOnDemandAppReplication Text
startOnDemandAppReplication_appId = 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 :: (Service -> Service)
-> StartOnDemandAppReplication
-> Request StartOnDemandAppReplication
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 StartOnDemandAppReplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartOnDemandAppReplication)))
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 -> StartOnDemandAppReplicationResponse
StartOnDemandAppReplicationResponse'
            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 StartOnDemandAppReplication where
  hashWithSalt :: Int -> StartOnDemandAppReplication -> Int
hashWithSalt Int
_salt StartOnDemandAppReplication' {Maybe Text
Text
appId :: Text
description :: Maybe Text
$sel:appId:StartOnDemandAppReplication' :: StartOnDemandAppReplication -> Text
$sel:description:StartOnDemandAppReplication' :: StartOnDemandAppReplication -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
appId

instance Prelude.NFData StartOnDemandAppReplication where
  rnf :: StartOnDemandAppReplication -> ()
rnf StartOnDemandAppReplication' {Maybe Text
Text
appId :: Text
description :: Maybe Text
$sel:appId:StartOnDemandAppReplication' :: StartOnDemandAppReplication -> Text
$sel:description:StartOnDemandAppReplication' :: StartOnDemandAppReplication -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
appId

instance Data.ToHeaders StartOnDemandAppReplication where
  toHeaders :: StartOnDemandAppReplication -> 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.StartOnDemandAppReplication" ::
                          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 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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"description" 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
description,
            forall a. a -> Maybe a
Prelude.Just (Key
"appId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
appId)
          ]
      )

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

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

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