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

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

-- | Information about the version (or revision) of a source artifact that
-- initiated a pipeline execution.
--
-- /See:/ 'newSourceRevision' smart constructor.
data SourceRevision = SourceRevision'
  { -- | Summary information about the most recent revision of the artifact. For
    -- GitHub and AWS CodeCommit repositories, the commit message. For Amazon
    -- S3 buckets or actions, the user-provided content of a
    -- @codepipeline-artifact-revision-summary@ key specified in the object
    -- metadata.
    SourceRevision -> Maybe Text
revisionSummary :: Prelude.Maybe Prelude.Text,
    -- | The commit ID for the artifact revision. For artifacts stored in GitHub
    -- or AWS CodeCommit repositories, the commit ID is linked to a commit
    -- details page.
    SourceRevision -> Maybe Text
revisionUrl :: Prelude.Maybe Prelude.Text,
    -- | The system-generated unique ID that identifies the revision number of
    -- the artifact.
    SourceRevision -> Maybe Text
revisionId :: Prelude.Maybe Prelude.Text,
    -- | The name of the action that processed the revision to the source
    -- artifact.
    SourceRevision -> Text
actionName :: Prelude.Text
  }
  deriving (SourceRevision -> SourceRevision -> Bool
(SourceRevision -> SourceRevision -> Bool)
-> (SourceRevision -> SourceRevision -> Bool) -> Eq SourceRevision
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceRevision -> SourceRevision -> Bool
$c/= :: SourceRevision -> SourceRevision -> Bool
== :: SourceRevision -> SourceRevision -> Bool
$c== :: SourceRevision -> SourceRevision -> Bool
Prelude.Eq, ReadPrec [SourceRevision]
ReadPrec SourceRevision
Int -> ReadS SourceRevision
ReadS [SourceRevision]
(Int -> ReadS SourceRevision)
-> ReadS [SourceRevision]
-> ReadPrec SourceRevision
-> ReadPrec [SourceRevision]
-> Read SourceRevision
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceRevision]
$creadListPrec :: ReadPrec [SourceRevision]
readPrec :: ReadPrec SourceRevision
$creadPrec :: ReadPrec SourceRevision
readList :: ReadS [SourceRevision]
$creadList :: ReadS [SourceRevision]
readsPrec :: Int -> ReadS SourceRevision
$creadsPrec :: Int -> ReadS SourceRevision
Prelude.Read, Int -> SourceRevision -> ShowS
[SourceRevision] -> ShowS
SourceRevision -> String
(Int -> SourceRevision -> ShowS)
-> (SourceRevision -> String)
-> ([SourceRevision] -> ShowS)
-> Show SourceRevision
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceRevision] -> ShowS
$cshowList :: [SourceRevision] -> ShowS
show :: SourceRevision -> String
$cshow :: SourceRevision -> String
showsPrec :: Int -> SourceRevision -> ShowS
$cshowsPrec :: Int -> SourceRevision -> ShowS
Prelude.Show, (forall x. SourceRevision -> Rep SourceRevision x)
-> (forall x. Rep SourceRevision x -> SourceRevision)
-> Generic SourceRevision
forall x. Rep SourceRevision x -> SourceRevision
forall x. SourceRevision -> Rep SourceRevision x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceRevision x -> SourceRevision
$cfrom :: forall x. SourceRevision -> Rep SourceRevision x
Prelude.Generic)

-- |
-- Create a value of 'SourceRevision' 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:
--
-- 'revisionSummary', 'sourceRevision_revisionSummary' - Summary information about the most recent revision of the artifact. For
-- GitHub and AWS CodeCommit repositories, the commit message. For Amazon
-- S3 buckets or actions, the user-provided content of a
-- @codepipeline-artifact-revision-summary@ key specified in the object
-- metadata.
--
-- 'revisionUrl', 'sourceRevision_revisionUrl' - The commit ID for the artifact revision. For artifacts stored in GitHub
-- or AWS CodeCommit repositories, the commit ID is linked to a commit
-- details page.
--
-- 'revisionId', 'sourceRevision_revisionId' - The system-generated unique ID that identifies the revision number of
-- the artifact.
--
-- 'actionName', 'sourceRevision_actionName' - The name of the action that processed the revision to the source
-- artifact.
newSourceRevision ::
  -- | 'actionName'
  Prelude.Text ->
  SourceRevision
