{-# 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.CreateReplicationJob
-- 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)
--
-- Creates a replication job. The replication job schedules periodic
-- replication runs to replicate your server to AWS. Each replication run
-- creates an Amazon Machine Image (AMI).
module Amazonka.SMS.CreateReplicationJob
  ( -- * Creating a Request
    CreateReplicationJob (..),
    newCreateReplicationJob,

    -- * Request Lenses
    createReplicationJob_frequency,
    createReplicationJob_numberOfRecentAmisToKeep,
    createReplicationJob_licenseType,
    createReplicationJob_roleName,
    createReplicationJob_encrypted,
    createReplicationJob_kmsKeyId,
    createReplicationJob_runOnce,
    createReplicationJob_description,
    createReplicationJob_serverId,
    createReplicationJob_seedReplicationTime,

    -- * Destructuring the Response
    CreateReplicationJobResponse (..),
    newCreateReplicationJobResponse,

    -- * Response Lenses
    createReplicationJobResponse_replicationJobId,
    createReplicationJobResponse_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:/ 'newCreateReplicationJob' smart constructor.
data CreateReplicationJob = CreateReplicationJob'
  { -- | The time between consecutive replication runs, in hours.
    CreateReplicationJob -> Maybe Int
frequency :: Prelude.Maybe Prelude.Int,
    -- | The maximum number of SMS-created AMIs to retain. The oldest is deleted
    -- after the maximum number is reached and a new AMI is created.
    CreateReplicationJob -> Maybe Int
numberOfRecentAmisToKeep :: Prelude.Maybe Prelude.Int,
    -- | The license type to be used for the AMI created by a successful
    -- replication run.
    CreateReplicationJob -> Maybe LicenseType
licenseType :: Prelude.Maybe LicenseType,
    -- | The name of the IAM role to be used by the AWS SMS.
    CreateReplicationJob -> Maybe Text
roleName :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether the replication job produces encrypted AMIs.
    CreateReplicationJob -> Maybe Bool
encrypted :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the KMS key for replication jobs that produce encrypted AMIs.
    -- This value can be any of the following:
    --
    -- -   KMS key ID
    --
    -- -   KMS key alias
    --
    -- -   ARN referring to the KMS key ID
    --
    -- -   ARN referring to the KMS key alias
    --
    -- If encrypted is /true/ but a KMS key ID is not specified, the
    -- customer\'s default KMS key for Amazon EBS is used.
    CreateReplicationJob -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether to run the replication job one time.
    CreateReplicationJob -> Maybe Bool
runOnce :: Prelude.Maybe Prelude.Bool,
    -- | The description of the replication job.
    CreateReplicationJob -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The ID of the server.
    CreateReplicationJob -> Text
serverId :: Prelude.Text,
    -- | The seed replication time.
    CreateReplicationJob -> POSIX
seedReplicationTime :: Core.POSIX
  }
  deriving (CreateReplicationJob -> CreateReplicationJob -> Bool
(CreateReplicationJob -> CreateReplicationJob -> Bool)
-> (CreateReplicationJob -> CreateReplicationJob -> Bool)
-> Eq CreateReplicationJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateReplicationJob -> CreateReplicationJob -> Bool
$c/= :: CreateReplicationJob -> CreateReplicationJob -> Bool
== :: CreateReplicationJob -> CreateReplicationJob -> Bool
$c== :: CreateReplicationJob -> CreateReplicationJob -> Bool
Prelude.Eq, ReadPrec [CreateReplicationJob]
ReadPrec CreateReplicationJob
Int -> ReadS CreateReplicationJob
ReadS [CreateReplicationJob]
(Int -> ReadS CreateReplicationJob)
-> ReadS [CreateReplicationJob]
-> ReadPrec CreateReplicationJob
-> ReadPrec [CreateReplicationJob]
-> Read CreateReplicationJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateReplicationJob]
$creadListPrec :: ReadPrec [CreateReplicationJob]
readPrec :: ReadPrec CreateReplicationJob
$creadPrec :: ReadPrec CreateReplicationJob
readList :: ReadS [CreateReplicationJob]
$creadList :: ReadS [CreateReplicationJob]
readsPrec :: Int -> ReadS CreateReplicationJob
$creadsPrec :: Int -> ReadS CreateReplicationJob
Prelude.Read, Int -> CreateReplicationJob -> ShowS
[CreateReplicationJob] -> ShowS
CreateReplicationJob -> String
(Int -> CreateReplicationJob -> ShowS)
-> (CreateReplicationJob -> String)
-> ([CreateReplicationJob] -> ShowS)
-> Show CreateReplicationJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateReplicationJob] -> ShowS
$cshowList :: [CreateReplicationJob] -> ShowS
show :: CreateReplicationJob -> String
$cshow :: CreateReplicationJob -> String
showsPrec :: Int -> CreateReplicationJob -> ShowS
$cshowsPrec :: Int -> CreateReplicationJob -> ShowS
Prelude.Show, (forall x. CreateReplicationJob -> Rep CreateReplicationJob x)
-> (forall x. Rep CreateReplicationJob x -> CreateReplicationJob)
-> Generic CreateReplicationJob
forall x. Rep CreateReplicationJob x -> CreateReplicationJob
forall x. CreateReplicationJob -> Rep CreateReplicationJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateReplicationJob x -> CreateReplicationJob
$cfrom :: forall x. CreateReplicationJob -> Rep CreateReplicationJob x
Prelude.Generic)

