{-# 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.CachePolicyConfig
-- 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)
module Amazonka.CloudFront.Types.CachePolicyConfig where

import Amazonka.CloudFront.Types.ParametersInCacheKeyAndForwardedToOrigin
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A cache policy configuration.
--
-- This configuration determines the following:
--
-- -   The values that CloudFront includes in the cache key. These values
--     can include HTTP headers, cookies, and URL query strings. CloudFront
--     uses the cache key to find an object in its cache that it can return
--     to the viewer.
--
-- -   The default, minimum, and maximum time to live (TTL) values that you
--     want objects to stay in the CloudFront cache.
--
-- The headers, cookies, and query strings that are included in the cache
-- key are automatically included in requests that CloudFront sends to the
-- origin. CloudFront sends a request when it can’t find a valid object in
-- its cache that matches the request’s cache key. If you want to send
-- values to the origin but /not/ include them in the cache key, use
-- @OriginRequestPolicy@.
--
-- /See:/ 'newCachePolicyConfig' smart constructor.
data CachePolicyConfig = CachePolicyConfig'
  { -- | The maximum amount of time, in seconds, that objects stay in the
    -- CloudFront cache before CloudFront sends another request to the origin
    -- to see if the object has been updated. CloudFront uses this value only
    -- when the origin sends @Cache-Control@ or @Expires@ headers with the
    -- object. For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html Managing How Long Content Stays in an Edge Cache (Expiration)>
    -- in the /Amazon CloudFront Developer Guide/.
    --
    -- The default value for this field is 31536000 seconds (one year). If the
    -- value of @MinTTL@ or @DefaultTTL@ is more than 31536000 seconds, then
    -- the default value for this field is the same as the value of
    -- @DefaultTTL@.
    CachePolicyConfig -> Maybe Integer
maxTTL :: Prelude.Maybe Prelude.Integer,
    -- | The HTTP headers, cookies, and URL query strings to include in the cache
    -- key. The values included in the cache key are automatically included in
    -- requests that CloudFront sends to the origin.
    CachePolicyConfig -> Maybe ParametersInCacheKeyAndForwardedToOrigin
parametersInCacheKeyAndForwardedToOrigin :: Prelude.Maybe ParametersInCacheKeyAndForwardedToOrigin,
    -- | The default amount of time, in seconds, that you want objects to stay in
    -- the CloudFront cache before CloudFront sends another request to the
    -- origin to see if the object has been updated. CloudFront uses this value
    -- as the object’s time to live (TTL) only when the origin does /not/ send
    -- @Cache-Control@ or @Expires@ headers with the object. For more
    -- information, see
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html Managing How Long Content Stays in an Edge Cache (Expiration)>
    -- in the /Amazon CloudFront Developer Guide/.
    --
    -- The default value for this field is 86400 seconds (one day). If the
    -- value of @MinTTL@ is more than 86400 seconds, then the default value for
    -- this field is the same as the value of @MinTTL@.
    CachePolicyConfig -> Maybe Integer
defaultTTL :: Prelude.Maybe Prelude.Integer,
    -- | A comment to describe the cache policy. The comment cannot be longer
    -- than 128 characters.
    CachePolicyConfig -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | A unique name to identify the cache policy.
    CachePolicyConfig -> Text
name :: Prelude.Text,
    -- | The minimum amount of time, in seconds, that you want objects to stay in
    -- the CloudFront cache before CloudFront sends another request to the
    -- origin to see if the object has been updated. For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html Managing How Long Content Stays in an Edge Cache (Expiration)>
    -- in the /Amazon CloudFront Developer Guide/.
    CachePolicyConfig -> Integer
minTTL :: Prelude.Integer
  }
  deriving (CachePolicyConfig -> CachePolicyConfig -> Bool
(CachePolicyConfig -> CachePolicyConfig -> Bool)
-> (CachePolicyConfig -> CachePolicyConfig -> Bool)
-> Eq CachePolicyConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CachePolicyConfig -> CachePolicyConfig -> Bool
$c/= :: CachePolicyConfig -> CachePolicyConfig -> Bool
== :: CachePolicyConfig -> CachePolicyConfig -> Bool
$c== :: CachePolicyConfig -> CachePolicyConfig -> Bool
Prelude.Eq, ReadPrec [CachePolicyConfig]
ReadPrec CachePolicyConfig
Int -> ReadS CachePolicyConfig
ReadS [CachePolicyConfig]
(Int -> ReadS CachePolicyConfig)
-> ReadS [CachePolicyConfig]
-> ReadPrec CachePolicyConfig
-> ReadPrec [CachePolicyConfig]
-> Read CachePolicyConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CachePolicyConfig]
$creadListPrec :: ReadPrec [CachePolicyConfig]
readPrec :: ReadPrec CachePolicyConfig
$creadPrec :: ReadPrec CachePolicyConfig
readList :: ReadS [CachePolicyConfig]
$creadList :: ReadS [CachePolicyConfig]
readsPrec :: Int -> ReadS CachePolicyConfig
$creadsPrec :: Int -> ReadS CachePolicyConfig
Prelude.Read, Int -> CachePolicyConfig -> ShowS
[CachePolicyConfig] -> ShowS
CachePolicyConfig -> String
(Int -> CachePolicyConfig -> ShowS)
-> (CachePolicyConfig -> String)
-> ([CachePolicyConfig] -> ShowS)
-> Show CachePolicyConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CachePolicyConfig] -> ShowS
$cshowList :: [CachePolicyConfig] -> ShowS
show :: CachePolicyConfig -> String
$cshow :: CachePolicyConfig -> String
showsPrec :: Int -> CachePolicyConfig -> ShowS
$cshowsPrec :: Int -> CachePolicyConfig -> ShowS
Prelude.Show, (forall x. CachePolicyConfig -> Rep CachePolicyConfig x)
-> (forall x. Rep CachePolicyConfig x -> CachePolicyConfig)
-> Generic CachePolicyConfig
forall x. Rep CachePolicyConfig x -> CachePolicyConfig
forall x. CachePolicyConfig -> Rep CachePolicyConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CachePolicyConfig x -> CachePolicyConfig
$cfrom :: forall x. CachePolicyConfig -> Rep CachePolicyConfig x
Prelude.Generic)

-- |
-- Create a value of 'CachePolicyConfig' 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:
--
-- 'maxTTL', 'cachePolicyConfig_maxTTL' - The maximum amount of time, in seconds, that objects stay in the
-- CloudFront cache before CloudFront sends another request to the origin
-- to see if the object has been updated. CloudFront uses this value only
-- when the origin sends @Cache-Control@ or @Expires@ headers with the
-- object. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html Managing How Long Content Stays in an Edge Cache (Expiration)>
-- in the /Amazon CloudFront Developer Guide/.
--
-- The default value for this field is 31536000 seconds (one year). If the
-- value of @MinTTL@ or @DefaultTTL@ is more than 31536000 seconds, then
-- the default value for this field is the same as the value of
-- @DefaultTTL@.
--
-- 'parametersInCacheKeyAndForwardedToOrigin', 'cachePolicyConfig_parametersInCacheKeyAndForwardedToOrigin' - The HTTP headers, cookies, and URL query strings to include in the cache
-- key. The values included in the cache key are automatically included in
-- requests that CloudFront sends to the origin.
--
-- 'defaultTTL', 'cachePolicyConfig_defaultTTL' - The default amount of time, in seconds, that you want objects to stay in
-- the CloudFront cache before CloudFront sends another request to the
-- origin to see if the object has been updated. CloudFront uses this value
-- as the object’s time to live (TTL) only when the origin does /not/ send
-- @Cache-Control@ or @Expires@ headers with the object. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html Managing How Long Content Stays in an Edge Cache (Expiration)>
-- in the /Amazon CloudFront Developer Guide/.
--
-- The default value for this field is 86400 seconds (one day). If the
-- value of @MinTTL@ is more than 86400 seconds, then the default value for
-- this field is the same as the value of @MinTTL@.
--
-- 'comment', 'cachePolicyConfig_comment' - A comment to describe the cache policy. The comment cannot be longer
-- than 128 characters.
--
-- 'name', 'cachePolicyConfig_name' - A unique name to identify the cache policy.
--
-- 'minTTL', 'cachePolicyConfig_minTTL' - The minimum amount of time, in seconds, that you want objects to stay in
-- the CloudFront cache before CloudFront sends another request to the
-- origin to see if the object has been updated. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html Managing How Long Content Stays in an Edge Cache (Expiration)>
-- in the /Amazon CloudFront Developer Guide/.
newCachePolicyConfig ::
  -- | 'name'
  Prelude.Text ->
  -- | 'minTTL'
  Prelude.Integer ->
  CachePolicyConfig
newCachePolicyConfig :: Text -> Integer -> CachePolicyConfig
newCachePolicyConfig Text
pName_ Integer
pMinTTL_ =
  CachePolicyConfig' :: Maybe Integer
