{-# 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.DeleteKeyGroup
-- 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 a key group.
--
-- You cannot delete a key group that is referenced in a cache behavior.
-- First update your distributions to remove the key group from all cache
-- behaviors, then delete the key group.
--
-- To delete a key group, you must provide the key group’s identifier and
-- version. To get these values, use @ListKeyGroups@ followed by
-- @GetKeyGroup@ or @GetKeyGroupConfig@.
module Amazonka.CloudFront.DeleteKeyGroup
  ( -- * Creating a Request
    DeleteKeyGroup (..),
    newDeleteKeyGroup,

    -- * Request Lenses
    deleteKeyGroup_ifMatch,
    deleteKeyGroup_id,

    -- * Destructuring the Response
    DeleteKeyGroupResponse (..),
    newDeleteKeyGroupResponse,
  )
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:/ 'newDeleteKeyGroup' smart constructor.
data DeleteKeyGroup = DeleteKeyGroup'
  { -- | The version of the key group that you are deleting. The version is the
    -- key group’s @ETag@ value. To get the @ETag@, use @GetKeyGroup@ or
    -- @GetKeyGroupConfig@.
    DeleteKeyGroup -> Maybe Text
ifMatch :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the key group that you are deleting. To get the
    -- identifier, use @ListKeyGroups@.
    DeleteKeyGroup -> Text
id :: Prelude.Text
  }
  deriving (DeleteKeyGroup -> DeleteKeyGroup -> Bool
(DeleteKeyGroup -> DeleteKeyGroup -> Bool)
-> (DeleteKeyGroup -> DeleteKeyGroup -> Bool) -> Eq DeleteKeyGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteKeyGroup -> DeleteKeyGroup -> Bool
$c/= :: DeleteKeyGroup -> DeleteKeyGroup -> Bool
== :: DeleteKeyGroup -> DeleteKeyGroup -> Bool
$c== :: DeleteKeyGroup -> DeleteKeyGroup -> Bool
Prelude.Eq, ReadPrec [DeleteKeyGroup]
ReadPrec DeleteKeyGroup
Int -> ReadS DeleteKeyGroup
ReadS [DeleteKeyGroup]
(Int -> ReadS DeleteKeyGroup)
-> ReadS [DeleteKeyGroup]
-> ReadPrec DeleteKeyGroup
-> ReadPrec [DeleteKeyGroup]
-> Read DeleteKeyGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteKeyGroup]
$creadListPrec :: ReadPrec [DeleteKeyGroup]
readPrec :: ReadPrec DeleteKeyGroup
$creadPrec :: ReadPrec DeleteKeyGroup
readList :: ReadS [DeleteKeyGroup]
$creadList :: ReadS [DeleteKeyGroup]
readsPrec :: Int -> ReadS DeleteKeyGroup
$creadsPrec :: Int -> ReadS DeleteKeyGroup
Prelude.Read, Int -> DeleteKeyGroup -> ShowS
[DeleteKeyGroup] -> ShowS
DeleteKeyGroup -> String
(Int -> DeleteKeyGroup -> ShowS)
-> (DeleteKeyGroup -> String)
-> ([DeleteKeyGroup] -> ShowS)
-> Show DeleteKeyGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteKeyGroup] -> ShowS
$cshowList :: [DeleteKeyGroup] -> ShowS
show :: DeleteKeyGroup -> String
$cshow :: DeleteKeyGroup -> String
showsPrec :: Int -> DeleteKeyGroup -> ShowS
$cshowsPrec :: Int -> DeleteKeyGroup -> ShowS
Prelude.Show, (forall x. DeleteKeyGroup -> Rep DeleteKeyGroup x)
-> (forall x. Rep DeleteKeyGroup x -> DeleteKeyGroup)
-> Generic DeleteKeyGroup
forall x. Rep DeleteKeyGroup x -> DeleteKeyGroup
forall x. DeleteKeyGroup -> Rep DeleteKeyGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteKeyGroup x -> DeleteKeyGroup
$cfrom :: forall x. DeleteKeyGroup -> Rep DeleteKeyGroup x
Prelude.Generic)