newSourceRevision :: Text -> SourceRevision
newSourceRevision Text
pActionName_ =
  SourceRevision' :: Maybe Text -> Maybe Text -> Maybe Text -> Text -> SourceRevision
SourceRevision'
    { $sel:revisionSummary:SourceRevision' :: Maybe Text
revisionSummary = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:revisionUrl:SourceRevision' :: Maybe Text
revisionUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:revisionId:SourceRevision' :: Maybe Text
revisionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:actionName:SourceRevision' :: Text
actionName = Text
pActionName_
    }

-- | Summary information about the most recent revision of the artifact. For
-- GitHub and AWS CodeCommit repositories, the commit message. For Amazon
-- S3 buckets or actions, the user-provided content of a
-- @codepipeline-artifact-revision-summary@ key specified in the object
-- metadata.
sourceRevision_revisionSummary :: Lens.Lens' SourceRevision (Prelude.Maybe Prelude.Text)
sourceRevision_revisionSummary :: (Maybe Text -> f (Maybe Text))
-> SourceRevision -> f SourceRevision
sourceRevision_revisionSummary = (SourceRevision -> Maybe Text)
-> (SourceRevision -> Maybe Text -> SourceRevision)
-> Lens SourceRevision SourceRevision (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceRevision' {Maybe Text
revisionSummary :: Maybe Text
$sel:revisionSummary:SourceRevision' :: SourceRevision -> Maybe Text
revisionSummary} -> Maybe Text
revisionSummary) (\s :: SourceRevision
s@SourceRevision' {} Maybe Text
a -> SourceRevision
s {$sel:revisionSummary:SourceRevision' :: Maybe Text
revisionSummary = Maybe Text
a} :: SourceRevision)

-- | The commit ID for the artifact revision. For artifacts stored in GitHub
-- or AWS CodeCommit repositories, the commit ID is linked to a commit
-- details page.
sourceRevision_revisionUrl :: Lens.Lens' SourceRevision (Prelude.Maybe Prelude.Text)
sourceRevision_revisionUrl :: (Maybe Text -> f (Maybe Text))
-> SourceRevision -> f SourceRevision
sourceRevision_revisionUrl = (SourceRevision -> Maybe Text)
-> (SourceRevision -> Maybe Text -> SourceRevision)
-> Lens SourceRevision SourceRevision (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceRevision' {Maybe Text
revisionUrl :: Maybe Text
$sel:revisionUrl:SourceRevision' :: SourceRevision -> Maybe Text
revisionUrl} -> Maybe Text
revisionUrl) (\s :: SourceRevision
s@SourceRevision' {} Maybe Text
a -> SourceRevision
s {$sel:revisionUrl:SourceRevision' :: Maybe Text
revisionUrl = Maybe Text
a} :: SourceRevision)

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

-- | The name of the action that processed the revision to the source
-- artifact.
sourceRevision_actionName :: Lens.Lens' SourceRevision Prelude.Text
sourceRevision_actionName :: (Text -> f Text) -> SourceRevision -> f SourceRevision
sourceRevision_actionName = (SourceRevision -> Text)
-> (SourceRevision -> Text -> SourceRevision)
-> Lens SourceRevision SourceRevision Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceRevision' {Text
actionName :: Text
$sel:actionName:SourceRevision' :: SourceRevision -> Text
actionName} -> Text
actionName) (\s :: SourceRevision
s@SourceRevision' {} Text
a -> SourceRevision
s {$sel:actionName:SourceRevision' :: Text
actionName = Text
a} :: SourceRevision)

instance Core.FromJSON SourceRevision where
  parseJSON :: Value -> Parser SourceRevision
parseJSON =
    String
-> (Object -> Parser SourceRevision)
-> Value
-> Parser SourceRevision
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SourceRevision"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> Text -> SourceRevision
SourceRevision'
            (Maybe Text -> Maybe Text -> Maybe Text -> Text -> SourceRevision)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Text -> SourceRevision)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"revisionSummary")
            Parser (Maybe Text -> Maybe Text -> Text -> SourceRevision)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Text -> SourceRevision)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"revisionUrl")
            Parser (Maybe Text -> Text -> SourceRevision)
-> Parser (Maybe Text) -> Parser (Text -> SourceRevision)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"revisionId")
            Parser (Text -> SourceRevision)
-> Parser Text -> Parser SourceRevision
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
"actionName")
      )

instance Prelude.Hashable SourceRevision

instance Prelude.NFData SourceRevision