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

import Amazonka.CodeBuild.Types.BuildBatchPhaseType
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

-- | Contains information about a stage for a batch build.
--
-- /See:/ 'newBuildBatchPhase' smart constructor.
data BuildBatchPhase = BuildBatchPhase'
  { -- | Additional information about the batch build phase. Especially to help
    -- troubleshoot a failed batch build.
    BuildBatchPhase -> Maybe [PhaseContext]
contexts :: Prelude.Maybe [PhaseContext],
    -- | How long, in seconds, between the starting and ending times of the batch
    -- build\'s phase.
    BuildBatchPhase -> Maybe Integer
durationInSeconds :: Prelude.Maybe Prelude.Integer,
    -- | When the batch build phase ended, expressed in Unix time format.
    BuildBatchPhase -> Maybe POSIX
endTime :: Prelude.Maybe Data.POSIX,
    -- | The current status of the batch 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.
    BuildBatchPhase -> Maybe StatusType
phaseStatus :: Prelude.Maybe StatusType,
    -- | The name of the batch build phase. Valid values include:
    --
    -- [COMBINE_ARTIFACTS]
    --     Build output artifacts are being combined and uploaded to the output
    --     location.
    --
    -- [DOWNLOAD_BATCHSPEC]
    --     The batch build specification is being downloaded.
    --
    -- [FAILED]
    --     One or more of the builds failed.
    --
    -- [IN_PROGRESS]
    --     The batch build is in progress.
    --
    -- [STOPPED]
    --     The batch build was stopped.
    --
    -- [SUBMITTED]
    --     The btach build has been submitted.
    --
    -- [SUCCEEDED]
    --     The batch build succeeded.
    BuildBatchPhase -> Maybe BuildBatchPhaseType
phaseType :: Prelude.Maybe BuildBatchPhaseType,
    -- | When the batch build phase started, expressed in Unix time format.
    BuildBatchPhase -> Maybe POSIX
startTime :: Prelude.Maybe Data.POSIX
  }
  deriving (BuildBatchPhase -> BuildBatchPhase -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BuildBatchPhase -> BuildBatchPhase -> Bool
$c/= :: BuildBatchPhase -> BuildBatchPhase -> Bool
== :: BuildBatchPhase -> BuildBatchPhase -> Bool
$c== :: BuildBatchPhase -> BuildBatchPhase -> Bool
Prelude.Eq, ReadPrec [BuildBatchPhase]
ReadPrec BuildBatchPhase
Int -> ReadS BuildBatchPhase
ReadS [BuildBatchPhase]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BuildBatchPhase]
$creadListPrec :: ReadPrec [BuildBatchPhase]
readPrec :: ReadPrec BuildBatchPhase
$creadPrec :: ReadPrec BuildBatchPhase
readList :: ReadS [BuildBatchPhase]
$creadList :: ReadS [BuildBatchPhase]
readsPrec :: Int -> ReadS BuildBatchPhase
$creadsPrec :: Int -> ReadS BuildBatchPhase
Prelude.Read, Int -> BuildBatchPhase -> ShowS
[BuildBatchPhase] -> ShowS
BuildBatchPhase -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BuildBatchPhase] -> ShowS
$cshowList :: [BuildBatchPhase] -> ShowS
show :: BuildBatchPhase -> String
$cshow :: BuildBatchPhase -> String
showsPrec :: Int -> BuildBatchPhase -> ShowS
$cshowsPrec :: Int -> BuildBatchPhase -> ShowS
Prelude.Show, forall x. Rep BuildBatchPhase x -> BuildBatchPhase
forall x. BuildBatchPhase -> Rep BuildBatchPhase x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BuildBatchPhase x -> BuildBatchPhase
$cfrom :: forall x. BuildBatchPhase -> Rep BuildBatchPhase x
Prelude.Generic)

-- |
-- Create a value of 'BuildBatchPhase' 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', 'buildBatchPhase_contexts' - Additional information about the batch build phase. Especially to help
-- troubleshoot a failed batch build.
--
-- 'durationInSeconds', 'buildBatchPhase_durationInSeconds' - How long, in seconds, between the starting and ending times of the batch
-- build\'s phase.
--
-- 'endTime', 'buildBatchPhase_endTime' - When the batch build phase ended, expressed in Unix time format.
--
-- 'phaseStatus', 'buildBatchPhase_phaseStatus' - The current status of the batch 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', 'buildBatchPhase_phaseType' - The name of the batch build phase. Valid values include:
--
-- [COMBINE_ARTIFACTS]
--     Build output artifacts are being combined and uploaded to the output
--     location.
--
-- [DOWNLOAD_BATCHSPEC]
--     The batch build specification is being downloaded.
--
-- [FAILED]
--     One or more of the builds failed.
--
-- [IN_PROGRESS]
--     The batch build is in progress.
--
-- [STOPPED]
--     The batch build was stopped.
--
-- [SUBMITTED]
--     The btach build has been submitted.
--
-- [SUCCEEDED]
--     The batch build succeeded.
--
-- 'startTime', 'buildBatchPhase_startTime' - When the batch build phase started, expressed in Unix time format.
newBuildBatchPhase ::
  BuildBatchPhase