-- |
-- Create a value of 'DeleteKeyGroup' 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', 'deleteKeyGroup_ifMatch' - The version of the key group that you are deleting. The version is the
-- key group’s @ETag@ value. To get the @ETag@, use @GetKeyGroup@ or
-- @GetKeyGroupConfig@.
--
-- 'id', 'deleteKeyGroup_id' - The identifier of the key group that you are deleting. To get the
-- identifier, use @ListKeyGroups@.
newDeleteKeyGroup ::
  -- | 'id'
  Prelude.Text ->
  DeleteKeyGroup
newDeleteKeyGroup :: Text -> DeleteKeyGroup
newDeleteKeyGroup Text
pId_ =
  DeleteKeyGroup' :: Maybe Text -> Text -> DeleteKeyGroup
DeleteKeyGroup'
    { $sel:ifMatch:DeleteKeyGroup' :: Maybe Text
ifMatch = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:DeleteKeyGroup' :: Text
id = Text
pId_
    }

-- | The version of the key group that you are deleting. The version is the
-- key group’s @ETag@ value. To get the @ETag@, use @GetKeyGroup@ or
-- @GetKeyGroupConfig@.
deleteKeyGroup_ifMatch :: Lens.Lens' DeleteKeyGroup (Prelude.Maybe Prelude.Text)
deleteKeyGroup_ifMatch :: (Maybe Text -> f (Maybe Text))
-> DeleteKeyGroup -> f DeleteKeyGroup
deleteKeyGroup_ifMatch = (DeleteKeyGroup -> Maybe Text)
-> (DeleteKeyGroup -> Maybe Text -> DeleteKeyGroup)
-> Lens DeleteKeyGroup DeleteKeyGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteKeyGroup' {Maybe Text
ifMatch :: Maybe Text
$sel:ifMatch:DeleteKeyGroup' :: DeleteKeyGroup -> Maybe Text
ifMatch} -> Maybe Text
ifMatch) (\s :: DeleteKeyGroup
s@DeleteKeyGroup' {} Maybe Text
a -> DeleteKeyGroup
s {$sel:ifMatch:DeleteKeyGroup' :: Maybe Text
ifMatch = Maybe Text
a} :: DeleteKeyGroup)

-- | The identifier of the key group that you are deleting. To get the
-- identifier, use @ListKeyGroups@.
deleteKeyGroup_id :: Lens.Lens' DeleteKeyGroup Prelude.Text
deleteKeyGroup_id :: (Text -> f Text) -> DeleteKeyGroup -> f DeleteKeyGroup
deleteKeyGroup_id = (DeleteKeyGroup -> Text)
-> (DeleteKeyGroup -> Text -> DeleteKeyGroup)
-> Lens DeleteKeyGroup DeleteKeyGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteKeyGroup' {Text
id :: Text
$sel:id:DeleteKeyGroup' :: DeleteKeyGroup -> Text
id} -> Text
id) (\s :: DeleteKeyGroup
s@DeleteKeyGroup' {} Text
a -> DeleteKeyGroup
s {$sel:id:DeleteKeyGroup' :: Text
id = Text
a} :: DeleteKeyGroup)

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

instance Prelude.Hashable DeleteKeyGroup

instance Prelude.NFData DeleteKeyGroup

instance Core.ToHeaders DeleteKeyGroup where
  toHeaders :: DeleteKeyGroup -> [Header]
toHeaders DeleteKeyGroup' {Maybe Text
Text
id :: Text
ifMatch :: Maybe Text
$sel:id:DeleteKeyGroup' :: DeleteKeyGroup -> Text
$sel:ifMatch:DeleteKeyGroup' :: DeleteKeyGroup -> 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 DeleteKeyGroup where
  toPath :: DeleteKeyGroup -> ByteString
toPath DeleteKeyGroup' {Maybe Text
Text
id :: Text
ifMatch :: Maybe Text
$sel:id:DeleteKeyGroup' :: DeleteKeyGroup -> Text
$sel:ifMatch:DeleteKeyGroup' :: DeleteKeyGroup -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2020-05-31/key-group/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id]

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

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

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

instance Prelude.NFData DeleteKeyGroupResponse