-> Maybe ParametersInCacheKeyAndForwardedToOrigin
-> Maybe Integer
-> Maybe Text
-> Text
-> Integer
-> CachePolicyConfig
CachePolicyConfig'
    { $sel:maxTTL:CachePolicyConfig' :: Maybe Integer
maxTTL = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:parametersInCacheKeyAndForwardedToOrigin:CachePolicyConfig' :: Maybe ParametersInCacheKeyAndForwardedToOrigin
parametersInCacheKeyAndForwardedToOrigin =
        Maybe ParametersInCacheKeyAndForwardedToOrigin
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultTTL:CachePolicyConfig' :: Maybe Integer
defaultTTL = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:comment:CachePolicyConfig' :: Maybe Text
comment = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CachePolicyConfig' :: Text
name = Text
pName_,
      $sel:minTTL:CachePolicyConfig' :: Integer
minTTL = Integer
pMinTTL_
    }

-- | The maximum amount of time, in seconds, that objects stay in the
-- CloudFront cache before CloudFront sends another request to the origin
-- to see if the object has been updated. CloudFront uses this value only
-- when the origin sends @Cache-Control@ or @Expires@ headers with the
-- object. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html Managing How Long Content Stays in an Edge Cache (Expiration)>
-- in the /Amazon CloudFront Developer Guide/.
--
-- The default value for this field is 31536000 seconds (one year). If the
-- value of @MinTTL@ or @DefaultTTL@ is more than 31536000 seconds, then
-- the default value for this field is the same as the value of
-- @DefaultTTL@.
cachePolicyConfig_maxTTL :: Lens.Lens' CachePolicyConfig (Prelude.Maybe Prelude.Integer)
cachePolicyConfig_maxTTL :: (Maybe Integer -> f (Maybe Integer))
-> CachePolicyConfig -> f CachePolicyConfig
cachePolicyConfig_maxTTL = (CachePolicyConfig -> Maybe Integer)
-> (CachePolicyConfig -> Maybe Integer -> CachePolicyConfig)
-> Lens
     CachePolicyConfig CachePolicyConfig (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicyConfig' {Maybe Integer
maxTTL :: Maybe Integer
$sel:maxTTL:CachePolicyConfig' :: CachePolicyConfig -> Maybe Integer
maxTTL} -> Maybe Integer
maxTTL) (\s :: CachePolicyConfig
s@CachePolicyConfig' {} Maybe Integer
a -> CachePolicyConfig
s {$sel:maxTTL:CachePolicyConfig' :: Maybe Integer
maxTTL = Maybe Integer
a} :: CachePolicyConfig)

-- | The HTTP headers, cookies, and URL query strings to include in the cache
-- key. The values included in the cache key are automatically included in
-- requests that CloudFront sends to the origin.
cachePolicyConfig_parametersInCacheKeyAndForwardedToOrigin :: Lens.Lens' CachePolicyConfig (Prelude.Maybe ParametersInCacheKeyAndForwardedToOrigin)
cachePolicyConfig_parametersInCacheKeyAndForwardedToOrigin :: (Maybe ParametersInCacheKeyAndForwardedToOrigin
 -> f (Maybe ParametersInCacheKeyAndForwardedToOrigin))
-> CachePolicyConfig -> f CachePolicyConfig
cachePolicyConfig_parametersInCacheKeyAndForwardedToOrigin = (CachePolicyConfig
 -> Maybe ParametersInCacheKeyAndForwardedToOrigin)
-> (CachePolicyConfig
    -> Maybe ParametersInCacheKeyAndForwardedToOrigin
    -> CachePolicyConfig)
-> Lens
     CachePolicyConfig
     CachePolicyConfig
     (Maybe ParametersInCacheKeyAndForwardedToOrigin)
     (Maybe ParametersInCacheKeyAndForwardedToOrigin)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicyConfig' {Maybe ParametersInCacheKeyAndForwardedToOrigin
parametersInCacheKeyAndForwardedToOrigin :: Maybe ParametersInCacheKeyAndForwardedToOrigin
$sel:parametersInCacheKeyAndForwardedToOrigin:CachePolicyConfig' :: CachePolicyConfig -> Maybe ParametersInCacheKeyAndForwardedToOrigin
parametersInCacheKeyAndForwardedToOrigin} -> Maybe ParametersInCacheKeyAndForwardedToOrigin
parametersInCacheKeyAndForwardedToOrigin) (\s :: CachePolicyConfig
s@CachePolicyConfig' {} Maybe ParametersInCacheKeyAndForwardedToOrigin
a -> CachePolicyConfig
s {$sel:parametersInCacheKeyAndForwardedToOrigin:CachePolicyConfig' :: Maybe ParametersInCacheKeyAndForwardedToOrigin
parametersInCacheKeyAndForwardedToOrigin = Maybe ParametersInCacheKeyAndForwardedToOrigin
a} :: CachePolicyConfig)

