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

import Amazonka.CodeBuild.Types.BatchReportModeType
import Amazonka.CodeBuild.Types.BatchRestrictions
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 configuration information about a batch build project.
--
-- /See:/ 'newProjectBuildBatchConfig' smart constructor.
data ProjectBuildBatchConfig = ProjectBuildBatchConfig'
  { -- | Specifies how build status reports are sent to the source provider for
    -- the batch build. This property is only used when the source provider for
    -- your project is Bitbucket, GitHub, or GitHub Enterprise, and your
    -- project is configured to report build statuses to the source provider.
    --
    -- [REPORT_AGGREGATED_BATCH]
    --     (Default) Aggregate all of the build statuses into a single status
    --     report.
    --
    -- [REPORT_INDIVIDUAL_BUILDS]
    --     Send a separate status report for each individual build.
    ProjectBuildBatchConfig -> Maybe BatchReportModeType
batchReportMode :: Prelude.Maybe BatchReportModeType,
    -- | Specifies if the build artifacts for the batch build should be combined
    -- into a single artifact location.
    ProjectBuildBatchConfig -> Maybe Bool
combineArtifacts :: Prelude.Maybe Prelude.Bool,
    -- | A @BatchRestrictions@ object that specifies the restrictions for the
    -- batch build.
    ProjectBuildBatchConfig -> Maybe BatchRestrictions
restrictions :: Prelude.Maybe BatchRestrictions,
    -- | Specifies the service role ARN for the batch build project.
    ProjectBuildBatchConfig -> Maybe Text
serviceRole :: Prelude.Maybe Prelude.Text,
    -- | Specifies the maximum amount of time, in minutes, that the batch build
    -- must be completed in.
    ProjectBuildBatchConfig -> Maybe Int
timeoutInMins :: Prelude.Maybe Prelude.Int
  }
  deriving (ProjectBuildBatchConfig -> ProjectBuildBatchConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProjectBuildBatchConfig -> ProjectBuildBatchConfig -> Bool
$c/= :: ProjectBuildBatchConfig -> ProjectBuildBatchConfig -> Bool
== :: ProjectBuildBatchConfig -> ProjectBuildBatchConfig -> Bool
$c== :: ProjectBuildBatchConfig -> ProjectBuildBatchConfig -> Bool
Prelude.Eq, ReadPrec [ProjectBuildBatchConfig]
ReadPrec ProjectBuildBatchConfig
Int -> ReadS ProjectBuildBatchConfig
ReadS [ProjectBuildBatchConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProjectBuildBatchConfig]
$creadListPrec :: ReadPrec [ProjectBuildBatchConfig]
readPrec :: ReadPrec ProjectBuildBatchConfig
$creadPrec :: ReadPrec ProjectBuildBatchConfig
readList :: ReadS [ProjectBuildBatchConfig]
$creadList :: ReadS [ProjectBuildBatchConfig]
readsPrec :: Int -> ReadS ProjectBuildBatchConfig
$creadsPrec :: Int -> ReadS ProjectBuildBatchConfig
Prelude.Read, Int -> ProjectBuildBatchConfig -> ShowS
[ProjectBuildBatchConfig] -> ShowS
ProjectBuildBatchConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProjectBuildBatchConfig] -> ShowS
$cshowList :: [ProjectBuildBatchConfig] -> ShowS
show :: ProjectBuildBatchConfig -> String
$cshow :: ProjectBuildBatchConfig -> String
showsPrec :: Int -> ProjectBuildBatchConfig -> ShowS
$cshowsPrec :: Int -> ProjectBuildBatchConfig -> ShowS
Prelude.Show, forall x. Rep ProjectBuildBatchConfig x -> ProjectBuildBatchConfig
forall x. ProjectBuildBatchConfig -> Rep ProjectBuildBatchConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProjectBuildBatchConfig x -> ProjectBuildBatchConfig
$cfrom :: forall x. ProjectBuildBatchConfig -> Rep ProjectBuildBatchConfig x
Prelude.Generic)

-- |
-- Create a value of 'ProjectBuildBatchConfig' 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:
--
-- 'batchReportMode', 'projectBuildBatchConfig_batchReportMode' - Specifies how build status reports are sent to the source provider for
-- the batch build. This property is only used when the source provider for
-- your project is Bitbucket, GitHub, or GitHub Enterprise, and your
-- project is configured to report build statuses to the source provider.
--
-- [REPORT_AGGREGATED_BATCH]
--     (Default) Aggregate all of the build statuses into a single status
--     report.
--
-- [REPORT_INDIVIDUAL_BUILDS]
--     Send a separate status report for each individual build.
--
-- 'combineArtifacts', 'projectBuildBatchConfig_combineArtifacts' - Specifies if the build artifacts for the batch build should be combined
-- into a single artifact location.
--
-- 'restrictions', 'projectBuildBatchConfig_restrictions' - A @BatchRestrictions@ object that specifies the restrictions for the
-- batch build.
--
-- 'serviceRole', 'projectBuildBatchConfig_serviceRole' - Specifies the service role ARN for the batch build project.
--
-- 'timeoutInMins', 'projectBuildBatchConfig_timeoutInMins' - Specifies the maximum amount of time, in minutes, that the batch build
-- must be completed in.
newProjectBuildBatchConfig ::
  ProjectBuildBatchConfig
