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

import Amazonka.CloudFront.Types.InvalidationBatch
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

-- | An invalidation.
--
-- /See:/ 'newInvalidation' smart constructor.
data Invalidation = Invalidation'
  { -- | The identifier for the invalidation request. For example:
    -- @IDFDVBD632BHDS5@.
    Invalidation -> Text
id :: Prelude.Text,
    -- | The status of the invalidation request. When the invalidation batch is
    -- finished, the status is @Completed@.
    Invalidation -> Text
status :: Prelude.Text,
    -- | The date and time the invalidation request was first made.
    Invalidation -> ISO8601
createTime :: Data.ISO8601,
    -- | The current invalidation information for the batch request.
    Invalidation -> InvalidationBatch
invalidationBatch :: InvalidationBatch
  }
  deriving (Invalidation -> Invalidation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Invalidation -> Invalidation -> Bool
$c/= :: Invalidation -> Invalidation -> Bool
== :: Invalidation -> Invalidation -> Bool
$c== :: Invalidation -> Invalidation -> Bool
Prelude.Eq, ReadPrec [Invalidation]
ReadPrec Invalidation
Int -> ReadS Invalidation
ReadS [Invalidation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Invalidation]
$creadListPrec :: ReadPrec [Invalidation]
readPrec :: ReadPrec Invalidation
$creadPrec :: ReadPrec Invalidation
readList :: ReadS [Invalidation]
$creadList :: ReadS [Invalidation]
readsPrec :: Int -> ReadS Invalidation
$creadsPrec :: Int -> ReadS Invalidation
Prelude.Read, Int -> Invalidation -> ShowS
[Invalidation] -> ShowS
Invalidation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Invalidation] -> ShowS
$cshowList :: [Invalidation] -> ShowS
show :: Invalidation -> String
$cshow :: Invalidation -> String
showsPrec :: Int -> Invalidation -> ShowS
$cshowsPrec :: Int -> Invalidation -> ShowS
Prelude.Show, forall x. Rep Invalidation x -> Invalidation
forall x. Invalidation -> Rep Invalidation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Invalidation x -> Invalidation
$cfrom :: forall x. Invalidation -> Rep Invalidation x
Prelude.Generic)

-- |
-- Create a value of 'Invalidation' 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:
--
-- 'id', 'invalidation_id' - The identifier for the invalidation request. For example:
-- @IDFDVBD632BHDS5@.
--
-- 'status', 'invalidation_status' - The status of the invalidation request. When the invalidation batch is
-- finished, the status is @Completed@.
--
-- 'createTime', 'invalidation_createTime' - The date and time the invalidation request was first made.
--
-- 'invalidationBatch', 'invalidation_invalidationBatch' - The current invalidation information for the batch request.
newInvalidation ::
  -- | 'id'
  Prelude.Text ->
  -- | 'status'
  Prelude.Text ->
  -- | 'createTime'
  Prelude.UTCTime ->
  -- | 'invalidationBatch'
  InvalidationBatch ->
  Invalidation
newInvalidation :: Text -> Text -> UTCTime -> InvalidationBatch -> Invalidation
newInvalidation
  Text
pId_
  Text
pStatus_
  UTCTime
pCreateTime_
  InvalidationBatch
pInvalidationBatch_ =
    Invalidation'
      { $sel:id:Invalidation' :: Text
id = Text
pId_,
        $sel:status:Invalidation' :: Text
status = Text
pStatus_,
        $sel:createTime:Invalidation' :: ISO8601
createTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreateTime_,
        $sel:invalidationBatch:Invalidation' :: InvalidationBatch
invalidationBatch = InvalidationBatch
pInvalidationBatch_
      }

-- | The identifier for the invalidation request. For example:
-- @IDFDVBD632BHDS5@.
invalidation_id :: Lens.Lens' Invalidation Prelude.Text
invalidation_id :: Lens' Invalidation Text
invalidation_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invalidation' {Text
id :: Text
$sel:id:Invalidation' :: Invalidation -> Text
id} -> Text
id) (\s :: Invalidation
s@Invalidation' {} Text
a -> Invalidation
s {$sel:id:Invalidation' :: Text
id = Text
a} :: Invalidation)

-- | The status of the invalidation request. When the invalidation batch is
-- finished, the status is @Completed@.
invalidation_status :: Lens.Lens' Invalidation Prelude.Text
invalidation_status :: Lens' Invalidation Text
invalidation_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invalidation' {Text
status :: Text
$sel:status:Invalidation' :: Invalidation -> Text
status} -> Text
status) (\s :: Invalidation
s@Invalidation' {} Text
a -> Invalidation
s {$sel:status:Invalidation' :: Text
status = Text
a} :: Invalidation)

-- | The date and time the invalidation request was first made.
invalidation_createTime :: Lens.Lens' Invalidation Prelude.UTCTime
invalidation_createTime :: Lens' Invalidation UTCTime
invalidation_createTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invalidation' {ISO8601
createTime :: ISO8601
$sel:createTime:Invalidation' :: Invalidation -> ISO8601
createTime} -> ISO8601
createTime) (\s :: Invalidation
s@Invalidation' {} ISO8601
a -> Invalidation
s {$sel:createTime:Invalidation' :: ISO8601
createTime = ISO8601
a} :: Invalidation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The current invalidation information for the batch request.
invalidation_invalidationBatch :: Lens.Lens' Invalidation InvalidationBatch
invalidation_invalidationBatch :: Lens' Invalidation InvalidationBatch
invalidation_invalidationBatch = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invalidation' {InvalidationBatch
invalidationBatch :: InvalidationBatch
$sel:invalidationBatch:Invalidation' :: Invalidation -> InvalidationBatch
invalidationBatch} -> InvalidationBatch
invalidationBatch) (\s :: Invalidation
s@Invalidation' {} InvalidationBatch
a -> Invalidation
s {$sel:invalidationBatch:Invalidation' :: InvalidationBatch
invalidationBatch = InvalidationBatch
a} :: Invalidation)

instance Data.FromXML Invalidation where
  parseXML :: [Node] -> Either String Invalidation
parseXML [Node]
x =
    Text -> Text -> ISO8601 -> InvalidationBatch -> Invalidation
Invalidation'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Id")
      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
"Status")
      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
"CreateTime")
      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
"InvalidationBatch")

instance Prelude.Hashable Invalidation where
  hashWithSalt :: Int -> Invalidation -> Int
hashWithSalt Int
_salt Invalidation' {Text
ISO8601
InvalidationBatch
invalidationBatch :: InvalidationBatch
createTime :: ISO8601
status :: Text
id :: Text
$sel:invalidationBatch:Invalidation' :: Invalidation -> InvalidationBatch
$sel:createTime:Invalidation' :: Invalidation -> ISO8601
$sel:status:Invalidation' :: Invalidation -> Text
$sel:id:Invalidation' :: Invalidation -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
createTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` InvalidationBatch
invalidationBatch

instance Prelude.NFData Invalidation where
  rnf :: Invalidation -> ()
rnf Invalidation' {Text
ISO8601
InvalidationBatch
invalidationBatch :: InvalidationBatch
createTime :: ISO8601
status :: Text
id :: Text
$sel:invalidationBatch:Invalidation' :: Invalidation -> InvalidationBatch
$sel:createTime:Invalidation' :: Invalidation -> ISO8601
$sel:status:Invalidation' :: Invalidation -> Text
$sel:id:Invalidation' :: Invalidation -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ISO8601
createTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf InvalidationBatch
invalidationBatch