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

import Amazonka.CloudFront.Types.OriginRequestPolicyQueryStringBehavior
import Amazonka.CloudFront.Types.QueryStringNames
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 requests that
-- CloudFront sends to the origin.
--
-- /See:/ 'newOriginRequestPolicyQueryStringsConfig' smart constructor.
data OriginRequestPolicyQueryStringsConfig = OriginRequestPolicyQueryStringsConfig'
  { -- | Contains a list of the query strings in viewer requests that are
    -- included in requests that CloudFront sends to the origin.
    OriginRequestPolicyQueryStringsConfig -> Maybe QueryStringNames
queryStrings :: Prelude.Maybe QueryStringNames,
    -- | Determines whether any URL query strings in viewer requests are included
    -- in requests that CloudFront sends to the origin. Valid values are:
    --
    -- -   @none@ – Query strings in viewer requests are not included in
    --     requests that CloudFront sends to the origin. Even when this field
    --     is set to @none@, any query strings that are listed in a
    --     @CachePolicy@ /are/ included in origin requests.
    --
    -- -   @whitelist@ – The query strings in viewer requests that are listed
    --     in the @QueryStringNames@ type are included in requests that
    --     CloudFront sends to the origin.
    --
    -- -   @all@ – All query strings in viewer requests are included in
    --     requests that CloudFront sends to the origin.
    OriginRequestPolicyQueryStringsConfig
-> OriginRequestPolicyQueryStringBehavior
queryStringBehavior :: OriginRequestPolicyQueryStringBehavior
  }
  deriving (OriginRequestPolicyQueryStringsConfig
-> OriginRequestPolicyQueryStringsConfig -> Bool
(OriginRequestPolicyQueryStringsConfig
 -> OriginRequestPolicyQueryStringsConfig -> Bool)
-> (OriginRequestPolicyQueryStringsConfig
    -> OriginRequestPolicyQueryStringsConfig -> Bool)
-> Eq OriginRequestPolicyQueryStringsConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OriginRequestPolicyQueryStringsConfig
-> OriginRequestPolicyQueryStringsConfig -> Bool
$c/= :: OriginRequestPolicyQueryStringsConfig
-> OriginRequestPolicyQueryStringsConfig -> Bool
== :: OriginRequestPolicyQueryStringsConfig
-> OriginRequestPolicyQueryStringsConfig -> Bool
$c== :: OriginRequestPolicyQueryStringsConfig
-> OriginRequestPolicyQueryStringsConfig -> Bool
Prelude.Eq, ReadPrec [OriginRequestPolicyQueryStringsConfig]
ReadPrec OriginRequestPolicyQueryStringsConfig
Int -> ReadS OriginRequestPolicyQueryStringsConfig
ReadS [OriginRequestPolicyQueryStringsConfig]
(Int -> ReadS OriginRequestPolicyQueryStringsConfig)
-> ReadS [OriginRequestPolicyQueryStringsConfig]
-> ReadPrec OriginRequestPolicyQueryStringsConfig
-> ReadPrec [OriginRequestPolicyQueryStringsConfig]
-> Read OriginRequestPolicyQueryStringsConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OriginRequestPolicyQueryStringsConfig]
$creadListPrec :: ReadPrec [OriginRequestPolicyQueryStringsConfig]
readPrec :: ReadPrec OriginRequestPolicyQueryStringsConfig
$creadPrec :: ReadPrec OriginRequestPolicyQueryStringsConfig
readList :: ReadS [OriginRequestPolicyQueryStringsConfig]
$creadList :: ReadS [OriginRequestPolicyQueryStringsConfig]
readsPrec :: Int -> ReadS OriginRequestPolicyQueryStringsConfig
$creadsPrec :: Int -> ReadS OriginRequestPolicyQueryStringsConfig
Prelude.Read, Int -> OriginRequestPolicyQueryStringsConfig -> ShowS
[OriginRequestPolicyQueryStringsConfig] -> ShowS
OriginRequestPolicyQueryStringsConfig -> String
(Int -> OriginRequestPolicyQueryStringsConfig -> ShowS)
-> (OriginRequestPolicyQueryStringsConfig -> String)
-> ([OriginRequestPolicyQueryStringsConfig] -> ShowS)
-> Show OriginRequestPolicyQueryStringsConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OriginRequestPolicyQueryStringsConfig] -> ShowS
$cshowList :: [OriginRequestPolicyQueryStringsConfig] -> ShowS
show :: OriginRequestPolicyQueryStringsConfig -> String
$cshow :: OriginRequestPolicyQueryStringsConfig -> String
showsPrec :: Int -> OriginRequestPolicyQueryStringsConfig -> ShowS
$cshowsPrec :: Int -> OriginRequestPolicyQueryStringsConfig -> ShowS
Prelude.Show, (forall x.
 OriginRequestPolicyQueryStringsConfig
 -> Rep OriginRequestPolicyQueryStringsConfig x)
