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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A list of distribution IDs.
--
-- /See:/ 'newDistributionIdList' smart constructor.
data DistributionIdList = DistributionIdList'
  { -- | Contains the distribution IDs in the list.
    DistributionIdList -> Maybe [Text]
items :: Prelude.Maybe [Prelude.Text],
    -- | Contains the value that you should use in the @Marker@ field of a
    -- subsequent request to continue listing distribution IDs where you left
    -- off.
    DistributionIdList -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    -- | The value provided in the @Marker@ request field.
    DistributionIdList -> Text
marker :: Prelude.Text,
    -- | The maximum number of distribution IDs requested.
    DistributionIdList -> Int
maxItems :: Prelude.Int,
    -- | A flag that indicates whether more distribution IDs remain to be listed.
    -- If your results were truncated, you can make a subsequent request using
    -- the @Marker@ request field to retrieve more distribution IDs in the
    -- list.
    DistributionIdList -> Bool
isTruncated :: Prelude.Bool,
    -- | The total number of distribution IDs returned in the response.
    DistributionIdList -> Int
quantity :: Prelude.Int
  }
  deriving (DistributionIdList -> DistributionIdList -> Bool
(DistributionIdList -> DistributionIdList -> Bool)
-> (DistributionIdList -> DistributionIdList -> Bool)
-> Eq DistributionIdList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DistributionIdList -> DistributionIdList -> Bool
$c/= :: DistributionIdList -> DistributionIdList -> Bool
== :: DistributionIdList -> DistributionIdList -> Bool
$c== :: DistributionIdList -> DistributionIdList -> Bool
Prelude.Eq, ReadPrec [DistributionIdList]
ReadPrec DistributionIdList
Int -> ReadS DistributionIdList
ReadS [DistributionIdList]
(Int -> ReadS DistributionIdList)
-> ReadS [DistributionIdList]
-> ReadPrec DistributionIdList
-> ReadPrec [DistributionIdList]
-> Read DistributionIdList
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DistributionIdList]
$creadListPrec :: ReadPrec [DistributionIdList]
readPrec :: ReadPrec DistributionIdList
$creadPrec :: ReadPrec DistributionIdList
readList :: ReadS [DistributionIdList]
$creadList :: ReadS [DistributionIdList]
readsPrec :: Int -> ReadS DistributionIdList
$creadsPrec :: Int -> ReadS DistributionIdList
Prelude.Read, Int -> DistributionIdList -> ShowS
[DistributionIdList] -> ShowS
DistributionIdList -> String
(Int -> DistributionIdList -> ShowS)
-> (DistributionIdList -> String)
-> ([DistributionIdList] -> ShowS)
-> Show DistributionIdList
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DistributionIdList] -> ShowS
$cshowList :: [DistributionIdList] -> ShowS
show :: DistributionIdList -> String
$cshow :: DistributionIdList -> String
showsPrec :: Int -> DistributionIdList -> ShowS
$cshowsPrec :: Int -> DistributionIdList -> ShowS
Prelude.Show, (forall x. DistributionIdList -> Rep DistributionIdList x)
-> (forall x. Rep DistributionIdList x -> DistributionIdList)
-> Generic DistributionIdList
forall x. Rep DistributionIdList x -> DistributionIdList
forall x. DistributionIdList -> Rep DistributionIdList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DistributionIdList x -> DistributionIdList
$cfrom :: forall x. DistributionIdList -> Rep DistributionIdList x
Prelude.Generic)

-- |
-- Create a value of 'DistributionIdList' 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', 'distributionIdList_items' - Contains the distribution IDs in the list.
--
-- 'nextMarker', 'distributionIdList_nextMarker' - Contains the value that you should use in the @Marker@ field of a
-- subsequent request to continue listing distribution IDs where you left
-- off.
--
-- 'marker', 'distributionIdList_marker' - The value provided in the @Marker@ request field.
--
-- 'maxItems', 'distributionIdList_maxItems' - The maximum number of distribution IDs requested.
--
-- 'isTruncated', 'distributionIdList_isTruncated' - A flag that indicates whether more distribution IDs remain to be listed.
-- If your results were truncated, you can make a subsequent request using
-- the @Marker@ request field to retrieve more distribution IDs in the
-- list.
--
-- 'quantity', 'distributionIdList_quantity' - The total number of distribution IDs returned in the response.
newDistributionIdList ::
  -- | 'marker'
  Prelude.Text ->
  -- | 'maxItems'
  Prelude.Int ->
  -- | 'isTruncated'
  Prelude.Bool ->
  -- | 'quantity'
  Prelude.Int ->
  DistributionIdList
newDistributionIdList :: Text -> Int -> Bool -> Int -> DistributionIdList
newDistributionIdList
  Text
