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

import Amazonka.CloudFront.Types.CachePolicySummary
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 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
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]
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
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. 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'
    { $sel:items:CachePolicyList' :: Maybe [CachePolicySummary]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:CachePolicyList' :: Maybe Text
nextMarker = 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 :: Lens' CachePolicyList (Maybe [CachePolicySummary])
cachePolicyList_items = 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) 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 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 :: Lens' CachePolicyList (Maybe Text)
cachePolicyList_nextMarker = 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 :: Lens' CachePolicyList Int
cachePolicyList_maxItems = 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 :: Lens' CachePolicyList Int
cachePolicyList_quantity = 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 Data.FromXML CachePolicyList where
  parseXML :: [Node] -> Either String CachePolicyList
parseXML [Node]
x =
    Maybe [CachePolicySummary]
-> Maybe Text -> Int -> Int -> CachePolicyList
CachePolicyList'
      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
"CachePolicySummary")
                  )
      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 CachePolicyList where
  hashWithSalt :: Int -> CachePolicyList -> Int
hashWithSalt Int
_salt CachePolicyList' {Int
Maybe [CachePolicySummary]
Maybe Text
quantity :: Int
maxItems :: Int
nextMarker :: Maybe Text
items :: Maybe [CachePolicySummary]
$sel:quantity:CachePolicyList' :: CachePolicyList -> Int
$sel:maxItems:CachePolicyList' :: CachePolicyList -> Int
$sel:nextMarker:CachePolicyList' :: CachePolicyList -> Maybe Text
$sel:items:CachePolicyList' :: CachePolicyList -> Maybe [CachePolicySummary]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [CachePolicySummary]
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 CachePolicyList where
  rnf :: CachePolicyList -> ()
rnf CachePolicyList' {Int
Maybe [CachePolicySummary]
Maybe Text
quantity :: Int
maxItems :: Int
nextMarker :: Maybe Text
items :: Maybe [CachePolicySummary]
$sel:quantity:CachePolicyList' :: CachePolicyList -> Int
$sel:maxItems:CachePolicyList' :: CachePolicyList -> Int
$sel:nextMarker:CachePolicyList' :: CachePolicyList -> Maybe Text
$sel:items:CachePolicyList' :: CachePolicyList -> Maybe [CachePolicySummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [CachePolicySummary]
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