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

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

-- | A list of cache policies.
--
-- /See:/ 'newCachePolicyList' smart constructor.
data CachePolicyList = CachePolicyList'
  { -- | Contains the cache policies in the list.
    CachePolicyList -> Maybe [CachePolicySummary]
items :: Prelude.Maybe [CachePolicySummary],
    -- | 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 cache
    -- policies where you left off.
    CachePolicyList -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of cache policies requested.
    CachePolicyList -> Int
maxItems :: Prelude.Int,
    -- | The total number of cache policies returned in the response.
    CachePolicyList -> Int
quantity :: Prelude.Int
  }
  deriving (CachePolicyList -> CachePolicyList -> Bool
(CachePolicyList -> CachePolicyList -> Bool)
-> (CachePolicyList -> CachePolicyList -> Bool)
-> Eq CachePolicyList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CachePolicyList -> CachePolicyList -> Bool
$c/= :: CachePolicyList -> CachePolicyList -> Bool
== :: CachePolicyList -> CachePolicyList -> Bool
$c== :: CachePolicyList -> CachePolicyList -> Bool
Prelude.Eq, ReadPrec [CachePolicyList]
ReadPrec CachePolicyList
Int -> ReadS CachePolicyList
ReadS [CachePolicyList]
(Int -> ReadS CachePolicyList)
-> ReadS [CachePolicyList]
-> ReadPrec CachePolicyList
-> ReadPrec [CachePolicyList]
-> Read CachePolicyList
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CachePolicyList]
$creadListPrec :: ReadPrec [CachePolicyList]
readPrec :: ReadPrec CachePolicyList
$creadPrec :: ReadPrec CachePolicyList
readList :: ReadS [CachePolicyList]
$creadList :: ReadS [CachePolicyList]
readsPrec :: Int -> ReadS CachePolicyList
$creadsPrec :: Int -> ReadS CachePolicyList
Prelude.Read, Int -> CachePolicyList -> ShowS
[CachePolicyList] -> ShowS
CachePolicyList -> String
(Int -> CachePolicyList -> ShowS)
-> (CachePolicyList -> String)
-> ([CachePolicyList] -> ShowS)
-> Show CachePolicyList
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CachePolicyList] -> ShowS
$cshowList :: [CachePolicyList] -> ShowS
show :: CachePolicyList -> String
$cshow :: CachePolicyList -> String
showsPrec :: Int -> CachePolicyList -> ShowS
$cshowsPrec :: Int -> CachePolicyList -> ShowS
Prelude.Show, (forall x. CachePolicyList -> Rep CachePolicyList x)
-> (forall x. Rep CachePolicyList x -> CachePolicyList)
-> Generic CachePolicyList
forall x. Rep CachePolicyList x -> CachePolicyList
forall x. CachePolicyList -> Rep CachePolicyList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CachePolicyList x -> CachePolicyList
$cfrom :: forall x. CachePolicyList -> Rep CachePolicyList x
Prelude.Generic)

-- |
-- Create a value of 'CachePolicyList' 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', 'cachePolicyList_items' - Contains the cache policies in the list.
--
-- 'nextMarker', 'cachePolicyList_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 cache
-- policies where you left off.
--
-- 'maxItems', 'cachePolicyList_maxItems' - The maximum number of cache policies requested.
--
-- 'quantity', 'cachePolicyList_quantity' - The total number of cache policies returned in the response.
newCachePolicyList ::
  -- | 'maxItems'
  Prelude.Int ->
  -- | 'quantity'
  Prelude.Int ->
  CachePolicyList
newCachePolicyList :: Int -> Int -> CachePolicyList
newCachePolicyList Int
pMaxItems_ Int
pQuantity_ =
  CachePolicyList' :: Maybe [CachePolicySummary]
