{-# 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.DMS.MoveReplicationTask
-- 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)
--
-- Moves a replication task from its current replication instance to a
-- different target replication instance using the specified parameters.
-- The target replication instance must be created with the same or later
-- DMS version as the current replication instance.
module Amazonka.DMS.MoveReplicationTask
  ( -- * Creating a Request
    MoveReplicationTask (..),
    newMoveReplicationTask,

    -- * Request Lenses
    moveReplicationTask_replicationTaskArn,
    moveReplicationTask_targetReplicationInstanceArn,

    -- * Destructuring the Response
    MoveReplicationTaskResponse (..),
    newMoveReplicationTaskResponse,

    -- * Response Lenses
    moveReplicationTaskResponse_replicationTask,
    moveReplicationTaskResponse_httpStatus,
  )
where

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

-- |
--
-- /See:/ 'newMoveReplicationTask' smart constructor.
data MoveReplicationTask = MoveReplicationTask'
  { -- | The Amazon Resource Name (ARN) of the task that you want to move.
    MoveReplicationTask -> Text
replicationTaskArn :: Prelude.Text,
    -- | The ARN of the replication instance where you want to move the task to.
    MoveReplicationTask -> Text
targetReplicationInstanceArn :: Prelude.Text
  }
  deriving (MoveReplicationTask -> MoveReplicationTask -> Bool
(MoveReplicationTask -> MoveReplicationTask -> Bool)
-> (MoveReplicationTask -> MoveReplicationTask -> Bool)
-> Eq MoveReplicationTask
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MoveReplicationTask -> MoveReplicationTask -> Bool
$c/= :: MoveReplicationTask -> MoveReplicationTask -> Bool
== :: MoveReplicationTask -> MoveReplicationTask -> Bool
$c== :: MoveReplicationTask -> MoveReplicationTask -> Bool
Prelude.Eq, ReadPrec [MoveReplicationTask]
ReadPrec MoveReplicationTask
Int -> ReadS MoveReplicationTask
ReadS [MoveReplicationTask]
(Int -> ReadS MoveReplicationTask)
-> ReadS [MoveReplicationTask]
-> ReadPrec MoveReplicationTask
-> ReadPrec [MoveReplicationTask]
-> Read MoveReplicationTask
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MoveReplicationTask]
$creadListPrec :: ReadPrec [MoveReplicationTask]
readPrec :: ReadPrec MoveReplicationTask
$creadPrec :: ReadPrec MoveReplicationTask
readList :: ReadS [MoveReplicationTask]
$creadList :: ReadS [MoveReplicationTask]
readsPrec :: Int -> ReadS MoveReplicationTask
$creadsPrec :: Int -> ReadS MoveReplicationTask
Prelude.Read, Int -> MoveReplicationTask -> ShowS
[MoveReplicationTask] -> ShowS
MoveReplicationTask -> String
(Int -> MoveReplicationTask -> ShowS)
-> (MoveReplicationTask -> String)
-> ([MoveReplicationTask] -> ShowS)
-> Show MoveReplicationTask
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MoveReplicationTask] -> ShowS
$cshowList :: [MoveReplicationTask] -> ShowS
show :: MoveReplicationTask -> String
$cshow :: MoveReplicationTask -> String
showsPrec :: Int -> MoveReplicationTask -> ShowS
$cshowsPrec :: Int -> MoveReplicationTask -> ShowS
Prelude.Show, (forall x. MoveReplicationTask -> Rep MoveReplicationTask x)
-> (forall x. Rep MoveReplicationTask x -> MoveReplicationTask)
-> Generic MoveReplicationTask
forall x. Rep MoveReplicationTask x -> MoveReplicationTask
forall x. MoveReplicationTask -> Rep MoveReplicationTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MoveReplicationTask x -> MoveReplicationTask
$cfrom :: forall x. MoveReplicationTask -> Rep MoveReplicationTask x
Prelude.Generic)

-- |
-- Create a value of 'MoveReplicationTask' 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:
--
-- 'replicationTaskArn', 'moveReplicationTask_replicationTaskArn' - The Amazon Resource Name (ARN) of the task that you want to move.
--
-- 'targetReplicationInstanceArn', 'moveReplicationTask_targetReplicationInstanceArn' - The ARN of the replication instance where you want to move the task to.
newMoveReplicationTask ::
  -- | 'replicationTaskArn'
  Prelude.Text ->
  -- | 'targetReplicationInstanceArn'
  Prelude.Text ->
  MoveReplicationTask
newMoveReplicationTask :: Text -> Text -> MoveReplicationTask
newMoveReplicationTask
  Text
pReplicationTaskArn_
  Text
pTargetReplicationInstanceArn_ =
    MoveReplicationTask' :: Text -> Text -> MoveReplicationTask
