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

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

-- | Query argument-profile mapping for field-level encryption.
--
-- /See:/ 'newQueryArgProfiles' smart constructor.
data QueryArgProfiles = QueryArgProfiles'
  { -- | Number of items for query argument-profile mapping for field-level
    -- encryption.
    QueryArgProfiles -> Maybe [QueryArgProfile]
items :: Prelude.Maybe [QueryArgProfile],
    -- | Number of profiles for query argument-profile mapping for field-level
    -- encryption.
    QueryArgProfiles -> Int
quantity :: Prelude.Int
  }
  deriving (QueryArgProfiles -> QueryArgProfiles -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueryArgProfiles -> QueryArgProfiles -> Bool
$c/= :: QueryArgProfiles -> QueryArgProfiles -> Bool
== :: QueryArgProfiles -> QueryArgProfiles -> Bool
$c== :: QueryArgProfiles -> QueryArgProfiles -> Bool
Prelude.Eq, ReadPrec [QueryArgProfiles]
ReadPrec QueryArgProfiles
Int -> ReadS QueryArgProfiles
ReadS [QueryArgProfiles]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QueryArgProfiles]
$creadListPrec :: ReadPrec [QueryArgProfiles]
readPrec :: ReadPrec QueryArgProfiles
$creadPrec :: ReadPrec QueryArgProfiles
readList :: ReadS [QueryArgProfiles]
$creadList :: ReadS [QueryArgProfiles]
readsPrec :: Int -> ReadS QueryArgProfiles
$creadsPrec :: Int -> ReadS QueryArgProfiles
Prelude.Read, Int -> QueryArgProfiles -> ShowS
[QueryArgProfiles] -> ShowS
QueryArgProfiles -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueryArgProfiles] -> ShowS
$cshowList :: [QueryArgProfiles] -> ShowS
show :: QueryArgProfiles -> String
$cshow :: QueryArgProfiles -> String
showsPrec :: Int -> QueryArgProfiles -> ShowS
$cshowsPrec :: Int -> QueryArgProfiles -> ShowS
Prelude.Show, forall x. Rep QueryArgProfiles x -> QueryArgProfiles
forall x. QueryArgProfiles -> Rep QueryArgProfiles x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QueryArgProfiles x -> QueryArgProfiles
$cfrom :: forall x. QueryArgProfiles -> Rep QueryArgProfiles x
Prelude.Generic)

-- |
-- Create a value of 'QueryArgProfiles' 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:
--
-- 'items', 'queryArgProfiles_items' - Number of items for query argument-profile mapping for field-level
-- encryption.
--
-- 'quantity', 'queryArgProfiles_quantity' - Number of profiles for query argument-profile mapping for field-level
-- encryption.
newQueryArgProfiles ::
  -- | 'quantity'
  Prelude.Int ->
  QueryArgProfiles
newQueryArgProfiles :: Int -> QueryArgProfiles
newQueryArgProfiles Int
pQuantity_ =
  QueryArgProfiles'
    { $sel:items:QueryArgProfiles' :: Maybe [QueryArgProfile]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:quantity:QueryArgProfiles' :: Int
quantity = Int
pQuantity_
    }

-- | Number of items for query argument-profile mapping for field-level
-- encryption.
queryArgProfiles_items :: Lens.Lens' QueryArgProfiles (Prelude.Maybe [QueryArgProfile])
queryArgProfiles_items :: Lens' QueryArgProfiles (Maybe [QueryArgProfile])
queryArgProfiles_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryArgProfiles' {Maybe [QueryArgProfile]
items :: Maybe [QueryArgProfile]
$sel:items:QueryArgProfiles' :: QueryArgProfiles -> Maybe [QueryArgProfile]
items} -> Maybe [QueryArgProfile]
items) (\s :: QueryArgProfiles
s@QueryArgProfiles' {} Maybe [QueryArgProfile]
a -> QueryArgProfiles
s {$sel:items:QueryArgProfiles' :: Maybe [QueryArgProfile]
items = Maybe [QueryArgProfile]
a} :: QueryArgProfiles) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Number of profiles for query argument-profile mapping for field-level
-- encryption.
queryArgProfiles_quantity :: Lens.Lens' QueryArgProfiles Prelude.Int
queryArgProfiles_quantity :: Lens' QueryArgProfiles Int
queryArgProfiles_quantity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryArgProfiles' {Int
quantity :: Int
$sel:quantity:QueryArgProfiles' :: QueryArgProfiles -> Int
quantity} -> Int
quantity) (\s :: QueryArgProfiles
s@QueryArgProfiles' {} Int
a -> QueryArgProfiles
s {$sel:quantity:QueryArgProfiles' :: Int
quantity = Int
a} :: QueryArgProfiles)

instance Data.FromXML QueryArgProfiles where
  parseXML :: [Node] -> Either String QueryArgProfiles
parseXML [Node]
x =
    Maybe [QueryArgProfile] -> Int -> QueryArgProfiles
QueryArgProfiles'
      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
"Items"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"QueryArgProfile")
                  )
      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
"Quantity")

instance Prelude.Hashable QueryArgProfiles where
  hashWithSalt :: Int -> QueryArgProfiles -> Int
hashWithSalt Int
_salt QueryArgProfiles' {Int
Maybe [QueryArgProfile]
quantity :: Int
items :: Maybe [QueryArgProfile]
$sel:quantity:QueryArgProfiles' :: QueryArgProfiles -> Int
$sel:items:QueryArgProfiles' :: QueryArgProfiles -> Maybe [QueryArgProfile]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [QueryArgProfile]
items
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
quantity

instance Prelude.NFData QueryArgProfiles where
  rnf :: QueryArgProfiles -> ()
rnf QueryArgProfiles' {Int
Maybe [QueryArgProfile]
quantity :: Int
items :: Maybe [QueryArgProfile]
$sel:quantity:QueryArgProfiles' :: QueryArgProfiles -> Int
$sel:items:QueryArgProfiles' :: QueryArgProfiles -> Maybe [QueryArgProfile]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [QueryArgProfile]
items
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
quantity

instance Data.ToXML QueryArgProfiles where
  toXML :: QueryArgProfiles -> XML
toXML QueryArgProfiles' {Int
Maybe [QueryArgProfile]
quantity :: Int
items :: Maybe [QueryArgProfile]
$sel:quantity:QueryArgProfiles' :: QueryArgProfiles -> Int
$sel:items:QueryArgProfiles' :: QueryArgProfiles -> Maybe [QueryArgProfile]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Items"
          forall a. ToXML a => Name -> a -> XML
Data.@= forall a. ToXML a => a -> XML
Data.toXML
            (forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Data.toXMLList Name
"QueryArgProfile" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [QueryArgProfile]
items),
        Name
"Quantity" forall a. ToXML a => Name -> a -> XML
Data.@= Int
quantity
      ]