{-# 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.CloudWatchEvents.Types.BatchArrayProperties
-- 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.CloudWatchEvents.Types.BatchArrayProperties 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

-- | The array properties for the submitted job, such as the size of the
-- array. The array size can be between 2 and 10,000. If you specify array
-- properties for a job, it becomes an array job. This parameter is used
-- only if the target is an Batch job.
--
-- /See:/ 'newBatchArrayProperties' smart constructor.
data BatchArrayProperties = BatchArrayProperties'
  { -- | The size of the array, if this is an array batch job. Valid values are
    -- integers between 2 and 10,000.
    BatchArrayProperties -> Maybe Int
size :: Prelude.Maybe Prelude.Int
  }
  deriving (BatchArrayProperties -> BatchArrayProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchArrayProperties -> BatchArrayProperties -> Bool
$c/= :: BatchArrayProperties -> BatchArrayProperties -> Bool
== :: BatchArrayProperties -> BatchArrayProperties -> Bool
$c== :: BatchArrayProperties -> BatchArrayProperties -> Bool
Prelude.Eq, ReadPrec [BatchArrayProperties]
ReadPrec BatchArrayProperties
Int -> ReadS BatchArrayProperties
ReadS [BatchArrayProperties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchArrayProperties]
$creadListPrec :: ReadPrec [BatchArrayProperties]
readPrec :: ReadPrec BatchArrayProperties
$creadPrec :: ReadPrec BatchArrayProperties
readList :: ReadS [BatchArrayProperties]
$creadList :: ReadS [BatchArrayProperties]
readsPrec :: Int -> ReadS BatchArrayProperties
$creadsPrec :: Int -> ReadS BatchArrayProperties
Prelude.Read, Int -> BatchArrayProperties -> ShowS
[BatchArrayProperties] -> ShowS
BatchArrayProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchArrayProperties] -> ShowS
$cshowList :: [BatchArrayProperties] -> ShowS
show :: BatchArrayProperties -> String
$cshow :: BatchArrayProperties -> String
showsPrec :: Int -> BatchArrayProperties -> ShowS
$cshowsPrec :: Int -> BatchArrayProperties -> ShowS
Prelude.Show, forall x. Rep BatchArrayProperties x -> BatchArrayProperties
forall x. BatchArrayProperties -> Rep BatchArrayProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchArrayProperties x -> BatchArrayProperties
$cfrom :: forall x. BatchArrayProperties -> Rep BatchArrayProperties x
Prelude.Generic)

-- |
-- Create a value of 'BatchArrayProperties' 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:
--
-- 'size', 'batchArrayProperties_size' - The size of the array, if this is an array batch job. Valid values are
-- integers between 2 and 10,000.
newBatchArrayProperties ::
  BatchArrayProperties
newBatchArrayProperties :: BatchArrayProperties
newBatchArrayProperties =
  BatchArrayProperties' {$sel:size:BatchArrayProperties' :: Maybe Int
size = forall a. Maybe a
Prelude.Nothing}

-- | The size of the array, if this is an array batch job. Valid values are
-- integers between 2 and 10,000.
batchArrayProperties_size :: Lens.Lens' BatchArrayProperties (Prelude.Maybe Prelude.Int)
batchArrayProperties_size :: Lens' BatchArrayProperties (Maybe Int)
batchArrayProperties_size = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchArrayProperties' {Maybe Int
size :: Maybe Int
$sel:size:BatchArrayProperties' :: BatchArrayProperties -> Maybe Int
size} -> Maybe Int
size) (\s :: BatchArrayProperties
s@BatchArrayProperties' {} Maybe Int
a -> BatchArrayProperties
s {$sel:size:BatchArrayProperties' :: Maybe Int
size = Maybe Int
a} :: BatchArrayProperties)

instance Data.FromJSON BatchArrayProperties where
  parseJSON :: Value -> Parser BatchArrayProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BatchArrayProperties"
      ( \Object
x ->
          Maybe Int -> BatchArrayProperties
BatchArrayProperties'
            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
"Size")
      )

instance Prelude.Hashable BatchArrayProperties where
  hashWithSalt :: Int -> BatchArrayProperties -> Int
hashWithSalt Int
_salt BatchArrayProperties' {Maybe Int
size :: Maybe Int
$sel:size:BatchArrayProperties' :: BatchArrayProperties -> Maybe Int
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
size

instance Prelude.NFData BatchArrayProperties where
  rnf :: BatchArrayProperties -> ()
rnf BatchArrayProperties' {Maybe Int
size :: Maybe Int
$sel:size:BatchArrayProperties' :: BatchArrayProperties -> Maybe Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
size

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