-- |
-- Create a value of 'CreateReplicationJob' 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:
--
-- 'frequency', 'createReplicationJob_frequency' - The time between consecutive replication runs, in hours.
--
-- 'numberOfRecentAmisToKeep', 'createReplicationJob_numberOfRecentAmisToKeep' - The maximum number of SMS-created AMIs to retain. The oldest is deleted
-- after the maximum number is reached and a new AMI is created.
--
-- 'licenseType', 'createReplicationJob_licenseType' - The license type to be used for the AMI created by a successful
-- replication run.
--
-- 'roleName', 'createReplicationJob_roleName' - The name of the IAM role to be used by the AWS SMS.
--
-- 'encrypted', 'createReplicationJob_encrypted' - Indicates whether the replication job produces encrypted AMIs.
--
-- 'kmsKeyId', 'createReplicationJob_kmsKeyId' - The ID of the KMS key for replication jobs that produce encrypted AMIs.
-- This value can be any of the following:
--
-- -   KMS key ID
--
-- -   KMS key alias
--
-- -   ARN referring to the KMS key ID
--
-- -   ARN referring to the KMS key alias
--
-- If encrypted is /true/ but a KMS key ID is not specified, the
-- customer\'s default KMS key for Amazon EBS is used.
--
-- 'runOnce', 'createReplicationJob_runOnce' - Indicates whether to run the replication job one time.
--
-- 'description', 'createReplicationJob_description' - The description of the replication job.
--
-- 'serverId', 'createReplicationJob_serverId' - The ID of the server.
--
-- 'seedReplicationTime', 'createReplicationJob_seedReplicationTime' - The seed replication time.
newCreateReplicationJob ::
  -- | 'serverId'
  Prelude.Text ->
  -- | 'seedReplicationTime'
  Prelude.UTCTime ->
  CreateReplicationJob
newCreateReplicationJob :: Text -> UTCTime -> CreateReplicationJob
newCreateReplicationJob
  Text
pServerId_
  UTCTime
pSeedReplicationTime_ =
    CreateReplicationJob' :: Maybe Int
