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

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

-- | A complex type that contains information about the objects that you want
-- to invalidate. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#invalidation-specifying-objects Specifying the Objects to Invalidate>
-- in the /Amazon CloudFront Developer Guide/.
--
-- /See:/ 'newPaths' smart constructor.
data Paths = Paths'
  { -- | A complex type that contains a list of the paths that you want to
    -- invalidate.
    Paths -> Maybe [Text]
items :: Prelude.Maybe [Prelude.Text],
    -- | The number of invalidation paths specified for the objects that you want
    -- to invalidate.
    Paths -> Int
quantity :: Prelude.Int
  }
  deriving (Paths -> Paths -> Bool
(Paths -> Paths -> Bool) -> (Paths -> Paths -> Bool) -> Eq Paths
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Paths -> Paths -> Bool
$c/= :: Paths -> Paths -> Bool
== :: Paths -> Paths -> Bool
$c== :: Paths -> Paths -> Bool
Prelude.Eq, ReadPrec [Paths]
ReadPrec Paths
Int -> ReadS Paths
ReadS [Paths]
(Int -> ReadS Paths)
-> ReadS [Paths]
-> ReadPrec Paths
-> ReadPrec [Paths]
-> Read Paths
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Paths]
$creadListPrec :: ReadPrec [Paths]
readPrec :: ReadPrec Paths
$creadPrec :: ReadPrec Paths
readList :: ReadS [Paths]
$creadList :: ReadS [Paths]
readsPrec :: Int -> ReadS Paths
$creadsPrec :: Int -> ReadS Paths
Prelude.Read, Int -> Paths -> ShowS
[Paths] -> ShowS
Paths -> String
(Int -> Paths -> ShowS)
-> (Paths -> String) -> ([Paths] -> ShowS) -> Show Paths
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Paths] -> ShowS
$cshowList :: [Paths] -> ShowS
show :: Paths -> String
$cshow :: Paths -> String
showsPrec :: Int -> Paths -> ShowS
$cshowsPrec :: Int -> Paths -> ShowS
Prelude.Show, (forall x. Paths -> Rep Paths x)
-> (forall x. Rep Paths x -> Paths) -> Generic Paths
forall x. Rep Paths x -> Paths
forall x. Paths -> Rep Paths x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Paths x -> Paths
$cfrom :: forall x. Paths -> Rep Paths x
Prelude.Generic)

-- |
-- Create a value of 'Paths' 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', 'paths_items' - A complex type that contains a list of the paths that you want to
-- invalidate.
--
-- 'quantity', 'paths_quantity' - The number of invalidation paths specified for the objects that you want
-- to invalidate.
newPaths ::
  -- | 'quantity'
  Prelude.Int ->
  Paths
newPaths :: Int -> Paths
newPaths Int
pQuantity_ =
  Paths' :: Maybe [Text] -> Int -> Paths
Paths'
    { $sel:items:Paths' :: Maybe [Text]
items = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:quantity:Paths' :: Int
quantity = Int
pQuantity_
    }

-- | A complex type that contains a list of the paths that you want to
-- invalidate.
paths_items :: Lens.Lens' Paths (Prelude.Maybe [Prelude.Text])
paths_items :: (Maybe [Text] -> f (Maybe [Text])) -> Paths -> f Paths
paths_items = (Paths -> Maybe [Text])
-> (Paths -> Maybe [Text] -> Paths)
-> Lens Paths Paths (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Paths' {Maybe [Text]
items :: Maybe [Text]
$sel:items:Paths' :: Paths -> Maybe [Text]
items} -> Maybe [Text]
items) (\s :: Paths
s@Paths' {} Maybe [Text]
a -> Paths
s {$sel:items:Paths' :: Maybe [Text]
items = Maybe [Text]
a} :: Paths) ((Maybe [Text] -> f (Maybe [Text])) -> Paths -> f Paths)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Paths
-> f Paths
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

-- | The number of invalidation paths specified for the objects that you want
-- to invalidate.
paths_quantity :: Lens.Lens' Paths Prelude.Int
paths_quantity :: (Int -> f Int) -> Paths -> f Paths
paths_quantity = (Paths -> Int)
-> (Paths -> Int -> Paths) -> Lens Paths Paths Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Paths' {Int
quantity :: Int
$sel:quantity:Paths' :: Paths -> Int
quantity} -> Int
quantity) (\s :: Paths
s@Paths' {} Int
a -> Paths
s {$sel:quantity:Paths' :: Int
quantity = Int
a} :: Paths)

instance Core.FromXML Paths where
  parseXML :: [Node] -> Either String Paths
parseXML [Node]
x =
    Maybe [Text] -> Int -> Paths
Paths'
      (Maybe [Text] -> Int -> Paths)
-> Either String (Maybe [Text]) -> Either String (Int -> Paths)
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
"Path")
                  )
      Either String (Int -> Paths)
-> Either String Int -> Either String Paths
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 Paths

instance Prelude.NFData Paths

instance Core.ToXML Paths where
  toXML :: Paths -> XML
toXML Paths' {Int
Maybe [Text]
quantity :: Int
items :: Maybe [Text]
$sel:quantity:Paths' :: Paths -> Int
$sel:items:Paths' :: Paths -> Maybe [Text]
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Items"
          Name -> XML -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe XML -> XML
forall a. ToXML a => a -> XML
Core.toXML (Name -> [Text] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"Path" ([Text] -> XML) -> Maybe [Text] -> Maybe XML
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
items),
        Name
"Quantity" Name -> Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Int
quantity
      ]