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

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 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
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]
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
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. 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'
    { $sel:items:Paths' :: Maybe [Text]
items = 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 :: Lens' Paths (Maybe [Text])
paths_items = 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) 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

-- | The number of invalidation paths specified for the objects that you want
-- to invalidate.
paths_quantity :: Lens.Lens' Paths Prelude.Int
paths_quantity :: Lens' Paths Int
paths_quantity = 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 Data.FromXML Paths where
  parseXML :: [Node] -> Either String Paths
parseXML [Node]
x =
    Maybe [Text] -> Int -> Paths
Paths'
      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
"Path")
                  )
      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 Paths where
  hashWithSalt :: Int -> Paths -> Int
hashWithSalt Int
_salt Paths' {Int
Maybe [Text]
quantity :: Int
items :: Maybe [Text]
$sel:quantity:Paths' :: Paths -> Int
$sel:items:Paths' :: Paths -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
items
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
quantity

instance Prelude.NFData Paths where
  rnf :: Paths -> ()
rnf Paths' {Int
Maybe [Text]
quantity :: Int
items :: Maybe [Text]
$sel:quantity:Paths' :: Paths -> Int
$sel:items:Paths' :: Paths -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
items
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
quantity

instance Data.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]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Items"
          forall a. ToXML a => Name -> a -> XML
Data.@= forall a. ToXML a => a -> XML
Data.toXML (forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Data.toXMLList Name
"Path" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
items),
        Name
"Quantity" forall a. ToXML a => Name -> a -> XML
Data.@= Int
quantity
      ]