{-# 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.CodePipeline.Types.ActionRevision
-- 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.CodePipeline.Types.ActionRevision where

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

-- | Represents information about the version (or revision) of an action.
--
-- /See:/ 'newActionRevision' smart constructor.
data ActionRevision = ActionRevision'
  { -- | The system-generated unique ID that identifies the revision number of
    -- the action.
    ActionRevision -> Text
revisionId :: Prelude.Text,
    -- | The unique identifier of the change that set the state to this revision
    -- (for example, a deployment ID or timestamp).
    ActionRevision -> Text
revisionChangeId :: Prelude.Text,
    -- | The date and time when the most recent version of the action was
    -- created, in timestamp format.
    ActionRevision -> POSIX
created :: Core.POSIX
  }
  deriving (ActionRevision -> ActionRevision -> Bool
(ActionRevision -> ActionRevision -> Bool)
-> (ActionRevision -> ActionRevision -> Bool) -> Eq ActionRevision
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActionRevision -> ActionRevision -> Bool
$c/= :: ActionRevision -> ActionRevision -> Bool
== :: ActionRevision -> ActionRevision -> Bool
$c== :: ActionRevision -> ActionRevision -> Bool
Prelude.Eq, ReadPrec [ActionRevision]
ReadPrec ActionRevision
Int -> ReadS ActionRevision
ReadS [ActionRevision]
(Int -> ReadS ActionRevision)
-> ReadS [ActionRevision]
-> ReadPrec ActionRevision
-> ReadPrec [ActionRevision]
-> Read ActionRevision
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActionRevision]
$creadListPrec :: ReadPrec [ActionRevision]
readPrec :: ReadPrec ActionRevision
$creadPrec :: ReadPrec ActionRevision
readList :: ReadS [ActionRevision]
$creadList :: ReadS [ActionRevision]
readsPrec :: Int -> ReadS ActionRevision
$creadsPrec :: Int -> ReadS ActionRevision
Prelude.Read, Int -> ActionRevision -> ShowS
[ActionRevision] -> ShowS
ActionRevision -> String
(Int -> ActionRevision -> ShowS)
-> (ActionRevision -> String)
-> ([ActionRevision] -> ShowS)
-> Show ActionRevision
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActionRevision] -> ShowS
$cshowList :: [ActionRevision] -> ShowS
show :: ActionRevision -> String
$cshow :: ActionRevision -> String
showsPrec :: Int -> ActionRevision -> ShowS
$cshowsPrec :: Int -> ActionRevision -> ShowS
Prelude.Show, (forall x. ActionRevision -> Rep ActionRevision x)
-> (forall x. Rep ActionRevision x -> ActionRevision)
-> Generic ActionRevision
forall x. Rep ActionRevision x -> ActionRevision
forall x. ActionRevision -> Rep ActionRevision x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActionRevision x -> ActionRevision
$cfrom :: forall x. ActionRevision -> Rep ActionRevision x
Prelude.Generic)

-- |
-- Create a value of 'ActionRevision' 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:
--
-- 'revisionId', 'actionRevision_revisionId' - The system-generated unique ID that identifies the revision number of
-- the action.
--
-- 'revisionChangeId', 'actionRevision_revisionChangeId' - The unique identifier of the change that set the state to this revision
-- (for example, a deployment ID or timestamp).
--
-- 'created', 'actionRevision_created' - The date and time when the most recent version of the action was
-- created, in timestamp format.
newActionRevision ::
  -- | 'revisionId'
  Prelude.Text ->
  -- | 'revisionChangeId'
  Prelude.Text ->
  -- | 'created'
  Prelude.UTCTime ->
  ActionRevision
newActionRevision :: Text -> Text -> UTCTime -> ActionRevision
newActionRevision
  Text
pRevisionId_
  Text
pRevisionChangeId_
  UTCTime
pCreated_ =
    ActionRevision' :: Text -> Text -> POSIX -> ActionRevision
