{-# 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.DeleteCertificate
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified certificate.
module Amazonka.DMS.DeleteCertificate
  ( -- * Creating a Request
    DeleteCertificate (..),
    newDeleteCertificate,

    -- * Request Lenses
    deleteCertificate_certificateArn,

    -- * Destructuring the Response
    DeleteCertificateResponse (..),
    newDeleteCertificateResponse,

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

-- |
-- Create a value of 'DeleteCertificate' 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:
--
-- 'certificateArn', 'deleteCertificate_certificateArn' - The Amazon Resource Name (ARN) of the certificate.
newDeleteCertificate ::
  -- | 'certificateArn'
  Prelude.Text ->
  DeleteCertificate
newDeleteCertificate :: Text -> DeleteCertificate
newDeleteCertificate Text
pCertificateArn_ =
  DeleteCertificate'
    { $sel:certificateArn:DeleteCertificate' :: Text
certificateArn =
        Text
pCertificateArn_
    }

-- | The Amazon Resource Name (ARN) of the certificate.
deleteCertificate_certificateArn :: Lens.Lens' DeleteCertificate Prelude.Text
deleteCertificate_certificateArn :: Lens' DeleteCertificate Text
deleteCertificate_certificateArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCertificate' {Text
certificateArn :: Text
$sel:certificateArn:DeleteCertificate' :: DeleteCertificate -> Text
certificateArn} -> Text
certificateArn) (\s :: DeleteCertificate
s@DeleteCertificate' {} Text
a -> DeleteCertificate
s {$sel:certificateArn:DeleteCertificate' :: Text
certificateArn = Text
a} :: DeleteCertificate)

instance Core.AWSRequest DeleteCertificate where
  type
    AWSResponse DeleteCertificate =
      DeleteCertificateResponse
  request :: (Service -> Service)
-> DeleteCertificate -> Request DeleteCertificate
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 DeleteCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteCertificate)))
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 Certificate -> Int -> DeleteCertificateResponse
DeleteCertificateResponse'
            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
"Certificate")
            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 DeleteCertificate where
  hashWithSalt :: Int -> DeleteCertificate -> Int
hashWithSalt Int
_salt DeleteCertificate' {Text
certificateArn :: Text
$sel:certificateArn:DeleteCertificate' :: DeleteCertificate -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
certificateArn

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

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

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

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

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

-- |
-- Create a value of 'DeleteCertificateResponse' 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:
--
-- 'certificate', 'deleteCertificateResponse_certificate' - The Secure Sockets Layer (SSL) certificate.
--
-- 'httpStatus', 'deleteCertificateResponse_httpStatus' - The response's http status code.
newDeleteCertificateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteCertificateResponse
newDeleteCertificateResponse :: Int -> DeleteCertificateResponse
newDeleteCertificateResponse Int
pHttpStatus_ =
  DeleteCertificateResponse'
    { $sel:certificate:DeleteCertificateResponse' :: Maybe Certificate
certificate =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteCertificateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Secure Sockets Layer (SSL) certificate.
deleteCertificateResponse_certificate :: Lens.Lens' DeleteCertificateResponse (Prelude.Maybe Certificate)
deleteCertificateResponse_certificate :: Lens' DeleteCertificateResponse (Maybe Certificate)
deleteCertificateResponse_certificate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCertificateResponse' {Maybe Certificate
certificate :: Maybe Certificate
$sel:certificate:DeleteCertificateResponse' :: DeleteCertificateResponse -> Maybe Certificate
certificate} -> Maybe Certificate
certificate) (\s :: DeleteCertificateResponse
s@DeleteCertificateResponse' {} Maybe Certificate
a -> DeleteCertificateResponse
s {$sel:certificate:DeleteCertificateResponse' :: Maybe Certificate
certificate = Maybe Certificate
a} :: DeleteCertificateResponse)

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

instance Prelude.NFData DeleteCertificateResponse where
  rnf :: DeleteCertificateResponse -> ()
rnf DeleteCertificateResponse' {Int
Maybe Certificate
httpStatus :: Int
certificate :: Maybe Certificate
$sel:httpStatus:DeleteCertificateResponse' :: DeleteCertificateResponse -> Int
$sel:certificate:DeleteCertificateResponse' :: DeleteCertificateResponse -> Maybe Certificate
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Certificate
certificate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus