{-# 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.Lightsail.Types.CacheSettings
-- 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.Lightsail.Types.CacheSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types.CookieObject
import Amazonka.Lightsail.Types.HeaderObject
import Amazonka.Lightsail.Types.QueryStringObject
import qualified Amazonka.Prelude as Prelude

-- | Describes the cache settings of an Amazon Lightsail content delivery
-- network (CDN) distribution.
--
-- These settings apply only to your distribution\'s @cacheBehaviors@
-- (including the @defaultCacheBehavior@) that have a @behavior@ of
-- @cache@.
--
-- /See:/ 'newCacheSettings' smart constructor.
data CacheSettings = CacheSettings'
  { -- | The maximum amount of time that objects stay in the distribution\'s
    -- cache before the distribution forwards another request to the origin to
    -- determine whether the object has been updated.
    --
    -- The value specified applies only when the origin adds HTTP headers such
    -- as @Cache-Control max-age@, @Cache-Control s-maxage@, and @Expires@ to
    -- objects.
    CacheSettings -> Maybe Integer
maximumTTL :: Prelude.Maybe Prelude.Integer,
    -- | The HTTP method responses that are cached by your distribution.
    --
    -- You can specify the following options:
    --
    -- -   @GET,HEAD@ - The distribution caches responses to the @GET@ and
    --     @HEAD@ methods.
    --
    -- -   @GET,HEAD,OPTIONS@ - The distribution caches responses to the @GET@,
    --     @HEAD@, and @OPTIONS@ methods.
    CacheSettings -> Maybe Text
cachedHTTPMethods :: Prelude.Maybe Prelude.Text,
    -- | An object that describes the cookies that are forwarded to the origin.
    -- Your content is cached based on the cookies that are forwarded.
    CacheSettings -> Maybe CookieObject
forwardedCookies :: Prelude.Maybe CookieObject,
    -- | The HTTP methods that are processed and forwarded to the distribution\'s
    -- origin.
    --
    -- You can specify the following options:
    --
    -- -   @GET,HEAD@ - The distribution forwards the @GET@ and @HEAD@ methods.
    --
    -- -   @GET,HEAD,OPTIONS@ - The distribution forwards the @GET@, @HEAD@,
    --     and @OPTIONS@ methods.
    --
    -- -   @GET,HEAD,OPTIONS,PUT,PATCH,POST,DELETE@ - The distribution forwards
    --     the @GET@, @HEAD@, @OPTIONS@, @PUT@, @PATCH@, @POST@, and @DELETE@
    --     methods.
    --
    -- If you specify the third option, you might need to restrict access to
    -- your distribution\'s origin so users can\'t perform operations that you
    -- don\'t want them to. For example, you might not want users to have
    -- permission to delete objects from your origin.
    CacheSettings -> Maybe Text
allowedHTTPMethods :: Prelude.Maybe Prelude.Text,
    -- | The default amount of time that objects stay in the distribution\'s
    -- cache before the distribution forwards another request to the origin to
    -- determine whether the content has been updated.
    --
    -- The value specified applies only when the origin does not add HTTP
    -- headers such as @Cache-Control max-age@, @Cache-Control s-maxage@, and
    -- @Expires@ to objects.
    CacheSettings -> Maybe Integer
defaultTTL :: Prelude.Maybe Prelude.Integer,
    -- | The minimum amount of time that objects stay in the distribution\'s
    -- cache before the distribution forwards another request to the origin to
    -- determine whether the object has been updated.
    --
    -- A value of @0@ must be specified for @minimumTTL@ if the distribution is
    -- configured to forward all headers to the origin.
    CacheSettings -> Maybe Integer
minimumTTL :: Prelude.Maybe Prelude.Integer,
    -- | An object that describes the headers that are forwarded to the origin.
    -- Your content is cached based on the headers that are forwarded.
    CacheSettings -> Maybe HeaderObject
forwardedHeaders :: Prelude.Maybe HeaderObject,
    -- | An object that describes the query strings that are forwarded to the
    -- origin. Your content is cached based on the query strings that are
    -- forwarded.
    CacheSettings -> Maybe QueryStringObject
forwardedQueryStrings :: Prelude.Maybe QueryStringObject
  }
  deriving (CacheSettings -> CacheSettings -> Bool
(CacheSettings -> CacheSettings -> Bool)
-> (CacheSettings -> CacheSettings -> Bool) -> Eq CacheSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CacheSettings -> CacheSettings -> Bool
$c/= :: CacheSettings -> CacheSettings -> Bool
== :: CacheSettings -> CacheSettings -> Bool
$c== :: CacheSettings -> CacheSettings -> Bool
Prelude.Eq, ReadPrec [CacheSettings]
ReadPrec CacheSettings
Int -> ReadS CacheSettings
ReadS [CacheSettings]
(Int -> ReadS CacheSettings)
-> ReadS [CacheSettings]
-> ReadPrec CacheSettings
-> ReadPrec [CacheSettings]
-> Read CacheSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CacheSettings]
$creadListPrec :: ReadPrec [CacheSettings]
readPrec :: ReadPrec CacheSettings
$creadPrec :: ReadPrec CacheSettings
readList :: ReadS [CacheSettings]
$creadList :: ReadS [CacheSettings]
readsPrec :: Int -> ReadS CacheSettings
$creadsPrec :: Int -> ReadS CacheSettings
Prelude.Read, Int -> CacheSettings -> ShowS
[CacheSettings] -> ShowS
CacheSettings -> String
(Int -> CacheSettings -> ShowS)
-> (CacheSettings -> String)
-> ([CacheSettings] -> ShowS)
-> Show CacheSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CacheSettings] -> ShowS
$cshowList :: [CacheSettings] -> ShowS
show :: CacheSettings -> String
$cshow :: CacheSettings -> String
showsPrec :: Int -> CacheSettings -> ShowS
$cshowsPrec :: Int -> CacheSettings -> ShowS
Prelude.Show, (forall x. CacheSettings -> Rep CacheSettings x)
-> (forall x. Rep CacheSettings x -> CacheSettings)
-> Generic CacheSettings
forall x. Rep CacheSettings x -> CacheSettings
forall x. CacheSettings -> Rep CacheSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CacheSettings x -> CacheSettings
$cfrom :: forall x. CacheSettings -> Rep CacheSettings x
Prelude.Generic)