-> Maybe Text -> Int -> Int -> CachePolicyList
CachePolicyList'
    { $sel:items:CachePolicyList' :: Maybe [CachePolicySummary]
items = Maybe [CachePolicySummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:CachePolicyList' :: Maybe Text
nextMarker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:CachePolicyList' :: Int
maxItems = Int
pMaxItems_,
      $sel:quantity:CachePolicyList' :: Int
quantity = Int
pQuantity_
    }

-- | Contains the cache policies in the list.
cachePolicyList_items :: Lens.Lens' CachePolicyList (Prelude.Maybe [CachePolicySummary])
cachePolicyList_items :: (Maybe [CachePolicySummary] -> f (Maybe [CachePolicySummary]))
-> CachePolicyList -> f CachePolicyList
cachePolicyList_items = (CachePolicyList -> Maybe [CachePolicySummary])
-> (CachePolicyList
    -> Maybe [CachePolicySummary] -> CachePolicyList)
-> Lens
     CachePolicyList
     CachePolicyList
     (Maybe [CachePolicySummary])
     (Maybe [CachePolicySummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicyList' {Maybe [CachePolicySummary]
items :: Maybe [CachePolicySummary]
$sel:items:CachePolicyList' :: CachePolicyList -> Maybe [CachePolicySummary]
items} -> Maybe [CachePolicySummary]
items) (\s :: CachePolicyList
s@CachePolicyList' {} Maybe [CachePolicySummary]
a -> CachePolicyList
s {$sel:items:CachePolicyList' :: Maybe [CachePolicySummary]
items = Maybe [CachePolicySummary]
a} :: CachePolicyList) ((Maybe [CachePolicySummary] -> f (Maybe [CachePolicySummary]))
 -> CachePolicyList -> f CachePolicyList)
-> ((Maybe [CachePolicySummary] -> f (Maybe [CachePolicySummary]))
    -> Maybe [CachePolicySummary] -> f (Maybe [CachePolicySummary]))
-> (Maybe [CachePolicySummary] -> f (Maybe [CachePolicySummary]))
-> CachePolicyList
-> f CachePolicyList
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CachePolicySummary]
  [CachePolicySummary]
  [CachePolicySummary]
  [CachePolicySummary]
-> Iso
     (Maybe [CachePolicySummary])
     (Maybe [CachePolicySummary])
     (Maybe [CachePolicySummary])
     (Maybe [CachePolicySummary])
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
  [CachePolicySummary]
  [CachePolicySummary]
  [CachePolicySummary]
  [CachePolicySummary]
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 cache
-- policies where you left off.
cachePolicyList_nextMarker :: Lens.Lens' CachePolicyList (Prelude.Maybe Prelude.Text)
cachePolicyList_nextMarker :: (Maybe Text -> f (Maybe Text))
-> CachePolicyList -> f CachePolicyList
cachePolicyList_nextMarker = (CachePolicyList -> Maybe Text)
-> (CachePolicyList -> Maybe Text -> CachePolicyList)
-> Lens CachePolicyList CachePolicyList (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicyList' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:CachePolicyList' :: CachePolicyList -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: CachePolicyList
s@CachePolicyList' {} Maybe Text
a -> CachePolicyList
s {$sel:nextMarker:CachePolicyList' :: Maybe Text
nextMarker = Maybe Text
a} :: CachePolicyList)

-- | The maximum number of cache policies requested.
cachePolicyList_maxItems :: Lens.Lens' CachePolicyList Prelude.Int
cachePolicyList_maxItems :: (Int -> f Int) -> CachePolicyList -> f CachePolicyList
cachePolicyList_maxItems = (CachePolicyList -> Int)
-> (CachePolicyList -> Int -> CachePolicyList)
-> Lens CachePolicyList CachePolicyList Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicyList' {Int
maxItems :: Int
$sel:maxItems:CachePolicyList' :: CachePolicyList -> Int
maxItems} -> Int
maxItems) (\s :: CachePolicyList
s@CachePolicyList' {} Int
a -> CachePolicyList
s {$sel:maxItems:CachePolicyList' :: Int
maxItems = Int
a} :: CachePolicyList)

-- | The total number of cache policies returned in the response.
cachePolicyList_quantity :: Lens.Lens' CachePolicyList Prelude.Int
cachePolicyList_quantity :: (Int -> f Int) -> CachePolicyList -> f CachePolicyList
cachePolicyList_quantity = (CachePolicyList -> Int)
-> (CachePolicyList -> Int -> CachePolicyList)
-> Lens CachePolicyList CachePolicyList Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicyList' {Int
quantity :: Int
$sel:quantity:CachePolicyList' :: CachePolicyList -> Int
quantity} -> Int
quantity) (\s :: CachePolicyList
s@CachePolicyList' {} Int
a -> CachePolicyList
s {$sel:quantity:CachePolicyList' :: Int
quantity = Int
a} :: CachePolicyList)

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

instance Prelude.NFData CachePolicyList