{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.ResponseHeadersPolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudFront.Types.ResponseHeadersPolicy where

import Amazonka.CloudFront.Types.ResponseHeadersPolicyConfig
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

-- | A response headers policy.
--
-- A response headers policy contains information about a set of HTTP
-- response headers.
--
-- After you create a response headers policy, you can use its ID to attach
-- it to one or more cache behaviors in a CloudFront distribution. When
-- it\'s attached to a cache behavior, the response headers policy affects
-- the HTTP headers that CloudFront includes in HTTP responses to requests
-- that match the cache behavior. CloudFront adds or removes response
-- headers according to the configuration of the response headers policy.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/modifying-response-headers.html Adding or removing HTTP headers in CloudFront responses>
-- in the /Amazon CloudFront Developer Guide/.
--
-- /See:/ 'newResponseHeadersPolicy' smart constructor.
data ResponseHeadersPolicy = ResponseHeadersPolicy'
  { -- | The identifier for the response headers policy.
    ResponseHeadersPolicy -> Text
id :: Prelude.Text,
    -- | The date and time when the response headers policy was last modified.
    ResponseHeadersPolicy -> ISO8601
lastModifiedTime :: Data.ISO8601,
    -- | A response headers policy configuration.
    ResponseHeadersPolicy -> ResponseHeadersPolicyConfig
responseHeadersPolicyConfig :: ResponseHeadersPolicyConfig
  }
  deriving (ResponseHeadersPolicy -> ResponseHeadersPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResponseHeadersPolicy -> ResponseHeadersPolicy -> Bool
$c/= :: ResponseHeadersPolicy -> ResponseHeadersPolicy -> Bool
== :: ResponseHeadersPolicy -> ResponseHeadersPolicy -> Bool
$c== :: ResponseHeadersPolicy -> ResponseHeadersPolicy -> Bool
Prelude.Eq, ReadPrec [ResponseHeadersPolicy]
ReadPrec ResponseHeadersPolicy
Int -> ReadS ResponseHeadersPolicy
ReadS [ResponseHeadersPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResponseHeadersPolicy]
$creadListPrec :: ReadPrec [ResponseHeadersPolicy]
readPrec :: ReadPrec ResponseHeadersPolicy
$creadPrec :: ReadPrec ResponseHeadersPolicy
readList :: ReadS [ResponseHeadersPolicy]
$creadList :: ReadS [ResponseHeadersPolicy]
readsPrec :: Int -> ReadS ResponseHeadersPolicy
$creadsPrec :: Int -> ReadS ResponseHeadersPolicy
Prelude.Read, Int -> ResponseHeadersPolicy -> ShowS
[ResponseHeadersPolicy] -> ShowS
ResponseHeadersPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResponseHeadersPolicy] -> ShowS
$cshowList :: [ResponseHeadersPolicy] -> ShowS
show :: ResponseHeadersPolicy -> String
$cshow :: ResponseHeadersPolicy -> String
showsPrec :: Int -> ResponseHeadersPolicy -> ShowS
$cshowsPrec :: Int -> ResponseHeadersPolicy -> ShowS
Prelude.Show, forall x. Rep ResponseHeadersPolicy x -> ResponseHeadersPolicy
forall x. ResponseHeadersPolicy -> Rep ResponseHeadersPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResponseHeadersPolicy x -> ResponseHeadersPolicy
$cfrom :: forall x. ResponseHeadersPolicy -> Rep ResponseHeadersPolicy x
Prelude.Generic)

-- |
-- Create a value of 'ResponseHeadersPolicy' 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:
--
-- 'id', 'responseHeadersPolicy_id' - The identifier for the response headers policy.
--
-- 'lastModifiedTime', 'responseHeadersPolicy_lastModifiedTime' - The date and time when the response headers policy was last modified.
--
-- 'responseHeadersPolicyConfig', 'responseHeadersPolicy_responseHeadersPolicyConfig' - A response headers policy configuration.
newResponseHeadersPolicy ::
  -- | 'id'
  Prelude.Text ->
  -- | 'lastModifiedTime'
  Prelude.UTCTime ->
  -- | 'responseHeadersPolicyConfig'
  ResponseHeadersPolicyConfig ->
  ResponseHeadersPolicy
newResponseHeadersPolicy :: Text
-> UTCTime -> ResponseHeadersPolicyConfig -> ResponseHeadersPolicy
newResponseHeadersPolicy
  Text
pId_
  UTCTime
pLastModifiedTime_
  ResponseHeadersPolicyConfig
pResponseHeadersPolicyConfig_ =
    ResponseHeadersPolicy'
      { $sel:id:ResponseHeadersPolicy' :: Text
id = Text
pId_,
        $sel:lastModifiedTime:ResponseHeadersPolicy' :: ISO8601
lastModifiedTime =
          forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pLastModifiedTime_,
        $sel:responseHeadersPolicyConfig:ResponseHeadersPolicy' :: ResponseHeadersPolicyConfig
responseHeadersPolicyConfig =
          ResponseHeadersPolicyConfig
pResponseHeadersPolicyConfig_
      }