-- |
-- Create a value of 'CacheSettings' 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:
--
-- 'maximumTTL', 'cacheSettings_maximumTTL' - The maximum amount of time that objects stay in the distribution\'s
-- cache before the distribution forwards another request to the origin to
-- determine whether the object has been updated.
--
-- The value specified applies only when the origin adds HTTP headers such
-- as @Cache-Control max-age@, @Cache-Control s-maxage@, and @Expires@ to
-- objects.
--
-- 'cachedHTTPMethods', 'cacheSettings_cachedHTTPMethods' - The HTTP method responses that are cached by your distribution.
--
-- You can specify the following options:
--
-- -   @GET,HEAD@ - The distribution caches responses to the @GET@ and
--     @HEAD@ methods.
--
-- -   @GET,HEAD,OPTIONS@ - The distribution caches responses to the @GET@,
--     @HEAD@, and @OPTIONS@ methods.
--
-- 'forwardedCookies', 'cacheSettings_forwardedCookies' - An object that describes the cookies that are forwarded to the origin.
-- Your content is cached based on the cookies that are forwarded.
--
-- 'allowedHTTPMethods', 'cacheSettings_allowedHTTPMethods' - The HTTP methods that are processed and forwarded to the distribution\'s
-- origin.
--
-- You can specify the following options:
--
-- -   @GET,HEAD@ - The distribution forwards the @GET@ and @HEAD@ methods.
--
-- -   @GET,HEAD,OPTIONS@ - The distribution forwards the @GET@, @HEAD@,
--     and @OPTIONS@ methods.
--
-- -   @GET,HEAD,OPTIONS,PUT,PATCH,POST,DELETE@ - The distribution forwards
--     the @GET@, @HEAD@, @OPTIONS@, @PUT@, @PATCH@, @POST@, and @DELETE@
--     methods.
--
-- If you specify the third option, you might need to restrict access to
-- your distribution\'s origin so users can\'t perform operations that you
-- don\'t want them to. For example, you might not want users to have
-- permission to delete objects from your origin.
--
-- 'defaultTTL', 'cacheSettings_defaultTTL' - The default amount of time that objects stay in the distribution\'s
-- cache before the distribution forwards another request to the origin to
-- determine whether the content has been updated.
--
-- The value specified applies only when the origin does not add HTTP
-- headers such as @Cache-Control max-age@, @Cache-Control s-maxage@, and
-- @Expires@ to objects.
--
-- 'minimumTTL', 'cacheSettings_minimumTTL' - The minimum amount of time that objects stay in the distribution\'s
-- cache before the distribution forwards another request to the origin to
-- determine whether the object has been updated.
--
-- A value of @0@ must be specified for @minimumTTL@ if the distribution is
-- configured to forward all headers to the origin.
--
-- 'forwardedHeaders', 'cacheSettings_forwardedHeaders' - An object that describes the headers that are forwarded to the origin.
-- Your content is cached based on the headers that are forwarded.
--
-- 'forwardedQueryStrings', 'cacheSettings_forwardedQueryStrings' - An object that describes the query strings that are forwarded to the
-- origin. Your content is cached based on the query strings that are
-- forwarded.
newCacheSettings ::
  CacheSettings