-> (forall x.
    Rep OriginRequestPolicyQueryStringsConfig x
    -> OriginRequestPolicyQueryStringsConfig)
-> Generic OriginRequestPolicyQueryStringsConfig
forall x.
Rep OriginRequestPolicyQueryStringsConfig x
-> OriginRequestPolicyQueryStringsConfig
forall x.
OriginRequestPolicyQueryStringsConfig
-> Rep OriginRequestPolicyQueryStringsConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep OriginRequestPolicyQueryStringsConfig x
-> OriginRequestPolicyQueryStringsConfig
$cfrom :: forall x.
OriginRequestPolicyQueryStringsConfig
-> Rep OriginRequestPolicyQueryStringsConfig x
Prelude.Generic)

-- |
-- Create a value of 'OriginRequestPolicyQueryStringsConfig' 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', 'originRequestPolicyQueryStringsConfig_queryStrings' - Contains a list of the query strings in viewer requests that are
-- included in requests that CloudFront sends to the origin.
--
-- 'queryStringBehavior', 'originRequestPolicyQueryStringsConfig_queryStringBehavior' - Determines whether any URL query strings in viewer requests are included
-- in requests that CloudFront sends to the origin. Valid values are:
--
-- -   @none@ – Query strings in viewer requests are not included in
--     requests that CloudFront sends to the origin. Even when this field
--     is set to @none@, any query strings that are listed in a
--     @CachePolicy@ /are/ included in origin requests.
--
-- -   @whitelist@ – The query strings in viewer requests that are listed
--     in the @QueryStringNames@ type are included in requests that
--     CloudFront sends to the origin.
--
-- -   @all@ – All query strings in viewer requests are included in
--     requests that CloudFront sends to the origin.
newOriginRequestPolicyQueryStringsConfig ::
  -- | 'queryStringBehavior'
  OriginRequestPolicyQueryStringBehavior ->
  OriginRequestPolicyQueryStringsConfig
newOriginRequestPolicyQueryStringsConfig :: OriginRequestPolicyQueryStringBehavior
-> OriginRequestPolicyQueryStringsConfig
newOriginRequestPolicyQueryStringsConfig
  OriginRequestPolicyQueryStringBehavior
pQueryStringBehavior_ =
    OriginRequestPolicyQueryStringsConfig' :: Maybe QueryStringNames
-> OriginRequestPolicyQueryStringBehavior
-> OriginRequestPolicyQueryStringsConfig
OriginRequestPolicyQueryStringsConfig'
      { $sel:queryStrings:OriginRequestPolicyQueryStringsConfig' :: Maybe QueryStringNames
queryStrings =
          Maybe QueryStringNames
forall a. Maybe a
Prelude.Nothing,
        $sel:queryStringBehavior:OriginRequestPolicyQueryStringsConfig' :: OriginRequestPolicyQueryStringBehavior
queryStringBehavior =
          OriginRequestPolicyQueryStringBehavior
pQueryStringBehavior_
      }

-- | Contains a list of the query strings in viewer requests that are
-- included in requests that CloudFront sends to the origin.
originRequestPolicyQueryStringsConfig_queryStrings :: Lens.Lens' OriginRequestPolicyQueryStringsConfig (Prelude.Maybe QueryStringNames)
originRequestPolicyQueryStringsConfig_queryStrings :: (Maybe QueryStringNames -> f (Maybe QueryStringNames))
-> OriginRequestPolicyQueryStringsConfig
-> f OriginRequestPolicyQueryStringsConfig
originRequestPolicyQueryStringsConfig_queryStrings = (OriginRequestPolicyQueryStringsConfig -> Maybe QueryStringNames)
-> (OriginRequestPolicyQueryStringsConfig
    -> Maybe QueryStringNames -> OriginRequestPolicyQueryStringsConfig)
-> Lens
     OriginRequestPolicyQueryStringsConfig
     OriginRequestPolicyQueryStringsConfig
     (Maybe QueryStringNames)
     (Maybe QueryStringNames)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginRequestPolicyQueryStringsConfig' {Maybe QueryStringNames
