{-# 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.DeleteReplicationTask
-- 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)
--
-- Deletes the specified replication task.
module Amazonka.DMS.DeleteReplicationTask
  ( -- * Creating a Request
    DeleteReplicationTask (..),
    newDeleteReplicationTask,

    -- * Request Lenses
    deleteReplicationTask_replicationTaskArn,

    -- * Destructuring the Response
    DeleteReplicationTaskResponse (..),
    newDeleteReplicationTaskResponse,

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

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

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

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

instance Prelude.NFData DeleteReplicationTask

instance Core.ToHeaders DeleteReplicationTask where
  toHeaders :: DeleteReplicationTask -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteReplicationTask -> 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.DeleteReplicationTask" ::
                          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 DeleteReplicationTask where
  toJSON :: DeleteReplicationTask -> Value
toJSON DeleteReplicationTask' {Text
replicationTaskArn :: Text
$sel:replicationTaskArn:DeleteReplicationTask' :: DeleteReplicationTask -> 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 DeleteReplicationTask where
  toPath :: DeleteReplicationTask -> ByteString
toPath = ByteString -> DeleteReplicationTask -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DeleteReplicationTaskResponse' 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', 'deleteReplicationTaskResponse_replicationTask' - The deleted replication task.
--
-- 'httpStatus', 'deleteReplicationTaskResponse_httpStatus' - The response's http status code.
newDeleteReplicationTaskResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteReplicationTaskResponse
newDeleteReplicationTaskResponse :: Int -> DeleteReplicationTaskResponse
newDeleteReplicationTaskResponse Int
pHttpStatus_ =
  DeleteReplicationTaskResponse' :: Maybe ReplicationTask -> Int -> DeleteReplicationTaskResponse
DeleteReplicationTaskResponse'
    { $sel:replicationTask:DeleteReplicationTaskResponse' :: Maybe ReplicationTask
replicationTask =
        Maybe ReplicationTask
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteReplicationTaskResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

instance Prelude.NFData DeleteReplicationTaskResponse