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

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

-- | 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
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]
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
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. 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'
      { $sel:queryArgProfiles:QueryArgProfileConfig' :: Maybe QueryArgProfiles
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 :: Lens' QueryArgProfileConfig (Maybe QueryArgProfiles)
queryArgProfileConfig_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 :: Lens' QueryArgProfileConfig Bool
queryArgProfileConfig_forwardWhenQueryArgProfileIsUnknown = 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 Data.FromXML QueryArgProfileConfig where
  parseXML :: [Node] -> Either String QueryArgProfileConfig
parseXML [Node]
x =
    Maybe QueryArgProfiles -> Bool -> QueryArgProfileConfig
QueryArgProfileConfig'
      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
"QueryArgProfiles")
      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
"ForwardWhenQueryArgProfileIsUnknown")

instance Prelude.Hashable QueryArgProfileConfig where
  hashWithSalt :: Int -> QueryArgProfileConfig -> Int
hashWithSalt Int
_salt QueryArgProfileConfig' {Bool
Maybe QueryArgProfiles
forwardWhenQueryArgProfileIsUnknown :: Bool
queryArgProfiles :: Maybe QueryArgProfiles
$sel:forwardWhenQueryArgProfileIsUnknown:QueryArgProfileConfig' :: QueryArgProfileConfig -> Bool
$sel:queryArgProfiles:QueryArgProfileConfig' :: QueryArgProfileConfig -> Maybe QueryArgProfiles
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QueryArgProfiles
queryArgProfiles
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
forwardWhenQueryArgProfileIsUnknown

instance Prelude.NFData QueryArgProfileConfig where
  rnf :: QueryArgProfileConfig -> ()
rnf QueryArgProfileConfig' {Bool
Maybe QueryArgProfiles
forwardWhenQueryArgProfileIsUnknown :: Bool
queryArgProfiles :: Maybe QueryArgProfiles
$sel:forwardWhenQueryArgProfileIsUnknown:QueryArgProfileConfig' :: QueryArgProfileConfig -> Bool
$sel:queryArgProfiles:QueryArgProfileConfig' :: QueryArgProfileConfig -> Maybe QueryArgProfiles
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe QueryArgProfiles
queryArgProfiles
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
forwardWhenQueryArgProfileIsUnknown

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"QueryArgProfiles" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe QueryArgProfiles
queryArgProfiles,
        Name
"ForwardWhenQueryArgProfileIsUnknown"
          forall a. ToXML a => Name -> a -> XML
Data.@= Bool
forwardWhenQueryArgProfileIsUnknown
      ]