-- | The default amount of time, in seconds, that you want objects to stay in
-- the CloudFront cache before CloudFront sends another request to the
-- origin to see if the object has been updated. CloudFront uses this value
-- as the object’s time to live (TTL) only when the origin does /not/ send
-- @Cache-Control@ or @Expires@ headers with the object. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html Managing How Long Content Stays in an Edge Cache (Expiration)>
-- in the /Amazon CloudFront Developer Guide/.
--
-- The default value for this field is 86400 seconds (one day). If the
-- value of @MinTTL@ is more than 86400 seconds, then the default value for
-- this field is the same as the value of @MinTTL@.
cachePolicyConfig_defaultTTL :: Lens.Lens' CachePolicyConfig (Prelude.Maybe Prelude.Integer)
cachePolicyConfig_defaultTTL :: (Maybe Integer -> f (Maybe Integer))
-> CachePolicyConfig -> f CachePolicyConfig
cachePolicyConfig_defaultTTL = (CachePolicyConfig -> Maybe Integer)
-> (CachePolicyConfig -> Maybe Integer -> CachePolicyConfig)
-> Lens
     CachePolicyConfig CachePolicyConfig (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicyConfig' {Maybe Integer
defaultTTL :: Maybe Integer
$sel:defaultTTL:CachePolicyConfig' :: CachePolicyConfig -> Maybe Integer
defaultTTL} -> Maybe Integer
defaultTTL) (\s :: CachePolicyConfig
s@CachePolicyConfig' {} Maybe Integer
a -> CachePolicyConfig
s {$sel:defaultTTL:CachePolicyConfig' :: Maybe Integer
defaultTTL = Maybe Integer
a} :: CachePolicyConfig)

-- | A comment to describe the cache policy. The comment cannot be longer
-- than 128 characters.
cachePolicyConfig_comment :: Lens.Lens' CachePolicyConfig (Prelude.Maybe Prelude.Text)
cachePolicyConfig_comment :: (Maybe Text -> f (Maybe Text))
-> CachePolicyConfig -> f CachePolicyConfig
cachePolicyConfig_comment = (CachePolicyConfig -> Maybe Text)
-> (CachePolicyConfig -> Maybe Text -> CachePolicyConfig)
-> Lens
     CachePolicyConfig CachePolicyConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicyConfig' {Maybe Text
comment :: Maybe Text
$sel:comment:CachePolicyConfig' :: CachePolicyConfig -> Maybe Text
comment} -> Maybe Text
comment) (\s :: CachePolicyConfig
s@CachePolicyConfig' {} Maybe Text
a -> CachePolicyConfig
s {$sel:comment:CachePolicyConfig' :: Maybe Text
comment = Maybe Text
a} :: CachePolicyConfig)

-- | A unique name to identify the cache policy.
cachePolicyConfig_name :: Lens.Lens' CachePolicyConfig Prelude.Text
cachePolicyConfig_name :: (Text -> f Text) -> CachePolicyConfig -> f CachePolicyConfig
cachePolicyConfig_name = (CachePolicyConfig -> Text)
-> (CachePolicyConfig -> Text -> CachePolicyConfig)
-> Lens CachePolicyConfig CachePolicyConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicyConfig' {Text
name :: Text
$sel:name:CachePolicyConfig' :: CachePolicyConfig -> Text
name} -> Text
name) (\s :: CachePolicyConfig
s@CachePolicyConfig' {} Text
a -> CachePolicyConfig
s {$sel:name:CachePolicyConfig' :: Text
name = Text
a} :: CachePolicyConfig)

-- | The minimum amount of time, in seconds, that you want objects to stay in
-- the CloudFront cache before CloudFront sends another request to the
-- origin to see if the object has been updated. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html Managing How Long Content Stays in an Edge Cache (Expiration)>
-- in the /Amazon CloudFront Developer Guide/.
cachePolicyConfig_minTTL :: Lens.Lens' CachePolicyConfig Prelude.Integer
cachePolicyConfig_minTTL :: (Integer -> f Integer) -> CachePolicyConfig -> f CachePolicyConfig
cachePolicyConfig_minTTL = (CachePolicyConfig -> Integer)
-> (CachePolicyConfig -> Integer -> CachePolicyConfig)
-> Lens CachePolicyConfig CachePolicyConfig Integer Integer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicyConfig' {Integer
minTTL :: Integer
$sel:minTTL:CachePolicyConfig' :: CachePolicyConfig -> Integer
minTTL} -> Integer
minTTL) (\s :: CachePolicyConfig
s@CachePolicyConfig' {} Integer
a -> CachePolicyConfig
s {$sel:minTTL:CachePolicyConfig' :: Integer
minTTL = Integer
a} :: CachePolicyConfig)

