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

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

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

-- |
-- Create a value of 'FunctionList' 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', 'functionList_items' - Contains the functions in the list.
--
-- 'nextMarker', 'functionList_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 functions
-- where you left off.
--
-- 'maxItems', 'functionList_maxItems' - The maximum number of functions requested.
--
-- 'quantity', 'functionList_quantity' - The number of functions returned in the response.
newFunctionList ::
  -- | 'maxItems'
  Prelude.Int ->
  -- | 'quantity'
  Prelude.Int ->
  FunctionList
newFunctionList :: Int -> Int -> FunctionList
newFunctionList Int
pMaxItems_ Int
pQuantity_ =
  FunctionList' :: Maybe [FunctionSummary] -> Maybe Text -> Int -> Int -> FunctionList
FunctionList'
    { $sel:items:FunctionList' :: Maybe [FunctionSummary]
items = Maybe [FunctionSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:FunctionList' :: Maybe Text
nextMarker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:FunctionList' :: Int
maxItems = Int
pMaxItems_,
      $sel:quantity:FunctionList' :: Int
quantity = Int
pQuantity_
    }

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

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

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

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

instance Prelude.NFData FunctionList