{-# 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.Firehose.Types.ElasticsearchBufferingHints
-- 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.Firehose.Types.ElasticsearchBufferingHints where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the buffering to perform before delivering data to the Amazon
-- ES destination.
--
-- /See:/ 'newElasticsearchBufferingHints' smart constructor.
data ElasticsearchBufferingHints = ElasticsearchBufferingHints'
  { -- | Buffer incoming data to the specified size, in MBs, before delivering it
    -- to the destination. The default value is 5.
    --
    -- We recommend setting this parameter to a value greater than the amount
    -- of data you typically ingest into the delivery stream in 10 seconds. For
    -- example, if you typically ingest data at 1 MB\/sec, the value should be
    -- 10 MB or higher.
    ElasticsearchBufferingHints -> Maybe Natural
sizeInMBs :: Prelude.Maybe Prelude.Natural,
    -- | Buffer incoming data for the specified period of time, in seconds,
    -- before delivering it to the destination. The default value is 300 (5
    -- minutes).
    ElasticsearchBufferingHints -> Maybe Natural
intervalInSeconds :: Prelude.Maybe Prelude.Natural
  }
  deriving (ElasticsearchBufferingHints -> ElasticsearchBufferingHints -> Bool
(ElasticsearchBufferingHints
 -> ElasticsearchBufferingHints -> Bool)
-> (ElasticsearchBufferingHints
    -> ElasticsearchBufferingHints -> Bool)
-> Eq ElasticsearchBufferingHints
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ElasticsearchBufferingHints -> ElasticsearchBufferingHints -> Bool
$c/= :: ElasticsearchBufferingHints -> ElasticsearchBufferingHints -> Bool
== :: ElasticsearchBufferingHints -> ElasticsearchBufferingHints -> Bool
$c== :: ElasticsearchBufferingHints -> ElasticsearchBufferingHints -> Bool
Prelude.Eq, ReadPrec [ElasticsearchBufferingHints]
ReadPrec ElasticsearchBufferingHints
Int -> ReadS ElasticsearchBufferingHints
ReadS [ElasticsearchBufferingHints]
(Int -> ReadS ElasticsearchBufferingHints)
-> ReadS [ElasticsearchBufferingHints]
-> ReadPrec ElasticsearchBufferingHints
-> ReadPrec [ElasticsearchBufferingHints]
-> Read ElasticsearchBufferingHints
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ElasticsearchBufferingHints]
$creadListPrec :: ReadPrec [ElasticsearchBufferingHints]
readPrec :: ReadPrec ElasticsearchBufferingHints
$creadPrec :: ReadPrec ElasticsearchBufferingHints
readList :: ReadS [ElasticsearchBufferingHints]
$creadList :: ReadS [ElasticsearchBufferingHints]
readsPrec :: Int -> ReadS ElasticsearchBufferingHints
$creadsPrec :: Int -> ReadS ElasticsearchBufferingHints
Prelude.Read, Int -> ElasticsearchBufferingHints -> ShowS
[ElasticsearchBufferingHints] -> ShowS
ElasticsearchBufferingHints -> String
(Int -> ElasticsearchBufferingHints -> ShowS)
-> (ElasticsearchBufferingHints -> String)
-> ([ElasticsearchBufferingHints] -> ShowS)
-> Show ElasticsearchBufferingHints
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ElasticsearchBufferingHints] -> ShowS
$cshowList :: [ElasticsearchBufferingHints] -> ShowS
show :: ElasticsearchBufferingHints -> String
$cshow :: ElasticsearchBufferingHints -> String
showsPrec :: Int -> ElasticsearchBufferingHints -> ShowS
$cshowsPrec :: Int -> ElasticsearchBufferingHints -> ShowS
Prelude.Show, (forall x.
 ElasticsearchBufferingHints -> Rep ElasticsearchBufferingHints x)
-> (forall x.
    Rep ElasticsearchBufferingHints x -> ElasticsearchBufferingHints)
-> Generic ElasticsearchBufferingHints
forall x.
Rep ElasticsearchBufferingHints x -> ElasticsearchBufferingHints
forall x.
ElasticsearchBufferingHints -> Rep ElasticsearchBufferingHints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ElasticsearchBufferingHints x -> ElasticsearchBufferingHints
$cfrom :: forall x.
ElasticsearchBufferingHints -> Rep ElasticsearchBufferingHints x
Prelude.Generic)

-- |
-- Create a value of 'ElasticsearchBufferingHints' 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:
--
-- 'sizeInMBs', 'elasticsearchBufferingHints_sizeInMBs' - Buffer incoming data to the specified size, in MBs, before delivering it
-- to the destination. The default value is 5.
--
-- We recommend setting this parameter to a value greater than the amount
-- of data you typically ingest into the delivery stream in 10 seconds. For
-- example, if you typically ingest data at 1 MB\/sec, the value should be
-- 10 MB or higher.
--
-- 'intervalInSeconds', 'elasticsearchBufferingHints_intervalInSeconds' - Buffer incoming data for the specified period of time, in seconds,
-- before delivering it to the destination. The default value is 300 (5
-- minutes).
newElasticsearchBufferingHints ::
  ElasticsearchBufferingHints