-- | The identifier for the response headers policy.
responseHeadersPolicy_id :: Lens.Lens' ResponseHeadersPolicy Prelude.Text
responseHeadersPolicy_id :: Lens' ResponseHeadersPolicy Text
responseHeadersPolicy_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseHeadersPolicy' {Text
id :: Text
$sel:id:ResponseHeadersPolicy' :: ResponseHeadersPolicy -> Text
id} -> Text
id) (\s :: ResponseHeadersPolicy
s@ResponseHeadersPolicy' {} Text
a -> ResponseHeadersPolicy
s {$sel:id:ResponseHeadersPolicy' :: Text
id = Text
a} :: ResponseHeadersPolicy)

-- | The date and time when the response headers policy was last modified.
responseHeadersPolicy_lastModifiedTime :: Lens.Lens' ResponseHeadersPolicy Prelude.UTCTime
responseHeadersPolicy_lastModifiedTime :: Lens' ResponseHeadersPolicy UTCTime
responseHeadersPolicy_lastModifiedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseHeadersPolicy' {ISO8601
lastModifiedTime :: ISO8601
$sel:lastModifiedTime:ResponseHeadersPolicy' :: ResponseHeadersPolicy -> ISO8601
lastModifiedTime} -> ISO8601
lastModifiedTime) (\s :: ResponseHeadersPolicy
s@ResponseHeadersPolicy' {} ISO8601
a -> ResponseHeadersPolicy
s {$sel:lastModifiedTime:ResponseHeadersPolicy' :: ISO8601
lastModifiedTime = ISO8601
a} :: ResponseHeadersPolicy) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | A response headers policy configuration.
responseHeadersPolicy_responseHeadersPolicyConfig :: Lens.Lens' ResponseHeadersPolicy ResponseHeadersPolicyConfig
responseHeadersPolicy_responseHeadersPolicyConfig :: Lens' ResponseHeadersPolicy ResponseHeadersPolicyConfig
responseHeadersPolicy_responseHeadersPolicyConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseHeadersPolicy' {ResponseHeadersPolicyConfig
responseHeadersPolicyConfig :: ResponseHeadersPolicyConfig
$sel:responseHeadersPolicyConfig:ResponseHeadersPolicy' :: ResponseHeadersPolicy -> ResponseHeadersPolicyConfig
responseHeadersPolicyConfig} -> ResponseHeadersPolicyConfig
responseHeadersPolicyConfig) (\s :: ResponseHeadersPolicy
s@ResponseHeadersPolicy' {} ResponseHeadersPolicyConfig
a -> ResponseHeadersPolicy
s {$sel:responseHeadersPolicyConfig:ResponseHeadersPolicy' :: ResponseHeadersPolicyConfig
responseHeadersPolicyConfig = ResponseHeadersPolicyConfig
a} :: ResponseHeadersPolicy)

instance Data.FromXML ResponseHeadersPolicy where
  parseXML :: [Node] -> Either String ResponseHeadersPolicy
parseXML [Node]
x =
    Text
-> ISO8601 -> ResponseHeadersPolicyConfig -> ResponseHeadersPolicy
ResponseHeadersPolicy'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Id")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"LastModifiedTime")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"ResponseHeadersPolicyConfig")

instance Prelude.Hashable ResponseHeadersPolicy where
  hashWithSalt :: Int -> ResponseHeadersPolicy -> Int
hashWithSalt Int
_salt ResponseHeadersPolicy' {Text
ISO8601
ResponseHeadersPolicyConfig
responseHeadersPolicyConfig :: ResponseHeadersPolicyConfig
lastModifiedTime :: ISO8601
id :: Text
$sel:responseHeadersPolicyConfig:ResponseHeadersPolicy' :: ResponseHeadersPolicy -> ResponseHeadersPolicyConfig
$sel:lastModifiedTime:ResponseHeadersPolicy' :: ResponseHeadersPolicy -> ISO8601
$sel:id:ResponseHeadersPolicy' :: ResponseHeadersPolicy -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
lastModifiedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResponseHeadersPolicyConfig
responseHeadersPolicyConfig

instance Prelude.NFData ResponseHeadersPolicy where
  rnf :: ResponseHeadersPolicy -> ()
rnf ResponseHeadersPolicy' {Text
ISO8601
ResponseHeadersPolicyConfig
responseHeadersPolicyConfig :: ResponseHeadersPolicyConfig
lastModifiedTime :: ISO8601
id :: Text
$sel:responseHeadersPolicyConfig:ResponseHeadersPolicy' :: ResponseHeadersPolicy -> ResponseHeadersPolicyConfig
$sel:lastModifiedTime:ResponseHeadersPolicy' :: ResponseHeadersPolicy -> ISO8601
$sel:id:ResponseHeadersPolicy' :: ResponseHeadersPolicy -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ISO8601
lastModifiedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ResponseHeadersPolicyConfig
responseHeadersPolicyConfig