{-# 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-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.Glue.Types.StartingEventBatchCondition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | Duration of the batch window in seconds.
    StartingEventBatchCondition -> Maybe Int
batchWindow :: Prelude.Maybe Prelude.Int,
    -- | Number of events in the batch.
    StartingEventBatchCondition -> Maybe Int
batchSize :: Prelude.Maybe Prelude.Int
  }
  deriving (StartingEventBatchCondition -> StartingEventBatchCondition -> Bool
(StartingEventBatchCondition
 -> StartingEventBatchCondition -> Bool)
-> (StartingEventBatchCondition
    -> StartingEventBatchCondition -> Bool)
-> Eq StartingEventBatchCondition
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]
(Int -> ReadS StartingEventBatchCondition)
-> ReadS [StartingEventBatchCondition]
-> ReadPrec StartingEventBatchCondition
-> ReadPrec [StartingEventBatchCondition]
-> Read 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
(Int -> StartingEventBatchCondition -> ShowS)
-> (StartingEventBatchCondition -> String)
-> ([StartingEventBatchCondition] -> ShowS)
-> Show StartingEventBatchCondition
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.
 StartingEventBatchCondition -> Rep StartingEventBatchCondition x)
-> (forall x.
    Rep StartingEventBatchCondition x -> StartingEventBatchCondition)
-> Generic StartingEventBatchCondition
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:
--
-- 'batchWindow', 'startingEventBatchCondition_batchWindow' - Duration of the batch window in seconds.
--
-- 'batchSize', 'startingEventBatchCondition_batchSize' - Number of events in the batch.
newStartingEventBatchCondition ::
  StartingEventBatchCondition
newStartingEventBatchCondition :: StartingEventBatchCondition
newStartingEventBatchCondition =
  StartingEventBatchCondition' :: Maybe Int -> Maybe Int -> StartingEventBatchCondition
StartingEventBatchCondition'
    { $sel:batchWindow:StartingEventBatchCondition' :: Maybe Int
batchWindow =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:batchSize:StartingEventBatchCondition' :: Maybe Int
batchSize = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Duration of the batch window in seconds.
startingEventBatchCondition_batchWindow :: Lens.Lens' StartingEventBatchCondition (Prelude.Maybe Prelude.Int)
startingEventBatchCondition_batchWindow :: (Maybe Int -> f (Maybe Int))
-> StartingEventBatchCondition -> f StartingEventBatchCondition
startingEventBatchCondition_batchWindow = (StartingEventBatchCondition -> Maybe Int)
-> (StartingEventBatchCondition
    -> Maybe Int -> StartingEventBatchCondition)
-> Lens
     StartingEventBatchCondition
     StartingEventBatchCondition
     (Maybe Int)
     (Maybe Int)
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)

-- | Number of events in the batch.
startingEventBatchCondition_batchSize :: Lens.Lens' StartingEventBatchCondition (Prelude.Maybe Prelude.Int)
startingEventBatchCondition_batchSize :: (Maybe Int -> f (Maybe Int))
-> StartingEventBatchCondition -> f StartingEventBatchCondition
startingEventBatchCondition_batchSize = (StartingEventBatchCondition -> Maybe Int)
-> (StartingEventBatchCondition
    -> Maybe Int -> StartingEventBatchCondition)
-> Lens
     StartingEventBatchCondition
     StartingEventBatchCondition
     (Maybe Int)
     (Maybe Int)
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)

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

instance Prelude.Hashable StartingEventBatchCondition

instance Prelude.NFData StartingEventBatchCondition