{-# 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.StopReplicationTask
-- 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)
--
-- Stops the replication task.
module Amazonka.DMS.StopReplicationTask
  ( -- * Creating a Request
    StopReplicationTask (..),
    newStopReplicationTask,

    -- * Request Lenses
    stopReplicationTask_replicationTaskArn,

    -- * Destructuring the Response
    StopReplicationTaskResponse (..),
    newStopReplicationTaskResponse,

    -- * Response Lenses
    stopReplicationTaskResponse_replicationTask,
    stopReplicationTaskResponse_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:/ 'newStopReplicationTask' smart constructor.
data StopReplicationTask = StopReplicationTask'
  { -- | The Amazon Resource Name(ARN) of the replication task to be stopped.
    StopReplicationTask -> Text
replicationTaskArn :: Prelude.Text
  }
  deriving (StopReplicationTask -> StopReplicationTask -> Bool
(StopReplicationTask -> StopReplicationTask -> Bool)
-> (StopReplicationTask -> StopReplicationTask -> Bool)
-> Eq StopReplicationTask
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopReplicationTask -> StopReplicationTask -> Bool
$c/= :: StopReplicationTask -> StopReplicationTask -> Bool
== :: StopReplicationTask -> StopReplicationTask -> Bool
$c== :: StopReplicationTask -> StopReplicationTask -> Bool
Prelude.Eq, ReadPrec [StopReplicationTask]
ReadPrec StopReplicationTask
Int -> ReadS StopReplicationTask
ReadS [StopReplicationTask]
(Int -> ReadS StopReplicationTask)
-> ReadS [StopReplicationTask]
-> ReadPrec StopReplicationTask
-> ReadPrec [StopReplicationTask]
-> Read StopReplicationTask
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopReplicationTask]
$creadListPrec :: ReadPrec [StopReplicationTask]
readPrec :: ReadPrec StopReplicationTask
$creadPrec :: ReadPrec StopReplicationTask
readList :: ReadS [StopReplicationTask]
$creadList :: ReadS [StopReplicationTask]
readsPrec :: Int -> ReadS StopReplicationTask
$creadsPrec :: Int -> ReadS StopReplicationTask
Prelude.Read, Int -> StopReplicationTask -> ShowS
[StopReplicationTask] -> ShowS
StopReplicationTask -> String
(Int -> StopReplicationTask -> ShowS)
-> (StopReplicationTask -> String)
-> ([StopReplicationTask] -> ShowS)
-> Show StopReplicationTask
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopReplicationTask] -> ShowS
$cshowList :: [StopReplicationTask] -> ShowS
show :: StopReplicationTask -> String
$cshow :: StopReplicationTask -> String
showsPrec :: Int -> StopReplicationTask -> ShowS
$cshowsPrec :: Int -> StopReplicationTask -> ShowS
Prelude.Show, (forall x. StopReplicationTask -> Rep StopReplicationTask x)
-> (forall x. Rep StopReplicationTask x -> StopReplicationTask)
-> Generic StopReplicationTask
forall x. Rep StopReplicationTask x -> StopReplicationTask
forall x. StopReplicationTask -> Rep StopReplicationTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopReplicationTask x -> StopReplicationTask
$cfrom :: forall x. StopReplicationTask -> Rep StopReplicationTask x
Prelude.Generic)

-- |
-- Create a value of 'StopReplicationTask' 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', 'stopReplicationTask_replicationTaskArn' - The Amazon Resource Name(ARN) of the replication task to be stopped.
newStopReplicationTask ::
  -- | 'replicationTaskArn'
  Prelude.Text ->
  StopReplicationTask
newStopReplicationTask :: Text -> StopReplicationTask
newStopReplicationTask Text
pReplicationTaskArn_ =
  StopReplicationTask' :: Text -> StopReplicationTask
StopReplicationTask'
    { $sel:replicationTaskArn:StopReplicationTask' :: Text
replicationTaskArn =
        Text
pReplicationTaskArn_
    }

-- | The Amazon Resource Name(ARN) of the replication task to be stopped.
stopReplicationTask_replicationTaskArn :: Lens.Lens' StopReplicationTask Prelude.Text
stopReplicationTask_replicationTaskArn :: (Text -> f Text) -> StopReplicationTask -> f StopReplicationTask
stopReplicationTask_replicationTaskArn = (StopReplicationTask -> Text)
-> (StopReplicationTask -> Text -> StopReplicationTask)
-> Lens StopReplicationTask StopReplicationTask Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopReplicationTask' {Text
replicationTaskArn :: Text
$sel:replicationTaskArn:StopReplicationTask' :: StopReplicationTask -> Text
replicationTaskArn} -> Text
replicationTaskArn) (\s :: StopReplicationTask
s@StopReplicationTask' {} Text
a -> StopReplicationTask
s {$sel:replicationTaskArn:StopReplicationTask' :: Text
replicationTaskArn = Text
a} :: StopReplicationTask)

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

instance Prelude.NFData StopReplicationTask

instance Core.ToHeaders StopReplicationTask where
  toHeaders :: StopReplicationTask -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StopReplicationTask -> 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.StopReplicationTask" ::
                          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 StopReplicationTask where
  toJSON :: StopReplicationTask -> Value
toJSON StopReplicationTask' {Text
replicationTaskArn :: Text
$sel:replicationTaskArn:StopReplicationTask' :: StopReplicationTask -> 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)
          ]
      )

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

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

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

-- |
-- Create a value of 'StopReplicationTaskResponse' 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', 'stopReplicationTaskResponse_replicationTask' - The replication task stopped.
--
-- 'httpStatus', 'stopReplicationTaskResponse_httpStatus' - The response's http status code.
newStopReplicationTaskResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopReplicationTaskResponse
newStopReplicationTaskResponse :: Int -> StopReplicationTaskResponse
newStopReplicationTaskResponse Int
pHttpStatus_ =
  StopReplicationTaskResponse' :: Maybe ReplicationTask -> Int -> StopReplicationTaskResponse
StopReplicationTaskResponse'
    { $sel:replicationTask:StopReplicationTaskResponse' :: Maybe ReplicationTask
replicationTask =
        Maybe ReplicationTask
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopReplicationTaskResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The replication task stopped.
stopReplicationTaskResponse_replicationTask :: Lens.Lens' StopReplicationTaskResponse (Prelude.Maybe ReplicationTask)
stopReplicationTaskResponse_replicationTask :: (Maybe ReplicationTask -> f (Maybe ReplicationTask))
-> StopReplicationTaskResponse -> f StopReplicationTaskResponse
stopReplicationTaskResponse_replicationTask = (StopReplicationTaskResponse -> Maybe ReplicationTask)
-> (StopReplicationTaskResponse
    -> Maybe ReplicationTask -> StopReplicationTaskResponse)
-> Lens
     StopReplicationTaskResponse
     StopReplicationTaskResponse
     (Maybe ReplicationTask)
     (Maybe ReplicationTask)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopReplicationTaskResponse' {Maybe ReplicationTask
replicationTask :: Maybe ReplicationTask
$sel:replicationTask:StopReplicationTaskResponse' :: StopReplicationTaskResponse -> Maybe ReplicationTask
replicationTask} -> Maybe ReplicationTask
replicationTask) (\s :: StopReplicationTaskResponse
s@StopReplicationTaskResponse' {} Maybe ReplicationTask
a -> StopReplicationTaskResponse
s {$sel:replicationTask:StopReplicationTaskResponse' :: Maybe ReplicationTask
replicationTask = Maybe ReplicationTask
a} :: StopReplicationTaskResponse)

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

instance Prelude.NFData StopReplicationTaskResponse