{-# 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.CachePolicyQueryStringsConfig
-- 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.CachePolicyQueryStringsConfig where

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

-- | An object that determines whether any URL query strings in viewer
-- requests (and if so, which query strings) are included in the cache key
-- and automatically included in requests that CloudFront sends to the
-- origin.
--
-- /See:/ 'newCachePolicyQueryStringsConfig' smart constructor.
data CachePolicyQueryStringsConfig = CachePolicyQueryStringsConfig'
  { -- | Contains the specific query strings in viewer requests that either
    -- /__are__/ or /__are not__/ included in the cache key and automatically
    -- included in requests that CloudFront sends to the origin. The behavior
    -- depends on whether the @QueryStringBehavior@ field in the
    -- @CachePolicyQueryStringsConfig@ type is set to @whitelist@ (the listed
    -- query strings /__are__/ included) or @allExcept@ (the listed query
    -- strings /__are not__/ included, but all other query strings are).
    CachePolicyQueryStringsConfig -> Maybe QueryStringNames
queryStrings :: Prelude.Maybe QueryStringNames,
    -- | Determines whether any URL query strings in viewer requests are included
    -- in the cache key and automatically included in requests that CloudFront
    -- sends to the origin. Valid values are:
    --
    -- -   @none@ – Query strings in viewer requests are not included in the
    --     cache key and are not automatically included in requests that
    --     CloudFront sends to the origin. Even when this field is set to
    --     @none@, any query strings that are listed in an
    --     @OriginRequestPolicy@ /are/ included in origin requests.
    --
    -- -   @whitelist@ – The query strings in viewer requests that are listed
    --     in the @QueryStringNames@ type are included in the cache key and
    --     automatically included in requests that CloudFront sends to the
    --     origin.
    --
    -- -   @allExcept@ – All query strings in viewer requests that are
    --     /__not__/ listed in the @QueryStringNames@ type are included in the
    --     cache key and automatically included in requests that CloudFront
    --     sends to the origin.
    --
    -- -   @all@ – All query strings in viewer requests are included in the
    --     cache key and are automatically included in requests that CloudFront
    --     sends to the origin.
    CachePolicyQueryStringsConfig -> CachePolicyQueryStringBehavior
queryStringBehavior :: CachePolicyQueryStringBehavior
  }
  deriving (CachePolicyQueryStringsConfig
-> CachePolicyQueryStringsConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CachePolicyQueryStringsConfig
-> CachePolicyQueryStringsConfig -> Bool
$c/= :: CachePolicyQueryStringsConfig
-> CachePolicyQueryStringsConfig -> Bool
== :: CachePolicyQueryStringsConfig
-> CachePolicyQueryStringsConfig -> Bool
$c== :: CachePolicyQueryStringsConfig
-> CachePolicyQueryStringsConfig -> Bool
Prelude.Eq, ReadPrec [CachePolicyQueryStringsConfig]
ReadPrec CachePolicyQueryStringsConfig
Int -> ReadS CachePolicyQueryStringsConfig
ReadS [CachePolicyQueryStringsConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CachePolicyQueryStringsConfig]
$creadListPrec :: ReadPrec [CachePolicyQueryStringsConfig]
readPrec :: ReadPrec CachePolicyQueryStringsConfig
$creadPrec :: ReadPrec CachePolicyQueryStringsConfig
readList :: ReadS [CachePolicyQueryStringsConfig]
$creadList :: ReadS [CachePolicyQueryStringsConfig]
readsPrec :: Int -> ReadS CachePolicyQueryStringsConfig
$creadsPrec :: Int -> ReadS CachePolicyQueryStringsConfig
Prelude.Read, Int -> CachePolicyQueryStringsConfig -> ShowS
[CachePolicyQueryStringsConfig] -> ShowS
CachePolicyQueryStringsConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CachePolicyQueryStringsConfig] -> ShowS
$cshowList :: [CachePolicyQueryStringsConfig] -> ShowS
show :: CachePolicyQueryStringsConfig -> String
$cshow :: CachePolicyQueryStringsConfig -> String
showsPrec :: Int -> CachePolicyQueryStringsConfig -> ShowS
$cshowsPrec :: Int -> CachePolicyQueryStringsConfig -> ShowS
Prelude.Show, forall x.
Rep CachePolicyQueryStringsConfig x
-> CachePolicyQueryStringsConfig
forall x.
CachePolicyQueryStringsConfig
-> Rep CachePolicyQueryStringsConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CachePolicyQueryStringsConfig x
-> CachePolicyQueryStringsConfig
$cfrom :: forall x.
CachePolicyQueryStringsConfig
-> Rep CachePolicyQueryStringsConfig x
Prelude.Generic)

