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

import Amazonka.CloudFront.Types.QueryArgProfile
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(QueryArgProfiles -> QueryArgProfiles -> Bool)
-> (QueryArgProfiles -> QueryArgProfiles -> Bool)
-> Eq QueryArgProfiles
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]
(Int -> ReadS QueryArgProfiles)
-> ReadS [QueryArgProfiles]
-> ReadPrec QueryArgProfiles
-> ReadPrec [QueryArgProfiles]
-> Read 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
(Int -> QueryArgProfiles -> ShowS)
-> (QueryArgProfiles -> String)
-> ([QueryArgProfiles] -> ShowS)
-> Show QueryArgProfiles
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. QueryArgProfiles -> Rep QueryArgProfiles x)
-> (forall x. Rep QueryArgProfiles x -> QueryArgProfiles)
-> Generic QueryArgProfiles
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' :: Maybe [QueryArgProfile] -> Int -> QueryArgProfiles
QueryArgProfiles'
    { $sel:items:QueryArgProfiles' :: Maybe [QueryArgProfile]
items = Maybe [QueryArgProfile]
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 :: (Maybe [QueryArgProfile] -> f (Maybe [QueryArgProfile]))
-> QueryArgProfiles -> f QueryArgProfiles
queryArgProfiles_items = (QueryArgProfiles -> Maybe [QueryArgProfile])
-> (QueryArgProfiles
    -> Maybe [QueryArgProfile] -> QueryArgProfiles)
-> Lens
     QueryArgProfiles
     QueryArgProfiles
     (Maybe [QueryArgProfile])
     (Maybe [QueryArgProfile])
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) ((Maybe [QueryArgProfile] -> f (Maybe [QueryArgProfile]))
 -> QueryArgProfiles -> f QueryArgProfiles)
-> ((Maybe [QueryArgProfile] -> f (Maybe [QueryArgProfile]))
    -> Maybe [QueryArgProfile] -> f (Maybe [QueryArgProfile]))
-> (Maybe [QueryArgProfile] -> f (Maybe [QueryArgProfile]))
-> QueryArgProfiles
-> f QueryArgProfiles
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [QueryArgProfile]
  [QueryArgProfile]
  [QueryArgProfile]
  [QueryArgProfile]
-> Iso
     (Maybe [QueryArgProfile])
     (Maybe [QueryArgProfile])
     (Maybe [QueryArgProfile])
     (Maybe [QueryArgProfile])
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 AnIso
  [QueryArgProfile]
  [QueryArgProfile]
  [QueryArgProfile]
  [QueryArgProfile]
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 :: (Int -> f Int) -> QueryArgProfiles -> f QueryArgProfiles
queryArgProfiles_quantity = (QueryArgProfiles -> Int)
-> (QueryArgProfiles -> Int -> QueryArgProfiles)
-> Lens QueryArgProfiles QueryArgProfiles Int Int
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 Core.FromXML QueryArgProfiles where
  parseXML :: [Node] -> Either String QueryArgProfiles
parseXML [Node]
x =
    Maybe [QueryArgProfile] -> Int -> QueryArgProfiles
QueryArgProfiles'
      (Maybe [QueryArgProfile] -> Int -> QueryArgProfiles)
-> Either String (Maybe [QueryArgProfile])
-> Either String (Int -> QueryArgProfiles)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Items" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [QueryArgProfile]))
-> Either String (Maybe [QueryArgProfile])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [QueryArgProfile])
-> [Node] -> Either String (Maybe [QueryArgProfile])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [QueryArgProfile]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"QueryArgProfile")
                  )
      Either String (Int -> QueryArgProfiles)
-> Either String Int -> Either String QueryArgProfiles
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Int
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Quantity")

instance Prelude.Hashable QueryArgProfiles

instance Prelude.NFData QueryArgProfiles

instance Core.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]
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Items"
          Name -> XML -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe XML -> XML
forall a. ToXML a => a -> XML
Core.toXML
            (Name -> [QueryArgProfile] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"QueryArgProfile" ([QueryArgProfile] -> XML) -> Maybe [QueryArgProfile] -> Maybe XML
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [QueryArgProfile]
items),
        Name
"Quantity" Name -> Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Int
quantity
      ]