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

import Amazonka.CodeBuild.Types.ResolvedArtifact
import Amazonka.CodeBuild.Types.StatusType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains summary information about a batch build group.
--
-- /See:/ 'newBuildSummary' smart constructor.
data BuildSummary = BuildSummary'
  { -- | An array of @ResolvedArtifact@ objects that represents the secondary
    -- build artifacts for the build group.
    BuildSummary -> Maybe [ResolvedArtifact]
secondaryArtifacts :: Prelude.Maybe [ResolvedArtifact],
    -- | A @ResolvedArtifact@ object that represents the primary build artifacts
    -- for the build group.
    BuildSummary -> Maybe ResolvedArtifact
primaryArtifact :: Prelude.Maybe ResolvedArtifact,
    -- | The batch build ARN.
    BuildSummary -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The status of the build group.
    --
    -- [FAILED]
    --     The build group failed.
    --
    -- [FAULT]
    --     The build group faulted.
    --
    -- [IN_PROGRESS]
    --     The build group is still in progress.
    --
    -- [STOPPED]
    --     The build group stopped.
    --
    -- [SUCCEEDED]
    --     The build group succeeded.
    --
    -- [TIMED_OUT]
    --     The build group timed out.
    BuildSummary -> Maybe StatusType
buildStatus :: Prelude.Maybe StatusType,
    -- | When the build was started, expressed in Unix time format.
    BuildSummary -> Maybe POSIX
requestedOn :: Prelude.Maybe Core.POSIX
  }
  deriving (BuildSummary -> BuildSummary -> Bool
(BuildSummary -> BuildSummary -> Bool)
-> (BuildSummary -> BuildSummary -> Bool) -> Eq BuildSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BuildSummary -> BuildSummary -> Bool
$c/= :: BuildSummary -> BuildSummary -> Bool
== :: BuildSummary -> BuildSummary -> Bool
$c== :: BuildSummary -> BuildSummary -> Bool
Prelude.Eq, ReadPrec [BuildSummary]
ReadPrec BuildSummary
Int -> ReadS BuildSummary
ReadS [BuildSummary]
(Int -> ReadS BuildSummary)
-> ReadS [BuildSummary]
-> ReadPrec BuildSummary
-> ReadPrec [BuildSummary]
-> Read BuildSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BuildSummary]
$creadListPrec :: ReadPrec [BuildSummary]
readPrec :: ReadPrec BuildSummary
$creadPrec :: ReadPrec BuildSummary
readList :: ReadS [BuildSummary]
$creadList :: ReadS [BuildSummary]
readsPrec :: Int -> ReadS BuildSummary
$creadsPrec :: Int -> ReadS BuildSummary
Prelude.Read, Int -> BuildSummary -> ShowS
[BuildSummary] -> ShowS
BuildSummary -> String
(Int -> BuildSummary -> ShowS)
-> (BuildSummary -> String)
-> ([BuildSummary] -> ShowS)
-> Show BuildSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BuildSummary] -> ShowS
$cshowList :: [BuildSummary] -> ShowS
show :: BuildSummary -> String
$cshow :: BuildSummary -> String
showsPrec :: Int -> BuildSummary -> ShowS
$cshowsPrec :: Int -> BuildSummary -> ShowS
Prelude.Show, (forall x. BuildSummary -> Rep BuildSummary x)
-> (forall x. Rep BuildSummary x -> BuildSummary)
-> Generic BuildSummary
forall x. Rep BuildSummary x -> BuildSummary
forall x. BuildSummary -> Rep BuildSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BuildSummary x -> BuildSummary
$cfrom :: forall x. BuildSummary -> Rep BuildSummary x
Prelude.Generic)

-- |
-- Create a value of 'BuildSummary' 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:
--
-- 'secondaryArtifacts', 'buildSummary_secondaryArtifacts' - An array of @ResolvedArtifact@ objects that represents the secondary
-- build artifacts for the build group.
--
-- 'primaryArtifact', 'buildSummary_primaryArtifact' - A @ResolvedArtifact@ object that represents the primary build artifacts
-- for the build group.
--
-- 'arn', 'buildSummary_arn' - The batch build ARN.
--
-- 'buildStatus', 'buildSummary_buildStatus' - The status of the build group.
--
-- [FAILED]
--     The build group failed.
--
-- [FAULT]
--     The build group faulted.
--
-- [IN_PROGRESS]
--     The build group is still in progress.
--
-- [STOPPED]
--     The build group stopped.
--
-- [SUCCEEDED]
--     The build group succeeded.
--
-- [TIMED_OUT]
--     The build group timed out.
--
-- 'requestedOn', 'buildSummary_requestedOn' - When the build was started, expressed in Unix time format.
newBuildSummary ::
  BuildSummary
newBuildSummary :: BuildSummary
newBuildSummary =
  BuildSummary' :: Maybe [ResolvedArtifact]
