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

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

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

-- |
-- Create a value of 'OriginRequestPolicyList' 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', 'originRequestPolicyList_items' - Contains the origin request policies in the list.
--
-- 'nextMarker', 'originRequestPolicyList_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 origin
-- request policies where you left off.
--
-- 'maxItems', 'originRequestPolicyList_maxItems' - The maximum number of origin request policies requested.
--
-- 'quantity', 'originRequestPolicyList_quantity' - The total number of origin request policies returned in the response.
newOriginRequestPolicyList ::
  -- | 'maxItems'
  Prelude.Int ->
  -- | 'quantity'
  Prelude.Int ->
  OriginRequestPolicyList
newOriginRequestPolicyList :: Int -> Int -> OriginRequestPolicyList
newOriginRequestPolicyList Int
pMaxItems_ Int
pQuantity_ =
  OriginRequestPolicyList' :: Maybe [OriginRequestPolicySummary]
-> Maybe Text -> Int -> Int -> OriginRequestPolicyList
OriginRequestPolicyList'
    { $sel:items:OriginRequestPolicyList' :: Maybe [OriginRequestPolicySummary]
items = Maybe [OriginRequestPolicySummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:OriginRequestPolicyList' :: Maybe Text
nextMarker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:OriginRequestPolicyList' :: Int
maxItems = Int
pMaxItems_,
      $sel:quantity:OriginRequestPolicyList' :: Int
quantity = Int
pQuantity_
    }

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

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

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

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

instance Prelude.NFData OriginRequestPolicyList