newProjectBuildBatchConfig :: ProjectBuildBatchConfig
newProjectBuildBatchConfig =
  ProjectBuildBatchConfig'
    { $sel:batchReportMode:ProjectBuildBatchConfig' :: Maybe BatchReportModeType
batchReportMode =
        forall a. Maybe a
Prelude.Nothing,
      $sel:combineArtifacts:ProjectBuildBatchConfig' :: Maybe Bool
combineArtifacts = forall a. Maybe a
Prelude.Nothing,
      $sel:restrictions:ProjectBuildBatchConfig' :: Maybe BatchRestrictions
restrictions = forall a. Maybe a
Prelude.Nothing,
      $sel:serviceRole:ProjectBuildBatchConfig' :: Maybe Text
serviceRole = forall a. Maybe a
Prelude.Nothing,
      $sel:timeoutInMins:ProjectBuildBatchConfig' :: Maybe Int
timeoutInMins = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies how build status reports are sent to the source provider for
-- the batch build. This property is only used when the source provider for
-- your project is Bitbucket, GitHub, or GitHub Enterprise, and your
-- project is configured to report build statuses to the source provider.
--
-- [REPORT_AGGREGATED_BATCH]
--     (Default) Aggregate all of the build statuses into a single status
--     report.
--
-- [REPORT_INDIVIDUAL_BUILDS]
--     Send a separate status report for each individual build.
projectBuildBatchConfig_batchReportMode :: Lens.Lens' ProjectBuildBatchConfig (Prelude.Maybe BatchReportModeType)
projectBuildBatchConfig_batchReportMode :: Lens' ProjectBuildBatchConfig (Maybe BatchReportModeType)
projectBuildBatchConfig_batchReportMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectBuildBatchConfig' {Maybe BatchReportModeType
batchReportMode :: Maybe BatchReportModeType
$sel:batchReportMode:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe BatchReportModeType
batchReportMode} -> Maybe BatchReportModeType
batchReportMode) (\s :: ProjectBuildBatchConfig
s@ProjectBuildBatchConfig' {} Maybe BatchReportModeType
a -> ProjectBuildBatchConfig
s {$sel:batchReportMode:ProjectBuildBatchConfig' :: Maybe BatchReportModeType
batchReportMode = Maybe BatchReportModeType
a} :: ProjectBuildBatchConfig)

-- | Specifies if the build artifacts for the batch build should be combined
-- into a single artifact location.
projectBuildBatchConfig_combineArtifacts :: Lens.Lens' ProjectBuildBatchConfig (Prelude.Maybe Prelude.Bool)
projectBuildBatchConfig_combineArtifacts :: Lens' ProjectBuildBatchConfig (Maybe Bool)
projectBuildBatchConfig_combineArtifacts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectBuildBatchConfig' {Maybe Bool
combineArtifacts :: Maybe Bool
$sel:combineArtifacts:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe Bool
combineArtifacts} -> Maybe Bool
combineArtifacts) (\s :: ProjectBuildBatchConfig
s@ProjectBuildBatchConfig' {} Maybe Bool
a -> ProjectBuildBatchConfig
s {$sel:combineArtifacts:ProjectBuildBatchConfig' :: Maybe Bool
combineArtifacts = Maybe Bool
a} :: ProjectBuildBatchConfig)

-- | A @BatchRestrictions@ object that specifies the restrictions for the
-- batch build.
projectBuildBatchConfig_restrictions :: Lens.Lens' ProjectBuildBatchConfig (Prelude.Maybe BatchRestrictions)
projectBuildBatchConfig_restrictions :: Lens' ProjectBuildBatchConfig (Maybe BatchRestrictions)
projectBuildBatchConfig_restrictions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectBuildBatchConfig' {Maybe BatchRestrictions
restrictions :: Maybe BatchRestrictions
$sel:restrictions:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe BatchRestrictions
restrictions} -> Maybe BatchRestrictions
restrictions) (\s :: ProjectBuildBatchConfig
s@ProjectBuildBatchConfig' {} Maybe BatchRestrictions
a -> ProjectBuildBatchConfig
s {$sel:restrictions:ProjectBuildBatchConfig' :: Maybe BatchRestrictions
restrictions = Maybe BatchRestrictions
a} :: ProjectBuildBatchConfig)

