{-# 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.DeleteOriginRequestPolicy
-- 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 an origin request policy.
--
-- You cannot delete an origin request policy if it’s attached to any cache
-- behaviors. First update your distributions to remove the origin request
-- policy from all cache behaviors, then delete the origin request policy.
--
-- To delete an origin request policy, you must provide the policy’s
-- identifier and version. To get the identifier, you can use
-- @ListOriginRequestPolicies@ or @GetOriginRequestPolicy@.
module Amazonka.CloudFront.DeleteOriginRequestPolicy
  ( -- * Creating a Request
    DeleteOriginRequestPolicy (..),
    newDeleteOriginRequestPolicy,

    -- * Request Lenses
    deleteOriginRequestPolicy_ifMatch,
    deleteOriginRequestPolicy_id,

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

-- |
-- Create a value of 'DeleteOriginRequestPolicy' 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', 'deleteOriginRequestPolicy_ifMatch' - The version of the origin request policy that you are deleting. The
-- version is the origin request policy’s @ETag@ value, which you can get
-- using @ListOriginRequestPolicies@, @GetOriginRequestPolicy@, or
-- @GetOriginRequestPolicyConfig@.
--
-- 'id', 'deleteOriginRequestPolicy_id' - The unique identifier for the origin request policy that you are
-- deleting. To get the identifier, you can use
-- @ListOriginRequestPolicies@.
newDeleteOriginRequestPolicy ::
  -- | 'id'
  Prelude.Text ->
  DeleteOriginRequestPolicy
newDeleteOriginRequestPolicy :: Text -> DeleteOriginRequestPolicy
newDeleteOriginRequestPolicy Text
pId_ =
  DeleteOriginRequestPolicy' :: Maybe Text -> Text -> DeleteOriginRequestPolicy
DeleteOriginRequestPolicy'
    { $sel:ifMatch:DeleteOriginRequestPolicy' :: Maybe Text
ifMatch =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:DeleteOriginRequestPolicy' :: Text
id = Text
pId_
    }

-- | The version of the origin request policy that you are deleting. The
-- version is the origin request policy’s @ETag@ value, which you can get
-- using @ListOriginRequestPolicies@, @GetOriginRequestPolicy@, or
-- @GetOriginRequestPolicyConfig@.
deleteOriginRequestPolicy_ifMatch :: Lens.Lens' DeleteOriginRequestPolicy (Prelude.Maybe Prelude.Text)
deleteOriginRequestPolicy_ifMatch :: (Maybe Text -> f (Maybe Text))
-> DeleteOriginRequestPolicy -> f DeleteOriginRequestPolicy
deleteOriginRequestPolicy_ifMatch = (DeleteOriginRequestPolicy -> Maybe Text)
-> (DeleteOriginRequestPolicy
    -> Maybe Text -> DeleteOriginRequestPolicy)
-> Lens
     DeleteOriginRequestPolicy
     DeleteOriginRequestPolicy
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteOriginRequestPolicy' {Maybe Text
ifMatch :: Maybe Text
$sel:ifMatch:DeleteOriginRequestPolicy' :: DeleteOriginRequestPolicy -> Maybe Text
ifMatch} -> Maybe Text
ifMatch) (\s :: DeleteOriginRequestPolicy
s@DeleteOriginRequestPolicy' {} Maybe Text
a -> DeleteOriginRequestPolicy
s {$sel:ifMatch:DeleteOriginRequestPolicy' :: Maybe Text
ifMatch = Maybe Text
a} :: DeleteOriginRequestPolicy)

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

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

instance Prelude.Hashable DeleteOriginRequestPolicy

instance Prelude.NFData DeleteOriginRequestPolicy

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

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

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

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

instance
  Prelude.NFData
    DeleteOriginRequestPolicyResponse