{-# 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-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)
--
-- 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.Lens as Lens
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
(DeletePublicKey -> DeletePublicKey -> Bool)
-> (DeletePublicKey -> DeletePublicKey -> Bool)
-> Eq DeletePublicKey
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]
(Int -> ReadS DeletePublicKey)
-> ReadS [DeletePublicKey]
-> ReadPrec DeletePublicKey
-> ReadPrec [DeletePublicKey]
-> Read 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
(Int -> DeletePublicKey -> ShowS)
-> (DeletePublicKey -> String)
-> ([DeletePublicKey] -> ShowS)
-> Show DeletePublicKey
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. DeletePublicKey -> Rep DeletePublicKey x)
-> (forall x. Rep DeletePublicKey x -> DeletePublicKey)
-> Generic DeletePublicKey
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' :: Maybe Text -> Text -> DeletePublicKey
DeletePublicKey'
    { $sel:ifMatch:DeletePublicKey' :: Maybe Text
ifMatch = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeletePublicKey -> f DeletePublicKey
deletePublicKey_ifMatch = (DeletePublicKey -> Maybe Text)
-> (DeletePublicKey -> Maybe Text -> DeletePublicKey)
-> Lens DeletePublicKey DeletePublicKey (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> DeletePublicKey -> f DeletePublicKey
deletePublicKey_id = (DeletePublicKey -> Text)
-> (DeletePublicKey -> Text -> DeletePublicKey)
-> Lens DeletePublicKey DeletePublicKey Text Text
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 :: DeletePublicKey -> Request DeletePublicKey
request = Service -> DeletePublicKey -> Request DeletePublicKey
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeletePublicKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeletePublicKey)))
response =
    AWSResponse DeletePublicKey
-> Logger
-> Service
-> Proxy DeletePublicKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeletePublicKey)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeletePublicKey
DeletePublicKeyResponse
DeletePublicKeyResponse'

instance Prelude.Hashable DeletePublicKey

instance Prelude.NFData DeletePublicKey

instance Core.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
..} =
    [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat [HeaderName
"If-Match" HeaderName -> Maybe Text -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe Text
ifMatch]

instance Core.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
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2020-05-31/public-key/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id]

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

-- | /See:/ 'newDeletePublicKeyResponse' smart constructor.
data DeletePublicKeyResponse = DeletePublicKeyResponse'
  {
  }
  deriving (DeletePublicKeyResponse -> DeletePublicKeyResponse -> Bool
(DeletePublicKeyResponse -> DeletePublicKeyResponse -> Bool)
-> (DeletePublicKeyResponse -> DeletePublicKeyResponse -> Bool)
-> Eq DeletePublicKeyResponse
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]
(Int -> ReadS DeletePublicKeyResponse)
-> ReadS [DeletePublicKeyResponse]
-> ReadPrec DeletePublicKeyResponse
-> ReadPrec [DeletePublicKeyResponse]
-> Read 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
(Int -> DeletePublicKeyResponse -> ShowS)
-> (DeletePublicKeyResponse -> String)
-> ([DeletePublicKeyResponse] -> ShowS)
-> Show DeletePublicKeyResponse
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.
 DeletePublicKeyResponse -> Rep DeletePublicKeyResponse x)
-> (forall x.
    Rep DeletePublicKeyResponse x -> DeletePublicKeyResponse)
-> Generic DeletePublicKeyResponse
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