newCacheSettings :: CacheSettings
newCacheSettings =
  CacheSettings' :: Maybe Integer
-> Maybe Text
-> Maybe CookieObject
-> Maybe Text
-> Maybe Integer
-> Maybe Integer
-> Maybe HeaderObject
-> Maybe QueryStringObject
-> CacheSettings
CacheSettings'
    { $sel:maximumTTL:CacheSettings' :: Maybe Integer
maximumTTL = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:cachedHTTPMethods:CacheSettings' :: Maybe Text
cachedHTTPMethods = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:forwardedCookies:CacheSettings' :: Maybe CookieObject
forwardedCookies = Maybe CookieObject
forall a. Maybe a
Prelude.Nothing,
      $sel:allowedHTTPMethods:CacheSettings' :: Maybe Text
allowedHTTPMethods = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultTTL:CacheSettings' :: Maybe Integer
defaultTTL = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:minimumTTL:CacheSettings' :: Maybe Integer
minimumTTL = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:forwardedHeaders:CacheSettings' :: Maybe HeaderObject
forwardedHeaders = Maybe HeaderObject
forall a. Maybe a
Prelude.Nothing,
      $sel:forwardedQueryStrings:CacheSettings' :: Maybe QueryStringObject
forwardedQueryStrings = Maybe QueryStringObject
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum amount of time that objects stay in the distribution\'s
-- cache before the distribution forwards another request to the origin to
-- determine whether the object has been updated.
--
-- The value specified applies only when the origin adds HTTP headers such
-- as @Cache-Control max-age@, @Cache-Control s-maxage@, and @Expires@ to
-- objects.
cacheSettings_maximumTTL :: Lens.Lens' CacheSettings (Prelude.Maybe Prelude.Integer)
cacheSettings_maximumTTL :: (Maybe Integer -> f (Maybe Integer))
-> CacheSettings -> f CacheSettings
cacheSettings_maximumTTL = (CacheSettings -> Maybe Integer)
-> (CacheSettings -> Maybe Integer -> CacheSettings)
-> Lens CacheSettings CacheSettings (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSettings' {Maybe Integer
maximumTTL :: Maybe Integer
$sel:maximumTTL:CacheSettings' :: CacheSettings -> Maybe Integer
maximumTTL} -> Maybe Integer
maximumTTL) (\s :: CacheSettings
s@CacheSettings' {} Maybe Integer
a -> CacheSettings
s {$sel:maximumTTL:CacheSettings' :: Maybe Integer
maximumTTL = Maybe Integer
a} :: CacheSettings)

