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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(BatchArrayProperties -> BatchArrayProperties -> Bool)
-> (BatchArrayProperties -> BatchArrayProperties -> Bool)
-> Eq BatchArrayProperties
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]
(Int -> ReadS BatchArrayProperties)
-> ReadS [BatchArrayProperties]
-> ReadPrec BatchArrayProperties
-> ReadPrec [BatchArrayProperties]
-> Read 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
(Int -> BatchArrayProperties -> ShowS)
-> (BatchArrayProperties -> String)
-> ([BatchArrayProperties] -> ShowS)
-> Show BatchArrayProperties
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. BatchArrayProperties -> Rep BatchArrayProperties x)
-> (forall x. Rep BatchArrayProperties x -> BatchArrayProperties)
-> Generic BatchArrayProperties
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' :: Maybe Int -> BatchArrayProperties
BatchArrayProperties' {$sel:size:BatchArrayProperties' :: Maybe Int
size = Maybe Int
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 :: (Maybe Int -> f (Maybe Int))
-> BatchArrayProperties -> f BatchArrayProperties
batchArrayProperties_size = (BatchArrayProperties -> Maybe Int)
-> (BatchArrayProperties -> Maybe Int -> BatchArrayProperties)
-> Lens
     BatchArrayProperties BatchArrayProperties (Maybe Int) (Maybe Int)
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 Core.FromJSON BatchArrayProperties where
  parseJSON :: Value -> Parser BatchArrayProperties
parseJSON =
    String
-> (Object -> Parser BatchArrayProperties)
-> Value
-> Parser BatchArrayProperties
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BatchArrayProperties"
      ( \Object
x ->
          Maybe Int -> BatchArrayProperties
BatchArrayProperties'
            (Maybe Int -> BatchArrayProperties)
-> Parser (Maybe Int) -> Parser BatchArrayProperties
forall (f :: * -> *) a b. Functor 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
"Size")
      )

instance Prelude.Hashable BatchArrayProperties

instance Prelude.NFData BatchArrayProperties

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