{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.DMS.Types
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' StopReplicationTask Text
stopReplicationTask_replicationTaskArn = 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 :: (Service -> Service)
-> StopReplicationTask -> Request StopReplicationTask
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 StopReplicationTask
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopReplicationTask)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ReplicationTask -> Int -> StopReplicationTaskResponse
StopReplicationTaskResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ReplicationTask")
            forall (f :: * -> *) a b. Applicative f => 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 StopReplicationTask where
  hashWithSalt :: Int -> StopReplicationTask -> Int
hashWithSalt Int
_salt StopReplicationTask' {Text
replicationTaskArn :: Text
$sel:replicationTaskArn:StopReplicationTask' :: StopReplicationTask -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
replicationTaskArn

instance Prelude.NFData StopReplicationTask where
  rnf :: StopReplicationTask -> ()
rnf StopReplicationTask' {Text
replicationTaskArn :: Text
$sel:replicationTaskArn:StopReplicationTask' :: StopReplicationTask -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
replicationTaskArn

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

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

instance Data.ToQuery StopReplicationTask where
  toQuery :: StopReplicationTask -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:replicationTask:StopReplicationTaskResponse' :: Maybe ReplicationTask
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 :: Lens' StopReplicationTaskResponse (Maybe ReplicationTask)
stopReplicationTaskResponse_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 :: Lens' StopReplicationTaskResponse Int
stopReplicationTaskResponse_httpStatus = 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 where
  rnf :: StopReplicationTaskResponse -> ()
rnf StopReplicationTaskResponse' {Int
Maybe ReplicationTask
httpStatus :: Int
replicationTask :: Maybe ReplicationTask
$sel:httpStatus:StopReplicationTaskResponse' :: StopReplicationTaskResponse -> Int
$sel:replicationTask:StopReplicationTaskResponse' :: StopReplicationTaskResponse -> Maybe ReplicationTask
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ReplicationTask
replicationTask
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus