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

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

-- | Specifies restrictions for the batch build.
--
-- /See:/ 'newBatchRestrictions' smart constructor.
data BatchRestrictions = BatchRestrictions'
  { -- | An array of strings that specify the compute types that are allowed for
    -- the batch build. See
    -- <https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html Build environment compute types>
    -- in the /CodeBuild User Guide/ for these values.
    BatchRestrictions -> Maybe [Text]
computeTypesAllowed :: Prelude.Maybe [Prelude.Text],
    -- | Specifies the maximum number of builds allowed.
    BatchRestrictions -> Maybe Int
maximumBuildsAllowed :: Prelude.Maybe Prelude.Int
  }
  deriving (BatchRestrictions -> BatchRestrictions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchRestrictions -> BatchRestrictions -> Bool
$c/= :: BatchRestrictions -> BatchRestrictions -> Bool
== :: BatchRestrictions -> BatchRestrictions -> Bool
$c== :: BatchRestrictions -> BatchRestrictions -> Bool
Prelude.Eq, ReadPrec [BatchRestrictions]
ReadPrec BatchRestrictions
Int -> ReadS BatchRestrictions
ReadS [BatchRestrictions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchRestrictions]
$creadListPrec :: ReadPrec [BatchRestrictions]
readPrec :: ReadPrec BatchRestrictions
$creadPrec :: ReadPrec BatchRestrictions
readList :: ReadS [BatchRestrictions]
$creadList :: ReadS [BatchRestrictions]
readsPrec :: Int -> ReadS BatchRestrictions
$creadsPrec :: Int -> ReadS BatchRestrictions
Prelude.Read, Int -> BatchRestrictions -> ShowS
[BatchRestrictions] -> ShowS
BatchRestrictions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchRestrictions] -> ShowS
$cshowList :: [BatchRestrictions] -> ShowS
show :: BatchRestrictions -> String
$cshow :: BatchRestrictions -> String
showsPrec :: Int -> BatchRestrictions -> ShowS
$cshowsPrec :: Int -> BatchRestrictions -> ShowS
Prelude.Show, forall x. Rep BatchRestrictions x -> BatchRestrictions
forall x. BatchRestrictions -> Rep BatchRestrictions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchRestrictions x -> BatchRestrictions
$cfrom :: forall x. BatchRestrictions -> Rep BatchRestrictions x
Prelude.Generic)

-- |
-- Create a value of 'BatchRestrictions' 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:
--
-- 'computeTypesAllowed', 'batchRestrictions_computeTypesAllowed' - An array of strings that specify the compute types that are allowed for
-- the batch build. See
-- <https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html Build environment compute types>
-- in the /CodeBuild User Guide/ for these values.
--
-- 'maximumBuildsAllowed', 'batchRestrictions_maximumBuildsAllowed' - Specifies the maximum number of builds allowed.
newBatchRestrictions ::
  BatchRestrictions
newBatchRestrictions :: BatchRestrictions
newBatchRestrictions =
  BatchRestrictions'
    { $sel:computeTypesAllowed:BatchRestrictions' :: Maybe [Text]
computeTypesAllowed =
        forall a. Maybe a
Prelude.Nothing,
      $sel:maximumBuildsAllowed:BatchRestrictions' :: Maybe Int
maximumBuildsAllowed = forall a. Maybe a
Prelude.Nothing
    }

-- | An array of strings that specify the compute types that are allowed for
-- the batch build. See
-- <https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html Build environment compute types>
-- in the /CodeBuild User Guide/ for these values.
batchRestrictions_computeTypesAllowed :: Lens.Lens' BatchRestrictions (Prelude.Maybe [Prelude.Text])
batchRestrictions_computeTypesAllowed :: Lens' BatchRestrictions (Maybe [Text])
batchRestrictions_computeTypesAllowed = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchRestrictions' {Maybe [Text]
computeTypesAllowed :: Maybe [Text]
$sel:computeTypesAllowed:BatchRestrictions' :: BatchRestrictions -> Maybe [Text]
computeTypesAllowed} -> Maybe [Text]
computeTypesAllowed) (\s :: BatchRestrictions
s@BatchRestrictions' {} Maybe [Text]
a -> BatchRestrictions
s {$sel:computeTypesAllowed:BatchRestrictions' :: Maybe [Text]
computeTypesAllowed = Maybe [Text]
a} :: BatchRestrictions) 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

-- | Specifies the maximum number of builds allowed.
batchRestrictions_maximumBuildsAllowed :: Lens.Lens' BatchRestrictions (Prelude.Maybe Prelude.Int)
batchRestrictions_maximumBuildsAllowed :: Lens' BatchRestrictions (Maybe Int)
batchRestrictions_maximumBuildsAllowed = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchRestrictions' {Maybe Int
maximumBuildsAllowed :: Maybe Int
$sel:maximumBuildsAllowed:BatchRestrictions' :: BatchRestrictions -> Maybe Int
maximumBuildsAllowed} -> Maybe Int
maximumBuildsAllowed) (\s :: BatchRestrictions
s@BatchRestrictions' {} Maybe Int
a -> BatchRestrictions
s {$sel:maximumBuildsAllowed:BatchRestrictions' :: Maybe Int
maximumBuildsAllowed = Maybe Int
a} :: BatchRestrictions)

instance Data.FromJSON BatchRestrictions where
  parseJSON :: Value -> Parser BatchRestrictions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BatchRestrictions"
      ( \Object
x ->
          Maybe [Text] -> Maybe Int -> BatchRestrictions
BatchRestrictions'
            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
"computeTypesAllowed"
                            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
"maximumBuildsAllowed")
      )

instance Prelude.Hashable BatchRestrictions where
  hashWithSalt :: Int -> BatchRestrictions -> Int
hashWithSalt Int
_salt BatchRestrictions' {Maybe Int
Maybe [Text]
maximumBuildsAllowed :: Maybe Int
computeTypesAllowed :: Maybe [Text]
$sel:maximumBuildsAllowed:BatchRestrictions' :: BatchRestrictions -> Maybe Int
$sel:computeTypesAllowed:BatchRestrictions' :: BatchRestrictions -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
computeTypesAllowed
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maximumBuildsAllowed

instance Prelude.NFData BatchRestrictions where
  rnf :: BatchRestrictions -> ()
rnf BatchRestrictions' {Maybe Int
Maybe [Text]
maximumBuildsAllowed :: Maybe Int
computeTypesAllowed :: Maybe [Text]
$sel:maximumBuildsAllowed:BatchRestrictions' :: BatchRestrictions -> Maybe Int
$sel:computeTypesAllowed:BatchRestrictions' :: BatchRestrictions -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
computeTypesAllowed
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maximumBuildsAllowed

instance Data.ToJSON BatchRestrictions where
  toJSON :: BatchRestrictions -> Value
toJSON BatchRestrictions' {Maybe Int
Maybe [Text]
maximumBuildsAllowed :: Maybe Int
computeTypesAllowed :: Maybe [Text]
$sel:maximumBuildsAllowed:BatchRestrictions' :: BatchRestrictions -> Maybe Int
$sel:computeTypesAllowed:BatchRestrictions' :: BatchRestrictions -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"computeTypesAllowed" 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]
computeTypesAllowed,
            (Key
"maximumBuildsAllowed" 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
maximumBuildsAllowed
          ]
      )