{-# 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.DeleteReplicationInstance
-- 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 instance.
--
-- You must delete any migration tasks that are associated with the
-- replication instance before you can delete it.
module Amazonka.DMS.DeleteReplicationInstance
  ( -- * Creating a Request
    DeleteReplicationInstance (..),
    newDeleteReplicationInstance,

    -- * Request Lenses
    deleteReplicationInstance_replicationInstanceArn,

    -- * Destructuring the Response
    DeleteReplicationInstanceResponse (..),
    newDeleteReplicationInstanceResponse,

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

-- |
-- Create a value of 'DeleteReplicationInstance' 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:
--
-- 'replicationInstanceArn', 'deleteReplicationInstance_replicationInstanceArn' - The Amazon Resource Name (ARN) of the replication instance to be
-- deleted.
newDeleteReplicationInstance ::
  -- | 'replicationInstanceArn'
  Prelude.Text ->
  DeleteReplicationInstance
newDeleteReplicationInstance :: Text -> DeleteReplicationInstance
newDeleteReplicationInstance Text
pReplicationInstanceArn_ =
  DeleteReplicationInstance' :: Text -> DeleteReplicationInstance
DeleteReplicationInstance'
    { $sel:replicationInstanceArn:DeleteReplicationInstance' :: Text
replicationInstanceArn =
        Text
pReplicationInstanceArn_
    }

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

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

instance Prelude.NFData DeleteReplicationInstance

instance Core.ToHeaders DeleteReplicationInstance where
  toHeaders :: DeleteReplicationInstance -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteReplicationInstance -> 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.DeleteReplicationInstance" ::
                          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 DeleteReplicationInstance where
  toJSON :: DeleteReplicationInstance -> Value
toJSON DeleteReplicationInstance' {Text
replicationInstanceArn :: Text
$sel:replicationInstanceArn:DeleteReplicationInstance' :: DeleteReplicationInstance -> 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
"ReplicationInstanceArn"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
replicationInstanceArn
              )
          ]
      )

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

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

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

-- |
-- Create a value of 'DeleteReplicationInstanceResponse' 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:
--
-- 'replicationInstance', 'deleteReplicationInstanceResponse_replicationInstance' - The replication instance that was deleted.
--
-- 'httpStatus', 'deleteReplicationInstanceResponse_httpStatus' - The response's http status code.
newDeleteReplicationInstanceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteReplicationInstanceResponse
newDeleteReplicationInstanceResponse :: Int -> DeleteReplicationInstanceResponse
newDeleteReplicationInstanceResponse Int
pHttpStatus_ =
  DeleteReplicationInstanceResponse' :: Maybe ReplicationInstance
-> Int -> DeleteReplicationInstanceResponse
DeleteReplicationInstanceResponse'
    { $sel:replicationInstance:DeleteReplicationInstanceResponse' :: Maybe ReplicationInstance
replicationInstance =
        Maybe ReplicationInstance
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteReplicationInstanceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The replication instance that was deleted.
deleteReplicationInstanceResponse_replicationInstance :: Lens.Lens' DeleteReplicationInstanceResponse (Prelude.Maybe ReplicationInstance)
deleteReplicationInstanceResponse_replicationInstance :: (Maybe ReplicationInstance -> f (Maybe ReplicationInstance))
-> DeleteReplicationInstanceResponse
-> f DeleteReplicationInstanceResponse
deleteReplicationInstanceResponse_replicationInstance = (DeleteReplicationInstanceResponse -> Maybe ReplicationInstance)
-> (DeleteReplicationInstanceResponse
    -> Maybe ReplicationInstance -> DeleteReplicationInstanceResponse)
-> Lens
     DeleteReplicationInstanceResponse
     DeleteReplicationInstanceResponse
     (Maybe ReplicationInstance)
     (Maybe ReplicationInstance)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteReplicationInstanceResponse' {Maybe ReplicationInstance
replicationInstance :: Maybe ReplicationInstance
$sel:replicationInstance:DeleteReplicationInstanceResponse' :: DeleteReplicationInstanceResponse -> Maybe ReplicationInstance
replicationInstance} -> Maybe ReplicationInstance
replicationInstance) (\s :: DeleteReplicationInstanceResponse
s@DeleteReplicationInstanceResponse' {} Maybe ReplicationInstance
a -> DeleteReplicationInstanceResponse
s {$sel:replicationInstance:DeleteReplicationInstanceResponse' :: Maybe ReplicationInstance
replicationInstance = Maybe ReplicationInstance
a} :: DeleteReplicationInstanceResponse)

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

instance
  Prelude.NFData
    DeleteReplicationInstanceResponse