{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodePipeline.Types.ActionRevision 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

-- | 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 :: Data.POSIX
  }
  deriving (ActionRevision -> ActionRevision -> Bool
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]
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
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. 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'
      { $sel:revisionId:ActionRevision' :: Text
revisionId = Text
pRevisionId_,
        $sel:revisionChangeId:ActionRevision' :: Text
revisionChangeId = Text
pRevisionChangeId_,
        $sel:created:ActionRevision' :: POSIX
created = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time 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 :: Lens' ActionRevision Text
actionRevision_revisionId = 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 :: Lens' ActionRevision Text
actionRevision_revisionChangeId = 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 :: Lens' ActionRevision UTCTime
actionRevision_created = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

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

instance Prelude.Hashable ActionRevision where
  hashWithSalt :: Int -> ActionRevision -> Int
hashWithSalt Int
_salt ActionRevision' {Text
POSIX
created :: POSIX
revisionChangeId :: Text
revisionId :: Text
$sel:created:ActionRevision' :: ActionRevision -> POSIX
$sel:revisionChangeId:ActionRevision' :: ActionRevision -> Text
$sel:revisionId:ActionRevision' :: ActionRevision -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
revisionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
revisionChangeId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
created

instance Prelude.NFData ActionRevision where
  rnf :: ActionRevision -> ()
rnf ActionRevision' {Text
POSIX
created :: POSIX
revisionChangeId :: Text
revisionId :: Text
$sel:created:ActionRevision' :: ActionRevision -> POSIX
$sel:revisionChangeId:ActionRevision' :: ActionRevision -> Text
$sel:revisionId:ActionRevision' :: ActionRevision -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
revisionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
revisionChangeId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
created

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"revisionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
revisionId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"revisionChangeId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
revisionChangeId),
            forall a. a -> Maybe a
Prelude.Just (Key
"created" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= POSIX
created)
          ]
      )