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

import Amazonka.CloudFront.Types.DistributionSummary
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 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 Amazon Web Services
    -- 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 Amazon Web
    -- Services account.
    DistributionList -> Int
quantity :: Prelude.Int
  }
  deriving (DistributionList -> DistributionList -> Bool
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, Int -> DistributionList -> ShowS
[DistributionList] -> ShowS
DistributionList -> String
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. 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 Amazon Web Services
-- 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 Amazon Web
-- Services 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'
      { $sel:items:DistributionList' :: Maybe [DistributionSummary]
items = forall a. Maybe a
Prelude.Nothing,
        $sel:nextMarker:DistributionList' :: Maybe Text
nextMarker = 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 Amazon Web Services
-- account.
distributionList_items :: Lens.Lens' DistributionList (Prelude.Maybe [DistributionSummary])
distributionList_items :: Lens' DistributionList (Maybe [DistributionSummary])
distributionList_items = 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) 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 @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 :: Lens' DistributionList (Maybe Text)
distributionList_nextMarker = 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 :: Lens' DistributionList Text
distributionList_marker = 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 :: Lens' DistributionList Int
distributionList_maxItems = 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 :: Lens' DistributionList Bool
distributionList_isTruncated = 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 Amazon Web
-- Services account.
distributionList_quantity :: Lens.Lens' DistributionList Prelude.Int
distributionList_quantity :: Lens' DistributionList Int
distributionList_quantity = 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 Data.FromXML DistributionList where
  parseXML :: [Node] -> Either String DistributionList
parseXML [Node]
x =
    Maybe [DistributionSummary]
-> Maybe Text -> Text -> Int -> Bool -> Int -> DistributionList
DistributionList'
      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
"DistributionSummary")
                  )
      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
"Marker")
      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
"IsTruncated")
      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 DistributionList where
  hashWithSalt :: Int -> DistributionList -> Int
hashWithSalt Int
_salt DistributionList' {Bool
Int
Maybe [DistributionSummary]
Maybe Text
Text
quantity :: Int
isTruncated :: Bool
maxItems :: Int
marker :: Text
nextMarker :: Maybe Text
items :: Maybe [DistributionSummary]
$sel:quantity:DistributionList' :: DistributionList -> Int
$sel:isTruncated:DistributionList' :: DistributionList -> Bool
$sel:maxItems:DistributionList' :: DistributionList -> Int
$sel:marker:DistributionList' :: DistributionList -> Text
$sel:nextMarker:DistributionList' :: DistributionList -> Maybe Text
$sel:items:DistributionList' :: DistributionList -> Maybe [DistributionSummary]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DistributionSummary]
items
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextMarker
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
marker
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
maxItems
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
isTruncated
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
quantity

instance Prelude.NFData DistributionList where
  rnf :: DistributionList -> ()
rnf DistributionList' {Bool
Int
Maybe [DistributionSummary]
Maybe Text
Text
quantity :: Int
isTruncated :: Bool
maxItems :: Int
marker :: Text
nextMarker :: Maybe Text
items :: Maybe [DistributionSummary]
$sel:quantity:DistributionList' :: DistributionList -> Int
$sel:isTruncated:DistributionList' :: DistributionList -> Bool
$sel:maxItems:DistributionList' :: DistributionList -> Int
$sel:marker:DistributionList' :: DistributionList -> Text
$sel:nextMarker:DistributionList' :: DistributionList -> Maybe Text
$sel:items:DistributionList' :: DistributionList -> Maybe [DistributionSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DistributionSummary]
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 Text
marker
      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 Bool
isTruncated
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
quantity