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

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

-- | A list of public keys that you can use with
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html signed URLs and signed cookies>,
-- or with
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/field-level-encryption.html field-level encryption>.
--
-- /See:/ 'newPublicKeyList' smart constructor.
data PublicKeyList = PublicKeyList'
  { -- | A list of public keys.
    PublicKeyList -> Maybe [PublicKeySummary]
items :: Prelude.Maybe [PublicKeySummary],
    -- | If there are more elements to be listed, this element is present and
    -- contains the value that you can use for the @Marker@ request parameter
    -- to continue listing your public keys where you left off.
    PublicKeyList -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of public keys you want in the response.
    PublicKeyList -> Int
maxItems :: Prelude.Int,
    -- | The number of public keys in the list.
    PublicKeyList -> Int
quantity :: Prelude.Int
  }
  deriving (PublicKeyList -> PublicKeyList -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PublicKeyList -> PublicKeyList -> Bool
$c/= :: PublicKeyList -> PublicKeyList -> Bool
== :: PublicKeyList -> PublicKeyList -> Bool
$c== :: PublicKeyList -> PublicKeyList -> Bool
Prelude.Eq, ReadPrec [PublicKeyList]
ReadPrec PublicKeyList
Int -> ReadS PublicKeyList
ReadS [PublicKeyList]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PublicKeyList]
$creadListPrec :: ReadPrec [PublicKeyList]
readPrec :: ReadPrec PublicKeyList
$creadPrec :: ReadPrec PublicKeyList
readList :: ReadS [PublicKeyList]
$creadList :: ReadS [PublicKeyList]
readsPrec :: Int -> ReadS PublicKeyList
$creadsPrec :: Int -> ReadS PublicKeyList
Prelude.Read, Int -> PublicKeyList -> ShowS
[PublicKeyList] -> ShowS
PublicKeyList -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PublicKeyList] -> ShowS
$cshowList :: [PublicKeyList] -> ShowS
show :: PublicKeyList -> String
$cshow :: PublicKeyList -> String
showsPrec :: Int -> PublicKeyList -> ShowS
$cshowsPrec :: Int -> PublicKeyList -> ShowS
Prelude.Show, forall x. Rep PublicKeyList x -> PublicKeyList
forall x. PublicKeyList -> Rep PublicKeyList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PublicKeyList x -> PublicKeyList
$cfrom :: forall x. PublicKeyList -> Rep PublicKeyList x
Prelude.Generic)

-- |
-- Create a value of 'PublicKeyList' 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', 'publicKeyList_items' - A list of public keys.
--
-- 'nextMarker', 'publicKeyList_nextMarker' - If there are more elements to be listed, this element is present and
-- contains the value that you can use for the @Marker@ request parameter
-- to continue listing your public keys where you left off.
--
-- 'maxItems', 'publicKeyList_maxItems' - The maximum number of public keys you want in the response.
--
-- 'quantity', 'publicKeyList_quantity' - The number of public keys in the list.
newPublicKeyList ::
  -- | 'maxItems'
  Prelude.Int ->
  -- | 'quantity'
  Prelude.Int ->
  PublicKeyList
newPublicKeyList :: Int -> Int -> PublicKeyList
newPublicKeyList Int
pMaxItems_ Int
pQuantity_ =
  PublicKeyList'
    { $sel:items:PublicKeyList' :: Maybe [PublicKeySummary]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:PublicKeyList' :: Maybe Text
nextMarker = forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:PublicKeyList' :: Int
maxItems = Int
pMaxItems_,
      $sel:quantity:PublicKeyList' :: Int
quantity = Int
pQuantity_
    }

-- | A list of public keys.
publicKeyList_items :: Lens.Lens' PublicKeyList (Prelude.Maybe [PublicKeySummary])
publicKeyList_items :: Lens' PublicKeyList (Maybe [PublicKeySummary])
publicKeyList_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeyList' {Maybe [PublicKeySummary]
items :: Maybe [PublicKeySummary]
$sel:items:PublicKeyList' :: PublicKeyList -> Maybe [PublicKeySummary]
items} -> Maybe [PublicKeySummary]
items) (\s :: PublicKeyList
s@PublicKeyList' {} Maybe [PublicKeySummary]
a -> PublicKeyList
s {$sel:items:PublicKeyList' :: Maybe [PublicKeySummary]
items = Maybe [PublicKeySummary]
a} :: PublicKeyList) 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

-- | If there are more elements to be listed, this element is present and
-- contains the value that you can use for the @Marker@ request parameter
-- to continue listing your public keys where you left off.
publicKeyList_nextMarker :: Lens.Lens' PublicKeyList (Prelude.Maybe Prelude.Text)
publicKeyList_nextMarker :: Lens' PublicKeyList (Maybe Text)
publicKeyList_nextMarker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeyList' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:PublicKeyList' :: PublicKeyList -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: PublicKeyList
s@PublicKeyList' {} Maybe Text
a -> PublicKeyList
s {$sel:nextMarker:PublicKeyList' :: Maybe Text
nextMarker = Maybe Text
a} :: PublicKeyList)

-- | The maximum number of public keys you want in the response.
publicKeyList_maxItems :: Lens.Lens' PublicKeyList Prelude.Int
publicKeyList_maxItems :: Lens' PublicKeyList Int
publicKeyList_maxItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeyList' {Int
maxItems :: Int
$sel:maxItems:PublicKeyList' :: PublicKeyList -> Int
maxItems} -> Int
maxItems) (\s :: PublicKeyList
s@PublicKeyList' {} Int
a -> PublicKeyList
s {$sel:maxItems:PublicKeyList' :: Int
maxItems = Int
a} :: PublicKeyList)

-- | The number of public keys in the list.
publicKeyList_quantity :: Lens.Lens' PublicKeyList Prelude.Int
publicKeyList_quantity :: Lens' PublicKeyList Int
publicKeyList_quantity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeyList' {Int
quantity :: Int
$sel:quantity:PublicKeyList' :: PublicKeyList -> Int
quantity} -> Int
quantity) (\s :: PublicKeyList
s@PublicKeyList' {} Int
a -> PublicKeyList
s {$sel:quantity:PublicKeyList' :: Int
quantity = Int
a} :: PublicKeyList)

instance Data.FromXML PublicKeyList where
  parseXML :: [Node] -> Either String PublicKeyList
parseXML [Node]
x =
    Maybe [PublicKeySummary]
-> Maybe Text -> Int -> Int -> PublicKeyList
PublicKeyList'
      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
"PublicKeySummary")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"NextMarker")
      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
"MaxItems")
      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 PublicKeyList where
  hashWithSalt :: Int -> PublicKeyList -> Int
hashWithSalt Int
_salt PublicKeyList' {Int
Maybe [PublicKeySummary]
Maybe Text
quantity :: Int
maxItems :: Int
nextMarker :: Maybe Text
items :: Maybe [PublicKeySummary]
$sel:quantity:PublicKeyList' :: PublicKeyList -> Int
$sel:maxItems:PublicKeyList' :: PublicKeyList -> Int
$sel:nextMarker:PublicKeyList' :: PublicKeyList -> Maybe Text
$sel:items:PublicKeyList' :: PublicKeyList -> Maybe [PublicKeySummary]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PublicKeySummary]
items
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextMarker
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
maxItems
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
quantity

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