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

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

-- | Configuration for query argument-profile mapping for field-level
-- encryption.
--
-- /See:/ 'newQueryArgProfileConfig' smart constructor.
data QueryArgProfileConfig = QueryArgProfileConfig'
  { -- | Profiles specified for query argument-profile mapping for field-level
    -- encryption.
    QueryArgProfileConfig -> Maybe QueryArgProfiles
queryArgProfiles :: Prelude.Maybe QueryArgProfiles,
    -- | Flag to set if you want a request to be forwarded to the origin even if
    -- the profile specified by the field-level encryption query argument,
    -- fle-profile, is unknown.
    QueryArgProfileConfig -> Bool
forwardWhenQueryArgProfileIsUnknown :: Prelude.Bool
  }
  deriving (QueryArgProfileConfig -> QueryArgProfileConfig -> Bool
(QueryArgProfileConfig -> QueryArgProfileConfig -> Bool)
-> (QueryArgProfileConfig -> QueryArgProfileConfig -> Bool)
-> Eq QueryArgProfileConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueryArgProfileConfig -> QueryArgProfileConfig -> Bool
$c/= :: QueryArgProfileConfig -> QueryArgProfileConfig -> Bool
== :: QueryArgProfileConfig -> QueryArgProfileConfig -> Bool
$c== :: QueryArgProfileConfig -> QueryArgProfileConfig -> Bool
Prelude.Eq, ReadPrec [QueryArgProfileConfig]
ReadPrec QueryArgProfileConfig
Int -> ReadS QueryArgProfileConfig
ReadS [QueryArgProfileConfig]
(Int -> ReadS QueryArgProfileConfig)
-> ReadS [QueryArgProfileConfig]
-> ReadPrec QueryArgProfileConfig
-> ReadPrec [QueryArgProfileConfig]
-> Read QueryArgProfileConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QueryArgProfileConfig]
$creadListPrec :: ReadPrec [QueryArgProfileConfig]
readPrec :: ReadPrec QueryArgProfileConfig
$creadPrec :: ReadPrec QueryArgProfileConfig
readList :: ReadS [QueryArgProfileConfig]
$creadList :: ReadS [QueryArgProfileConfig]
readsPrec :: Int -> ReadS QueryArgProfileConfig
$creadsPrec :: Int -> ReadS QueryArgProfileConfig
Prelude.Read, Int -> QueryArgProfileConfig -> ShowS
[QueryArgProfileConfig] -> ShowS
QueryArgProfileConfig -> String
(Int -> QueryArgProfileConfig -> ShowS)
-> (QueryArgProfileConfig -> String)
-> ([QueryArgProfileConfig] -> ShowS)
-> Show QueryArgProfileConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueryArgProfileConfig] -> ShowS
$cshowList :: [QueryArgProfileConfig] -> ShowS
show :: QueryArgProfileConfig -> String
$cshow :: QueryArgProfileConfig -> String
showsPrec :: Int -> QueryArgProfileConfig -> ShowS
$cshowsPrec :: Int -> QueryArgProfileConfig -> ShowS
Prelude.Show, (forall x. QueryArgProfileConfig -> Rep QueryArgProfileConfig x)
-> (forall x. Rep QueryArgProfileConfig x -> QueryArgProfileConfig)
-> Generic QueryArgProfileConfig
forall x. Rep QueryArgProfileConfig x -> QueryArgProfileConfig
forall x. QueryArgProfileConfig -> Rep QueryArgProfileConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QueryArgProfileConfig x -> QueryArgProfileConfig
$cfrom :: forall x. QueryArgProfileConfig -> Rep QueryArgProfileConfig x
Prelude.Generic)

-- |
-- Create a value of 'QueryArgProfileConfig' 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:
--
-- 'queryArgProfiles', 'queryArgProfileConfig_queryArgProfiles' - Profiles specified for query argument-profile mapping for field-level
-- encryption.
--
-- 'forwardWhenQueryArgProfileIsUnknown', 'queryArgProfileConfig_forwardWhenQueryArgProfileIsUnknown' - Flag to set if you want a request to be forwarded to the origin even if
-- the profile specified by the field-level encryption query argument,
-- fle-profile, is unknown.
newQueryArgProfileConfig ::
  -- | 'forwardWhenQueryArgProfileIsUnknown'
  Prelude.Bool ->
  QueryArgProfileConfig
newQueryArgProfileConfig :: Bool -> QueryArgProfileConfig
newQueryArgProfileConfig
  Bool
pForwardWhenQueryArgProfileIsUnknown_ =
    QueryArgProfileConfig' :: Maybe QueryArgProfiles -> Bool -> QueryArgProfileConfig
QueryArgProfileConfig'
      { $sel:queryArgProfiles:QueryArgProfileConfig' :: Maybe QueryArgProfiles
queryArgProfiles =
          Maybe QueryArgProfiles
forall a. Maybe a
Prelude.Nothing,
        $sel:forwardWhenQueryArgProfileIsUnknown:QueryArgProfileConfig' :: Bool
forwardWhenQueryArgProfileIsUnknown =
          Bool
pForwardWhenQueryArgProfileIsUnknown_
      }