newBuildBatchPhase :: BuildBatchPhase
newBuildBatchPhase =
  BuildBatchPhase'
    { $sel:contexts:BuildBatchPhase' :: Maybe [PhaseContext]
contexts = forall a. Maybe a
Prelude.Nothing,
      $sel:durationInSeconds:BuildBatchPhase' :: Maybe Integer
durationInSeconds = forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:BuildBatchPhase' :: Maybe POSIX
endTime = forall a. Maybe a
Prelude.Nothing,
      $sel:phaseStatus:BuildBatchPhase' :: Maybe StatusType
phaseStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:phaseType:BuildBatchPhase' :: Maybe BuildBatchPhaseType
phaseType = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:BuildBatchPhase' :: Maybe POSIX
startTime = forall a. Maybe a
Prelude.Nothing
    }

-- | Additional information about the batch build phase. Especially to help
-- troubleshoot a failed batch build.
buildBatchPhase_contexts :: Lens.Lens' BuildBatchPhase (Prelude.Maybe [PhaseContext])
buildBatchPhase_contexts :: Lens' BuildBatchPhase (Maybe [PhaseContext])
buildBatchPhase_contexts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildBatchPhase' {Maybe [PhaseContext]
contexts :: Maybe [PhaseContext]
$sel:contexts:BuildBatchPhase' :: BuildBatchPhase -> Maybe [PhaseContext]
contexts} -> Maybe [PhaseContext]
contexts) (\s :: BuildBatchPhase
s@BuildBatchPhase' {} Maybe [PhaseContext]
a -> BuildBatchPhase
s {$sel:contexts:BuildBatchPhase' :: Maybe [PhaseContext]
contexts = Maybe [PhaseContext]
a} :: BuildBatchPhase) 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 batch
-- build\'s phase.
buildBatchPhase_durationInSeconds :: Lens.Lens' BuildBatchPhase (Prelude.Maybe Prelude.Integer)
buildBatchPhase_durationInSeconds :: Lens' BuildBatchPhase (Maybe Integer)
buildBatchPhase_durationInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildBatchPhase' {Maybe Integer
durationInSeconds :: Maybe Integer
$sel:durationInSeconds:BuildBatchPhase' :: BuildBatchPhase -> Maybe Integer
durationInSeconds} -> Maybe Integer
durationInSeconds) (\s :: BuildBatchPhase
s@BuildBatchPhase' {} Maybe Integer
a -> BuildBatchPhase
s {$sel:durationInSeconds:BuildBatchPhase' :: Maybe Integer
durationInSeconds = Maybe Integer
a} :: BuildBatchPhase)

-- | When the batch build phase ended, expressed in Unix time format.
buildBatchPhase_endTime :: Lens.Lens' BuildBatchPhase (Prelude.Maybe Prelude.UTCTime)
buildBatchPhase_endTime :: Lens' BuildBatchPhase (Maybe UTCTime)
buildBatchPhase_endTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildBatchPhase' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:BuildBatchPhase' :: BuildBatchPhase -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: BuildBatchPhase
s@BuildBatchPhase' {} Maybe POSIX
a -> BuildBatchPhase
s {$sel:endTime:BuildBatchPhase' :: Maybe POSIX
endTime = Maybe POSIX
a} :: BuildBatchPhase) 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 batch 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.
buildBatchPhase_phaseStatus :: Lens.Lens' BuildBatchPhase (Prelude.Maybe StatusType)
buildBatchPhase_phaseStatus :: Lens' BuildBatchPhase (Maybe StatusType)
buildBatchPhase_phaseStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildBatchPhase' {Maybe StatusType
phaseStatus :: Maybe StatusType
$sel:phaseStatus:BuildBatchPhase' :: BuildBatchPhase -> Maybe StatusType
phaseStatus} -> Maybe StatusType
phaseStatus) (\s :: BuildBatchPhase
s@BuildBatchPhase' {} Maybe StatusType
a -> BuildBatchPhase
s {$sel:phaseStatus:BuildBatchPhase' :: Maybe StatusType
phaseStatus = Maybe StatusType
a} :: BuildBatchPhase)

