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

import Amazonka.CodeBuild.Types.BatchReportModeType
import Amazonka.CodeBuild.Types.BatchRestrictions
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains configuration information about a batch build project.
--
-- /See:/ 'newProjectBuildBatchConfig' smart constructor.
data ProjectBuildBatchConfig = ProjectBuildBatchConfig'
  { -- | 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,
    -- | Specifies the maximum amount of time, in minutes, that the batch build
    -- must be completed in.
    ProjectBuildBatchConfig -> Maybe Int
timeoutInMins :: Prelude.Maybe Prelude.Int,
    -- | A @BatchRestrictions@ object that specifies the restrictions for the
    -- batch build.
    ProjectBuildBatchConfig -> Maybe BatchRestrictions
restrictions :: Prelude.Maybe BatchRestrictions,
    -- | 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 the service role ARN for the batch build project.
    ProjectBuildBatchConfig -> Maybe Text
serviceRole :: Prelude.Maybe Prelude.Text
  }
  deriving (ProjectBuildBatchConfig -> ProjectBuildBatchConfig -> Bool
(ProjectBuildBatchConfig -> ProjectBuildBatchConfig -> Bool)
-> (ProjectBuildBatchConfig -> ProjectBuildBatchConfig -> Bool)
-> Eq ProjectBuildBatchConfig
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]
(Int -> ReadS ProjectBuildBatchConfig)
-> ReadS [ProjectBuildBatchConfig]
-> ReadPrec ProjectBuildBatchConfig
-> ReadPrec [ProjectBuildBatchConfig]
-> Read 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
(Int -> ProjectBuildBatchConfig -> ShowS)
-> (ProjectBuildBatchConfig -> String)
-> ([ProjectBuildBatchConfig] -> ShowS)
-> Show ProjectBuildBatchConfig
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.
 ProjectBuildBatchConfig -> Rep ProjectBuildBatchConfig x)
-> (forall x.
    Rep ProjectBuildBatchConfig x -> ProjectBuildBatchConfig)
-> Generic ProjectBuildBatchConfig
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:
--
-- 'combineArtifacts', 'projectBuildBatchConfig_combineArtifacts' - Specifies if the build artifacts for the batch build should be combined
-- into a single artifact location.
--
-- 'timeoutInMins', 'projectBuildBatchConfig_timeoutInMins' - Specifies the maximum amount of time, in minutes, that the batch build
-- must be completed in.
--
-- 'restrictions', 'projectBuildBatchConfig_restrictions' - A @BatchRestrictions@ object that specifies the restrictions for the
-- batch build.
--
-- '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.
--
-- 'serviceRole', 'projectBuildBatchConfig_serviceRole' - Specifies the service role ARN for the batch build project.
newProjectBuildBatchConfig ::
  ProjectBuildBatchConfig
newProjectBuildBatchConfig :: ProjectBuildBatchConfig
newProjectBuildBatchConfig =
  ProjectBuildBatchConfig' :: Maybe Bool
-> Maybe Int
-> Maybe BatchRestrictions
-> Maybe BatchReportModeType
-> Maybe Text
-> ProjectBuildBatchConfig
ProjectBuildBatchConfig'
    { $sel:combineArtifacts:ProjectBuildBatchConfig' :: Maybe Bool
combineArtifacts =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:timeoutInMins:ProjectBuildBatchConfig' :: Maybe Int
timeoutInMins = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:restrictions:ProjectBuildBatchConfig' :: Maybe BatchRestrictions
restrictions = Maybe BatchRestrictions
forall a. Maybe a
Prelude.Nothing,
      $sel:batchReportMode:ProjectBuildBatchConfig' :: Maybe BatchReportModeType
batchReportMode = Maybe BatchReportModeType
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceRole:ProjectBuildBatchConfig' :: Maybe Text
serviceRole = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Bool -> f (Maybe Bool))
-> ProjectBuildBatchConfig -> f ProjectBuildBatchConfig
projectBuildBatchConfig_combineArtifacts = (ProjectBuildBatchConfig -> Maybe Bool)
-> (ProjectBuildBatchConfig
    -> Maybe Bool -> ProjectBuildBatchConfig)
-> Lens
     ProjectBuildBatchConfig
     ProjectBuildBatchConfig
     (Maybe Bool)
     (Maybe Bool)
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)

-- | 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 :: (Maybe Int -> f (Maybe Int))
-> ProjectBuildBatchConfig -> f ProjectBuildBatchConfig
projectBuildBatchConfig_timeoutInMins = (ProjectBuildBatchConfig -> Maybe Int)
-> (ProjectBuildBatchConfig
    -> Maybe Int -> ProjectBuildBatchConfig)
-> Lens
     ProjectBuildBatchConfig
     ProjectBuildBatchConfig
     (Maybe Int)
     (Maybe Int)
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)

-- | A @BatchRestrictions@ object that specifies the restrictions for the
-- batch build.
projectBuildBatchConfig_restrictions :: Lens.Lens' ProjectBuildBatchConfig (Prelude.Maybe BatchRestrictions)
projectBuildBatchConfig_restrictions :: (Maybe BatchRestrictions -> f (Maybe BatchRestrictions))
-> ProjectBuildBatchConfig -> f ProjectBuildBatchConfig
projectBuildBatchConfig_restrictions = (ProjectBuildBatchConfig -> Maybe BatchRestrictions)
-> (ProjectBuildBatchConfig
    -> Maybe BatchRestrictions -> ProjectBuildBatchConfig)
-> Lens
     ProjectBuildBatchConfig
     ProjectBuildBatchConfig
     (Maybe BatchRestrictions)
     (Maybe BatchRestrictions)
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 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 :: (Maybe BatchReportModeType -> f (Maybe BatchReportModeType))
-> ProjectBuildBatchConfig -> f ProjectBuildBatchConfig
projectBuildBatchConfig_batchReportMode = (ProjectBuildBatchConfig -> Maybe BatchReportModeType)
-> (ProjectBuildBatchConfig
    -> Maybe BatchReportModeType -> ProjectBuildBatchConfig)
-> Lens
     ProjectBuildBatchConfig
     ProjectBuildBatchConfig
     (Maybe BatchReportModeType)
     (Maybe BatchReportModeType)
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 the service role ARN for the batch build project.
projectBuildBatchConfig_serviceRole :: Lens.Lens' ProjectBuildBatchConfig (Prelude.Maybe Prelude.Text)
projectBuildBatchConfig_serviceRole :: (Maybe Text -> f (Maybe Text))
-> ProjectBuildBatchConfig -> f ProjectBuildBatchConfig
projectBuildBatchConfig_serviceRole = (ProjectBuildBatchConfig -> Maybe Text)
-> (ProjectBuildBatchConfig
    -> Maybe Text -> ProjectBuildBatchConfig)
-> Lens
     ProjectBuildBatchConfig
     ProjectBuildBatchConfig
     (Maybe Text)
     (Maybe Text)
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)

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

instance Prelude.Hashable ProjectBuildBatchConfig

instance Prelude.NFData ProjectBuildBatchConfig

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