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

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

-- | Contains metadata about a CloudFront function.
--
-- /See:/ 'newFunctionMetadata' smart constructor.
data FunctionMetadata = FunctionMetadata'
  { -- | The stage that the function is in, either @DEVELOPMENT@ or @LIVE@.
    --
    -- When a function is in the @DEVELOPMENT@ stage, you can test the function
    -- with @TestFunction@, and update it with @UpdateFunction@.
    --
    -- When a function is in the @LIVE@ stage, you can attach the function to a
    -- distribution’s cache behavior, using the function’s ARN.
    FunctionMetadata -> Maybe FunctionStage
stage :: Prelude.Maybe FunctionStage,
    -- | The date and time when the function was created.
    FunctionMetadata -> Maybe ISO8601
createdTime :: Prelude.Maybe Core.ISO8601,
    -- | The Amazon Resource Name (ARN) of the function. The ARN uniquely
    -- identifies the function.
    FunctionMetadata -> Text
functionARN :: Prelude.Text,
    -- | The date and time when the function was most recently updated.
    FunctionMetadata -> ISO8601
lastModifiedTime :: Core.ISO8601
  }
  deriving (FunctionMetadata -> FunctionMetadata -> Bool
(FunctionMetadata -> FunctionMetadata -> Bool)
-> (FunctionMetadata -> FunctionMetadata -> Bool)
-> Eq FunctionMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FunctionMetadata -> FunctionMetadata -> Bool
$c/= :: FunctionMetadata -> FunctionMetadata -> Bool
== :: FunctionMetadata -> FunctionMetadata -> Bool
$c== :: FunctionMetadata -> FunctionMetadata -> Bool
Prelude.Eq, ReadPrec [FunctionMetadata]
ReadPrec FunctionMetadata
Int -> ReadS FunctionMetadata
ReadS [FunctionMetadata]
(Int -> ReadS FunctionMetadata)
-> ReadS [FunctionMetadata]
-> ReadPrec FunctionMetadata
-> ReadPrec [FunctionMetadata]
-> Read FunctionMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FunctionMetadata]
$creadListPrec :: ReadPrec [FunctionMetadata]
readPrec :: ReadPrec FunctionMetadata
$creadPrec :: ReadPrec FunctionMetadata
readList :: ReadS [FunctionMetadata]
$creadList :: ReadS [FunctionMetadata]
readsPrec :: Int -> ReadS FunctionMetadata
$creadsPrec :: Int -> ReadS FunctionMetadata
Prelude.Read, Int -> FunctionMetadata -> ShowS
[FunctionMetadata] -> ShowS
FunctionMetadata -> String
(Int -> FunctionMetadata -> ShowS)
-> (FunctionMetadata -> String)
-> ([FunctionMetadata] -> ShowS)
-> Show FunctionMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionMetadata] -> ShowS
$cshowList :: [FunctionMetadata] -> ShowS
show :: FunctionMetadata -> String
$cshow :: FunctionMetadata -> String
showsPrec :: Int -> FunctionMetadata -> ShowS
$cshowsPrec :: Int -> FunctionMetadata -> ShowS
Prelude.Show, (forall x. FunctionMetadata -> Rep FunctionMetadata x)
-> (forall x. Rep FunctionMetadata x -> FunctionMetadata)
-> Generic FunctionMetadata
forall x. Rep FunctionMetadata x -> FunctionMetadata
forall x. FunctionMetadata -> Rep FunctionMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FunctionMetadata x -> FunctionMetadata
$cfrom :: forall x. FunctionMetadata -> Rep FunctionMetadata x
Prelude.Generic)

-- |
-- Create a value of 'FunctionMetadata' 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:
--
-- 'stage', 'functionMetadata_stage' - The stage that the function is in, either @DEVELOPMENT@ or @LIVE@.
--
-- When a function is in the @DEVELOPMENT@ stage, you can test the function
-- with @TestFunction@, and update it with @UpdateFunction@.
--
-- When a function is in the @LIVE@ stage, you can attach the function to a
-- distribution’s cache behavior, using the function’s ARN.
--
-- 'createdTime', 'functionMetadata_createdTime' - The date and time when the function was created.
--
-- 'functionARN', 'functionMetadata_functionARN' - The Amazon Resource Name (ARN) of the function. The ARN uniquely
-- identifies the function.
--
-- 'lastModifiedTime', 'functionMetadata_lastModifiedTime' - The date and time when the function was most recently updated.
newFunctionMetadata ::
  -- | 'functionARN'
  Prelude.Text ->
  -- | 'lastModifiedTime'
  Prelude.UTCTime ->
  FunctionMetadata
newFunctionMetadata :: Text -> UTCTime -> FunctionMetadata
newFunctionMetadata Text
pFunctionARN_ UTCTime
pLastModifiedTime_ =
  FunctionMetadata' :: Maybe FunctionStage
-> Maybe ISO8601 -> Text -> ISO8601 -> FunctionMetadata
FunctionMetadata'
    { $sel:stage:FunctionMetadata' :: Maybe FunctionStage
stage = Maybe FunctionStage
forall a. Maybe a
Prelude.Nothing,
      $sel:createdTime:FunctionMetadata' :: Maybe ISO8601
createdTime = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing,
      $sel:functionARN:FunctionMetadata' :: Text
functionARN = Text
pFunctionARN_,
      $sel:lastModifiedTime:FunctionMetadata' :: ISO8601
lastModifiedTime =
        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
pLastModifiedTime_
    }

