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

import Amazonka.CloudFront.Types.KeyGroupSummary
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A list of key groups.
--
-- /See:/ 'newKeyGroupList' smart constructor.
data KeyGroupList = KeyGroupList'
  { -- | A list of key groups.
    KeyGroupList -> Maybe [KeyGroupSummary]
items :: Prelude.Maybe [KeyGroupSummary],
    -- | If there are more items in the list than are in this response, this
    -- element is present. It contains the value that you should use in the
    -- @Marker@ field of a subsequent request to continue listing key groups.
    KeyGroupList -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of key groups requested.
    KeyGroupList -> Int
maxItems :: Prelude.Int,
    -- | The number of key groups returned in the response.
    KeyGroupList -> Int
quantity :: Prelude.Int
  }
  deriving (KeyGroupList -> KeyGroupList -> Bool
(KeyGroupList -> KeyGroupList -> Bool)
-> (KeyGroupList -> KeyGroupList -> Bool) -> Eq KeyGroupList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KeyGroupList -> KeyGroupList -> Bool
$c/= :: KeyGroupList -> KeyGroupList -> Bool
== :: KeyGroupList -> KeyGroupList -> Bool
$c== :: KeyGroupList -> KeyGroupList -> Bool
Prelude.Eq, ReadPrec [KeyGroupList]
ReadPrec KeyGroupList
Int -> ReadS KeyGroupList
ReadS [KeyGroupList]
(Int -> ReadS KeyGroupList)
-> ReadS [KeyGroupList]
-> ReadPrec KeyGroupList
-> ReadPrec [KeyGroupList]
-> Read KeyGroupList
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KeyGroupList]
$creadListPrec :: ReadPrec [KeyGroupList]
readPrec :: ReadPrec KeyGroupList
$creadPrec :: ReadPrec KeyGroupList
readList :: ReadS [KeyGroupList]
$creadList :: ReadS [KeyGroupList]
readsPrec :: Int -> ReadS KeyGroupList
$creadsPrec :: Int -> ReadS KeyGroupList
Prelude.Read, Int -> KeyGroupList -> ShowS
[KeyGroupList] -> ShowS
KeyGroupList -> String
(Int -> KeyGroupList -> ShowS)
-> (KeyGroupList -> String)
-> ([KeyGroupList] -> ShowS)
-> Show KeyGroupList
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KeyGroupList] -> ShowS
$cshowList :: [KeyGroupList] -> ShowS
show :: KeyGroupList -> String
$cshow :: KeyGroupList -> String
showsPrec :: Int -> KeyGroupList -> ShowS
$cshowsPrec :: Int -> KeyGroupList -> ShowS
Prelude.Show, (forall x. KeyGroupList -> Rep KeyGroupList x)
-> (forall x. Rep KeyGroupList x -> KeyGroupList)
-> Generic KeyGroupList
forall x. Rep KeyGroupList x -> KeyGroupList
forall x. KeyGroupList -> Rep KeyGroupList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KeyGroupList x -> KeyGroupList
$cfrom :: forall x. KeyGroupList -> Rep KeyGroupList x
Prelude.Generic)

-- |
-- Create a value of 'KeyGroupList' 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', 'keyGroupList_items' - A list of key groups.
--
-- 'nextMarker', 'keyGroupList_nextMarker' - If there are more items in the list than are in this response, this
-- element is present. It contains the value that you should use in the
-- @Marker@ field of a subsequent request to continue listing key groups.
--
-- 'maxItems', 'keyGroupList_maxItems' - The maximum number of key groups requested.
--
-- 'quantity', 'keyGroupList_quantity' - The number of key groups returned in the response.
newKeyGroupList ::
  -- | 'maxItems'
  Prelude.Int ->
  -- | 'quantity'
  Prelude.Int ->
  KeyGroupList
newKeyGroupList :: Int -> Int -> KeyGroupList
newKeyGroupList Int
pMaxItems_ Int
pQuantity_ =
  KeyGroupList' :: Maybe [KeyGroupSummary] -> Maybe Text -> Int -> Int -> KeyGroupList
