{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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:/ '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
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]
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
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. 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'
    { $sel:ifMatch:DeleteCachePolicy' :: Maybe Text
ifMatch = 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 :: Lens' DeleteCachePolicy (Maybe Text)
deleteCachePolicy_ifMatch = 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 :: Lens' DeleteCachePolicy Text
deleteCachePolicy_id = 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 :: (Service -> Service)
-> DeleteCachePolicy -> Request DeleteCachePolicy
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 DeleteCachePolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteCachePolicy)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull DeleteCachePolicyResponse
DeleteCachePolicyResponse'

instance Prelude.Hashable DeleteCachePolicy where
  hashWithSalt :: Int -> DeleteCachePolicy -> Int
hashWithSalt Int
_salt DeleteCachePolicy' {Maybe Text
Text
id :: Text
ifMatch :: Maybe Text
$sel:id:DeleteCachePolicy' :: DeleteCachePolicy -> Text
$sel:ifMatch:DeleteCachePolicy' :: DeleteCachePolicy -> 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 DeleteCachePolicy where
  rnf :: DeleteCachePolicy -> ()
rnf DeleteCachePolicy' {Maybe Text
Text
id :: Text
ifMatch :: Maybe Text
$sel:id:DeleteCachePolicy' :: DeleteCachePolicy -> Text
$sel:ifMatch:DeleteCachePolicy' :: DeleteCachePolicy -> 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 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
..} =
    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 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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2020-05-31/cache-policy/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id]

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

-- | /See:/ 'newDeleteCachePolicyResponse' smart constructor.
data DeleteCachePolicyResponse = DeleteCachePolicyResponse'
  {
  }
  deriving (DeleteCachePolicyResponse -> DeleteCachePolicyResponse -> Bool
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]
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
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.
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 where
  rnf :: DeleteCachePolicyResponse -> ()
rnf DeleteCachePolicyResponse
_ = ()