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

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

-- | A distribution list.
--
-- /See:/ 'newDistributionList' smart constructor.
data DistributionList = DistributionList'
  { -- | A complex type that contains one @DistributionSummary@ element for each
    -- distribution that was created by the current account.
    DistributionList -> Maybe [DistributionSummary]
items :: Prelude.Maybe [DistributionSummary],
    -- | If @IsTruncated@ is @true@, this element is present and contains the
    -- value you can use for the @Marker@ request parameter to continue listing
    -- your distributions where they left off.
    DistributionList -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    -- | The value you provided for the @Marker@ request parameter.
    DistributionList -> Text
marker :: Prelude.Text,
    -- | The value you provided for the @MaxItems@ request parameter.
    DistributionList -> Int
maxItems :: Prelude.Int,
    -- | A flag that indicates whether more distributions remain to be listed. If
    -- your results were truncated, you can make a follow-up pagination request
    -- using the @Marker@ request parameter to retrieve more distributions in
    -- the list.
    DistributionList -> Bool
isTruncated :: Prelude.Bool,
    -- | The number of distributions that were created by the current account.
    DistributionList -> Int
quantity :: Prelude.Int
  }
  deriving (DistributionList -> DistributionList -> Bool
(DistributionList -> DistributionList -> Bool)
-> (DistributionList -> DistributionList -> Bool)
-> Eq DistributionList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DistributionList -> DistributionList -> Bool
$c/= :: DistributionList -> DistributionList -> Bool
== :: DistributionList -> DistributionList -> Bool
$c== :: DistributionList -> DistributionList -> Bool
Prelude.Eq, ReadPrec [DistributionList]
ReadPrec DistributionList
Int -> ReadS DistributionList
ReadS [DistributionList]
(Int -> ReadS DistributionList)
-> ReadS [DistributionList]
-> ReadPrec DistributionList
-> ReadPrec [DistributionList]
-> Read DistributionList
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DistributionList]
$creadListPrec :: ReadPrec [DistributionList]
readPrec :: ReadPrec DistributionList
$creadPrec :: ReadPrec DistributionList
readList :: ReadS [DistributionList]
$creadList :: ReadS [DistributionList]
readsPrec :: Int -> ReadS DistributionList
$creadsPrec :: Int -> ReadS DistributionList
Prelude.Read, Int -> DistributionList -> ShowS
[DistributionList] -> ShowS
DistributionList -> String
(Int -> DistributionList -> ShowS)
-> (DistributionList -> String)
-> ([DistributionList] -> ShowS)
-> Show DistributionList
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DistributionList] -> ShowS
$cshowList :: [DistributionList] -> ShowS
show :: DistributionList -> String
$cshow :: DistributionList -> String
showsPrec :: Int -> DistributionList -> ShowS
$cshowsPrec :: Int -> DistributionList -> ShowS
Prelude.Show, (forall x. DistributionList -> Rep DistributionList x)
-> (forall x. Rep DistributionList x -> DistributionList)
-> Generic DistributionList
forall x. Rep DistributionList x -> DistributionList
forall x. DistributionList -> Rep DistributionList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DistributionList x -> DistributionList
$cfrom :: forall x. DistributionList -> Rep DistributionList x
Prelude.Generic)

-- |
-- Create a value of 'DistributionList' 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', 'distributionList_items' - A complex type that contains one @DistributionSummary@ element for each
-- distribution that was created by the current account.
--
-- 'nextMarker', 'distributionList_nextMarker' - If @IsTruncated@ is @true@, this element is present and contains the
-- value you can use for the @Marker@ request parameter to continue listing
-- your distributions where they left off.
--
-- 'marker', 'distributionList_marker' - The value you provided for the @Marker@ request parameter.
--
-- 'maxItems', 'distributionList_maxItems' - The value you provided for the @MaxItems@ request parameter.
--
-- 'isTruncated', 'distributionList_isTruncated' - A flag that indicates whether more distributions remain to be listed. If
-- your results were truncated, you can make a follow-up pagination request
-- using the @Marker@ request parameter to retrieve more distributions in
-- the list.
--
-- 'quantity', 'distributionList_quantity' - The number of distributions that were created by the current account.
newDistributionList ::
  -- | 'marker'
  Prelude.Text ->
  -- | 'maxItems'
  Prelude.Int ->
  -- | 'isTruncated'
  Prelude.Bool ->
  -- | 'quantity'
  Prelude.Int ->
  DistributionList
newDistributionList :: Text -> Int -> Bool -> Int -> DistributionList
newDistributionList
  Text
pMarker_
  Int
pMaxItems_
  Bool
pIsTruncated_
  Int
pQuantity_ =
    DistributionList' :: Maybe [DistributionSummary]
-> Maybe Text -> Text -> Int -> Bool -> Int -> DistributionList
DistributionList'
      { $sel:items:DistributionList' :: Maybe [DistributionSummary]
items = Maybe [DistributionSummary]
forall a. Maybe a
Prelude.Nothing,
        $sel:nextMarker:DistributionList' :: Maybe Text
nextMarker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:marker:DistributionList' :: Text
marker = Text
pMarker_,
        $sel:maxItems:DistributionList' :: Int
maxItems = Int
pMaxItems_,
        $sel:isTruncated:DistributionList' :: Bool
isTruncated = Bool
pIsTruncated_,
        $sel:quantity:DistributionList' :: Int
quantity = Int
pQuantity_
      }