-> Maybe Int
-> Maybe LicenseType
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> Text
-> POSIX
-> CreateReplicationJob
CreateReplicationJob'
      { $sel:frequency:CreateReplicationJob' :: Maybe Int
frequency = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:numberOfRecentAmisToKeep:CreateReplicationJob' :: Maybe Int
numberOfRecentAmisToKeep = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:licenseType:CreateReplicationJob' :: Maybe LicenseType
licenseType = Maybe LicenseType
forall a. Maybe a
Prelude.Nothing,
        $sel:roleName:CreateReplicationJob' :: Maybe Text
roleName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:encrypted:CreateReplicationJob' :: Maybe Bool
encrypted = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:kmsKeyId:CreateReplicationJob' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:runOnce:CreateReplicationJob' :: Maybe Bool
runOnce = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:description:CreateReplicationJob' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:serverId:CreateReplicationJob' :: Text
serverId = Text
pServerId_,
        $sel:seedReplicationTime:CreateReplicationJob' :: POSIX
seedReplicationTime =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pSeedReplicationTime_
      }

-- | The time between consecutive replication runs, in hours.
createReplicationJob_frequency :: Lens.Lens' CreateReplicationJob (Prelude.Maybe Prelude.Int)
createReplicationJob_frequency :: (Maybe Int -> f (Maybe Int))
-> CreateReplicationJob -> f CreateReplicationJob
createReplicationJob_frequency = (CreateReplicationJob -> Maybe Int)
-> (CreateReplicationJob -> Maybe Int -> CreateReplicationJob)
-> Lens
     CreateReplicationJob CreateReplicationJob (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReplicationJob' {Maybe Int
frequency :: Maybe Int
$sel:frequency:CreateReplicationJob' :: CreateReplicationJob -> Maybe Int
frequency} -> Maybe Int
frequency) (\s :: CreateReplicationJob
s@CreateReplicationJob' {} Maybe Int
a -> CreateReplicationJob
s {$sel:frequency:CreateReplicationJob' :: Maybe Int
frequency = Maybe Int
a} :: CreateReplicationJob)

-- | The maximum number of SMS-created AMIs to retain. The oldest is deleted
-- after the maximum number is reached and a new AMI is created.
createReplicationJob_numberOfRecentAmisToKeep :: Lens.Lens' CreateReplicationJob (Prelude.Maybe Prelude.Int)
createReplicationJob_numberOfRecentAmisToKeep :: (Maybe Int -> f (Maybe Int))
-> CreateReplicationJob -> f CreateReplicationJob
createReplicationJob_numberOfRecentAmisToKeep = (CreateReplicationJob -> Maybe Int)
-> (CreateReplicationJob -> Maybe Int -> CreateReplicationJob)
-> Lens
     CreateReplicationJob CreateReplicationJob (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReplicationJob' {Maybe Int
numberOfRecentAmisToKeep :: Maybe Int
$sel:numberOfRecentAmisToKeep:CreateReplicationJob' :: CreateReplicationJob -> Maybe Int
numberOfRecentAmisToKeep} -> Maybe Int
numberOfRecentAmisToKeep) (\s :: CreateReplicationJob
s@CreateReplicationJob' {} Maybe Int
a -> CreateReplicationJob
s {$sel:numberOfRecentAmisToKeep:CreateReplicationJob' :: Maybe Int
numberOfRecentAmisToKeep = Maybe Int
a} :: CreateReplicationJob)

-- | The license type to be used for the AMI created by a successful
-- replication run.
createReplicationJob_licenseType :: Lens.Lens' CreateReplicationJob (Prelude.Maybe LicenseType)
createReplicationJob_licenseType :: (Maybe LicenseType -> f (Maybe LicenseType))
-> CreateReplicationJob -> f CreateReplicationJob
createReplicationJob_licenseType = (CreateReplicationJob -> Maybe LicenseType)
-> (CreateReplicationJob
    -> Maybe LicenseType -> CreateReplicationJob)
-> Lens
     CreateReplicationJob
     CreateReplicationJob
     (Maybe LicenseType)
     (Maybe LicenseType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReplicationJob' {Maybe LicenseType
licenseType :: Maybe LicenseType
$sel:licenseType:CreateReplicationJob' :: CreateReplicationJob -> Maybe LicenseType
licenseType} -> Maybe LicenseType
licenseType) (\s :: CreateReplicationJob
s@CreateReplicationJob' {} Maybe LicenseType
a -> CreateReplicationJob
s {$sel:licenseType:CreateReplicationJob' :: Maybe LicenseType
licenseType = Maybe LicenseType
a} :: CreateReplicationJob)

