{-# 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.DirectoryService.DeregisterCertificate
-- 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 from the system the certificate that was registered for secure
-- LDAP or client certificate authentication.
module Amazonka.DirectoryService.DeregisterCertificate
  ( -- * Creating a Request
    DeregisterCertificate (..),
    newDeregisterCertificate,

    -- * Request Lenses
    deregisterCertificate_directoryId,
    deregisterCertificate_certificateId,

    -- * Destructuring the Response
    DeregisterCertificateResponse (..),
    newDeregisterCertificateResponse,

    -- * Response Lenses
    deregisterCertificateResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DirectoryService.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:/ 'newDeregisterCertificate' smart constructor.
data DeregisterCertificate = DeregisterCertificate'
  { -- | The identifier of the directory.
    DeregisterCertificate -> Text
directoryId :: Prelude.Text,
    -- | The identifier of the certificate.
    DeregisterCertificate -> Text
certificateId :: Prelude.Text
  }
  deriving (DeregisterCertificate -> DeregisterCertificate -> Bool
(DeregisterCertificate -> DeregisterCertificate -> Bool)
-> (DeregisterCertificate -> DeregisterCertificate -> Bool)
-> Eq DeregisterCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterCertificate -> DeregisterCertificate -> Bool
$c/= :: DeregisterCertificate -> DeregisterCertificate -> Bool
== :: DeregisterCertificate -> DeregisterCertificate -> Bool
$c== :: DeregisterCertificate -> DeregisterCertificate -> Bool
Prelude.Eq, ReadPrec [DeregisterCertificate]
ReadPrec DeregisterCertificate
Int -> ReadS DeregisterCertificate
ReadS [DeregisterCertificate]
(Int -> ReadS DeregisterCertificate)
-> ReadS [DeregisterCertificate]
-> ReadPrec DeregisterCertificate
-> ReadPrec [DeregisterCertificate]
-> Read DeregisterCertificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterCertificate]
$creadListPrec :: ReadPrec [DeregisterCertificate]
readPrec :: ReadPrec DeregisterCertificate
$creadPrec :: ReadPrec DeregisterCertificate
readList :: ReadS [DeregisterCertificate]
$creadList :: ReadS [DeregisterCertificate]
readsPrec :: Int -> ReadS DeregisterCertificate
$creadsPrec :: Int -> ReadS DeregisterCertificate
Prelude.Read, Int -> DeregisterCertificate -> ShowS
[DeregisterCertificate] -> ShowS
DeregisterCertificate -> String
(Int -> DeregisterCertificate -> ShowS)
-> (DeregisterCertificate -> String)
-> ([DeregisterCertificate] -> ShowS)
-> Show DeregisterCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterCertificate] -> ShowS
$cshowList :: [DeregisterCertificate] -> ShowS
show :: DeregisterCertificate -> String
$cshow :: DeregisterCertificate -> String
showsPrec :: Int -> DeregisterCertificate -> ShowS
$cshowsPrec :: Int -> DeregisterCertificate -> ShowS
Prelude.Show, (forall x. DeregisterCertificate -> Rep DeregisterCertificate x)
-> (forall x. Rep DeregisterCertificate x -> DeregisterCertificate)
-> Generic DeregisterCertificate
forall x. Rep DeregisterCertificate x -> DeregisterCertificate
forall x. DeregisterCertificate -> Rep DeregisterCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeregisterCertificate x -> DeregisterCertificate
$cfrom :: forall x. DeregisterCertificate -> Rep DeregisterCertificate x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterCertificate' 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:
--
-- 'directoryId', 'deregisterCertificate_directoryId' - The identifier of the directory.
--
-- 'certificateId', 'deregisterCertificate_certificateId' - The identifier of the certificate.
newDeregisterCertificate ::
  -- | 'directoryId'
  Prelude.Text ->
  -- | 'certificateId'
  Prelude.Text ->
  DeregisterCertificate
newDeregisterCertificate :: Text -> Text -> DeregisterCertificate
newDeregisterCertificate
  Text
pDirectoryId_
  Text
pCertificateId_ =
    DeregisterCertificate' :: Text -> Text -> DeregisterCertificate
DeregisterCertificate'
      { $sel:directoryId:DeregisterCertificate' :: Text
directoryId = Text
pDirectoryId_,
        $sel:certificateId:DeregisterCertificate' :: Text
certificateId = Text
pCertificateId_
      }

-- | The identifier of the directory.
deregisterCertificate_directoryId :: Lens.Lens' DeregisterCertificate Prelude.Text
deregisterCertificate_directoryId :: (Text -> f Text)
-> DeregisterCertificate -> f DeregisterCertificate
deregisterCertificate_directoryId = (DeregisterCertificate -> Text)
-> (DeregisterCertificate -> Text -> DeregisterCertificate)
-> Lens DeregisterCertificate DeregisterCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterCertificate' {Text
directoryId :: Text
$sel:directoryId:DeregisterCertificate' :: DeregisterCertificate -> Text
directoryId} -> Text
directoryId) (\s :: DeregisterCertificate
s@DeregisterCertificate' {} Text
a -> DeregisterCertificate
s {$sel:directoryId:DeregisterCertificate' :: Text
directoryId = Text
a} :: DeregisterCertificate)