-- |
-- Create a value of 'CachePolicyQueryStringsConfig' 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:
--
-- 'queryStrings', 'cachePolicyQueryStringsConfig_queryStrings' - Contains the specific query strings in viewer requests that either
-- /__are__/ or /__are not__/ included in the cache key and automatically
-- included in requests that CloudFront sends to the origin. The behavior
-- depends on whether the @QueryStringBehavior@ field in the
-- @CachePolicyQueryStringsConfig@ type is set to @whitelist@ (the listed
-- query strings /__are__/ included) or @allExcept@ (the listed query
-- strings /__are not__/ included, but all other query strings are).
--
-- 'queryStringBehavior', 'cachePolicyQueryStringsConfig_queryStringBehavior' - Determines whether any URL query strings in viewer requests are included
-- in the cache key and automatically included in requests that CloudFront
-- sends to the origin. Valid values are:
--
-- -   @none@ – Query strings in viewer requests are not included in the
--     cache key and are not automatically included in requests that
--     CloudFront sends to the origin. Even when this field is set to
--     @none@, any query strings that are listed in an
--     @OriginRequestPolicy@ /are/ included in origin requests.
--
-- -   @whitelist@ – The query strings in viewer requests that are listed
--     in the @QueryStringNames@ type are included in the cache key and
--     automatically included in requests that CloudFront sends to the
--     origin.
--
-- -   @allExcept@ – All query strings in viewer requests that are
--     /__not__/ listed in the @QueryStringNames@ type are included in the
--     cache key and automatically included in requests that CloudFront
--     sends to the origin.
--
-- -   @all@ – All query strings in viewer requests are included in the
--     cache key and are automatically included in requests that CloudFront
--     sends to the origin.
newCachePolicyQueryStringsConfig ::
  -- | 'queryStringBehavior'
  CachePolicyQueryStringBehavior ->
  CachePolicyQueryStringsConfig
newCachePolicyQueryStringsConfig :: CachePolicyQueryStringBehavior -> CachePolicyQueryStringsConfig
newCachePolicyQueryStringsConfig
  CachePolicyQueryStringBehavior
pQueryStringBehavior_ =
    CachePolicyQueryStringsConfig'
      { $sel:queryStrings:CachePolicyQueryStringsConfig' :: Maybe QueryStringNames
queryStrings =
          forall a. Maybe a
Prelude.Nothing,
        $sel:queryStringBehavior:CachePolicyQueryStringsConfig' :: CachePolicyQueryStringBehavior
queryStringBehavior = CachePolicyQueryStringBehavior
pQueryStringBehavior_
      }

-- | Contains the specific query strings in viewer requests that either
-- /__are__/ or /__are not__/ included in the cache key and automatically
-- included in requests that CloudFront sends to the origin. The behavior
-- depends on whether the @QueryStringBehavior@ field in the
-- @CachePolicyQueryStringsConfig@ type is set to @whitelist@ (the listed
-- query strings /__are__/ included) or @allExcept@ (the listed query
-- strings /__are not__/ included, but all other query strings are).
cachePolicyQueryStringsConfig_queryStrings :: Lens.Lens' CachePolicyQueryStringsConfig (Prelude.Maybe QueryStringNames)
cachePolicyQueryStringsConfig_queryStrings :: Lens' CachePolicyQueryStringsConfig (Maybe QueryStringNames)
cachePolicyQueryStringsConfig_queryStrings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicyQueryStringsConfig' {Maybe QueryStringNames
queryStrings :: Maybe QueryStringNames
$sel:queryStrings:CachePolicyQueryStringsConfig' :: CachePolicyQueryStringsConfig -> Maybe QueryStringNames
queryStrings} -> Maybe QueryStringNames
queryStrings) (\s :: CachePolicyQueryStringsConfig
s@CachePolicyQueryStringsConfig' {} Maybe QueryStringNames
a -> CachePolicyQueryStringsConfig
s {$sel:queryStrings:CachePolicyQueryStringsConfig' :: Maybe QueryStringNames
queryStrings = Maybe QueryStringNames
a} :: CachePolicyQueryStringsConfig)