-> Maybe ResolvedArtifact
-> Maybe Text
-> Maybe StatusType
-> Maybe POSIX
-> BuildSummary
BuildSummary'
    { $sel:secondaryArtifacts:BuildSummary' :: Maybe [ResolvedArtifact]
secondaryArtifacts = Maybe [ResolvedArtifact]
forall a. Maybe a
Prelude.Nothing,
      $sel:primaryArtifact:BuildSummary' :: Maybe ResolvedArtifact
primaryArtifact = Maybe ResolvedArtifact
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:BuildSummary' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:buildStatus:BuildSummary' :: Maybe StatusType
buildStatus = Maybe StatusType
forall a. Maybe a
Prelude.Nothing,
      $sel:requestedOn:BuildSummary' :: Maybe POSIX
requestedOn = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | An array of @ResolvedArtifact@ objects that represents the secondary
-- build artifacts for the build group.
buildSummary_secondaryArtifacts :: Lens.Lens' BuildSummary (Prelude.Maybe [ResolvedArtifact])
buildSummary_secondaryArtifacts :: (Maybe [ResolvedArtifact] -> f (Maybe [ResolvedArtifact]))
-> BuildSummary -> f BuildSummary
buildSummary_secondaryArtifacts = (BuildSummary -> Maybe [ResolvedArtifact])
-> (BuildSummary -> Maybe [ResolvedArtifact] -> BuildSummary)
-> Lens
     BuildSummary
     BuildSummary
     (Maybe [ResolvedArtifact])
     (Maybe [ResolvedArtifact])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildSummary' {Maybe [ResolvedArtifact]
secondaryArtifacts :: Maybe [ResolvedArtifact]
$sel:secondaryArtifacts:BuildSummary' :: BuildSummary -> Maybe [ResolvedArtifact]
secondaryArtifacts} -> Maybe [ResolvedArtifact]
secondaryArtifacts) (\s :: BuildSummary
s@BuildSummary' {} Maybe [ResolvedArtifact]
a -> BuildSummary
s {$sel:secondaryArtifacts:BuildSummary' :: Maybe [ResolvedArtifact]
secondaryArtifacts = Maybe [ResolvedArtifact]
a} :: BuildSummary) ((Maybe [ResolvedArtifact] -> f (Maybe [ResolvedArtifact]))
 -> BuildSummary -> f BuildSummary)
-> ((Maybe [ResolvedArtifact] -> f (Maybe [ResolvedArtifact]))
    -> Maybe [ResolvedArtifact] -> f (Maybe [ResolvedArtifact]))
-> (Maybe [ResolvedArtifact] -> f (Maybe [ResolvedArtifact]))
-> BuildSummary
-> f BuildSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ResolvedArtifact]
  [ResolvedArtifact]
  [ResolvedArtifact]
  [ResolvedArtifact]
-> Iso
     (Maybe [ResolvedArtifact])
     (Maybe [ResolvedArtifact])
     (Maybe [ResolvedArtifact])
     (Maybe [ResolvedArtifact])
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
  [ResolvedArtifact]
  [ResolvedArtifact]
  [ResolvedArtifact]
  [ResolvedArtifact]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A @ResolvedArtifact@ object that represents the primary build artifacts
-- for the build group.
buildSummary_primaryArtifact :: Lens.Lens' BuildSummary (Prelude.Maybe ResolvedArtifact)
buildSummary_primaryArtifact :: (Maybe ResolvedArtifact -> f (Maybe ResolvedArtifact))
-> BuildSummary -> f BuildSummary
buildSummary_primaryArtifact = (BuildSummary -> Maybe ResolvedArtifact)
-> (BuildSummary -> Maybe ResolvedArtifact -> BuildSummary)
-> Lens
     BuildSummary
     BuildSummary
     (Maybe ResolvedArtifact)
     (Maybe ResolvedArtifact)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildSummary' {Maybe ResolvedArtifact
primaryArtifact :: Maybe ResolvedArtifact
$sel:primaryArtifact:BuildSummary' :: BuildSummary -> Maybe ResolvedArtifact
primaryArtifact} -> Maybe ResolvedArtifact
primaryArtifact) (\s :: BuildSummary
s@BuildSummary' {} Maybe ResolvedArtifact
a -> BuildSummary
s {$sel:primaryArtifact:BuildSummary' :: Maybe ResolvedArtifact
primaryArtifact = Maybe ResolvedArtifact
a} :: BuildSummary)

-- | The batch build ARN.
buildSummary_arn :: Lens.Lens' BuildSummary (Prelude.Maybe Prelude.Text)
buildSummary_arn :: (Maybe Text -> f (Maybe Text)) -> BuildSummary -> f BuildSummary
buildSummary_arn = (BuildSummary -> Maybe Text)
-> (BuildSummary -> Maybe Text -> BuildSummary)
-> Lens BuildSummary BuildSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildSummary' {Maybe Text
arn :: Maybe Text
$sel:arn:BuildSummary' :: BuildSummary -> Maybe Text
arn} -> Maybe Text
arn) (\s :: BuildSummary
s@BuildSummary' {} Maybe Text
a -> BuildSummary
s {$sel:arn:BuildSummary' :: Maybe Text
arn = Maybe Text
a} :: BuildSummary)

