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

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

-- | The @InvalidationList@ complex type describes the list of invalidation
-- objects. For more information about invalidation, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html Invalidating Objects (Web Distributions Only)>
-- in the /Amazon CloudFront Developer Guide/.
--
-- /See:/ 'newInvalidationList' smart constructor.
data InvalidationList = InvalidationList'
  { -- | A complex type that contains one @InvalidationSummary@ element for each
    -- invalidation batch created by the current account.
    InvalidationList -> Maybe [InvalidationSummary]
items :: Prelude.Maybe [InvalidationSummary],
    -- | If @IsTruncated@ is @true@, this element is present and contains the
    -- value that you can use for the @Marker@ request parameter to continue
    -- listing your invalidation batches where they left off.
    InvalidationList -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    -- | The value that you provided for the @Marker@ request parameter.
    InvalidationList -> Text
marker :: Prelude.Text,
    -- | The value that you provided for the @MaxItems@ request parameter.
    InvalidationList -> Int
maxItems :: Prelude.Int,
    -- | A flag that indicates whether more invalidation batch requests 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
    -- invalidation batches in the list.
    InvalidationList -> Bool
isTruncated :: Prelude.Bool,
    -- | The number of invalidation batches that were created by the current
    -- account.
    InvalidationList -> Int
quantity :: Prelude.Int
  }
  deriving (InvalidationList -> InvalidationList -> Bool
(InvalidationList -> InvalidationList -> Bool)
-> (InvalidationList -> InvalidationList -> Bool)
-> Eq InvalidationList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InvalidationList -> InvalidationList -> Bool
$c/= :: InvalidationList -> InvalidationList -> Bool
== :: InvalidationList -> InvalidationList -> Bool
$c== :: InvalidationList -> InvalidationList -> Bool
Prelude.Eq, ReadPrec [InvalidationList]
ReadPrec InvalidationList
Int -> ReadS InvalidationList
ReadS [InvalidationList]
(Int -> ReadS InvalidationList)
-> ReadS [InvalidationList]
-> ReadPrec InvalidationList
-> ReadPrec [InvalidationList]
-> Read InvalidationList
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InvalidationList]
$creadListPrec :: ReadPrec [InvalidationList]
readPrec :: ReadPrec InvalidationList
$creadPrec :: ReadPrec InvalidationList
readList :: ReadS [InvalidationList]
$creadList :: ReadS [InvalidationList]
readsPrec :: Int -> ReadS InvalidationList
$creadsPrec :: Int -> ReadS InvalidationList
Prelude.Read, Int -> InvalidationList -> ShowS
[InvalidationList] -> ShowS
InvalidationList -> String
(Int -> InvalidationList -> ShowS)
-> (InvalidationList -> String)
-> ([InvalidationList] -> ShowS)
-> Show InvalidationList
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InvalidationList] -> ShowS
$cshowList :: [InvalidationList] -> ShowS
show :: InvalidationList -> String
$cshow :: InvalidationList -> String
showsPrec :: Int -> InvalidationList -> ShowS
$cshowsPrec :: Int -> InvalidationList -> ShowS
Prelude.Show, (forall x. InvalidationList -> Rep InvalidationList x)
-> (forall x. Rep InvalidationList x -> InvalidationList)
-> Generic InvalidationList
forall x. Rep InvalidationList x -> InvalidationList
forall x. InvalidationList -> Rep InvalidationList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InvalidationList x -> InvalidationList
$cfrom :: forall x. InvalidationList -> Rep InvalidationList x
Prelude.Generic)

-- |
-- Create a value of 'InvalidationList' 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', 'invalidationList_items' - A complex type that contains one @InvalidationSummary@ element for each
-- invalidation batch created by the current account.
--
-- 'nextMarker', 'invalidationList_nextMarker' - If @IsTruncated@ is @true@, this element is present and contains the
-- value that you can use for the @Marker@ request parameter to continue
-- listing your invalidation batches where they left off.
--
-- 'marker', 'invalidationList_marker' - The value that you provided for the @Marker@ request parameter.
--
-- 'maxItems', 'invalidationList_maxItems' - The value that you provided for the @MaxItems@ request parameter.
--
-- 'isTruncated', 'invalidationList_isTruncated' - A flag that indicates whether more invalidation batch requests 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
-- invalidation batches in the list.
--
-- 'quantity', 'invalidationList_quantity' - The number of invalidation batches that were created by the current
-- account.
newInvalidationList ::
  -- | 'marker'
  Prelude.Text ->
  -- | 'maxItems'
  Prelude.Int ->
  -- | 'isTruncated'
  Prelude.Bool ->
  -- | 'quantity'
  Prelude.Int ->
  InvalidationList
newInvalidationList :: Text -> Int -> Bool -> Int -> InvalidationList
newInvalidationList
  Text
pMarker_
  Int
pMaxItems_
  Bool
pIsTruncated_
  Int
pQuantity_ =
    InvalidationList' :: Maybe [InvalidationSummary]
-> Maybe Text -> Text -> Int -> Bool -> Int -> InvalidationList
InvalidationList'
      { $sel:items:InvalidationList' :: Maybe [InvalidationSummary]
items = Maybe [InvalidationSummary]
forall a. Maybe a
Prelude.Nothing,
        $sel:nextMarker:InvalidationList' :: Maybe Text
nextMarker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:marker:InvalidationList' :: Text
marker = Text
pMarker_,
        $sel:maxItems:InvalidationList' :: Int
maxItems = Int
pMaxItems_,
        $sel:isTruncated:InvalidationList' :: Bool
isTruncated = Bool
pIsTruncated_,
        $sel:quantity:InvalidationList' :: Int
quantity = Int
pQuantity_
      }

-- | A complex type that contains one @InvalidationSummary@ element for each
-- invalidation batch created by the current account.
invalidationList_items :: Lens.Lens' InvalidationList (Prelude.Maybe [InvalidationSummary])
invalidationList_items :: (Maybe [InvalidationSummary] -> f (Maybe [InvalidationSummary]))
-> InvalidationList -> f InvalidationList
invalidationList_items = (InvalidationList -> Maybe [InvalidationSummary])
-> (InvalidationList
    -> Maybe [InvalidationSummary] -> InvalidationList)
-> Lens
     InvalidationList
     InvalidationList
     (Maybe [InvalidationSummary])
     (Maybe [InvalidationSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvalidationList' {Maybe [InvalidationSummary]
items :: Maybe [InvalidationSummary]
$sel:items:InvalidationList' :: InvalidationList -> Maybe [InvalidationSummary]
items} -> Maybe [InvalidationSummary]
items) (\s :: InvalidationList
s@InvalidationList' {} Maybe [InvalidationSummary]
a -> InvalidationList
s {$sel:items:InvalidationList' :: Maybe [InvalidationSummary]
items = Maybe [InvalidationSummary]
a} :: InvalidationList) ((Maybe [InvalidationSummary] -> f (Maybe [InvalidationSummary]))
 -> InvalidationList -> f InvalidationList)
-> ((Maybe [InvalidationSummary]
     -> f (Maybe [InvalidationSummary]))
    -> Maybe [InvalidationSummary] -> f (Maybe [InvalidationSummary]))
-> (Maybe [InvalidationSummary] -> f (Maybe [InvalidationSummary]))
-> InvalidationList
-> f InvalidationList
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [InvalidationSummary]
  [InvalidationSummary]
  [InvalidationSummary]
  [InvalidationSummary]
-> Iso
     (Maybe [InvalidationSummary])
     (Maybe [InvalidationSummary])
     (Maybe [InvalidationSummary])
     (Maybe [InvalidationSummary])
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
  [InvalidationSummary]
  [InvalidationSummary]
  [InvalidationSummary]
  [InvalidationSummary]
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 that you can use for the @Marker@ request parameter to continue
-- listing your invalidation batches where they left off.
invalidationList_nextMarker :: Lens.Lens' InvalidationList (Prelude.Maybe Prelude.Text)
invalidationList_nextMarker :: (Maybe Text -> f (Maybe Text))
-> InvalidationList -> f InvalidationList
invalidationList_nextMarker = (InvalidationList -> Maybe Text)
-> (InvalidationList -> Maybe Text -> InvalidationList)
-> Lens InvalidationList InvalidationList (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvalidationList' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:InvalidationList' :: InvalidationList -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: InvalidationList
s@InvalidationList' {} Maybe Text
a -> InvalidationList
s {$sel:nextMarker:InvalidationList' :: Maybe Text
nextMarker = Maybe Text
a} :: InvalidationList)

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

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

-- | A flag that indicates whether more invalidation batch requests 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
-- invalidation batches in the list.
invalidationList_isTruncated :: Lens.Lens' InvalidationList Prelude.Bool
invalidationList_isTruncated :: (Bool -> f Bool) -> InvalidationList -> f InvalidationList
invalidationList_isTruncated = (InvalidationList -> Bool)
-> (InvalidationList -> Bool -> InvalidationList)
-> Lens InvalidationList InvalidationList Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvalidationList' {Bool
isTruncated :: Bool
$sel:isTruncated:InvalidationList' :: InvalidationList -> Bool
isTruncated} -> Bool
isTruncated) (\s :: InvalidationList
s@InvalidationList' {} Bool
a -> InvalidationList
s {$sel:isTruncated:InvalidationList' :: Bool
isTruncated = Bool
a} :: InvalidationList)

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

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

instance Prelude.NFData InvalidationList