{-# 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.DeleteCachePolicy
-- 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 cache policy.
--
-- You cannot delete a cache policy if it’s attached to a cache behavior.
-- First update your distributions to remove the cache policy from all
-- cache behaviors, then delete the cache policy.
--
-- To delete a cache policy, you must provide the policy’s identifier and
-- version. To get these values, you can use @ListCachePolicies@ or
-- @GetCachePolicy@.
module Amazonka.CloudFront.DeleteCachePolicy
  ( -- * Creating a Request
    DeleteCachePolicy (..),
    newDeleteCachePolicy,

    -- * Request Lenses
    deleteCachePolicy_ifMatch,
    deleteCachePolicy_id,

    -- * Destructuring the Response
    DeleteCachePolicyResponse (..),
    newDeleteCachePolicyResponse,
  )
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:/ 'newDeleteCachePolicy' smart constructor.
data DeleteCachePolicy = DeleteCachePolicy'
  { -- | The version of the cache policy that you are deleting. The version is
    -- the cache policy’s @ETag@ value, which you can get using
    -- @ListCachePolicies@, @GetCachePolicy@, or @GetCachePolicyConfig@.
    DeleteCachePolicy -> Maybe Text
ifMatch :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the cache policy that you are deleting. To get
    -- the identifier, you can use @ListCachePolicies@.
    DeleteCachePolicy -> Text
id :: Prelude.Text
  }
  deriving (DeleteCachePolicy -> DeleteCachePolicy -> Bool
(DeleteCachePolicy -> DeleteCachePolicy -> Bool)
-> (DeleteCachePolicy -> DeleteCachePolicy -> Bool)
-> Eq DeleteCachePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteCachePolicy -> DeleteCachePolicy -> Bool
$c/= :: DeleteCachePolicy -> DeleteCachePolicy -> Bool
== :: DeleteCachePolicy -> DeleteCachePolicy -> Bool
$c== :: DeleteCachePolicy -> DeleteCachePolicy -> Bool
Prelude.Eq, ReadPrec [DeleteCachePolicy]
ReadPrec DeleteCachePolicy
Int -> ReadS DeleteCachePolicy
ReadS [DeleteCachePolicy]
(Int -> ReadS DeleteCachePolicy)
-> ReadS [DeleteCachePolicy]
-> ReadPrec DeleteCachePolicy
-> ReadPrec [DeleteCachePolicy]
-> Read DeleteCachePolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteCachePolicy]
$creadListPrec :: ReadPrec [DeleteCachePolicy]
readPrec :: ReadPrec DeleteCachePolicy
$creadPrec :: ReadPrec DeleteCachePolicy
readList :: ReadS [DeleteCachePolicy]
$creadList :: ReadS [DeleteCachePolicy]
readsPrec :: Int -> ReadS DeleteCachePolicy
$creadsPrec :: Int -> ReadS DeleteCachePolicy
Prelude.Read, Int -> DeleteCachePolicy -> ShowS
[DeleteCachePolicy] -> ShowS
DeleteCachePolicy -> String
(Int -> DeleteCachePolicy -> ShowS)
-> (DeleteCachePolicy -> String)
-> ([DeleteCachePolicy] -> ShowS)
-> Show DeleteCachePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteCachePolicy] -> ShowS
$cshowList :: [DeleteCachePolicy] -> ShowS
show :: DeleteCachePolicy -> String
$cshow :: DeleteCachePolicy -> String
showsPrec :: Int -> DeleteCachePolicy -> ShowS
$cshowsPrec :: Int -> DeleteCachePolicy -> ShowS
Prelude.Show, (forall x. DeleteCachePolicy -> Rep DeleteCachePolicy x)
-> (forall x. Rep DeleteCachePolicy x -> DeleteCachePolicy)
-> Generic DeleteCachePolicy
forall x. Rep DeleteCachePolicy x -> DeleteCachePolicy
forall x. DeleteCachePolicy -> Rep DeleteCachePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteCachePolicy x -> DeleteCachePolicy
$cfrom :: forall x. DeleteCachePolicy -> Rep DeleteCachePolicy x
Prelude.Generic)

-- |
-- Create a value of 'DeleteCachePolicy' 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', 'deleteCachePolicy_ifMatch' - The version of the cache policy that you are deleting. The version is
-- the cache policy’s @ETag@ value, which you can get using
-- @ListCachePolicies@, @GetCachePolicy@, or @GetCachePolicyConfig@.
--
-- 'id', 'deleteCachePolicy_id' - The unique identifier for the cache policy that you are deleting. To get
-- the identifier, you can use @ListCachePolicies@.
newDeleteCachePolicy ::
  -- | 'id'
  Prelude.Text ->
  DeleteCachePolicy
newDeleteCachePolicy :: Text -> DeleteCachePolicy
newDeleteCachePolicy Text
pId_ =
  DeleteCachePolicy' :: Maybe Text -> Text -> DeleteCachePolicy
DeleteCachePolicy'
    { $sel:ifMatch:DeleteCachePolicy' :: Maybe Text
ifMatch = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:DeleteCachePolicy' :: Text
id = Text
pId_
    }

-- | The version of the cache policy that you are deleting. The version is
-- the cache policy’s @ETag@ value, which you can get using
-- @ListCachePolicies@, @GetCachePolicy@, or @GetCachePolicyConfig@.
deleteCachePolicy_ifMatch :: Lens.Lens' DeleteCachePolicy (Prelude.Maybe Prelude.Text)
deleteCachePolicy_ifMatch :: (Maybe Text -> f (Maybe Text))
-> DeleteCachePolicy -> f DeleteCachePolicy
deleteCachePolicy_ifMatch = (DeleteCachePolicy -> Maybe Text)
-> (DeleteCachePolicy -> Maybe Text -> DeleteCachePolicy)
-> Lens
     DeleteCachePolicy DeleteCachePolicy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCachePolicy' {Maybe Text
ifMatch :: Maybe Text
$sel:ifMatch:DeleteCachePolicy' :: DeleteCachePolicy -> Maybe Text
ifMatch} -> Maybe Text
ifMatch) (\s :: DeleteCachePolicy
s@DeleteCachePolicy' {} Maybe Text
a -> DeleteCachePolicy
s {$sel:ifMatch:DeleteCachePolicy' :: Maybe Text
ifMatch = Maybe Text
a} :: DeleteCachePolicy)

-- | The unique identifier for the cache policy that you are deleting. To get
-- the identifier, you can use @ListCachePolicies@.
deleteCachePolicy_id :: Lens.Lens' DeleteCachePolicy Prelude.Text
deleteCachePolicy_id :: (Text -> f Text) -> DeleteCachePolicy -> f DeleteCachePolicy
deleteCachePolicy_id = (DeleteCachePolicy -> Text)
-> (DeleteCachePolicy -> Text -> DeleteCachePolicy)
-> Lens DeleteCachePolicy DeleteCachePolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCachePolicy' {Text
id :: Text
$sel:id:DeleteCachePolicy' :: DeleteCachePolicy -> Text
id} -> Text
id) (\s :: DeleteCachePolicy
s@DeleteCachePolicy' {} Text
a -> DeleteCachePolicy
s {$sel:id:DeleteCachePolicy' :: Text
id = Text
a} :: DeleteCachePolicy)

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

instance Prelude.Hashable DeleteCachePolicy

instance Prelude.NFData DeleteCachePolicy

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

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

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

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

instance Prelude.NFData DeleteCachePolicyResponse