queryStrings :: Maybe QueryStringNames
$sel:queryStrings:OriginRequestPolicyQueryStringsConfig' :: OriginRequestPolicyQueryStringsConfig -> Maybe QueryStringNames
queryStrings} -> Maybe QueryStringNames
queryStrings) (\s :: OriginRequestPolicyQueryStringsConfig
s@OriginRequestPolicyQueryStringsConfig' {} Maybe QueryStringNames
a -> OriginRequestPolicyQueryStringsConfig
s {$sel:queryStrings:OriginRequestPolicyQueryStringsConfig' :: Maybe QueryStringNames
queryStrings = Maybe QueryStringNames
a} :: OriginRequestPolicyQueryStringsConfig)

-- | Determines whether any URL query strings in viewer requests are included
-- in requests that CloudFront sends to the origin. Valid values are:
--
-- -   @none@ – Query strings in viewer requests are not included in
--     requests that CloudFront sends to the origin. Even when this field
--     is set to @none@, any query strings that are listed in a
--     @CachePolicy@ /are/ included in origin requests.
--
-- -   @whitelist@ – The query strings in viewer requests that are listed
--     in the @QueryStringNames@ type are included in requests that
--     CloudFront sends to the origin.
--
-- -   @all@ – All query strings in viewer requests are included in
--     requests that CloudFront sends to the origin.
originRequestPolicyQueryStringsConfig_queryStringBehavior :: Lens.Lens' OriginRequestPolicyQueryStringsConfig OriginRequestPolicyQueryStringBehavior
originRequestPolicyQueryStringsConfig_queryStringBehavior :: (OriginRequestPolicyQueryStringBehavior
 -> f OriginRequestPolicyQueryStringBehavior)
-> OriginRequestPolicyQueryStringsConfig
-> f OriginRequestPolicyQueryStringsConfig
originRequestPolicyQueryStringsConfig_queryStringBehavior = (OriginRequestPolicyQueryStringsConfig
 -> OriginRequestPolicyQueryStringBehavior)
-> (OriginRequestPolicyQueryStringsConfig
    -> OriginRequestPolicyQueryStringBehavior
    -> OriginRequestPolicyQueryStringsConfig)
-> Lens
     OriginRequestPolicyQueryStringsConfig
     OriginRequestPolicyQueryStringsConfig
     OriginRequestPolicyQueryStringBehavior
     OriginRequestPolicyQueryStringBehavior
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginRequestPolicyQueryStringsConfig' {OriginRequestPolicyQueryStringBehavior
queryStringBehavior :: OriginRequestPolicyQueryStringBehavior
$sel:queryStringBehavior:OriginRequestPolicyQueryStringsConfig' :: OriginRequestPolicyQueryStringsConfig
-> OriginRequestPolicyQueryStringBehavior
queryStringBehavior} -> OriginRequestPolicyQueryStringBehavior
queryStringBehavior) (\s :: OriginRequestPolicyQueryStringsConfig
s@OriginRequestPolicyQueryStringsConfig' {} OriginRequestPolicyQueryStringBehavior
a -> OriginRequestPolicyQueryStringsConfig
s {$sel:queryStringBehavior:OriginRequestPolicyQueryStringsConfig' :: OriginRequestPolicyQueryStringBehavior
queryStringBehavior = OriginRequestPolicyQueryStringBehavior
a} :: OriginRequestPolicyQueryStringsConfig)

instance
  Core.FromXML
    OriginRequestPolicyQueryStringsConfig
  where
  parseXML :: [Node] -> Either String OriginRequestPolicyQueryStringsConfig
parseXML [Node]
x =
    Maybe QueryStringNames
-> OriginRequestPolicyQueryStringBehavior
-> OriginRequestPolicyQueryStringsConfig
OriginRequestPolicyQueryStringsConfig'
      (Maybe QueryStringNames
 -> OriginRequestPolicyQueryStringBehavior
 -> OriginRequestPolicyQueryStringsConfig)
-> Either String (Maybe QueryStringNames)
-> Either
     String
     (OriginRequestPolicyQueryStringBehavior
      -> OriginRequestPolicyQueryStringsConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe QueryStringNames)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"QueryStrings")
      Either
  String
  (OriginRequestPolicyQueryStringBehavior
   -> OriginRequestPolicyQueryStringsConfig)
-> Either String OriginRequestPolicyQueryStringBehavior
-> Either String OriginRequestPolicyQueryStringsConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node]
-> Text -> Either String OriginRequestPolicyQueryStringBehavior
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"QueryStringBehavior")

instance
  Prelude.Hashable
    OriginRequestPolicyQueryStringsConfig

instance
  Prelude.NFData
    OriginRequestPolicyQueryStringsConfig

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