-- | Determines whether any URL query strings in viewer requests are included
-- in the cache key and automatically included in requests that CloudFront
-- sends to the origin. Valid values are:
--
-- -   @none@ – Query strings in viewer requests are not included in the
--     cache key and are not automatically included in requests that
--     CloudFront sends to the origin. Even when this field is set to
--     @none@, any query strings that are listed in an
--     @OriginRequestPolicy@ /are/ included in origin requests.
--
-- -   @whitelist@ – The query strings in viewer requests that are listed
--     in the @QueryStringNames@ type are included in the cache key and
--     automatically included in requests that CloudFront sends to the
--     origin.
--
-- -   @allExcept@ – All query strings in viewer requests that are
--     /__not__/ listed in the @QueryStringNames@ type are included in the
--     cache key and automatically included in requests that CloudFront
--     sends to the origin.
--
-- -   @all@ – All query strings in viewer requests are included in the
--     cache key and are automatically included in requests that CloudFront
--     sends to the origin.
cachePolicyQueryStringsConfig_queryStringBehavior :: Lens.Lens' CachePolicyQueryStringsConfig CachePolicyQueryStringBehavior
cachePolicyQueryStringsConfig_queryStringBehavior :: Lens' CachePolicyQueryStringsConfig CachePolicyQueryStringBehavior
cachePolicyQueryStringsConfig_queryStringBehavior = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicyQueryStringsConfig' {CachePolicyQueryStringBehavior
queryStringBehavior :: CachePolicyQueryStringBehavior
$sel:queryStringBehavior:CachePolicyQueryStringsConfig' :: CachePolicyQueryStringsConfig -> CachePolicyQueryStringBehavior
queryStringBehavior} -> CachePolicyQueryStringBehavior
queryStringBehavior) (\s :: CachePolicyQueryStringsConfig
s@CachePolicyQueryStringsConfig' {} CachePolicyQueryStringBehavior
a -> CachePolicyQueryStringsConfig
s {$sel:queryStringBehavior:CachePolicyQueryStringsConfig' :: CachePolicyQueryStringBehavior
queryStringBehavior = CachePolicyQueryStringBehavior
a} :: CachePolicyQueryStringsConfig)

instance Data.FromXML CachePolicyQueryStringsConfig where
  parseXML :: [Node] -> Either String CachePolicyQueryStringsConfig
parseXML [Node]
x =
    Maybe QueryStringNames
-> CachePolicyQueryStringBehavior -> CachePolicyQueryStringsConfig
CachePolicyQueryStringsConfig'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"QueryStrings")
      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
"QueryStringBehavior")

instance
  Prelude.Hashable
    CachePolicyQueryStringsConfig
  where
  hashWithSalt :: Int -> CachePolicyQueryStringsConfig -> Int
hashWithSalt Int
_salt CachePolicyQueryStringsConfig' {Maybe QueryStringNames
CachePolicyQueryStringBehavior
queryStringBehavior :: CachePolicyQueryStringBehavior
queryStrings :: Maybe QueryStringNames
$sel:queryStringBehavior:CachePolicyQueryStringsConfig' :: CachePolicyQueryStringsConfig -> CachePolicyQueryStringBehavior
$sel:queryStrings:CachePolicyQueryStringsConfig' :: CachePolicyQueryStringsConfig -> Maybe QueryStringNames
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QueryStringNames
queryStrings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CachePolicyQueryStringBehavior
queryStringBehavior

instance Prelude.NFData CachePolicyQueryStringsConfig where
  rnf :: CachePolicyQueryStringsConfig -> ()
rnf CachePolicyQueryStringsConfig' {Maybe QueryStringNames
CachePolicyQueryStringBehavior
queryStringBehavior :: CachePolicyQueryStringBehavior
queryStrings :: Maybe QueryStringNames
$sel:queryStringBehavior:CachePolicyQueryStringsConfig' :: CachePolicyQueryStringsConfig -> CachePolicyQueryStringBehavior
$sel:queryStrings:CachePolicyQueryStringsConfig' :: CachePolicyQueryStringsConfig -> Maybe QueryStringNames
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe QueryStringNames
queryStrings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CachePolicyQueryStringBehavior
queryStringBehavior

instance Data.ToXML CachePolicyQueryStringsConfig where
  toXML :: CachePolicyQueryStringsConfig -> XML
toXML CachePolicyQueryStringsConfig' {Maybe QueryStringNames
CachePolicyQueryStringBehavior
queryStringBehavior :: CachePolicyQueryStringBehavior
queryStrings :: Maybe QueryStringNames
$sel:queryStringBehavior:CachePolicyQueryStringsConfig' :: CachePolicyQueryStringsConfig -> CachePolicyQueryStringBehavior
$sel:queryStrings:CachePolicyQueryStringsConfig' :: CachePolicyQueryStringsConfig -> Maybe QueryStringNames
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"QueryStrings" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe QueryStringNames
queryStrings,
        Name
"QueryStringBehavior" forall a. ToXML a => Name -> a -> XML
Data.@= CachePolicyQueryStringBehavior
queryStringBehavior
      ]