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

import Amazonka.CloudFront.Types.PublicKeySummary
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(PublicKeyList -> PublicKeyList -> Bool)
-> (PublicKeyList -> PublicKeyList -> Bool) -> Eq PublicKeyList
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]
(Int -> ReadS PublicKeyList)
-> ReadS [PublicKeyList]
-> ReadPrec PublicKeyList
-> ReadPrec [PublicKeyList]
-> Read 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
(Int -> PublicKeyList -> ShowS)
-> (PublicKeyList -> String)
-> ([PublicKeyList] -> ShowS)
-> Show PublicKeyList
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. PublicKeyList -> Rep PublicKeyList x)
-> (forall x. Rep PublicKeyList x -> PublicKeyList)
-> Generic PublicKeyList
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' :: Maybe [PublicKeySummary]
-> Maybe Text -> Int -> Int -> PublicKeyList
PublicKeyList'
    { $sel:items:PublicKeyList' :: Maybe [PublicKeySummary]
items = Maybe [PublicKeySummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:PublicKeyList' :: Maybe Text
nextMarker = Maybe Text
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 :: (Maybe [PublicKeySummary] -> f (Maybe [PublicKeySummary]))
-> PublicKeyList -> f PublicKeyList
publicKeyList_items = (PublicKeyList -> Maybe [PublicKeySummary])
-> (PublicKeyList -> Maybe [PublicKeySummary] -> PublicKeyList)
-> Lens
     PublicKeyList
     PublicKeyList
     (Maybe [PublicKeySummary])
     (Maybe [PublicKeySummary])
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) ((Maybe [PublicKeySummary] -> f (Maybe [PublicKeySummary]))
 -> PublicKeyList -> f PublicKeyList)
-> ((Maybe [PublicKeySummary] -> f (Maybe [PublicKeySummary]))
    -> Maybe [PublicKeySummary] -> f (Maybe [PublicKeySummary]))
-> (Maybe [PublicKeySummary] -> f (Maybe [PublicKeySummary]))
-> PublicKeyList
-> f PublicKeyList
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PublicKeySummary]
  [PublicKeySummary]
  [PublicKeySummary]
  [PublicKeySummary]
-> Iso
     (Maybe [PublicKeySummary])
     (Maybe [PublicKeySummary])
     (Maybe [PublicKeySummary])
     (Maybe [PublicKeySummary])
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
  [PublicKeySummary]
  [PublicKeySummary]
  [PublicKeySummary]
  [PublicKeySummary]
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 :: (Maybe Text -> f (Maybe Text)) -> PublicKeyList -> f PublicKeyList
publicKeyList_nextMarker = (PublicKeyList -> Maybe Text)
-> (PublicKeyList -> Maybe Text -> PublicKeyList)
-> Lens PublicKeyList PublicKeyList (Maybe Text) (Maybe Text)
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 :: (Int -> f Int) -> PublicKeyList -> f PublicKeyList
publicKeyList_maxItems = (PublicKeyList -> Int)
-> (PublicKeyList -> Int -> PublicKeyList)
-> Lens PublicKeyList PublicKeyList Int Int
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 :: (Int -> f Int) -> PublicKeyList -> f PublicKeyList
publicKeyList_quantity = (PublicKeyList -> Int)
-> (PublicKeyList -> Int -> PublicKeyList)
-> Lens PublicKeyList PublicKeyList Int Int
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 Core.FromXML PublicKeyList where
  parseXML :: [Node] -> Either String PublicKeyList
parseXML [Node]
x =
    Maybe [PublicKeySummary]
-> Maybe Text -> Int -> Int -> PublicKeyList
PublicKeyList'
      (Maybe [PublicKeySummary]
 -> Maybe Text -> Int -> Int -> PublicKeyList)
-> Either String (Maybe [PublicKeySummary])
-> Either String (Maybe Text -> Int -> Int -> PublicKeyList)
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 [PublicKeySummary]))
-> Either String (Maybe [PublicKeySummary])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [PublicKeySummary])
-> [Node] -> Either String (Maybe [PublicKeySummary])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [PublicKeySummary]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"PublicKeySummary")
                  )
      Either String (Maybe Text -> Int -> Int -> PublicKeyList)
-> Either String (Maybe Text)
-> Either String (Int -> Int -> PublicKeyList)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"NextMarker")
      Either String (Int -> Int -> PublicKeyList)
-> Either String Int -> Either String (Int -> PublicKeyList)
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
"MaxItems")
      Either String (Int -> PublicKeyList)
-> Either String Int -> Either String PublicKeyList
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 PublicKeyList

instance Prelude.NFData PublicKeyList