KeyGroupList'
    { $sel:items:KeyGroupList' :: Maybe [KeyGroupSummary]
items = Maybe [KeyGroupSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:KeyGroupList' :: Maybe Text
nextMarker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:KeyGroupList' :: Int
maxItems = Int
pMaxItems_,
      $sel:quantity:KeyGroupList' :: Int
quantity = Int
pQuantity_
    }

-- | A list of key groups.
keyGroupList_items :: Lens.Lens' KeyGroupList (Prelude.Maybe [KeyGroupSummary])
keyGroupList_items :: (Maybe [KeyGroupSummary] -> f (Maybe [KeyGroupSummary]))
-> KeyGroupList -> f KeyGroupList
keyGroupList_items = (KeyGroupList -> Maybe [KeyGroupSummary])
-> (KeyGroupList -> Maybe [KeyGroupSummary] -> KeyGroupList)
-> Lens
     KeyGroupList
     KeyGroupList
     (Maybe [KeyGroupSummary])
     (Maybe [KeyGroupSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyGroupList' {Maybe [KeyGroupSummary]
items :: Maybe [KeyGroupSummary]
$sel:items:KeyGroupList' :: KeyGroupList -> Maybe [KeyGroupSummary]
items} -> Maybe [KeyGroupSummary]
items) (\s :: KeyGroupList
s@KeyGroupList' {} Maybe [KeyGroupSummary]
a -> KeyGroupList
s {$sel:items:KeyGroupList' :: Maybe [KeyGroupSummary]
items = Maybe [KeyGroupSummary]
a} :: KeyGroupList) ((Maybe [KeyGroupSummary] -> f (Maybe [KeyGroupSummary]))
 -> KeyGroupList -> f KeyGroupList)
-> ((Maybe [KeyGroupSummary] -> f (Maybe [KeyGroupSummary]))
    -> Maybe [KeyGroupSummary] -> f (Maybe [KeyGroupSummary]))
-> (Maybe [KeyGroupSummary] -> f (Maybe [KeyGroupSummary]))
-> KeyGroupList
-> f KeyGroupList
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [KeyGroupSummary]
  [KeyGroupSummary]
  [KeyGroupSummary]
  [KeyGroupSummary]
-> Iso
     (Maybe [KeyGroupSummary])
     (Maybe [KeyGroupSummary])
     (Maybe [KeyGroupSummary])
     (Maybe [KeyGroupSummary])
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
  [KeyGroupSummary]
  [KeyGroupSummary]
  [KeyGroupSummary]
  [KeyGroupSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If there are more items in the list than are in this response, this
-- element is present. It contains the value that you should use in the
-- @Marker@ field of a subsequent request to continue listing key groups.
keyGroupList_nextMarker :: Lens.Lens' KeyGroupList (Prelude.Maybe Prelude.Text)
keyGroupList_nextMarker :: (Maybe Text -> f (Maybe Text)) -> KeyGroupList -> f KeyGroupList
keyGroupList_nextMarker = (KeyGroupList -> Maybe Text)
-> (KeyGroupList -> Maybe Text -> KeyGroupList)
-> Lens KeyGroupList KeyGroupList (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyGroupList' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:KeyGroupList' :: KeyGroupList -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: KeyGroupList
s@KeyGroupList' {} Maybe Text
a -> KeyGroupList
s {$sel:nextMarker:KeyGroupList' :: Maybe Text
nextMarker = Maybe Text
a} :: KeyGroupList)

-- | The maximum number of key groups requested.
keyGroupList_maxItems :: Lens.Lens' KeyGroupList Prelude.Int
keyGroupList_maxItems :: (Int -> f Int) -> KeyGroupList -> f KeyGroupList
keyGroupList_maxItems = (KeyGroupList -> Int)
-> (KeyGroupList -> Int -> KeyGroupList)
-> Lens KeyGroupList KeyGroupList Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyGroupList' {Int
maxItems :: Int
$sel:maxItems:KeyGroupList' :: KeyGroupList -> Int
maxItems} -> Int
maxItems) (\s :: KeyGroupList
s@KeyGroupList' {} Int
a -> KeyGroupList
s {$sel:maxItems:KeyGroupList' :: Int
maxItems = Int
a} :: KeyGroupList)

-- | The number of key groups returned in the response.
keyGroupList_quantity :: Lens.Lens' KeyGroupList Prelude.Int
keyGroupList_quantity :: (Int -> f Int) -> KeyGroupList -> f KeyGroupList
keyGroupList_quantity = (KeyGroupList -> Int)
-> (KeyGroupList -> Int -> KeyGroupList)
-> Lens KeyGroupList KeyGroupList Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyGroupList' {Int
quantity :: Int
$sel:quantity:KeyGroupList' :: KeyGroupList -> Int
quantity} -> Int
quantity) (\s :: KeyGroupList
s@KeyGroupList' {} Int
a -> KeyGroupList
s {$sel:quantity:KeyGroupList' :: Int
quantity = Int
a} :: KeyGroupList)

instance Core.FromXML KeyGroupList where
  parseXML :: [Node] -> Either String KeyGroupList
parseXML [Node]
x =
    Maybe [KeyGroupSummary] -> Maybe Text -> Int -> Int -> KeyGroupList
KeyGroupList'
      (Maybe [KeyGroupSummary]
 -> Maybe Text -> Int -> Int -> KeyGroupList)
-> Either String (Maybe [KeyGroupSummary])
-> Either String (Maybe Text -> Int -> Int -> KeyGroupList)
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 [KeyGroupSummary]))
-> Either String (Maybe [KeyGroupSummary])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [KeyGroupSummary])
-> [Node] -> Either String (Maybe [KeyGroupSummary])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [KeyGroupSummary]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"KeyGroupSummary")
                  )
      Either String (Maybe Text -> Int -> Int -> KeyGroupList)
-> Either String (Maybe Text)
-> Either String (Int -> Int -> KeyGroupList)
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 -> KeyGroupList)
-> Either String Int -> Either String (Int -> KeyGroupList)
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 -> KeyGroupList)
-> Either String Int -> Either String KeyGroupList
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 KeyGroupList

instance Prelude.NFData KeyGroupList