-- | The HTTP method responses that are cached by your distribution.
--
-- You can specify the following options:
--
-- -   @GET,HEAD@ - The distribution caches responses to the @GET@ and
--     @HEAD@ methods.
--
-- -   @GET,HEAD,OPTIONS@ - The distribution caches responses to the @GET@,
--     @HEAD@, and @OPTIONS@ methods.
cacheSettings_cachedHTTPMethods :: Lens.Lens' CacheSettings (Prelude.Maybe Prelude.Text)
cacheSettings_cachedHTTPMethods :: (Maybe Text -> f (Maybe Text)) -> CacheSettings -> f CacheSettings
cacheSettings_cachedHTTPMethods = (CacheSettings -> Maybe Text)
-> (CacheSettings -> Maybe Text -> CacheSettings)
-> Lens CacheSettings CacheSettings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSettings' {Maybe Text
cachedHTTPMethods :: Maybe Text
$sel:cachedHTTPMethods:CacheSettings' :: CacheSettings -> Maybe Text
cachedHTTPMethods} -> Maybe Text
cachedHTTPMethods) (\s :: CacheSettings
s@CacheSettings' {} Maybe Text
a -> CacheSettings
s {$sel:cachedHTTPMethods:CacheSettings' :: Maybe Text
cachedHTTPMethods = Maybe Text
a} :: CacheSettings)

-- | An object that describes the cookies that are forwarded to the origin.
-- Your content is cached based on the cookies that are forwarded.
cacheSettings_forwardedCookies :: Lens.Lens' CacheSettings (Prelude.Maybe CookieObject)
cacheSettings_forwardedCookies :: (Maybe CookieObject -> f (Maybe CookieObject))
-> CacheSettings -> f CacheSettings
cacheSettings_forwardedCookies = (CacheSettings -> Maybe CookieObject)
-> (CacheSettings -> Maybe CookieObject -> CacheSettings)
-> Lens
     CacheSettings
     CacheSettings
     (Maybe CookieObject)
     (Maybe CookieObject)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSettings' {Maybe CookieObject
forwardedCookies :: Maybe CookieObject
$sel:forwardedCookies:CacheSettings' :: CacheSettings -> Maybe CookieObject
forwardedCookies} -> Maybe CookieObject
forwardedCookies) (\s :: CacheSettings
s@CacheSettings' {} Maybe CookieObject
a -> CacheSettings
s {$sel:forwardedCookies:CacheSettings' :: Maybe CookieObject
forwardedCookies = Maybe CookieObject
a} :: CacheSettings)

-- | The HTTP methods that are processed and forwarded to the distribution\'s
-- origin.
--
-- You can specify the following options:
--
-- -   @GET,HEAD@ - The distribution forwards the @GET@ and @HEAD@ methods.
--
-- -   @GET,HEAD,OPTIONS@ - The distribution forwards the @GET@, @HEAD@,
--     and @OPTIONS@ methods.
--
-- -   @GET,HEAD,OPTIONS,PUT,PATCH,POST,DELETE@ - The distribution forwards
--     the @GET@, @HEAD@, @OPTIONS@, @PUT@, @PATCH@, @POST@, and @DELETE@
--     methods.
--
-- If you specify the third option, you might need to restrict access to
-- your distribution\'s origin so users can\'t perform operations that you
-- don\'t want them to. For example, you might not want users to have
-- permission to delete objects from your origin.
cacheSettings_allowedHTTPMethods :: Lens.Lens' CacheSettings (Prelude.Maybe Prelude.Text)
cacheSettings_allowedHTTPMethods :: (Maybe Text -> f (Maybe Text)) -> CacheSettings -> f CacheSettings
cacheSettings_allowedHTTPMethods = (CacheSettings -> Maybe Text)
-> (CacheSettings -> Maybe Text -> CacheSettings)
-> Lens CacheSettings CacheSettings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSettings' {Maybe Text
allowedHTTPMethods :: Maybe Text
$sel:allowedHTTPMethods:CacheSettings' :: CacheSettings -> Maybe Text
allowedHTTPMethods} -> Maybe Text
allowedHTTPMethods) (\s :: CacheSettings
s@CacheSettings' {} Maybe Text
a -> CacheSettings
s {$sel:allowedHTTPMethods:CacheSettings' :: Maybe Text
allowedHTTPMethods = Maybe Text
a} :: CacheSettings)

