{-# 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.CodeBuild.Types.BuildPhase
-- 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.CodeBuild.Types.BuildPhase where

import Amazonka.CodeBuild.Types.BuildPhaseType
import Amazonka.CodeBuild.Types.PhaseContext
import Amazonka.CodeBuild.Types.StatusType
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

-- | Information about a stage for a build.
--
-- /See:/ 'newBuildPhase' smart constructor.
data BuildPhase = BuildPhase'
  { -- | Additional information about a build phase, especially to help
    -- troubleshoot a failed build.
    BuildPhase -> Maybe [PhaseContext]
contexts :: Prelude.Maybe [PhaseContext],
    -- | How long, in seconds, between the starting and ending times of the
    -- build\'s phase.
    BuildPhase -> Maybe Integer
durationInSeconds :: Prelude.Maybe Prelude.Integer,
    -- | When the build phase ended, expressed in Unix time format.
    BuildPhase -> Maybe POSIX
endTime :: Prelude.Maybe Data.POSIX,
    -- | The current status of the build phase. Valid values include:
    --
    -- [FAILED]
    --     The build phase failed.
    --
    -- [FAULT]
    --     The build phase faulted.
    --
    -- [IN_PROGRESS]
    --     The build phase is still in progress.
    --
    -- [STOPPED]
    --     The build phase stopped.
    --
    -- [SUCCEEDED]
    --     The build phase succeeded.
    --
    -- [TIMED_OUT]
    --     The build phase timed out.
    BuildPhase -> Maybe StatusType
phaseStatus :: Prelude.Maybe StatusType,
    -- | The name of the build phase. Valid values include:
    --
    -- [BUILD]
    --     Core build activities typically occur in this build phase.
    --
    -- [COMPLETED]
    --     The build has been completed.
    --
    -- [DOWNLOAD_SOURCE]
    --     Source code is being downloaded in this build phase.
    --
    -- [FINALIZING]
    --     The build process is completing in this build phase.
    --
    -- [INSTALL]
    --     Installation activities typically occur in this build phase.
    --
    -- [POST_BUILD]
    --     Post-build activities typically occur in this build phase.
    --
    -- [PRE_BUILD]
    --     Pre-build activities typically occur in this build phase.
    --
    -- [PROVISIONING]
    --     The build environment is being set up.
    --
    -- [QUEUED]
    --     The build has been submitted and is queued behind other submitted
    --     builds.
    --
    -- [SUBMITTED]
    --     The build has been submitted.
    --
    -- [UPLOAD_ARTIFACTS]
    --     Build output artifacts are being uploaded to the output location.
    BuildPhase -> Maybe BuildPhaseType
phaseType :: Prelude.Maybe BuildPhaseType,
    -- | When the build phase started, expressed in Unix time format.
    BuildPhase -> Maybe POSIX
startTime :: Prelude.Maybe Data.POSIX
  }
  deriving (BuildPhase -> BuildPhase -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BuildPhase -> BuildPhase -> Bool
$c/= :: BuildPhase -> BuildPhase -> Bool
== :: BuildPhase -> BuildPhase -> Bool
$c== :: BuildPhase -> BuildPhase -> Bool
Prelude.Eq, ReadPrec [BuildPhase]
ReadPrec BuildPhase
Int -> ReadS BuildPhase
ReadS [BuildPhase]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BuildPhase]
$creadListPrec :: ReadPrec [BuildPhase]
readPrec :: ReadPrec BuildPhase
$creadPrec :: ReadPrec BuildPhase
readList :: ReadS [BuildPhase]
$creadList :: ReadS [BuildPhase]
readsPrec :: Int -> ReadS BuildPhase
$creadsPrec :: Int -> ReadS BuildPhase
Prelude.Read, Int -> BuildPhase -> ShowS
[BuildPhase] -> ShowS
BuildPhase -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BuildPhase] -> ShowS
$cshowList :: [BuildPhase] -> ShowS
show :: BuildPhase -> String
$cshow :: BuildPhase -> String
showsPrec :: Int -> BuildPhase -> ShowS
$cshowsPrec :: Int -> BuildPhase -> ShowS
Prelude.Show, forall x. Rep BuildPhase x -> BuildPhase
forall x. BuildPhase -> Rep BuildPhase x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BuildPhase x -> BuildPhase
$cfrom :: forall x. BuildPhase -> Rep BuildPhase x
Prelude.Generic)