pMarker_
  Int
pMaxItems_
  Bool
pIsTruncated_
  Int
pQuantity_ =
    DistributionIdList' :: Maybe [Text]
-> Maybe Text -> Text -> Int -> Bool -> Int -> DistributionIdList
DistributionIdList'
      { $sel:items:DistributionIdList' :: Maybe [Text]
items = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:nextMarker:DistributionIdList' :: Maybe Text
nextMarker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:marker:DistributionIdList' :: Text
marker = Text
pMarker_,
        $sel:maxItems:DistributionIdList' :: Int
maxItems = Int
pMaxItems_,
        $sel:isTruncated:DistributionIdList' :: Bool
isTruncated = Bool
pIsTruncated_,
        $sel:quantity:DistributionIdList' :: Int
quantity = Int
pQuantity_
      }

-- | Contains the distribution IDs in the list.
distributionIdList_items :: Lens.Lens' DistributionIdList (Prelude.Maybe [Prelude.Text])
distributionIdList_items :: (Maybe [Text] -> f (Maybe [Text]))
-> DistributionIdList -> f DistributionIdList
distributionIdList_items = (DistributionIdList -> Maybe [Text])
-> (DistributionIdList -> Maybe [Text] -> DistributionIdList)
-> Lens
     DistributionIdList DistributionIdList (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DistributionIdList' {Maybe [Text]
items :: Maybe [Text]
$sel:items:DistributionIdList' :: DistributionIdList -> Maybe [Text]
items} -> Maybe [Text]
items) (\s :: DistributionIdList
s@DistributionIdList' {} Maybe [Text]
a -> DistributionIdList
s {$sel:items:DistributionIdList' :: Maybe [Text]
items = Maybe [Text]
a} :: DistributionIdList) ((Maybe [Text] -> f (Maybe [Text]))
 -> DistributionIdList -> f DistributionIdList)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DistributionIdList
-> f DistributionIdList
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Contains the value that you should use in the @Marker@ field of a
-- subsequent request to continue listing distribution IDs where you left
-- off.
distributionIdList_nextMarker :: Lens.Lens' DistributionIdList (Prelude.Maybe Prelude.Text)
distributionIdList_nextMarker :: (Maybe Text -> f (Maybe Text))
-> DistributionIdList -> f DistributionIdList
distributionIdList_nextMarker = (DistributionIdList -> Maybe Text)
-> (DistributionIdList -> Maybe Text -> DistributionIdList)
-> Lens
     DistributionIdList DistributionIdList (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DistributionIdList' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:DistributionIdList' :: DistributionIdList -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: DistributionIdList
s@DistributionIdList' {} Maybe Text
a -> DistributionIdList
s {$sel:nextMarker:DistributionIdList' :: Maybe Text
nextMarker = Maybe Text
a} :: DistributionIdList)

-- | The value provided in the @Marker@ request field.
distributionIdList_marker :: Lens.Lens' DistributionIdList Prelude.Text
distributionIdList_marker :: (Text -> f Text) -> DistributionIdList -> f DistributionIdList
distributionIdList_marker = (DistributionIdList -> Text)
-> (DistributionIdList -> Text -> DistributionIdList)
-> Lens DistributionIdList DistributionIdList Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DistributionIdList' {Text
marker :: Text
$sel:marker:DistributionIdList' :: DistributionIdList -> Text
marker} -> Text
marker) (\s :: DistributionIdList
s@DistributionIdList' {} Text
a -> DistributionIdList
s {$sel:marker:DistributionIdList' :: Text
marker = Text
a} :: DistributionIdList)

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

-- | A flag that indicates whether more distribution IDs remain to be listed.
-- If your results were truncated, you can make a subsequent request using
-- the @Marker@ request field to retrieve more distribution IDs in the
-- list.
distributionIdList_isTruncated :: Lens.Lens' DistributionIdList Prelude.Bool
distributionIdList_isTruncated :: (Bool -> f Bool) -> DistributionIdList -> f DistributionIdList
distributionIdList_isTruncated = (DistributionIdList -> Bool)
-> (DistributionIdList -> Bool -> DistributionIdList)
-> Lens DistributionIdList DistributionIdList Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DistributionIdList' {Bool
isTruncated :: Bool
$sel:isTruncated:DistributionIdList' :: DistributionIdList -> Bool
isTruncated} -> Bool
isTruncated) (\s :: DistributionIdList
s@DistributionIdList' {} Bool
a -> DistributionIdList
s {$sel:isTruncated:DistributionIdList' :: Bool
isTruncated = Bool
a} :: DistributionIdList)

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

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

instance Prelude.NFData DistributionIdList