-- | The default amount of time that objects stay in the distribution\'s
-- cache before the distribution forwards another request to the origin to
-- determine whether the content has been updated.
--
-- The value specified applies only when the origin does not add HTTP
-- headers such as @Cache-Control max-age@, @Cache-Control s-maxage@, and
-- @Expires@ to objects.
cacheSettings_defaultTTL :: Lens.Lens' CacheSettings (Prelude.Maybe Prelude.Integer)
cacheSettings_defaultTTL :: (Maybe Integer -> f (Maybe Integer))
-> CacheSettings -> f CacheSettings
cacheSettings_defaultTTL = (CacheSettings -> Maybe Integer)
-> (CacheSettings -> Maybe Integer -> CacheSettings)
-> Lens CacheSettings CacheSettings (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSettings' {Maybe Integer
defaultTTL :: Maybe Integer
$sel:defaultTTL:CacheSettings' :: CacheSettings -> Maybe Integer
defaultTTL} -> Maybe Integer
defaultTTL) (\s :: CacheSettings
s@CacheSettings' {} Maybe Integer
a -> CacheSettings
s {$sel:defaultTTL:CacheSettings' :: Maybe Integer
defaultTTL = Maybe Integer
a} :: CacheSettings)

-- | The minimum amount of time that objects stay in the distribution\'s
-- cache before the distribution forwards another request to the origin to
-- determine whether the object has been updated.
--
-- A value of @0@ must be specified for @minimumTTL@ if the distribution is
-- configured to forward all headers to the origin.
cacheSettings_minimumTTL :: Lens.Lens' CacheSettings (Prelude.Maybe Prelude.Integer)
cacheSettings_minimumTTL :: (Maybe Integer -> f (Maybe Integer))
-> CacheSettings -> f CacheSettings
cacheSettings_minimumTTL = (CacheSettings -> Maybe Integer)
-> (CacheSettings -> Maybe Integer -> CacheSettings)
-> Lens CacheSettings CacheSettings (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSettings' {Maybe Integer
minimumTTL :: Maybe Integer
$sel:minimumTTL:CacheSettings' :: CacheSettings -> Maybe Integer
minimumTTL} -> Maybe Integer
minimumTTL) (\s :: CacheSettings
s@CacheSettings' {} Maybe Integer
a -> CacheSettings
s {$sel:minimumTTL:CacheSettings' :: Maybe Integer
minimumTTL = Maybe Integer
a} :: CacheSettings)

-- | An object that describes the headers that are forwarded to the origin.
-- Your content is cached based on the headers that are forwarded.
cacheSettings_forwardedHeaders :: Lens.Lens' CacheSettings (Prelude.Maybe HeaderObject)
cacheSettings_forwardedHeaders :: (Maybe HeaderObject -> f (Maybe HeaderObject))
-> CacheSettings -> f CacheSettings
cacheSettings_forwardedHeaders = (CacheSettings -> Maybe HeaderObject)
-> (CacheSettings -> Maybe HeaderObject -> CacheSettings)
-> Lens
     CacheSettings
     CacheSettings
     (Maybe HeaderObject)
     (Maybe HeaderObject)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSettings' {Maybe HeaderObject