-- |
-- Create a value of 'BuildPhase' 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:
--
-- 'contexts', 'buildPhase_contexts' - Additional information about a build phase, especially to help
-- troubleshoot a failed build.
--
-- 'durationInSeconds', 'buildPhase_durationInSeconds' - How long, in seconds, between the starting and ending times of the
-- build\'s phase.
--
-- 'endTime', 'buildPhase_endTime' - When the build phase ended, expressed in Unix time format.
--
-- 'phaseStatus', 'buildPhase_phaseStatus' - The current status of the build phase. Valid values include:
--
-- [FAILED]
--     The build phase failed.
--
-- [FAULT]
--     The build phase faulted.
--
-- [IN_PROGRESS]
--     The build phase is still in progress.
--
-- [STOPPED]
--     The build phase stopped.
--
-- [SUCCEEDED]
--     The build phase succeeded.
--
-- [TIMED_OUT]
--     The build phase timed out.
--
-- 'phaseType', 'buildPhase_phaseType' - The name of the build phase. Valid values include:
--
-- [BUILD]
--     Core build activities typically occur in this build phase.
--
-- [COMPLETED]
--     The build has been completed.
--
-- [DOWNLOAD_SOURCE]
--     Source code is being downloaded in this build phase.
--
-- [FINALIZING]
--     The build process is completing in this build phase.
--
-- [INSTALL]
--     Installation activities typically occur in this build phase.
--
-- [POST_BUILD]
--     Post-build activities typically occur in this build phase.
--
-- [PRE_BUILD]
--     Pre-build activities typically occur in this build phase.
--
-- [PROVISIONING]
--     The build environment is being set up.
--
-- [QUEUED]
--     The build has been submitted and is queued behind other submitted
--     builds.
--
-- [SUBMITTED]
--     The build has been submitted.
--
-- [UPLOAD_ARTIFACTS]
--     Build output artifacts are being uploaded to the output location.
--
-- 'startTime', 'buildPhase_startTime' - When the build phase started, expressed in Unix time format.
newBuildPhase ::
  BuildPhase
newBuildPhase :: BuildPhase
newBuildPhase =
  BuildPhase'
    { $sel:contexts:BuildPhase' :: Maybe [PhaseContext]
contexts = forall a. Maybe a
Prelude.Nothing,
      $sel:durationInSeconds:BuildPhase' :: Maybe Integer
durationInSeconds = forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:BuildPhase' :: Maybe POSIX
endTime = forall a. Maybe a
Prelude.Nothing,
      $sel:phaseStatus:BuildPhase' :: Maybe StatusType
phaseStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:phaseType:BuildPhase' :: Maybe BuildPhaseType
phaseType = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:BuildPhase' :: Maybe POSIX
startTime = forall a. Maybe a
Prelude.Nothing
    }