-- | The name of the batch build phase. Valid values include:
--
-- [COMBINE_ARTIFACTS]
--     Build output artifacts are being combined and uploaded to the output
--     location.
--
-- [DOWNLOAD_BATCHSPEC]
--     The batch build specification is being downloaded.
--
-- [FAILED]
--     One or more of the builds failed.
--
-- [IN_PROGRESS]
--     The batch build is in progress.
--
-- [STOPPED]
--     The batch build was stopped.
--
-- [SUBMITTED]
--     The btach build has been submitted.
--
-- [SUCCEEDED]
--     The batch build succeeded.
buildBatchPhase_phaseType :: Lens.Lens' BuildBatchPhase (Prelude.Maybe BuildBatchPhaseType)
buildBatchPhase_phaseType :: Lens' BuildBatchPhase (Maybe BuildBatchPhaseType)
buildBatchPhase_phaseType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildBatchPhase' {Maybe BuildBatchPhaseType
phaseType :: Maybe BuildBatchPhaseType
$sel:phaseType:BuildBatchPhase' :: BuildBatchPhase -> Maybe BuildBatchPhaseType
phaseType} -> Maybe BuildBatchPhaseType
phaseType) (\s :: BuildBatchPhase
s@BuildBatchPhase' {} Maybe BuildBatchPhaseType
a -> BuildBatchPhase
s {$sel:phaseType:BuildBatchPhase' :: Maybe BuildBatchPhaseType
phaseType = Maybe BuildBatchPhaseType
a} :: BuildBatchPhase)

-- | When the batch build phase started, expressed in Unix time format.
buildBatchPhase_startTime :: Lens.Lens' BuildBatchPhase (Prelude.Maybe Prelude.UTCTime)
buildBatchPhase_startTime :: Lens' BuildBatchPhase (Maybe UTCTime)
buildBatchPhase_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildBatchPhase' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:BuildBatchPhase' :: BuildBatchPhase -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: BuildBatchPhase
s@BuildBatchPhase' {} Maybe POSIX
a -> BuildBatchPhase
s {$sel:startTime:BuildBatchPhase' :: Maybe POSIX
startTime = Maybe POSIX
a} :: BuildBatchPhase) 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 BuildBatchPhase where
  parseJSON :: Value -> Parser BuildBatchPhase
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BuildBatchPhase"
      ( \Object
x ->
          Maybe [PhaseContext]
-> Maybe Integer
-> Maybe POSIX
-> Maybe StatusType
-> Maybe BuildBatchPhaseType
-> Maybe POSIX
-> BuildBatchPhase
BuildBatchPhase'
            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 BuildBatchPhase where
  hashWithSalt :: Int -> BuildBatchPhase -> Int
hashWithSalt Int
_salt BuildBatchPhase' {Maybe Integer
Maybe [PhaseContext]
Maybe POSIX
Maybe BuildBatchPhaseType
Maybe StatusType
startTime :: Maybe POSIX
phaseType :: Maybe BuildBatchPhaseType
phaseStatus :: Maybe StatusType
endTime :: Maybe POSIX
durationInSeconds :: Maybe Integer
contexts :: Maybe [PhaseContext]
$sel:startTime:BuildBatchPhase' :: BuildBatchPhase -> Maybe POSIX
$sel:phaseType:BuildBatchPhase' :: BuildBatchPhase -> Maybe BuildBatchPhaseType
$sel:phaseStatus:BuildBatchPhase' :: BuildBatchPhase -> Maybe StatusType
$sel:endTime:BuildBatchPhase' :: BuildBatchPhase -> Maybe POSIX
$sel:durationInSeconds:BuildBatchPhase' :: BuildBatchPhase -> Maybe Integer
$sel:contexts:BuildBatchPhase' :: BuildBatchPhase -> 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 BuildBatchPhaseType
phaseType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startTime

instance Prelude.NFData BuildBatchPhase where
  rnf :: BuildBatchPhase -> ()
rnf BuildBatchPhase' {Maybe Integer
Maybe [PhaseContext]
Maybe POSIX
Maybe BuildBatchPhaseType
Maybe StatusType
startTime :: Maybe POSIX
phaseType :: Maybe BuildBatchPhaseType
phaseStatus :: Maybe StatusType
endTime :: Maybe POSIX
durationInSeconds :: Maybe Integer
contexts :: Maybe [PhaseContext]
$sel:startTime:BuildBatchPhase' :: BuildBatchPhase -> Maybe POSIX
$sel:phaseType:BuildBatchPhase' :: BuildBatchPhase -> Maybe BuildBatchPhaseType
$sel:phaseStatus:BuildBatchPhase' :: BuildBatchPhase -> Maybe StatusType
$sel:endTime:BuildBatchPhase' :: BuildBatchPhase -> Maybe POSIX
$sel:durationInSeconds:BuildBatchPhase' :: BuildBatchPhase -> Maybe Integer
$sel:contexts:BuildBatchPhase' :: BuildBatchPhase -> 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 BuildBatchPhaseType
phaseType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startTime