forwardedHeaders :: Maybe HeaderObject
$sel:forwardedHeaders:CacheSettings' :: CacheSettings -> Maybe HeaderObject
forwardedHeaders} -> Maybe HeaderObject
forwardedHeaders) (\s :: CacheSettings
s@CacheSettings' {} Maybe HeaderObject
a -> CacheSettings
s {$sel:forwardedHeaders:CacheSettings' :: Maybe HeaderObject
forwardedHeaders = Maybe HeaderObject
a} :: CacheSettings)

-- | An object that describes the query strings that are forwarded to the
-- origin. Your content is cached based on the query strings that are
-- forwarded.
cacheSettings_forwardedQueryStrings :: Lens.Lens' CacheSettings (Prelude.Maybe QueryStringObject)
cacheSettings_forwardedQueryStrings :: (Maybe QueryStringObject -> f (Maybe QueryStringObject))
-> CacheSettings -> f CacheSettings
cacheSettings_forwardedQueryStrings = (CacheSettings -> Maybe QueryStringObject)
-> (CacheSettings -> Maybe QueryStringObject -> CacheSettings)
-> Lens
     CacheSettings
     CacheSettings
     (Maybe QueryStringObject)
     (Maybe QueryStringObject)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSettings' {Maybe QueryStringObject
forwardedQueryStrings :: Maybe QueryStringObject
$sel:forwardedQueryStrings:CacheSettings' :: CacheSettings -> Maybe QueryStringObject
forwardedQueryStrings} -> Maybe QueryStringObject
forwardedQueryStrings) (\s :: CacheSettings
s@CacheSettings' {} Maybe QueryStringObject
a -> CacheSettings
s {$sel:forwardedQueryStrings:CacheSettings' :: Maybe QueryStringObject
forwardedQueryStrings = Maybe QueryStringObject
a} :: CacheSettings)

instance Core.FromJSON CacheSettings where
  parseJSON :: Value -> Parser CacheSettings
parseJSON =
    String
-> (Object -> Parser CacheSettings)
-> Value
-> Parser CacheSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CacheSettings"
      ( \Object
x ->
          Maybe Integer
-> Maybe Text
-> Maybe CookieObject
-> Maybe Text
-> Maybe Integer
-> Maybe Integer
-> Maybe HeaderObject
-> Maybe QueryStringObject
-> CacheSettings
CacheSettings'
            (Maybe Integer
 -> Maybe Text
 -> Maybe CookieObject
 -> Maybe Text
 -> Maybe Integer
 -> Maybe Integer
 -> Maybe HeaderObject
 -> Maybe QueryStringObject
 -> CacheSettings)
-> Parser (Maybe Integer)
-> Parser
     (Maybe Text
      -> Maybe CookieObject
      -> Maybe Text
      -> Maybe Integer
      -> Maybe Integer
      -> Maybe HeaderObject
      -> Maybe QueryStringObject
      -> CacheSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"maximumTTL")
            Parser
  (Maybe Text
   -> Maybe CookieObject
   -> Maybe Text
   -> Maybe Integer
   -> Maybe Integer
   -> Maybe HeaderObject
   -> Maybe QueryStringObject
   -> CacheSettings)
-> Parser (Maybe Text)
-> Parser
     (Maybe CookieObject
      -> Maybe Text
      -> Maybe Integer
      -> Maybe Integer
      -> Maybe HeaderObject
      -> Maybe QueryStringObject
      -> CacheSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"cachedHTTPMethods")
            Parser
  (Maybe CookieObject
   -> Maybe Text
   -> Maybe Integer
   -> Maybe Integer
   -> Maybe HeaderObject
   -> Maybe QueryStringObject
   -> CacheSettings)
-> Parser (Maybe CookieObject)
-> Parser
     (Maybe Text
      -> Maybe Integer
      -> Maybe Integer
      -> Maybe HeaderObject
      -> Maybe QueryStringObject
      -> CacheSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CookieObject)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"forwardedCookies")
            Parser
  (Maybe Text
   -> Maybe Integer
   -> Maybe Integer
   -> Maybe HeaderObject
   -> Maybe QueryStringObject
   -> CacheSettings)
