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

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

-- | Represents information about a current revision.
--
-- /See:/ 'newCurrentRevision' smart constructor.
data CurrentRevision = CurrentRevision'
  { -- | The summary of the most recent revision of the artifact.
    CurrentRevision -> Maybe Text
revisionSummary :: Prelude.Maybe Prelude.Text,
    -- | The date and time when the most recent revision of the artifact was
    -- created, in timestamp format.
    CurrentRevision -> Maybe POSIX
created :: Prelude.Maybe Core.POSIX,
    -- | The revision ID of the current version of an artifact.
    CurrentRevision -> Text
revision :: Prelude.Text,
    -- | The change identifier for the current revision.
    CurrentRevision -> Text
changeIdentifier :: Prelude.Text
  }
  deriving (CurrentRevision -> CurrentRevision -> Bool
(CurrentRevision -> CurrentRevision -> Bool)
-> (CurrentRevision -> CurrentRevision -> Bool)
-> Eq CurrentRevision
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CurrentRevision -> CurrentRevision -> Bool
$c/= :: CurrentRevision -> CurrentRevision -> Bool
== :: CurrentRevision -> CurrentRevision -> Bool
$c== :: CurrentRevision -> CurrentRevision -> Bool
Prelude.Eq, ReadPrec [CurrentRevision]
ReadPrec CurrentRevision
Int -> ReadS CurrentRevision
ReadS [CurrentRevision]
(Int -> ReadS CurrentRevision)
-> ReadS [CurrentRevision]
-> ReadPrec CurrentRevision
-> ReadPrec [CurrentRevision]
-> Read CurrentRevision
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CurrentRevision]
$creadListPrec :: ReadPrec [CurrentRevision]
readPrec :: ReadPrec CurrentRevision
$creadPrec :: ReadPrec CurrentRevision
readList :: ReadS [CurrentRevision]
$creadList :: ReadS [CurrentRevision]
readsPrec :: Int -> ReadS CurrentRevision
$creadsPrec :: Int -> ReadS CurrentRevision
Prelude.Read, Int -> CurrentRevision -> ShowS
[CurrentRevision] -> ShowS
CurrentRevision -> String
(Int -> CurrentRevision -> ShowS)
-> (CurrentRevision -> String)
-> ([CurrentRevision] -> ShowS)
-> Show CurrentRevision
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CurrentRevision] -> ShowS
$cshowList :: [CurrentRevision] -> ShowS
show :: CurrentRevision -> String
$cshow :: CurrentRevision -> String
showsPrec :: Int -> CurrentRevision -> ShowS
$cshowsPrec :: Int -> CurrentRevision -> ShowS
Prelude.Show, (forall x. CurrentRevision -> Rep CurrentRevision x)
-> (forall x. Rep CurrentRevision x -> CurrentRevision)
-> Generic CurrentRevision
forall x. Rep CurrentRevision x -> CurrentRevision
forall x. CurrentRevision -> Rep CurrentRevision x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CurrentRevision x -> CurrentRevision
$cfrom :: forall x. CurrentRevision -> Rep CurrentRevision x
Prelude.Generic)

-- |
-- Create a value of 'CurrentRevision' 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', 'currentRevision_revisionSummary' - The summary of the most recent revision of the artifact.
--
-- 'created', 'currentRevision_created' - The date and time when the most recent revision of the artifact was
-- created, in timestamp format.
--
-- 'revision', 'currentRevision_revision' - The revision ID of the current version of an artifact.
--
-- 'changeIdentifier', 'currentRevision_changeIdentifier' - The change identifier for the current revision.
newCurrentRevision ::
  -- | 'revision'
  Prelude.Text ->
  -- | 'changeIdentifier'
  Prelude.Text ->
  CurrentRevision
newCurrentRevision :: Text -> Text -> CurrentRevision
newCurrentRevision Text
pRevision_ Text
pChangeIdentifier_ =
  CurrentRevision' :: Maybe Text -> Maybe POSIX -> Text -> Text -> CurrentRevision
CurrentRevision'
    { $sel:revisionSummary:CurrentRevision' :: Maybe Text
revisionSummary = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:created:CurrentRevision' :: Maybe POSIX
created = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:revision:CurrentRevision' :: Text
revision = Text
pRevision_,
      $sel:changeIdentifier:CurrentRevision' :: Text
changeIdentifier = Text
pChangeIdentifier_
    }