newElasticsearchBufferingHints :: ElasticsearchBufferingHints
newElasticsearchBufferingHints =
  ElasticsearchBufferingHints' :: Maybe Natural -> Maybe Natural -> ElasticsearchBufferingHints
ElasticsearchBufferingHints'
    { $sel:sizeInMBs:ElasticsearchBufferingHints' :: Maybe Natural
sizeInMBs =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:intervalInSeconds:ElasticsearchBufferingHints' :: Maybe Natural
intervalInSeconds = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Buffer incoming data to the specified size, in MBs, before delivering it
-- to the destination. The default value is 5.
--
-- We recommend setting this parameter to a value greater than the amount
-- of data you typically ingest into the delivery stream in 10 seconds. For
-- example, if you typically ingest data at 1 MB\/sec, the value should be
-- 10 MB or higher.
elasticsearchBufferingHints_sizeInMBs :: Lens.Lens' ElasticsearchBufferingHints (Prelude.Maybe Prelude.Natural)
elasticsearchBufferingHints_sizeInMBs :: (Maybe Natural -> f (Maybe Natural))
-> ElasticsearchBufferingHints -> f ElasticsearchBufferingHints
elasticsearchBufferingHints_sizeInMBs = (ElasticsearchBufferingHints -> Maybe Natural)
-> (ElasticsearchBufferingHints
    -> Maybe Natural -> ElasticsearchBufferingHints)
-> Lens
     ElasticsearchBufferingHints
     ElasticsearchBufferingHints
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticsearchBufferingHints' {Maybe Natural
sizeInMBs :: Maybe Natural
$sel:sizeInMBs:ElasticsearchBufferingHints' :: ElasticsearchBufferingHints -> Maybe Natural
sizeInMBs} -> Maybe Natural
sizeInMBs) (\s :: ElasticsearchBufferingHints
s@ElasticsearchBufferingHints' {} Maybe Natural
a -> ElasticsearchBufferingHints
s {$sel:sizeInMBs:ElasticsearchBufferingHints' :: Maybe Natural
sizeInMBs = Maybe Natural
a} :: ElasticsearchBufferingHints)

-- | Buffer incoming data for the specified period of time, in seconds,
-- before delivering it to the destination. The default value is 300 (5
-- minutes).
elasticsearchBufferingHints_intervalInSeconds :: Lens.Lens' ElasticsearchBufferingHints (Prelude.Maybe Prelude.Natural)
elasticsearchBufferingHints_intervalInSeconds :: (Maybe Natural -> f (Maybe Natural))
-> ElasticsearchBufferingHints -> f ElasticsearchBufferingHints
elasticsearchBufferingHints_intervalInSeconds = (ElasticsearchBufferingHints -> Maybe Natural)
-> (ElasticsearchBufferingHints
    -> Maybe Natural -> ElasticsearchBufferingHints)
-> Lens
     ElasticsearchBufferingHints
     ElasticsearchBufferingHints
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticsearchBufferingHints' {Maybe Natural
intervalInSeconds :: Maybe Natural
$sel:intervalInSeconds:ElasticsearchBufferingHints' :: ElasticsearchBufferingHints -> Maybe Natural
intervalInSeconds} -> Maybe Natural
intervalInSeconds) (\s :: ElasticsearchBufferingHints
s@ElasticsearchBufferingHints' {} Maybe Natural
a -> ElasticsearchBufferingHints
s {$sel:intervalInSeconds:ElasticsearchBufferingHints' :: Maybe Natural
intervalInSeconds = Maybe Natural
a} :: ElasticsearchBufferingHints)

instance Core.FromJSON ElasticsearchBufferingHints where
  parseJSON :: Value -> Parser ElasticsearchBufferingHints
parseJSON =
    String
-> (Object -> Parser ElasticsearchBufferingHints)
-> Value
-> Parser ElasticsearchBufferingHints
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ElasticsearchBufferingHints"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> ElasticsearchBufferingHints
ElasticsearchBufferingHints'
            (Maybe Natural -> Maybe Natural -> ElasticsearchBufferingHints)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> ElasticsearchBufferingHints)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SizeInMBs")
            Parser (Maybe Natural -> ElasticsearchBufferingHints)
-> Parser (Maybe Natural) -> Parser ElasticsearchBufferingHints
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IntervalInSeconds")
      )

instance Prelude.Hashable ElasticsearchBufferingHints

instance Prelude.NFData ElasticsearchBufferingHints

instance Core.ToJSON ElasticsearchBufferingHints where
  toJSON :: ElasticsearchBufferingHints -> Value
toJSON ElasticsearchBufferingHints' {Maybe Natural
intervalInSeconds :: Maybe Natural
sizeInMBs :: Maybe Natural
$sel:intervalInSeconds:ElasticsearchBufferingHints' :: ElasticsearchBufferingHints -> Maybe Natural
$sel:sizeInMBs:ElasticsearchBufferingHints' :: ElasticsearchBufferingHints -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SizeInMBs" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
sizeInMBs,
            (Text
"IntervalInSeconds" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
intervalInSeconds
          ]
      )