-- | The name of the IAM role to be used by the AWS SMS.
createReplicationJob_roleName :: Lens.Lens' CreateReplicationJob (Prelude.Maybe Prelude.Text)
createReplicationJob_roleName :: (Maybe Text -> f (Maybe Text))
-> CreateReplicationJob -> f CreateReplicationJob
createReplicationJob_roleName = (CreateReplicationJob -> Maybe Text)
-> (CreateReplicationJob -> Maybe Text -> CreateReplicationJob)
-> Lens
     CreateReplicationJob CreateReplicationJob (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReplicationJob' {Maybe Text
roleName :: Maybe Text
$sel:roleName:CreateReplicationJob' :: CreateReplicationJob -> Maybe Text
roleName} -> Maybe Text
roleName) (\s :: CreateReplicationJob
s@CreateReplicationJob' {} Maybe Text
a -> CreateReplicationJob
s {$sel:roleName:CreateReplicationJob' :: Maybe Text
roleName = Maybe Text
a} :: CreateReplicationJob)

-- | Indicates whether the replication job produces encrypted AMIs.
createReplicationJob_encrypted :: Lens.Lens' CreateReplicationJob (Prelude.Maybe Prelude.Bool)
createReplicationJob_encrypted :: (Maybe Bool -> f (Maybe Bool))
-> CreateReplicationJob -> f CreateReplicationJob
createReplicationJob_encrypted = (CreateReplicationJob -> Maybe Bool)
-> (CreateReplicationJob -> Maybe Bool -> CreateReplicationJob)
-> Lens
     CreateReplicationJob CreateReplicationJob (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReplicationJob' {Maybe Bool
encrypted :: Maybe Bool
$sel:encrypted:CreateReplicationJob' :: CreateReplicationJob -> Maybe Bool
encrypted} -> Maybe Bool
encrypted) (\s :: CreateReplicationJob
s@CreateReplicationJob' {} Maybe Bool
a -> CreateReplicationJob
s {$sel:encrypted:CreateReplicationJob' :: Maybe Bool
encrypted = Maybe Bool
a} :: CreateReplicationJob)

-- | The ID of the KMS key for replication jobs that produce encrypted AMIs.
-- This value can be any of the following:
--
-- -   KMS key ID
--
-- -   KMS key alias
--
-- -   ARN referring to the KMS key ID
--
-- -   ARN referring to the KMS key alias
--
-- If encrypted is /true/ but a KMS key ID is not specified, the
-- customer\'s default KMS key for Amazon EBS is used.
createReplicationJob_kmsKeyId :: Lens.Lens' CreateReplicationJob (Prelude.Maybe Prelude.Text)
createReplicationJob_kmsKeyId :: (Maybe Text -> f (Maybe Text))
-> CreateReplicationJob -> f CreateReplicationJob
createReplicationJob_kmsKeyId = (CreateReplicationJob -> Maybe Text)
-> (CreateReplicationJob -> Maybe Text -> CreateReplicationJob)
-> Lens
     CreateReplicationJob CreateReplicationJob (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReplicationJob' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:CreateReplicationJob' :: CreateReplicationJob -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: CreateReplicationJob
s@CreateReplicationJob' {} Maybe Text
a -> CreateReplicationJob
s {$sel:kmsKeyId:CreateReplicationJob' :: Maybe Text
kmsKeyId = Maybe Text
a} :: CreateReplicationJob)