-- | Additional information about a build phase, especially to help
-- troubleshoot a failed build.
buildPhase_contexts :: Lens.Lens' BuildPhase (Prelude.Maybe [PhaseContext])
buildPhase_contexts :: Lens' BuildPhase (Maybe [PhaseContext])
buildPhase_contexts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildPhase' {Maybe [PhaseContext]
contexts :: Maybe [PhaseContext]
$sel:contexts:BuildPhase' :: BuildPhase -> Maybe [PhaseContext]
contexts} -> Maybe [PhaseContext]
contexts) (\s :: BuildPhase
s@BuildPhase' {} Maybe [PhaseContext]
a -> BuildPhase
s {$sel:contexts:BuildPhase' :: Maybe [PhaseContext]
contexts = Maybe [PhaseContext]
a} :: BuildPhase) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | How long, in seconds, between the starting and ending times of the
-- build\'s phase.
buildPhase_durationInSeconds :: Lens.Lens' BuildPhase (Prelude.Maybe Prelude.Integer)
buildPhase_durationInSeconds :: Lens' BuildPhase (Maybe Integer)
buildPhase_durationInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildPhase' {Maybe Integer
durationInSeconds :: Maybe Integer
$sel:durationInSeconds:BuildPhase' :: BuildPhase -> Maybe Integer
durationInSeconds} -> Maybe Integer
durationInSeconds) (\s :: BuildPhase
s@BuildPhase' {} Maybe Integer
a -> BuildPhase
s {$sel:durationInSeconds:BuildPhase' :: Maybe Integer
durationInSeconds = Maybe Integer
a} :: BuildPhase)

-- | When the build phase ended, expressed in Unix time format.
buildPhase_endTime :: Lens.Lens' BuildPhase (Prelude.Maybe Prelude.UTCTime)
buildPhase_endTime :: Lens' BuildPhase (Maybe UTCTime)
buildPhase_endTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildPhase' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:BuildPhase' :: BuildPhase -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: BuildPhase
s@BuildPhase' {} Maybe POSIX
a -> BuildPhase
s {$sel:endTime:BuildPhase' :: Maybe POSIX
endTime = Maybe POSIX
a} :: BuildPhase) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The current status of the build phase. Valid values include:
--
-- [FAILED]
--     The build phase failed.
--
-- [FAULT]
--     The build phase faulted.
--
-- [IN_PROGRESS]
--     The build phase is still in progress.
--
-- [STOPPED]
--     The build phase stopped.
--
-- [SUCCEEDED]
--     The build phase succeeded.
--
-- [TIMED_OUT]
--     The build phase timed out.
buildPhase_phaseStatus :: Lens.Lens' BuildPhase (Prelude.Maybe StatusType)
buildPhase_phaseStatus :: Lens' BuildPhase (Maybe StatusType)
buildPhase_phaseStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildPhase' {Maybe StatusType
phaseStatus :: Maybe StatusType
$sel:phaseStatus:BuildPhase' :: BuildPhase -> Maybe StatusType
phaseStatus} -> Maybe StatusType
phaseStatus) (\s :: BuildPhase
s@BuildPhase' {} Maybe StatusType
a -> BuildPhase
s {$sel:phaseStatus:BuildPhase' :: Maybe StatusType
phaseStatus = Maybe StatusType
a} :: BuildPhase)

-- | The name of the build phase. Valid values include:
--
-- [BUILD]
--     Core build activities typically occur in this build phase.
--
-- [COMPLETED]
--     The build has been completed.
--
-- [DOWNLOAD_SOURCE]
--     Source code is being downloaded in this build phase.
--
-- [FINALIZING]
--     The build process is completing in this build phase.
--
-- [INSTALL]
--     Installation activities typically occur in this build phase.
--
-- [POST_BUILD]
--     Post-build activities typically occur in this build phase.
--
-- [PRE_BUILD]
--     Pre-build activities typically occur in this build phase.
--
-- [PROVISIONING]
--     The build environment is being set up.
--
-- [QUEUED]
--     The build has been submitted and is queued behind other submitted
--     builds.
--
-- [SUBMITTED]
--     The build has been submitted.
--
-- [UPLOAD_ARTIFACTS]
--     Build output artifacts are being uploaded to the output location.
buildPhase_phaseType :: Lens.Lens' BuildPhase (Prelude.Maybe BuildPhaseType)
buildPhase_phaseType :: Lens' BuildPhase (Maybe BuildPhaseType)
buildPhase_phaseType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildPhase' {Maybe BuildPhaseType
phaseType :: Maybe BuildPhaseType
$sel:phaseType:BuildPhase' :: BuildPhase -> Maybe BuildPhaseType
phaseType} -> Maybe BuildPhaseType
phaseType) (\s :: BuildPhase
s@BuildPhase' {} Maybe BuildPhaseType
a -> BuildPhase
s {$sel:phaseType:BuildPhase' :: Maybe BuildPhaseType
phaseType = Maybe BuildPhaseType
a} :: BuildPhase)