ActionRevision'
      { $sel:revisionId:ActionRevision' :: Text
revisionId = Text
pRevisionId_,
        $sel:revisionChangeId:ActionRevision' :: Text
revisionChangeId = Text
pRevisionChangeId_,
        $sel:created:ActionRevision' :: POSIX
created = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreated_
      }

-- | The system-generated unique ID that identifies the revision number of
-- the action.
actionRevision_revisionId :: Lens.Lens' ActionRevision Prelude.Text
actionRevision_revisionId :: (Text -> f Text) -> ActionRevision -> f ActionRevision
actionRevision_revisionId = (ActionRevision -> Text)
-> (ActionRevision -> Text -> ActionRevision)
-> Lens ActionRevision ActionRevision Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionRevision' {Text
revisionId :: Text
$sel:revisionId:ActionRevision' :: ActionRevision -> Text
revisionId} -> Text
revisionId) (\s :: ActionRevision
s@ActionRevision' {} Text
a -> ActionRevision
s {$sel:revisionId:ActionRevision' :: Text
revisionId = Text
a} :: ActionRevision)

-- | The unique identifier of the change that set the state to this revision
-- (for example, a deployment ID or timestamp).
actionRevision_revisionChangeId :: Lens.Lens' ActionRevision Prelude.Text
actionRevision_revisionChangeId :: (Text -> f Text) -> ActionRevision -> f ActionRevision
actionRevision_revisionChangeId = (ActionRevision -> Text)
-> (ActionRevision -> Text -> ActionRevision)
-> Lens ActionRevision ActionRevision Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionRevision' {Text
revisionChangeId :: Text
$sel:revisionChangeId:ActionRevision' :: ActionRevision -> Text
revisionChangeId} -> Text
revisionChangeId) (\s :: ActionRevision
s@ActionRevision' {} Text
a -> ActionRevision
s {$sel:revisionChangeId:ActionRevision' :: Text
revisionChangeId = Text
a} :: ActionRevision)

-- | The date and time when the most recent version of the action was
-- created, in timestamp format.
actionRevision_created :: Lens.Lens' ActionRevision Prelude.UTCTime
actionRevision_created :: (UTCTime -> f UTCTime) -> ActionRevision -> f ActionRevision
actionRevision_created = (ActionRevision -> POSIX)
-> (ActionRevision -> POSIX -> ActionRevision)
-> Lens ActionRevision ActionRevision POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionRevision' {POSIX
created :: POSIX
$sel:created:ActionRevision' :: ActionRevision -> POSIX
created} -> POSIX
created) (\s :: ActionRevision
s@ActionRevision' {} POSIX
a -> ActionRevision
s {$sel:created:ActionRevision' :: POSIX
created = POSIX
a} :: ActionRevision) ((POSIX -> f POSIX) -> ActionRevision -> f ActionRevision)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ActionRevision
-> f ActionRevision
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON ActionRevision where
  parseJSON :: Value -> Parser ActionRevision
parseJSON =
    String
-> (Object -> Parser ActionRevision)
-> Value
-> Parser ActionRevision
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ActionRevision"
      ( \Object
x ->
          Text -> Text -> POSIX -> ActionRevision
ActionRevision'
            (Text -> Text -> POSIX -> ActionRevision)
-> Parser Text -> Parser (Text -> POSIX -> ActionRevision)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"revisionId")
            Parser (Text -> POSIX -> ActionRevision)
-> Parser Text -> Parser (POSIX -> ActionRevision)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"revisionChangeId")
            Parser (POSIX -> ActionRevision)
-> Parser POSIX -> Parser ActionRevision
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"created")
      )

instance Prelude.Hashable ActionRevision

instance Prelude.NFData ActionRevision

instance Core.ToJSON ActionRevision where
  toJSON :: ActionRevision -> Value
toJSON ActionRevision' {Text
POSIX
created :: POSIX
revisionChangeId :: Text
revisionId :: Text
$sel:created:ActionRevision' :: ActionRevision -> POSIX
$sel:revisionChangeId:ActionRevision' :: ActionRevision -> Text
$sel:revisionId:ActionRevision' :: ActionRevision -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"revisionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
revisionId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"revisionChangeId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
revisionChangeId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"created" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
created)
          ]
      )