-- | Indicates whether to run the replication job one time.
createReplicationJob_runOnce :: Lens.Lens' CreateReplicationJob (Prelude.Maybe Prelude.Bool)
createReplicationJob_runOnce :: (Maybe Bool -> f (Maybe Bool))
-> CreateReplicationJob -> f CreateReplicationJob
createReplicationJob_runOnce = (CreateReplicationJob -> Maybe Bool)
-> (CreateReplicationJob -> Maybe Bool -> CreateReplicationJob)
-> Lens
     CreateReplicationJob CreateReplicationJob (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReplicationJob' {Maybe Bool
runOnce :: Maybe Bool
$sel:runOnce:CreateReplicationJob' :: CreateReplicationJob -> Maybe Bool
runOnce} -> Maybe Bool
runOnce) (\s :: CreateReplicationJob
s@CreateReplicationJob' {} Maybe Bool
a -> CreateReplicationJob
s {$sel:runOnce:CreateReplicationJob' :: Maybe Bool
runOnce = Maybe Bool
a} :: CreateReplicationJob)

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

-- | The ID of the server.
createReplicationJob_serverId :: Lens.Lens' CreateReplicationJob Prelude.Text
createReplicationJob_serverId :: (Text -> f Text) -> CreateReplicationJob -> f CreateReplicationJob
createReplicationJob_serverId = (CreateReplicationJob -> Text)
-> (CreateReplicationJob -> Text -> CreateReplicationJob)
-> Lens CreateReplicationJob CreateReplicationJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReplicationJob' {Text
serverId :: Text
$sel:serverId:CreateReplicationJob' :: CreateReplicationJob -> Text
serverId} -> Text
serverId) (\s :: CreateReplicationJob
s@CreateReplicationJob' {} Text
a -> CreateReplicationJob
s {$sel:serverId:CreateReplicationJob' :: Text
serverId = Text
a} :: CreateReplicationJob)

-- | The seed replication time.
createReplicationJob_seedReplicationTime :: Lens.Lens' CreateReplicationJob Prelude.UTCTime
createReplicationJob_seedReplicationTime :: (UTCTime -> f UTCTime)
-> CreateReplicationJob -> f CreateReplicationJob
createReplicationJob_seedReplicationTime = (CreateReplicationJob -> POSIX)
-> (CreateReplicationJob -> POSIX -> CreateReplicationJob)
-> Lens CreateReplicationJob CreateReplicationJob POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReplicationJob' {POSIX
seedReplicationTime :: POSIX
$sel:seedReplicationTime:CreateReplicationJob' :: CreateReplicationJob -> POSIX
seedReplicationTime} -> POSIX
seedReplicationTime) (\s :: CreateReplicationJob
s@CreateReplicationJob' {} POSIX
a -> CreateReplicationJob
s {$sel:seedReplicationTime:CreateReplicationJob' :: POSIX
seedReplicationTime = POSIX
a} :: CreateReplicationJob) ((POSIX -> f POSIX)
 -> CreateReplicationJob -> f CreateReplicationJob)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> CreateReplicationJob
-> f CreateReplicationJob
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.AWSRequest CreateReplicationJob where
  type
    AWSResponse CreateReplicationJob =
      CreateReplicationJobResponse
  request :: CreateReplicationJob -> Request CreateReplicationJob
request = Service -> CreateReplicationJob -> Request CreateReplicationJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateReplicationJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateReplicationJob)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateReplicationJob))
-> Logger
-> Service
-> Proxy CreateReplicationJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateReplicationJob)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> CreateReplicationJobResponse
CreateReplicationJobResponse'
            (Maybe Text -> Int -> CreateReplicationJobResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateReplicationJobResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"replicationJobId")
            Either String (Int -> CreateReplicationJobResponse)
-> Either String Int -> Either String CreateReplicationJobResponse
forall (f :: * -> *) a b. Applicative f => 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 CreateReplicationJob

instance Prelude.NFData CreateReplicationJob

instance Core.ToHeaders CreateReplicationJob where
  toHeaders :: CreateReplicationJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateReplicationJob -> 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.CreateReplicationJob" ::
                          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 CreateReplicationJob where
  toJSON :: CreateReplicationJob -> Value