-- | When the build phase started, expressed in Unix time format.
buildPhase_startTime :: Lens.Lens' BuildPhase (Prelude.Maybe Prelude.UTCTime)
buildPhase_startTime :: Lens' BuildPhase (Maybe UTCTime)
buildPhase_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildPhase' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:BuildPhase' :: BuildPhase -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: BuildPhase
s@BuildPhase' {} Maybe POSIX
a -> BuildPhase
s {$sel:startTime:BuildPhase' :: Maybe POSIX
startTime = Maybe POSIX
a} :: BuildPhase) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON BuildPhase where
  parseJSON :: Value -> Parser BuildPhase
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BuildPhase"
      ( \Object
x ->
          Maybe [PhaseContext]
-> Maybe Integer
-> Maybe POSIX
-> Maybe StatusType
-> Maybe BuildPhaseType
-> Maybe POSIX
-> BuildPhase
BuildPhase'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"contexts" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"durationInSeconds")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"endTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"phaseStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"phaseType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"startTime")
      )

instance Prelude.Hashable BuildPhase where
  hashWithSalt :: Int -> BuildPhase -> Int
hashWithSalt Int
_salt BuildPhase' {Maybe Integer
Maybe [PhaseContext]
Maybe POSIX
Maybe BuildPhaseType
Maybe StatusType
startTime :: Maybe POSIX
phaseType :: Maybe BuildPhaseType
phaseStatus :: Maybe StatusType
endTime :: Maybe POSIX
durationInSeconds :: Maybe Integer
contexts :: Maybe [PhaseContext]
$sel:startTime:BuildPhase' :: BuildPhase -> Maybe POSIX
$sel:phaseType:BuildPhase' :: BuildPhase -> Maybe BuildPhaseType
$sel:phaseStatus:BuildPhase' :: BuildPhase -> Maybe StatusType
$sel:endTime:BuildPhase' :: BuildPhase -> Maybe POSIX
$sel:durationInSeconds:BuildPhase' :: BuildPhase -> Maybe Integer
$sel:contexts:BuildPhase' :: BuildPhase -> Maybe [PhaseContext]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PhaseContext]
contexts
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
durationInSeconds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
endTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StatusType
phaseStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BuildPhaseType
phaseType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startTime

instance Prelude.NFData BuildPhase where
  rnf :: BuildPhase -> ()
rnf BuildPhase' {Maybe Integer
Maybe [PhaseContext]
Maybe POSIX
Maybe BuildPhaseType
Maybe StatusType
startTime :: Maybe POSIX
phaseType :: Maybe BuildPhaseType
phaseStatus :: Maybe StatusType
endTime :: Maybe POSIX
durationInSeconds :: Maybe Integer
contexts :: Maybe [PhaseContext]
$sel:startTime:BuildPhase' :: BuildPhase -> Maybe POSIX
$sel:phaseType:BuildPhase' :: BuildPhase -> Maybe BuildPhaseType
$sel:phaseStatus:BuildPhase' :: BuildPhase -> Maybe StatusType
$sel:endTime:BuildPhase' :: BuildPhase -> Maybe POSIX
$sel:durationInSeconds:BuildPhase' :: BuildPhase -> Maybe Integer
$sel:contexts:BuildPhase' :: BuildPhase -> Maybe [PhaseContext]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [PhaseContext]
contexts
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
durationInSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
endTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StatusType
phaseStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BuildPhaseType
phaseType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startTime