-- | The stage that the function is in, either @DEVELOPMENT@ or @LIVE@.
--
-- When a function is in the @DEVELOPMENT@ stage, you can test the function
-- with @TestFunction@, and update it with @UpdateFunction@.
--
-- When a function is in the @LIVE@ stage, you can attach the function to a
-- distribution’s cache behavior, using the function’s ARN.
functionMetadata_stage :: Lens.Lens' FunctionMetadata (Prelude.Maybe FunctionStage)
functionMetadata_stage :: (Maybe FunctionStage -> f (Maybe FunctionStage))
-> FunctionMetadata -> f FunctionMetadata
functionMetadata_stage = (FunctionMetadata -> Maybe FunctionStage)
-> (FunctionMetadata -> Maybe FunctionStage -> FunctionMetadata)
-> Lens
     FunctionMetadata
     FunctionMetadata
     (Maybe FunctionStage)
     (Maybe FunctionStage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionMetadata' {Maybe FunctionStage
stage :: Maybe FunctionStage
$sel:stage:FunctionMetadata' :: FunctionMetadata -> Maybe FunctionStage
stage} -> Maybe FunctionStage
stage) (\s :: FunctionMetadata
s@FunctionMetadata' {} Maybe FunctionStage
a -> FunctionMetadata
s {$sel:stage:FunctionMetadata' :: Maybe FunctionStage
stage = Maybe FunctionStage
a} :: FunctionMetadata)

-- | The date and time when the function was created.
functionMetadata_createdTime :: Lens.Lens' FunctionMetadata (Prelude.Maybe Prelude.UTCTime)
functionMetadata_createdTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> FunctionMetadata -> f FunctionMetadata
functionMetadata_createdTime = (FunctionMetadata -> Maybe ISO8601)
-> (FunctionMetadata -> Maybe ISO8601 -> FunctionMetadata)
-> Lens
     FunctionMetadata FunctionMetadata (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionMetadata' {Maybe ISO8601
createdTime :: Maybe ISO8601
$sel:createdTime:FunctionMetadata' :: FunctionMetadata -> Maybe ISO8601
createdTime} -> Maybe ISO8601
createdTime) (\s :: FunctionMetadata
s@FunctionMetadata' {} Maybe ISO8601
a -> FunctionMetadata
s {$sel:createdTime:FunctionMetadata' :: Maybe ISO8601
createdTime = Maybe ISO8601
a} :: FunctionMetadata) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> FunctionMetadata -> f FunctionMetadata)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> FunctionMetadata
-> f FunctionMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (Maybe UTCTime) (Maybe UTCTime)
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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The Amazon Resource Name (ARN) of the function. The ARN uniquely
-- identifies the function.
functionMetadata_functionARN :: Lens.Lens' FunctionMetadata Prelude.Text
functionMetadata_functionARN :: (Text -> f Text) -> FunctionMetadata -> f FunctionMetadata
functionMetadata_functionARN = (FunctionMetadata -> Text)
-> (FunctionMetadata -> Text -> FunctionMetadata)
-> Lens FunctionMetadata FunctionMetadata Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionMetadata' {Text
functionARN :: Text
$sel:functionARN:FunctionMetadata' :: FunctionMetadata -> Text
functionARN} -> Text
functionARN) (\s :: FunctionMetadata
s@FunctionMetadata' {} Text
a -> FunctionMetadata
s {$sel:functionARN:FunctionMetadata' :: Text
functionARN = Text
a} :: FunctionMetadata)

-- | The date and time when the function was most recently updated.
functionMetadata_lastModifiedTime :: Lens.Lens' FunctionMetadata Prelude.UTCTime
functionMetadata_lastModifiedTime :: (UTCTime -> f UTCTime) -> FunctionMetadata -> f FunctionMetadata
functionMetadata_lastModifiedTime = (FunctionMetadata -> ISO8601)
-> (FunctionMetadata -> ISO8601 -> FunctionMetadata)
-> Lens FunctionMetadata FunctionMetadata ISO8601 ISO8601
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionMetadata' {ISO8601
lastModifiedTime :: ISO8601
$sel:lastModifiedTime:FunctionMetadata' :: FunctionMetadata -> ISO8601
lastModifiedTime} -> ISO8601
lastModifiedTime) (\s :: FunctionMetadata
s@FunctionMetadata' {} ISO8601
a -> FunctionMetadata
s {$sel:lastModifiedTime:FunctionMetadata' :: ISO8601
lastModifiedTime = ISO8601
a} :: FunctionMetadata) ((ISO8601 -> f ISO8601) -> FunctionMetadata -> f FunctionMetadata)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> FunctionMetadata
-> f FunctionMetadata
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

instance Core.FromXML FunctionMetadata where
  parseXML :: [Node] -> Either String FunctionMetadata
parseXML [Node]
x =
    Maybe FunctionStage
-> Maybe ISO8601 -> Text -> ISO8601 -> FunctionMetadata
FunctionMetadata'
      (Maybe FunctionStage
 -> Maybe ISO8601 -> Text -> ISO8601 -> FunctionMetadata)
-> Either String (Maybe FunctionStage)
-> Either
     String (Maybe ISO8601 -> Text -> ISO8601 -> FunctionMetadata)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe FunctionStage)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Stage")
      Either
  String (Maybe ISO8601 -> Text -> ISO8601 -> FunctionMetadata)
-> Either String (Maybe ISO8601)
-> Either String (Text -> ISO8601 -> FunctionMetadata)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CreatedTime")
      Either String (Text -> ISO8601 -> FunctionMetadata)
-> Either String Text
-> Either String (ISO8601 -> FunctionMetadata)
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
"FunctionARN")
      Either String (ISO8601 -> FunctionMetadata)
-> Either String ISO8601 -> Either String FunctionMetadata
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
"LastModifiedTime")

instance Prelude.Hashable FunctionMetadata

instance Prelude.NFData FunctionMetadata