-- | Profiles specified for query argument-profile mapping for field-level
-- encryption.
queryArgProfileConfig_queryArgProfiles :: Lens.Lens' QueryArgProfileConfig (Prelude.Maybe QueryArgProfiles)
queryArgProfileConfig_queryArgProfiles :: (Maybe QueryArgProfiles -> f (Maybe QueryArgProfiles))
-> QueryArgProfileConfig -> f QueryArgProfileConfig
queryArgProfileConfig_queryArgProfiles = (QueryArgProfileConfig -> Maybe QueryArgProfiles)
-> (QueryArgProfileConfig
    -> Maybe QueryArgProfiles -> QueryArgProfileConfig)
-> Lens
     QueryArgProfileConfig
     QueryArgProfileConfig
     (Maybe QueryArgProfiles)
     (Maybe QueryArgProfiles)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryArgProfileConfig' {Maybe QueryArgProfiles
queryArgProfiles :: Maybe QueryArgProfiles
$sel:queryArgProfiles:QueryArgProfileConfig' :: QueryArgProfileConfig -> Maybe QueryArgProfiles
queryArgProfiles} -> Maybe QueryArgProfiles
queryArgProfiles) (\s :: QueryArgProfileConfig
s@QueryArgProfileConfig' {} Maybe QueryArgProfiles
a -> QueryArgProfileConfig
s {$sel:queryArgProfiles:QueryArgProfileConfig' :: Maybe QueryArgProfiles
queryArgProfiles = Maybe QueryArgProfiles
a} :: QueryArgProfileConfig)

-- | Flag to set if you want a request to be forwarded to the origin even if
-- the profile specified by the field-level encryption query argument,
-- fle-profile, is unknown.
queryArgProfileConfig_forwardWhenQueryArgProfileIsUnknown :: Lens.Lens' QueryArgProfileConfig Prelude.Bool
queryArgProfileConfig_forwardWhenQueryArgProfileIsUnknown :: (Bool -> f Bool)
-> QueryArgProfileConfig -> f QueryArgProfileConfig
queryArgProfileConfig_forwardWhenQueryArgProfileIsUnknown = (QueryArgProfileConfig -> Bool)
-> (QueryArgProfileConfig -> Bool -> QueryArgProfileConfig)
-> Lens QueryArgProfileConfig QueryArgProfileConfig Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryArgProfileConfig' {Bool
forwardWhenQueryArgProfileIsUnknown :: Bool
$sel:forwardWhenQueryArgProfileIsUnknown:QueryArgProfileConfig' :: QueryArgProfileConfig -> Bool
forwardWhenQueryArgProfileIsUnknown} -> Bool
forwardWhenQueryArgProfileIsUnknown) (\s :: QueryArgProfileConfig
s@QueryArgProfileConfig' {} Bool
a -> QueryArgProfileConfig
s {$sel:forwardWhenQueryArgProfileIsUnknown:QueryArgProfileConfig' :: Bool
forwardWhenQueryArgProfileIsUnknown = Bool
a} :: QueryArgProfileConfig)

instance Core.FromXML QueryArgProfileConfig where
  parseXML :: [Node] -> Either String QueryArgProfileConfig
parseXML [Node]
x =
    Maybe QueryArgProfiles -> Bool -> QueryArgProfileConfig
QueryArgProfileConfig'
      (Maybe QueryArgProfiles -> Bool -> QueryArgProfileConfig)
-> Either String (Maybe QueryArgProfiles)
-> Either String (Bool -> QueryArgProfileConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe QueryArgProfiles)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"QueryArgProfiles")
      Either String (Bool -> QueryArgProfileConfig)
-> Either String Bool -> Either String QueryArgProfileConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Bool
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ForwardWhenQueryArgProfileIsUnknown")

instance Prelude.Hashable QueryArgProfileConfig

instance Prelude.NFData QueryArgProfileConfig

instance Core.ToXML QueryArgProfileConfig where
  toXML :: QueryArgProfileConfig -> XML
toXML QueryArgProfileConfig' {Bool
Maybe QueryArgProfiles
forwardWhenQueryArgProfileIsUnknown :: Bool
queryArgProfiles :: Maybe QueryArgProfiles
$sel:forwardWhenQueryArgProfileIsUnknown:QueryArgProfileConfig' :: QueryArgProfileConfig -> Bool
$sel:queryArgProfiles:QueryArgProfileConfig' :: QueryArgProfileConfig -> Maybe QueryArgProfiles
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"QueryArgProfiles" Name -> Maybe QueryArgProfiles -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe QueryArgProfiles
queryArgProfiles,
        Name
"ForwardWhenQueryArgProfileIsUnknown"
          Name -> Bool -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Bool
forwardWhenQueryArgProfileIsUnknown
      ]