-- | The summary of the most recent revision of the artifact.
currentRevision_revisionSummary :: Lens.Lens' CurrentRevision (Prelude.Maybe Prelude.Text)
currentRevision_revisionSummary :: (Maybe Text -> f (Maybe Text))
-> CurrentRevision -> f CurrentRevision
currentRevision_revisionSummary = (CurrentRevision -> Maybe Text)
-> (CurrentRevision -> Maybe Text -> CurrentRevision)
-> Lens CurrentRevision CurrentRevision (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CurrentRevision' {Maybe Text
revisionSummary :: Maybe Text
$sel:revisionSummary:CurrentRevision' :: CurrentRevision -> Maybe Text
revisionSummary} -> Maybe Text
revisionSummary) (\s :: CurrentRevision
s@CurrentRevision' {} Maybe Text
a -> CurrentRevision
s {$sel:revisionSummary:CurrentRevision' :: Maybe Text
revisionSummary = Maybe Text
a} :: CurrentRevision)

-- | The date and time when the most recent revision of the artifact was
-- created, in timestamp format.
currentRevision_created :: Lens.Lens' CurrentRevision (Prelude.Maybe Prelude.UTCTime)
currentRevision_created :: (Maybe UTCTime -> f (Maybe UTCTime))
-> CurrentRevision -> f CurrentRevision
currentRevision_created = (CurrentRevision -> Maybe POSIX)
-> (CurrentRevision -> Maybe POSIX -> CurrentRevision)
-> Lens CurrentRevision CurrentRevision (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CurrentRevision' {Maybe POSIX
created :: Maybe POSIX
$sel:created:CurrentRevision' :: CurrentRevision -> Maybe POSIX
created} -> Maybe POSIX
created) (\s :: CurrentRevision
s@CurrentRevision' {} Maybe POSIX
a -> CurrentRevision
s {$sel:created:CurrentRevision' :: Maybe POSIX
created = Maybe POSIX
a} :: CurrentRevision) ((Maybe POSIX -> f (Maybe POSIX))
 -> CurrentRevision -> f CurrentRevision)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> CurrentRevision
-> f CurrentRevision
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The revision ID of the current version of an artifact.
currentRevision_revision :: Lens.Lens' CurrentRevision Prelude.Text
currentRevision_revision :: (Text -> f Text) -> CurrentRevision -> f CurrentRevision
currentRevision_revision = (CurrentRevision -> Text)
-> (CurrentRevision -> Text -> CurrentRevision)
-> Lens CurrentRevision CurrentRevision Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CurrentRevision' {Text
revision :: Text
$sel:revision:CurrentRevision' :: CurrentRevision -> Text
revision} -> Text
revision) (\s :: CurrentRevision
s@CurrentRevision' {} Text
a -> CurrentRevision
s {$sel:revision:CurrentRevision' :: Text
revision = Text
a} :: CurrentRevision)

-- | The change identifier for the current revision.
currentRevision_changeIdentifier :: Lens.Lens' CurrentRevision Prelude.Text
currentRevision_changeIdentifier :: (Text -> f Text) -> CurrentRevision -> f CurrentRevision
currentRevision_changeIdentifier = (CurrentRevision -> Text)
-> (CurrentRevision -> Text -> CurrentRevision)
-> Lens CurrentRevision CurrentRevision Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CurrentRevision' {Text
changeIdentifier :: Text
$sel:changeIdentifier:CurrentRevision' :: CurrentRevision -> Text
changeIdentifier} -> Text
changeIdentifier) (\s :: CurrentRevision
s@CurrentRevision' {} Text
a -> CurrentRevision
s {$sel:changeIdentifier:CurrentRevision' :: Text
changeIdentifier = Text
a} :: CurrentRevision)

instance Prelude.Hashable CurrentRevision

instance Prelude.NFData CurrentRevision

instance Core.ToJSON CurrentRevision where
  toJSON :: CurrentRevision -> Value
toJSON CurrentRevision' {Maybe Text
Maybe POSIX
Text
changeIdentifier :: Text
revision :: Text
created :: Maybe POSIX
revisionSummary :: Maybe Text
$sel:changeIdentifier:CurrentRevision' :: CurrentRevision -> Text
$sel:revision:CurrentRevision' :: CurrentRevision -> Text
$sel:created:CurrentRevision' :: CurrentRevision -> Maybe POSIX
$sel:revisionSummary:CurrentRevision' :: CurrentRevision -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"revisionSummary" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
revisionSummary,
            (Text
"created" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
created,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"revision" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
revision),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"changeIdentifier" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
changeIdentifier)
          ]
      )