instance Core.FromXML CachePolicyConfig where
  parseXML :: [Node] -> Either String CachePolicyConfig
parseXML [Node]
x =
    Maybe Integer
-> Maybe ParametersInCacheKeyAndForwardedToOrigin
-> Maybe Integer
-> Maybe Text
-> Text
-> Integer
-> CachePolicyConfig
CachePolicyConfig'
      (Maybe Integer
 -> Maybe ParametersInCacheKeyAndForwardedToOrigin
 -> Maybe Integer
 -> Maybe Text
 -> Text
 -> Integer
 -> CachePolicyConfig)
-> Either String (Maybe Integer)
-> Either
     String
     (Maybe ParametersInCacheKeyAndForwardedToOrigin
      -> Maybe Integer
      -> Maybe Text
      -> Text
      -> Integer
      -> CachePolicyConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MaxTTL")
      Either
  String
  (Maybe ParametersInCacheKeyAndForwardedToOrigin
   -> Maybe Integer
   -> Maybe Text
   -> Text
   -> Integer
   -> CachePolicyConfig)
-> Either String (Maybe ParametersInCacheKeyAndForwardedToOrigin)
-> Either
     String
     (Maybe Integer
      -> Maybe Text -> Text -> Integer -> CachePolicyConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      [Node]
-> Text
-> Either String (Maybe ParametersInCacheKeyAndForwardedToOrigin)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ParametersInCacheKeyAndForwardedToOrigin"
                  )
      Either
  String
  (Maybe Integer
   -> Maybe Text -> Text -> Integer -> CachePolicyConfig)
-> Either String (Maybe Integer)
-> Either
     String (Maybe Text -> Text -> Integer -> CachePolicyConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DefaultTTL")
      Either String (Maybe Text -> Text -> Integer -> CachePolicyConfig)
-> Either String (Maybe Text)
-> Either String (Text -> Integer -> CachePolicyConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Comment")
      Either String (Text -> Integer -> CachePolicyConfig)
-> Either String Text
-> Either String (Integer -> CachePolicyConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Name")
      Either String (Integer -> CachePolicyConfig)
-> Either String Integer -> Either String CachePolicyConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Integer
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"MinTTL")

instance Prelude.Hashable CachePolicyConfig

instance Prelude.NFData CachePolicyConfig

instance Core.ToXML CachePolicyConfig where
  toXML :: CachePolicyConfig -> XML
toXML CachePolicyConfig' {Integer
Maybe Integer
Maybe Text
Maybe ParametersInCacheKeyAndForwardedToOrigin
Text
minTTL :: Integer
name :: Text
comment :: Maybe Text
defaultTTL :: Maybe Integer
parametersInCacheKeyAndForwardedToOrigin :: Maybe ParametersInCacheKeyAndForwardedToOrigin
maxTTL :: Maybe Integer
$sel:minTTL:CachePolicyConfig' :: CachePolicyConfig -> Integer
$sel:name:CachePolicyConfig' :: CachePolicyConfig -> Text
$sel:comment:CachePolicyConfig' :: CachePolicyConfig -> Maybe Text
$sel:defaultTTL:CachePolicyConfig' :: CachePolicyConfig -> Maybe Integer
$sel:parametersInCacheKeyAndForwardedToOrigin:CachePolicyConfig' :: CachePolicyConfig -> Maybe ParametersInCacheKeyAndForwardedToOrigin
$sel:maxTTL:CachePolicyConfig' :: CachePolicyConfig -> Maybe Integer
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"MaxTTL" Name -> Maybe Integer -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Integer
maxTTL,
        Name
"ParametersInCacheKeyAndForwardedToOrigin"
          Name -> Maybe ParametersInCacheKeyAndForwardedToOrigin -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe ParametersInCacheKeyAndForwardedToOrigin
parametersInCacheKeyAndForwardedToOrigin,
        Name
"DefaultTTL" Name -> Maybe Integer -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Integer
defaultTTL,
        Name
"Comment" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
comment,
        Name
"Name" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
name,
        Name
"MinTTL" Name -> Integer -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Integer
minTTL
      ]