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

import Amazonka.CloudFront.Types.InvalidationBatch
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 :: Core.ISO8601,
    -- | The current invalidation information for the batch request.
    Invalidation -> InvalidationBatch
invalidationBatch :: InvalidationBatch
  }
  deriving (Invalidation -> Invalidation -> Bool
(Invalidation -> Invalidation -> Bool)
-> (Invalidation -> Invalidation -> Bool) -> Eq Invalidation
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]
(Int -> ReadS Invalidation)
-> ReadS [Invalidation]
-> ReadPrec Invalidation
-> ReadPrec [Invalidation]
-> Read 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
(Int -> Invalidation -> ShowS)
-> (Invalidation -> String)
-> ([Invalidation] -> ShowS)
-> Show Invalidation
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. Invalidation -> Rep Invalidation x)
-> (forall x. Rep Invalidation x -> Invalidation)
-> Generic Invalidation
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' :: Text -> Text -> ISO8601 -> InvalidationBatch -> Invalidation
Invalidation'
      { $sel:id:Invalidation' :: Text
id = Text
pId_,
        $sel:status:Invalidation' :: Text
status = Text
pStatus_,
        $sel:createTime:Invalidation' :: ISO8601
createTime = Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged ISO8601 (Identity ISO8601))
-> UTCTime -> ISO8601
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 :: (Text -> f Text) -> Invalidation -> f Invalidation
invalidation_id = (Invalidation -> Text)
-> (Invalidation -> Text -> Invalidation)
-> Lens Invalidation Invalidation Text Text
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 :: (Text -> f Text) -> Invalidation -> f Invalidation
invalidation_status = (Invalidation -> Text)
-> (Invalidation -> Text -> Invalidation)
-> Lens Invalidation Invalidation Text Text
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 :: (UTCTime -> f UTCTime) -> Invalidation -> f Invalidation
invalidation_createTime = (Invalidation -> ISO8601)
-> (Invalidation -> ISO8601 -> Invalidation)
-> Lens Invalidation Invalidation ISO8601 ISO8601
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) ((ISO8601 -> f ISO8601) -> Invalidation -> f Invalidation)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> Invalidation
-> f Invalidation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The current invalidation information for the batch request.
invalidation_invalidationBatch :: Lens.Lens' Invalidation InvalidationBatch
invalidation_invalidationBatch :: (InvalidationBatch -> f InvalidationBatch)
-> Invalidation -> f Invalidation
invalidation_invalidationBatch = (Invalidation -> InvalidationBatch)
-> (Invalidation -> InvalidationBatch -> Invalidation)
-> Lens
     Invalidation Invalidation InvalidationBatch 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 Core.FromXML Invalidation where
  parseXML :: [Node] -> Either String Invalidation
parseXML [Node]
x =
    Text -> Text -> ISO8601 -> InvalidationBatch -> Invalidation
Invalidation'
      (Text -> Text -> ISO8601 -> InvalidationBatch -> Invalidation)
-> Either String Text
-> Either
     String (Text -> ISO8601 -> InvalidationBatch -> Invalidation)
forall (f :: * -> *) a b. Functor 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
"Id")
      Either
  String (Text -> ISO8601 -> InvalidationBatch -> Invalidation)
-> Either String Text
-> Either String (ISO8601 -> InvalidationBatch -> Invalidation)
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
"Status")
      Either String (ISO8601 -> InvalidationBatch -> Invalidation)
-> Either String ISO8601
-> Either String (InvalidationBatch -> Invalidation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String ISO8601
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"CreateTime")
      Either String (InvalidationBatch -> Invalidation)
-> Either String InvalidationBatch -> Either String Invalidation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String InvalidationBatch
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"InvalidationBatch")

instance Prelude.Hashable Invalidation

instance Prelude.NFData Invalidation