{-# 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.Glue.Types.StartingEventBatchCondition
-- 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.Glue.Types.StartingEventBatchCondition 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 batch condition that started the workflow run. Either the number of
-- events in the batch size arrived, in which case the BatchSize member is
-- non-zero, or the batch window expired, in which case the BatchWindow
-- member is non-zero.
--
-- /See:/ 'newStartingEventBatchCondition' smart constructor.
data StartingEventBatchCondition = StartingEventBatchCondition'
  { -- | Number of events in the batch.
    StartingEventBatchCondition -> Maybe Int
batchSize :: Prelude.Maybe Prelude.Int,
    -- | Duration of the batch window in seconds.
    StartingEventBatchCondition -> Maybe Int
batchWindow :: Prelude.Maybe Prelude.Int
  }
  deriving (StartingEventBatchCondition -> StartingEventBatchCondition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartingEventBatchCondition -> StartingEventBatchCondition -> Bool
$c/= :: StartingEventBatchCondition -> StartingEventBatchCondition -> Bool
== :: StartingEventBatchCondition -> StartingEventBatchCondition -> Bool
$c== :: StartingEventBatchCondition -> StartingEventBatchCondition -> Bool
Prelude.Eq, ReadPrec [StartingEventBatchCondition]
ReadPrec StartingEventBatchCondition
Int -> ReadS StartingEventBatchCondition
ReadS [StartingEventBatchCondition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartingEventBatchCondition]
$creadListPrec :: ReadPrec [StartingEventBatchCondition]
readPrec :: ReadPrec StartingEventBatchCondition
$creadPrec :: ReadPrec StartingEventBatchCondition
readList :: ReadS [StartingEventBatchCondition]
$creadList :: ReadS [StartingEventBatchCondition]
readsPrec :: Int -> ReadS StartingEventBatchCondition
$creadsPrec :: Int -> ReadS StartingEventBatchCondition
Prelude.Read, Int -> StartingEventBatchCondition -> ShowS
[StartingEventBatchCondition] -> ShowS
StartingEventBatchCondition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartingEventBatchCondition] -> ShowS
$cshowList :: [StartingEventBatchCondition] -> ShowS
show :: StartingEventBatchCondition -> String
$cshow :: StartingEventBatchCondition -> String
showsPrec :: Int -> StartingEventBatchCondition -> ShowS
$cshowsPrec :: Int -> StartingEventBatchCondition -> ShowS
Prelude.Show, forall x.
Rep StartingEventBatchCondition x -> StartingEventBatchCondition
forall x.
StartingEventBatchCondition -> Rep StartingEventBatchCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartingEventBatchCondition x -> StartingEventBatchCondition
$cfrom :: forall x.
StartingEventBatchCondition -> Rep StartingEventBatchCondition x
Prelude.Generic)

-- |
-- Create a value of 'StartingEventBatchCondition' 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:
--
-- 'batchSize', 'startingEventBatchCondition_batchSize' - Number of events in the batch.
--
-- 'batchWindow', 'startingEventBatchCondition_batchWindow' - Duration of the batch window in seconds.
newStartingEventBatchCondition ::
  StartingEventBatchCondition
newStartingEventBatchCondition :: StartingEventBatchCondition
newStartingEventBatchCondition =
  StartingEventBatchCondition'
    { $sel:batchSize:StartingEventBatchCondition' :: Maybe Int
batchSize =
        forall a. Maybe a
Prelude.Nothing,
      $sel:batchWindow:StartingEventBatchCondition' :: Maybe Int
batchWindow = forall a. Maybe a
Prelude.Nothing
    }

-- | Number of events in the batch.
startingEventBatchCondition_batchSize :: Lens.Lens' StartingEventBatchCondition (Prelude.Maybe Prelude.Int)
startingEventBatchCondition_batchSize :: Lens' StartingEventBatchCondition (Maybe Int)
startingEventBatchCondition_batchSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartingEventBatchCondition' {Maybe Int
batchSize :: Maybe Int
$sel:batchSize:StartingEventBatchCondition' :: StartingEventBatchCondition -> Maybe Int
batchSize} -> Maybe Int
batchSize) (\s :: StartingEventBatchCondition
s@StartingEventBatchCondition' {} Maybe Int
a -> StartingEventBatchCondition
s {$sel:batchSize:StartingEventBatchCondition' :: Maybe Int
batchSize = Maybe Int
a} :: StartingEventBatchCondition)

-- | Duration of the batch window in seconds.
startingEventBatchCondition_batchWindow :: Lens.Lens' StartingEventBatchCondition (Prelude.Maybe Prelude.Int)
startingEventBatchCondition_batchWindow :: Lens' StartingEventBatchCondition (Maybe Int)
startingEventBatchCondition_batchWindow = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartingEventBatchCondition' {Maybe Int
batchWindow :: Maybe Int
$sel:batchWindow:StartingEventBatchCondition' :: StartingEventBatchCondition -> Maybe Int
batchWindow} -> Maybe Int
batchWindow) (\s :: StartingEventBatchCondition
s@StartingEventBatchCondition' {} Maybe Int
a -> StartingEventBatchCondition
s {$sel:batchWindow:StartingEventBatchCondition' :: Maybe Int
batchWindow = Maybe Int
a} :: StartingEventBatchCondition)

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

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

instance Prelude.NFData StartingEventBatchCondition where
  rnf :: StartingEventBatchCondition -> ()
rnf StartingEventBatchCondition' {Maybe Int
batchWindow :: Maybe Int
batchSize :: Maybe Int
$sel:batchWindow:StartingEventBatchCondition' :: StartingEventBatchCondition -> Maybe Int
$sel:batchSize:StartingEventBatchCondition' :: StartingEventBatchCondition -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
batchSize
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
batchWindow