MoveReplicationTask'
      { $sel:replicationTaskArn:MoveReplicationTask' :: Text
replicationTaskArn =
          Text
pReplicationTaskArn_,
        $sel:targetReplicationInstanceArn:MoveReplicationTask' :: Text
targetReplicationInstanceArn =
          Text
pTargetReplicationInstanceArn_
      }

-- | The Amazon Resource Name (ARN) of the task that you want to move.
moveReplicationTask_replicationTaskArn :: Lens.Lens' MoveReplicationTask Prelude.Text
moveReplicationTask_replicationTaskArn :: (Text -> f Text) -> MoveReplicationTask -> f MoveReplicationTask
moveReplicationTask_replicationTaskArn = (MoveReplicationTask -> Text)
-> (MoveReplicationTask -> Text -> MoveReplicationTask)
-> Lens MoveReplicationTask MoveReplicationTask Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MoveReplicationTask' {Text
replicationTaskArn :: Text
$sel:replicationTaskArn:MoveReplicationTask' :: MoveReplicationTask -> Text
replicationTaskArn} -> Text
replicationTaskArn) (\s :: MoveReplicationTask
s@MoveReplicationTask' {} Text
a -> MoveReplicationTask
s {$sel:replicationTaskArn:MoveReplicationTask' :: Text
replicationTaskArn = Text
a} :: MoveReplicationTask)

-- | The ARN of the replication instance where you want to move the task to.
moveReplicationTask_targetReplicationInstanceArn :: Lens.Lens' MoveReplicationTask Prelude.Text
moveReplicationTask_targetReplicationInstanceArn :: (Text -> f Text) -> MoveReplicationTask -> f MoveReplicationTask
moveReplicationTask_targetReplicationInstanceArn = (MoveReplicationTask -> Text)
-> (MoveReplicationTask -> Text -> MoveReplicationTask)
-> Lens MoveReplicationTask MoveReplicationTask Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MoveReplicationTask' {Text
targetReplicationInstanceArn :: Text
$sel:targetReplicationInstanceArn:MoveReplicationTask' :: MoveReplicationTask -> Text
targetReplicationInstanceArn} -> Text
targetReplicationInstanceArn) (\s :: MoveReplicationTask
s@MoveReplicationTask' {} Text
a -> MoveReplicationTask
s {$sel:targetReplicationInstanceArn:MoveReplicationTask' :: Text
targetReplicationInstanceArn = Text
a} :: MoveReplicationTask)

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

instance Prelude.NFData MoveReplicationTask

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

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

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

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

-- |
-- Create a value of 'MoveReplicationTaskResponse' 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:
--
-- 'replicationTask', 'moveReplicationTaskResponse_replicationTask' - The replication task that was moved.
--
-- 'httpStatus', 'moveReplicationTaskResponse_httpStatus' - The response's http status code.
newMoveReplicationTaskResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  MoveReplicationTaskResponse
newMoveReplicationTaskResponse :: Int -> MoveReplicationTaskResponse
newMoveReplicationTaskResponse Int
pHttpStatus_ =
  MoveReplicationTaskResponse' :: Maybe ReplicationTask -> Int -> MoveReplicationTaskResponse
MoveReplicationTaskResponse'
    { $sel:replicationTask:MoveReplicationTaskResponse' :: Maybe ReplicationTask
replicationTask =
        Maybe ReplicationTask
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:MoveReplicationTaskResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The replication task that was moved.
moveReplicationTaskResponse_replicationTask :: Lens.Lens' MoveReplicationTaskResponse (Prelude.Maybe ReplicationTask)
moveReplicationTaskResponse_replicationTask :: (Maybe ReplicationTask -> f (Maybe ReplicationTask))
-> MoveReplicationTaskResponse -> f MoveReplicationTaskResponse
moveReplicationTaskResponse_replicationTask = (MoveReplicationTaskResponse -> Maybe ReplicationTask)
-> (MoveReplicationTaskResponse
    -> Maybe ReplicationTask -> MoveReplicationTaskResponse)
-> Lens
     MoveReplicationTaskResponse
     MoveReplicationTaskResponse
     (Maybe ReplicationTask)
     (Maybe ReplicationTask)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MoveReplicationTaskResponse' {Maybe ReplicationTask
replicationTask :: Maybe ReplicationTask
$sel:replicationTask:MoveReplicationTaskResponse' :: MoveReplicationTaskResponse -> Maybe ReplicationTask
replicationTask} -> Maybe ReplicationTask
replicationTask) (\s :: MoveReplicationTaskResponse
s@MoveReplicationTaskResponse' {} Maybe ReplicationTask
a -> MoveReplicationTaskResponse
s {$sel:replicationTask:MoveReplicationTaskResponse' :: Maybe ReplicationTask
replicationTask = Maybe ReplicationTask
a} :: MoveReplicationTaskResponse)

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

instance Prelude.NFData MoveReplicationTaskResponse