-- | A complex type that contains one @DistributionSummary@ element for each
-- distribution that was created by the current account.
distributionList_items :: Lens.Lens' DistributionList (Prelude.Maybe [DistributionSummary])
distributionList_items :: (Maybe [DistributionSummary] -> f (Maybe [DistributionSummary]))
-> DistributionList -> f DistributionList
distributionList_items = (DistributionList -> Maybe [DistributionSummary])
-> (DistributionList
    -> Maybe [DistributionSummary] -> DistributionList)
-> Lens
     DistributionList
     DistributionList
     (Maybe [DistributionSummary])
     (Maybe [DistributionSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DistributionList' {Maybe [DistributionSummary]
items :: Maybe [DistributionSummary]
$sel:items:DistributionList' :: DistributionList -> Maybe [DistributionSummary]
items} -> Maybe [DistributionSummary]
items) (\s :: DistributionList
s@DistributionList' {} Maybe [DistributionSummary]
a -> DistributionList
s {$sel:items:DistributionList' :: Maybe [DistributionSummary]
items = Maybe [DistributionSummary]
a} :: DistributionList) ((Maybe [DistributionSummary] -> f (Maybe [DistributionSummary]))
 -> DistributionList -> f DistributionList)
-> ((Maybe [DistributionSummary]
     -> f (Maybe [DistributionSummary]))
    -> Maybe [DistributionSummary] -> f (Maybe [DistributionSummary]))
-> (Maybe [DistributionSummary] -> f (Maybe [DistributionSummary]))
-> DistributionList
-> f DistributionList
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DistributionSummary]
  [DistributionSummary]
  [DistributionSummary]
  [DistributionSummary]
-> Iso
     (Maybe [DistributionSummary])
     (Maybe [DistributionSummary])
     (Maybe [DistributionSummary])
     (Maybe [DistributionSummary])
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
  [DistributionSummary]
  [DistributionSummary]
  [DistributionSummary]
  [DistributionSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If @IsTruncated@ is @true@, this element is present and contains the
-- value you can use for the @Marker@ request parameter to continue listing
-- your distributions where they left off.
distributionList_nextMarker :: Lens.Lens' DistributionList (Prelude.Maybe Prelude.Text)
distributionList_nextMarker :: (Maybe Text -> f (Maybe Text))
-> DistributionList -> f DistributionList
distributionList_nextMarker = (DistributionList -> Maybe Text)
-> (DistributionList -> Maybe Text -> DistributionList)
-> Lens DistributionList DistributionList (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DistributionList' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:DistributionList' :: DistributionList -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: DistributionList
s@DistributionList' {} Maybe Text
a -> DistributionList
s {$sel:nextMarker:DistributionList' :: Maybe Text
nextMarker = Maybe Text
a} :: DistributionList)

-- | The value you provided for the @Marker@ request parameter.
distributionList_marker :: Lens.Lens' DistributionList Prelude.Text
distributionList_marker :: (Text -> f Text) -> DistributionList -> f DistributionList
distributionList_marker = (DistributionList -> Text)
-> (DistributionList -> Text -> DistributionList)
-> Lens DistributionList DistributionList Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DistributionList' {Text
marker :: Text
$sel:marker:DistributionList' :: DistributionList -> Text
marker} -> Text
marker) (\s :: DistributionList
s@DistributionList' {} Text
a -> DistributionList
s {$sel:marker:DistributionList' :: Text
marker = Text
a} :: DistributionList)

-- | The value you provided for the @MaxItems@ request parameter.
distributionList_maxItems :: Lens.Lens' DistributionList Prelude.Int
distributionList_maxItems :: (Int -> f Int) -> DistributionList -> f DistributionList
distributionList_maxItems = (DistributionList -> Int)
-> (DistributionList -> Int -> DistributionList)
-> Lens DistributionList DistributionList Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DistributionList' {Int
maxItems :: Int
$sel:maxItems:DistributionList' :: DistributionList -> Int
maxItems} -> Int
maxItems) (\s :: DistributionList
s@DistributionList' {} Int
a -> DistributionList
s {$sel:maxItems:DistributionList' :: Int
maxItems = Int
a} :: DistributionList)

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

-- | The number of distributions that were created by the current account.
distributionList_quantity :: Lens.Lens' DistributionList Prelude.Int
distributionList_quantity :: (Int -> f Int) -> DistributionList -> f DistributionList
distributionList_quantity = (DistributionList -> Int)
-> (DistributionList -> Int -> DistributionList)
-> Lens DistributionList DistributionList Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DistributionList' {Int
quantity :: Int
$sel:quantity:DistributionList' :: DistributionList -> Int
quantity} -> Int
quantity) (\s :: DistributionList
s@DistributionList' {} Int
a -> DistributionList
s {$sel:quantity:DistributionList' :: Int
quantity = Int
a} :: DistributionList)

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

instance Prelude.NFData DistributionList