{-# 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.CloudFront.DeletePublicKey
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Remove a public key you previously added to CloudFront.
module Amazonka.CloudFront.DeletePublicKey
  ( -- * Creating a Request
    DeletePublicKey (..),
    newDeletePublicKey,

    -- * Request Lenses
    deletePublicKey_ifMatch,
    deletePublicKey_id,

    -- * Destructuring the Response
    DeletePublicKeyResponse (..),
    newDeletePublicKeyResponse,
  )
where

import Amazonka.CloudFront.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
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:/ 'newDeletePublicKey' smart constructor.
data DeletePublicKey = DeletePublicKey'
  { -- | The value of the @ETag@ header that you received when retrieving the
    -- public key identity to delete. For example: @E2QWRUHAPOMQZL@.
    DeletePublicKey -> Maybe Text
ifMatch :: Prelude.Maybe Prelude.Text,
    -- | The ID of the public key you want to remove from CloudFront.
    DeletePublicKey -> Text
id :: Prelude.Text
  }
  deriving (DeletePublicKey -> DeletePublicKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletePublicKey -> DeletePublicKey -> Bool
$c/= :: DeletePublicKey -> DeletePublicKey -> Bool
== :: DeletePublicKey -> DeletePublicKey -> Bool
$c== :: DeletePublicKey -> DeletePublicKey -> Bool
Prelude.Eq, ReadPrec [DeletePublicKey]
ReadPrec DeletePublicKey
Int -> ReadS DeletePublicKey
ReadS [DeletePublicKey]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletePublicKey]
$creadListPrec :: ReadPrec [DeletePublicKey]
readPrec :: ReadPrec DeletePublicKey
$creadPrec :: ReadPrec DeletePublicKey
readList :: ReadS [DeletePublicKey]
$creadList :: ReadS [DeletePublicKey]
readsPrec :: Int -> ReadS DeletePublicKey
$creadsPrec :: Int -> ReadS DeletePublicKey
Prelude.Read, Int -> DeletePublicKey -> ShowS
[DeletePublicKey] -> ShowS
DeletePublicKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletePublicKey] -> ShowS
$cshowList :: [DeletePublicKey] -> ShowS
show :: DeletePublicKey -> String
$cshow :: DeletePublicKey -> String
showsPrec :: Int -> DeletePublicKey -> ShowS
$cshowsPrec :: Int -> DeletePublicKey -> ShowS
Prelude.Show, forall x. Rep DeletePublicKey x -> DeletePublicKey
forall x. DeletePublicKey -> Rep DeletePublicKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeletePublicKey x -> DeletePublicKey
$cfrom :: forall x. DeletePublicKey -> Rep DeletePublicKey x
Prelude.Generic)

-- |
-- Create a value of 'DeletePublicKey' 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:
--
-- 'ifMatch', 'deletePublicKey_ifMatch' - The value of the @ETag@ header that you received when retrieving the
-- public key identity to delete. For example: @E2QWRUHAPOMQZL@.
--
-- 'id', 'deletePublicKey_id' - The ID of the public key you want to remove from CloudFront.
newDeletePublicKey ::
  -- | 'id'
  Prelude.Text ->
  DeletePublicKey
newDeletePublicKey :: Text -> DeletePublicKey
newDeletePublicKey Text
pId_ =
  DeletePublicKey'
    { $sel:ifMatch:DeletePublicKey' :: Maybe Text
ifMatch = forall a. Maybe a
Prelude.Nothing,
      $sel:id:DeletePublicKey' :: Text
id = Text
pId_
    }

-- | The value of the @ETag@ header that you received when retrieving the
-- public key identity to delete. For example: @E2QWRUHAPOMQZL@.
deletePublicKey_ifMatch :: Lens.Lens' DeletePublicKey (Prelude.Maybe Prelude.Text)
deletePublicKey_ifMatch :: Lens' DeletePublicKey (Maybe Text)
deletePublicKey_ifMatch = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePublicKey' {Maybe Text
ifMatch :: Maybe Text
$sel:ifMatch:DeletePublicKey' :: DeletePublicKey -> Maybe Text
ifMatch} -> Maybe Text
ifMatch) (\s :: DeletePublicKey
s@DeletePublicKey' {} Maybe Text
a -> DeletePublicKey
s {$sel:ifMatch:DeletePublicKey' :: Maybe Text
ifMatch = Maybe Text
a} :: DeletePublicKey)

-- | The ID of the public key you want to remove from CloudFront.
deletePublicKey_id :: Lens.Lens' DeletePublicKey Prelude.Text
deletePublicKey_id :: Lens' DeletePublicKey Text
deletePublicKey_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePublicKey' {Text
id :: Text
$sel:id:DeletePublicKey' :: DeletePublicKey -> Text
id} -> Text
id) (\s :: DeletePublicKey
s@DeletePublicKey' {} Text
a -> DeletePublicKey
s {$sel:id:DeletePublicKey' :: Text
id = Text
a} :: DeletePublicKey)

instance Core.AWSRequest DeletePublicKey where
  type
    AWSResponse DeletePublicKey =
      DeletePublicKeyResponse
  request :: (Service -> Service) -> DeletePublicKey -> Request DeletePublicKey
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeletePublicKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeletePublicKey)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull DeletePublicKeyResponse
DeletePublicKeyResponse'

instance Prelude.Hashable DeletePublicKey where
  hashWithSalt :: Int -> DeletePublicKey -> Int
hashWithSalt Int
_salt DeletePublicKey' {Maybe Text
Text
id :: Text
ifMatch :: Maybe Text
$sel:id:DeletePublicKey' :: DeletePublicKey -> Text
$sel:ifMatch:DeletePublicKey' :: DeletePublicKey -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ifMatch
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData DeletePublicKey where
  rnf :: DeletePublicKey -> ()
rnf DeletePublicKey' {Maybe Text
Text
id :: Text
ifMatch :: Maybe Text
$sel:id:DeletePublicKey' :: DeletePublicKey -> Text
$sel:ifMatch:DeletePublicKey' :: DeletePublicKey -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ifMatch seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance Data.ToHeaders DeletePublicKey where
  toHeaders :: DeletePublicKey -> [Header]
toHeaders DeletePublicKey' {Maybe Text
Text
id :: Text
ifMatch :: Maybe Text
$sel:id:DeletePublicKey' :: DeletePublicKey -> Text
$sel:ifMatch:DeletePublicKey' :: DeletePublicKey -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [HeaderName
"If-Match" forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# Maybe Text
ifMatch]

instance Data.ToPath DeletePublicKey where
  toPath :: DeletePublicKey -> ByteString
toPath DeletePublicKey' {Maybe Text
Text
id :: Text
ifMatch :: Maybe Text
$sel:id:DeletePublicKey' :: DeletePublicKey -> Text
$sel:ifMatch:DeletePublicKey' :: DeletePublicKey -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2020-05-31/public-key/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id]

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

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

-- |
-- Create a value of 'DeletePublicKeyResponse' 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.
newDeletePublicKeyResponse ::
  DeletePublicKeyResponse
newDeletePublicKeyResponse :: DeletePublicKeyResponse
newDeletePublicKeyResponse = DeletePublicKeyResponse
DeletePublicKeyResponse'

instance Prelude.NFData DeletePublicKeyResponse where
  rnf :: DeletePublicKeyResponse -> ()
rnf DeletePublicKeyResponse
_ = ()