-- | Specifies the service role ARN for the batch build project.
projectBuildBatchConfig_serviceRole :: Lens.Lens' ProjectBuildBatchConfig (Prelude.Maybe Prelude.Text)
projectBuildBatchConfig_serviceRole :: Lens' ProjectBuildBatchConfig (Maybe Text)
projectBuildBatchConfig_serviceRole = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectBuildBatchConfig' {Maybe Text
serviceRole :: Maybe Text
$sel:serviceRole:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe Text
serviceRole} -> Maybe Text
serviceRole) (\s :: ProjectBuildBatchConfig
s@ProjectBuildBatchConfig' {} Maybe Text
a -> ProjectBuildBatchConfig
s {$sel:serviceRole:ProjectBuildBatchConfig' :: Maybe Text
serviceRole = Maybe Text
a} :: ProjectBuildBatchConfig)

-- | Specifies the maximum amount of time, in minutes, that the batch build
-- must be completed in.
projectBuildBatchConfig_timeoutInMins :: Lens.Lens' ProjectBuildBatchConfig (Prelude.Maybe Prelude.Int)
projectBuildBatchConfig_timeoutInMins :: Lens' ProjectBuildBatchConfig (Maybe Int)
projectBuildBatchConfig_timeoutInMins = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectBuildBatchConfig' {Maybe Int
timeoutInMins :: Maybe Int
$sel:timeoutInMins:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe Int
timeoutInMins} -> Maybe Int
timeoutInMins) (\s :: ProjectBuildBatchConfig
s@ProjectBuildBatchConfig' {} Maybe Int
a -> ProjectBuildBatchConfig
s {$sel:timeoutInMins:ProjectBuildBatchConfig' :: Maybe Int
timeoutInMins = Maybe Int
a} :: ProjectBuildBatchConfig)

instance Data.FromJSON ProjectBuildBatchConfig where
  parseJSON :: Value -> Parser ProjectBuildBatchConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ProjectBuildBatchConfig"
      ( \Object
x ->
          Maybe BatchReportModeType
-> Maybe Bool
-> Maybe BatchRestrictions
-> Maybe Text
-> Maybe Int
-> ProjectBuildBatchConfig
ProjectBuildBatchConfig'
            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
"batchReportMode")
            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
"combineArtifacts")
            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
"restrictions")
            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
"serviceRole")
            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
"timeoutInMins")
      )

instance Prelude.Hashable ProjectBuildBatchConfig where
  hashWithSalt :: Int -> ProjectBuildBatchConfig -> Int
hashWithSalt Int
_salt ProjectBuildBatchConfig' {Maybe Bool
Maybe Int
Maybe Text
Maybe BatchReportModeType
Maybe BatchRestrictions
timeoutInMins :: Maybe Int
serviceRole :: Maybe Text
restrictions :: Maybe BatchRestrictions
combineArtifacts :: Maybe Bool
batchReportMode :: Maybe BatchReportModeType
$sel:timeoutInMins:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe Int
$sel:serviceRole:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe Text
$sel:restrictions:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe BatchRestrictions
$sel:combineArtifacts:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe Bool
$sel:batchReportMode:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe BatchReportModeType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BatchReportModeType
batchReportMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
combineArtifacts
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BatchRestrictions
restrictions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
serviceRole
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
timeoutInMins

instance Prelude.NFData ProjectBuildBatchConfig where
  rnf :: ProjectBuildBatchConfig -> ()
rnf ProjectBuildBatchConfig' {Maybe Bool
Maybe Int
Maybe Text
Maybe BatchReportModeType
Maybe BatchRestrictions
timeoutInMins :: Maybe Int
serviceRole :: Maybe Text
restrictions :: Maybe BatchRestrictions
combineArtifacts :: Maybe Bool
batchReportMode :: Maybe BatchReportModeType
$sel:timeoutInMins:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe Int
$sel:serviceRole:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe Text
$sel:restrictions:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe BatchRestrictions
$sel:combineArtifacts:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe Bool
$sel:batchReportMode:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe BatchReportModeType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BatchReportModeType
batchReportMode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
combineArtifacts
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BatchRestrictions
restrictions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
serviceRole
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
timeoutInMins

instance Data.ToJSON ProjectBuildBatchConfig where
  toJSON :: ProjectBuildBatchConfig -> Value
toJSON ProjectBuildBatchConfig' {Maybe Bool
Maybe Int
Maybe Text
Maybe BatchReportModeType
Maybe BatchRestrictions
timeoutInMins :: Maybe Int
serviceRole :: Maybe Text
restrictions :: Maybe BatchRestrictions
combineArtifacts :: Maybe Bool
batchReportMode :: Maybe BatchReportModeType
$sel:timeoutInMins:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe Int
$sel:serviceRole:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe Text
$sel:restrictions:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe BatchRestrictions
$sel:combineArtifacts:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe Bool
$sel:batchReportMode:ProjectBuildBatchConfig' :: ProjectBuildBatchConfig -> Maybe BatchReportModeType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"batchReportMode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BatchReportModeType
batchReportMode,
            (Key
"combineArtifacts" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
combineArtifacts,
            (Key
"restrictions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BatchRestrictions
restrictions,
            (Key
"serviceRole" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
serviceRole,
            (Key
"timeoutInMins" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
timeoutInMins
          ]
      )