-- | The status of the build group.
--
-- [FAILED]
--     The build group failed.
--
-- [FAULT]
--     The build group faulted.
--
-- [IN_PROGRESS]
--     The build group is still in progress.
--
-- [STOPPED]
--     The build group stopped.
--
-- [SUCCEEDED]
--     The build group succeeded.
--
-- [TIMED_OUT]
--     The build group timed out.
buildSummary_buildStatus :: Lens.Lens' BuildSummary (Prelude.Maybe StatusType)
buildSummary_buildStatus :: (Maybe StatusType -> f (Maybe StatusType))
-> BuildSummary -> f BuildSummary
buildSummary_buildStatus = (BuildSummary -> Maybe StatusType)
-> (BuildSummary -> Maybe StatusType -> BuildSummary)
-> Lens
     BuildSummary BuildSummary (Maybe StatusType) (Maybe StatusType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildSummary' {Maybe StatusType
buildStatus :: Maybe StatusType
$sel:buildStatus:BuildSummary' :: BuildSummary -> Maybe StatusType
buildStatus} -> Maybe StatusType
buildStatus) (\s :: BuildSummary
s@BuildSummary' {} Maybe StatusType
a -> BuildSummary
s {$sel:buildStatus:BuildSummary' :: Maybe StatusType
buildStatus = Maybe StatusType
a} :: BuildSummary)

-- | When the build was started, expressed in Unix time format.
buildSummary_requestedOn :: Lens.Lens' BuildSummary (Prelude.Maybe Prelude.UTCTime)
buildSummary_requestedOn :: (Maybe UTCTime -> f (Maybe UTCTime))
-> BuildSummary -> f BuildSummary
buildSummary_requestedOn = (BuildSummary -> Maybe POSIX)
-> (BuildSummary -> Maybe POSIX -> BuildSummary)
-> Lens BuildSummary BuildSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildSummary' {Maybe POSIX
requestedOn :: Maybe POSIX
$sel:requestedOn:BuildSummary' :: BuildSummary -> Maybe POSIX
requestedOn} -> Maybe POSIX
requestedOn) (\s :: BuildSummary
s@BuildSummary' {} Maybe POSIX
a -> BuildSummary
s {$sel:requestedOn:BuildSummary' :: Maybe POSIX
requestedOn = Maybe POSIX
a} :: BuildSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> BuildSummary -> f BuildSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> BuildSummary
-> f BuildSummary
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

instance Core.FromJSON BuildSummary where
  parseJSON :: Value -> Parser BuildSummary
parseJSON =
    String
-> (Object -> Parser BuildSummary) -> Value -> Parser BuildSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BuildSummary"
      ( \Object
x ->
          Maybe [ResolvedArtifact]
-> Maybe ResolvedArtifact
-> Maybe Text
-> Maybe StatusType
-> Maybe POSIX
-> BuildSummary
BuildSummary'
            (Maybe [ResolvedArtifact]
 -> Maybe ResolvedArtifact
 -> Maybe Text
 -> Maybe StatusType
 -> Maybe POSIX
 -> BuildSummary)
-> Parser (Maybe [ResolvedArtifact])
-> Parser
     (Maybe ResolvedArtifact
      -> Maybe Text -> Maybe StatusType -> Maybe POSIX -> BuildSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [ResolvedArtifact]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"secondaryArtifacts"
                            Parser (Maybe (Maybe [ResolvedArtifact]))
-> Maybe [ResolvedArtifact] -> Parser (Maybe [ResolvedArtifact])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ResolvedArtifact]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe ResolvedArtifact
   -> Maybe Text -> Maybe StatusType -> Maybe POSIX -> BuildSummary)
-> Parser (Maybe ResolvedArtifact)
-> Parser
     (Maybe Text -> Maybe StatusType -> Maybe POSIX -> BuildSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ResolvedArtifact)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"primaryArtifact")
            Parser
  (Maybe Text -> Maybe StatusType -> Maybe POSIX -> BuildSummary)
-> Parser (Maybe Text)
-> Parser (Maybe StatusType -> Maybe POSIX -> BuildSummary)
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
"arn")
            Parser (Maybe StatusType -> Maybe POSIX -> BuildSummary)
-> Parser (Maybe StatusType)
-> Parser (Maybe POSIX -> BuildSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe StatusType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"buildStatus")
            Parser (Maybe POSIX -> BuildSummary)
-> Parser (Maybe POSIX) -> Parser BuildSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"requestedOn")
      )

instance Prelude.Hashable BuildSummary

instance Prelude.NFData BuildSummary