toJSON CreateReplicationJob' {Maybe Bool
Maybe Int
Maybe Text
Maybe LicenseType
Text
POSIX
seedReplicationTime :: POSIX
serverId :: Text
description :: Maybe Text
runOnce :: Maybe Bool
kmsKeyId :: Maybe Text
encrypted :: Maybe Bool
roleName :: Maybe Text
licenseType :: Maybe LicenseType
numberOfRecentAmisToKeep :: Maybe Int
frequency :: Maybe Int
$sel:seedReplicationTime:CreateReplicationJob' :: CreateReplicationJob -> POSIX
$sel:serverId:CreateReplicationJob' :: CreateReplicationJob -> Text
$sel:description:CreateReplicationJob' :: CreateReplicationJob -> Maybe Text
$sel:runOnce:CreateReplicationJob' :: CreateReplicationJob -> Maybe Bool
$sel:kmsKeyId:CreateReplicationJob' :: CreateReplicationJob -> Maybe Text
$sel:encrypted:CreateReplicationJob' :: CreateReplicationJob -> Maybe Bool
$sel:roleName:CreateReplicationJob' :: CreateReplicationJob -> Maybe Text
$sel:licenseType:CreateReplicationJob' :: CreateReplicationJob -> Maybe LicenseType
$sel:numberOfRecentAmisToKeep:CreateReplicationJob' :: CreateReplicationJob -> Maybe Int
$sel:frequency:CreateReplicationJob' :: CreateReplicationJob -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"frequency" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
frequency,
            (Text
"numberOfRecentAmisToKeep" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
numberOfRecentAmisToKeep,
            (Text
"licenseType" Text -> LicenseType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LicenseType -> Pair) -> Maybe LicenseType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LicenseType
licenseType,
            (Text
"roleName" 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
roleName,
            (Text
"encrypted" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
encrypted,
            (Text
"kmsKeyId" 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
kmsKeyId,
            (Text
"runOnce" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
runOnce,
            (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
"serverId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serverId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"seedReplicationTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
seedReplicationTime)
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateReplicationJobResponse' 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:
--
-- 'replicationJobId', 'createReplicationJobResponse_replicationJobId' - The unique identifier of the replication job.
--
-- 'httpStatus', 'createReplicationJobResponse_httpStatus' - The response's http status code.
newCreateReplicationJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateReplicationJobResponse
newCreateReplicationJobResponse :: Int -> CreateReplicationJobResponse
newCreateReplicationJobResponse Int
pHttpStatus_ =
  CreateReplicationJobResponse' :: Maybe Text -> Int -> CreateReplicationJobResponse
CreateReplicationJobResponse'
    { $sel:replicationJobId:CreateReplicationJobResponse' :: Maybe Text
replicationJobId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateReplicationJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The unique identifier of the replication job.
createReplicationJobResponse_replicationJobId :: Lens.Lens' CreateReplicationJobResponse (Prelude.Maybe Prelude.Text)
createReplicationJobResponse_replicationJobId :: (Maybe Text -> f (Maybe Text))
-> CreateReplicationJobResponse -> f CreateReplicationJobResponse
createReplicationJobResponse_replicationJobId = (CreateReplicationJobResponse -> Maybe Text)
-> (CreateReplicationJobResponse
    -> Maybe Text -> CreateReplicationJobResponse)
-> Lens
     CreateReplicationJobResponse
     CreateReplicationJobResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReplicationJobResponse' {Maybe Text
replicationJobId :: Maybe Text
$sel:replicationJobId:CreateReplicationJobResponse' :: CreateReplicationJobResponse -> Maybe Text
replicationJobId} -> Maybe Text
replicationJobId) (\s :: CreateReplicationJobResponse
s@CreateReplicationJobResponse' {} Maybe Text
a -> CreateReplicationJobResponse
s {$sel:replicationJobId:CreateReplicationJobResponse' :: Maybe Text
replicationJobId = Maybe Text
a} :: CreateReplicationJobResponse)

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

instance Prelude.NFData CreateReplicationJobResponse