-> Parser (Maybe Text)
-> Parser
     (Maybe Integer
      -> Maybe Integer
      -> Maybe HeaderObject
      -> Maybe QueryStringObject
      -> CacheSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"allowedHTTPMethods")
            Parser
  (Maybe Integer
   -> Maybe Integer
   -> Maybe HeaderObject
   -> Maybe QueryStringObject
   -> CacheSettings)
-> Parser (Maybe Integer)
-> Parser
     (Maybe Integer
      -> Maybe HeaderObject -> Maybe QueryStringObject -> CacheSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"defaultTTL")
            Parser
  (Maybe Integer
   -> Maybe HeaderObject -> Maybe QueryStringObject -> CacheSettings)
-> Parser (Maybe Integer)
-> Parser
     (Maybe HeaderObject -> Maybe QueryStringObject -> CacheSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"minimumTTL")
            Parser
  (Maybe HeaderObject -> Maybe QueryStringObject -> CacheSettings)
-> Parser (Maybe HeaderObject)
-> Parser (Maybe QueryStringObject -> CacheSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HeaderObject)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"forwardedHeaders")
            Parser (Maybe QueryStringObject -> CacheSettings)
-> Parser (Maybe QueryStringObject) -> Parser CacheSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe QueryStringObject)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"forwardedQueryStrings")
      )

instance Prelude.Hashable CacheSettings

instance Prelude.NFData CacheSettings

instance Core.ToJSON CacheSettings where
  toJSON :: CacheSettings -> Value
toJSON CacheSettings' {Maybe Integer
Maybe Text
Maybe CookieObject
Maybe HeaderObject
Maybe QueryStringObject
forwardedQueryStrings :: Maybe QueryStringObject
forwardedHeaders :: Maybe HeaderObject
minimumTTL :: Maybe Integer
defaultTTL :: Maybe Integer
allowedHTTPMethods :: Maybe Text
forwardedCookies :: Maybe CookieObject
cachedHTTPMethods :: Maybe Text
maximumTTL :: Maybe Integer
$sel:forwardedQueryStrings:CacheSettings' :: CacheSettings -> Maybe QueryStringObject
$sel:forwardedHeaders:CacheSettings' :: CacheSettings -> Maybe HeaderObject
$sel:minimumTTL:CacheSettings' :: CacheSettings -> Maybe Integer
$sel:defaultTTL:CacheSettings' :: CacheSettings -> Maybe Integer
$sel:allowedHTTPMethods:CacheSettings' :: CacheSettings -> Maybe Text
$sel:forwardedCookies:CacheSettings' :: CacheSettings -> Maybe CookieObject
$sel:cachedHTTPMethods:CacheSettings' :: CacheSettings -> Maybe Text
$sel:maximumTTL:CacheSettings' :: CacheSettings -> Maybe Integer
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"maximumTTL" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
maximumTTL,
            (Text
"cachedHTTPMethods" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
cachedHTTPMethods,
            (Text
"forwardedCookies" Text -> CookieObject -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CookieObject -> Pair) -> Maybe CookieObject -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CookieObject
forwardedCookies,
            (Text
"allowedHTTPMethods" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
allowedHTTPMethods,
            (Text
"defaultTTL" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
defaultTTL,
            (Text
"minimumTTL" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
minimumTTL,
            (Text
"forwardedHeaders" Text -> HeaderObject -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HeaderObject -> Pair) -> Maybe HeaderObject -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HeaderObject
forwardedHeaders,
            (Text
"forwardedQueryStrings" Text -> QueryStringObject -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (QueryStringObject -> Pair)
-> Maybe QueryStringObject -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe QueryStringObject
forwardedQueryStrings
          ]
      )