-- | The identifier of the certificate.
deregisterCertificate_certificateId :: Lens.Lens' DeregisterCertificate Prelude.Text
deregisterCertificate_certificateId :: (Text -> f Text)
-> DeregisterCertificate -> f DeregisterCertificate
deregisterCertificate_certificateId = (DeregisterCertificate -> Text)
-> (DeregisterCertificate -> Text -> DeregisterCertificate)
-> Lens DeregisterCertificate DeregisterCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterCertificate' {Text
certificateId :: Text
$sel:certificateId:DeregisterCertificate' :: DeregisterCertificate -> Text
certificateId} -> Text
certificateId) (\s :: DeregisterCertificate
s@DeregisterCertificate' {} Text
a -> DeregisterCertificate
s {$sel:certificateId:DeregisterCertificate' :: Text
certificateId = Text
a} :: DeregisterCertificate)

instance Core.AWSRequest DeregisterCertificate where
  type
    AWSResponse DeregisterCertificate =
      DeregisterCertificateResponse
  request :: DeregisterCertificate -> Request DeregisterCertificate
request = Service -> DeregisterCertificate -> Request DeregisterCertificate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeregisterCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterCertificate)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeregisterCertificate))
-> Logger
-> Service
-> Proxy DeregisterCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterCertificate)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeregisterCertificateResponse
DeregisterCertificateResponse'
            (Int -> DeregisterCertificateResponse)
-> Either String Int -> Either String DeregisterCertificateResponse
forall (f :: * -> *) a b. Functor 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 DeregisterCertificate

instance Prelude.NFData DeregisterCertificate

instance Core.ToHeaders DeregisterCertificate where
  toHeaders :: DeregisterCertificate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeregisterCertificate -> 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
"DirectoryService_20150416.DeregisterCertificate" ::
                          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 DeregisterCertificate where
  toJSON :: DeregisterCertificate -> Value
toJSON DeregisterCertificate' {Text
certificateId :: Text
directoryId :: Text
$sel:certificateId:DeregisterCertificate' :: DeregisterCertificate -> Text
$sel:directoryId:DeregisterCertificate' :: DeregisterCertificate -> 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
"DirectoryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
directoryId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CertificateId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
certificateId)
          ]
      )

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

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

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

-- |
-- Create a value of 'DeregisterCertificateResponse' 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:
--
-- 'httpStatus', 'deregisterCertificateResponse_httpStatus' - The response's http status code.
newDeregisterCertificateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeregisterCertificateResponse
newDeregisterCertificateResponse :: Int -> DeregisterCertificateResponse
newDeregisterCertificateResponse Int
pHttpStatus_ =
  DeregisterCertificateResponse' :: Int -> DeregisterCertificateResponse
DeregisterCertificateResponse'
    { $sel:httpStatus:DeregisterCertificateResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeregisterCertificateResponse