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

-- | Describes hints for the buffering to perform before delivering data to
-- the destination. These options are treated as hints, and therefore
-- Kinesis Data Firehose might choose to use different values when it is
-- optimal. The @SizeInMBs@ and @IntervalInSeconds@ parameters are
-- optional. However, if specify a value for one of them, you must also
-- provide a value for the other.
--
-- /See:/ 'newBufferingHints' smart constructor.
data BufferingHints = BufferingHints'
  { -- | Buffer incoming data for the specified period of time, in seconds,
    -- before delivering it to the destination. The default value is 300. This
    -- parameter is optional but if you specify a value for it, you must also
    -- specify a value for @SizeInMBs@, and vice versa.
    BufferingHints -> Maybe Natural
intervalInSeconds :: Prelude.Maybe Prelude.Natural,
    -- | Buffer incoming data to the specified size, in MiBs, before delivering
    -- it to the destination. The default value is 5. This parameter is
    -- optional but if you specify a value for it, you must also specify a
    -- value for @IntervalInSeconds@, and vice versa.
    --
    -- 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 MiB\/sec, the value should be
    -- 10 MiB or higher.
    BufferingHints -> Maybe Natural
sizeInMBs :: Prelude.Maybe Prelude.Natural
  }
  deriving (BufferingHints -> BufferingHints -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BufferingHints -> BufferingHints -> Bool
$c/= :: BufferingHints -> BufferingHints -> Bool
== :: BufferingHints -> BufferingHints -> Bool
$c== :: BufferingHints -> BufferingHints -> Bool
Prelude.Eq, ReadPrec [BufferingHints]
ReadPrec BufferingHints
Int -> ReadS BufferingHints
ReadS [BufferingHints]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BufferingHints]
$creadListPrec :: ReadPrec [BufferingHints]
readPrec :: ReadPrec BufferingHints
$creadPrec :: ReadPrec BufferingHints
readList :: ReadS [BufferingHints]
$creadList :: ReadS [BufferingHints]
readsPrec :: Int -> ReadS BufferingHints
$creadsPrec :: Int -> ReadS BufferingHints
Prelude.Read, Int -> BufferingHints -> ShowS
[BufferingHints] -> ShowS
BufferingHints -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BufferingHints] -> ShowS
$cshowList :: [BufferingHints] -> ShowS
show :: BufferingHints -> String
$cshow :: BufferingHints -> String
showsPrec :: Int -> BufferingHints -> ShowS
$cshowsPrec :: Int -> BufferingHints -> ShowS
Prelude.Show, forall x. Rep BufferingHints x -> BufferingHints
forall x. BufferingHints -> Rep BufferingHints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BufferingHints x -> BufferingHints
$cfrom :: forall x. BufferingHints -> Rep BufferingHints x
Prelude.Generic)

-- |
-- Create a value of 'BufferingHints' 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:
--
-- 'intervalInSeconds', 'bufferingHints_intervalInSeconds' - Buffer incoming data for the specified period of time, in seconds,
-- before delivering it to the destination. The default value is 300. This
-- parameter is optional but if you specify a value for it, you must also
-- specify a value for @SizeInMBs@, and vice versa.
--
-- 'sizeInMBs', 'bufferingHints_sizeInMBs' - Buffer incoming data to the specified size, in MiBs, before delivering
-- it to the destination. The default value is 5. This parameter is
-- optional but if you specify a value for it, you must also specify a
-- value for @IntervalInSeconds@, and vice versa.
--
-- 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 MiB\/sec, the value should be
-- 10 MiB or higher.
newBufferingHints ::
  BufferingHints
newBufferingHints :: BufferingHints
newBufferingHints =
  BufferingHints'
    { $sel:intervalInSeconds:BufferingHints' :: Maybe Natural
intervalInSeconds =
        forall a. Maybe a
Prelude.Nothing,
      $sel:sizeInMBs:BufferingHints' :: Maybe Natural
sizeInMBs = forall a. Maybe a
Prelude.Nothing
    }

-- | Buffer incoming data for the specified period of time, in seconds,
-- before delivering it to the destination. The default value is 300. This
-- parameter is optional but if you specify a value for it, you must also
-- specify a value for @SizeInMBs@, and vice versa.
bufferingHints_intervalInSeconds :: Lens.Lens' BufferingHints (Prelude.Maybe Prelude.Natural)
bufferingHints_intervalInSeconds :: Lens' BufferingHints (Maybe Natural)
bufferingHints_intervalInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BufferingHints' {Maybe Natural
intervalInSeconds :: Maybe Natural
$sel:intervalInSeconds:BufferingHints' :: BufferingHints -> Maybe Natural
intervalInSeconds} -> Maybe Natural
intervalInSeconds) (\s :: BufferingHints
s@BufferingHints' {} Maybe Natural
a -> BufferingHints
s {$sel:intervalInSeconds:BufferingHints' :: Maybe Natural
intervalInSeconds = Maybe Natural
a} :: BufferingHints)

-- | Buffer incoming data to the specified size, in MiBs, before delivering
-- it to the destination. The default value is 5. This parameter is
-- optional but if you specify a value for it, you must also specify a
-- value for @IntervalInSeconds@, and vice versa.
--
-- 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 MiB\/sec, the value should be
-- 10 MiB or higher.
bufferingHints_sizeInMBs :: Lens.Lens' BufferingHints (Prelude.Maybe Prelude.Natural)
bufferingHints_sizeInMBs :: Lens' BufferingHints (Maybe Natural)
bufferingHints_sizeInMBs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BufferingHints' {Maybe Natural
sizeInMBs :: Maybe Natural
$sel:sizeInMBs:BufferingHints' :: BufferingHints -> Maybe Natural
sizeInMBs} -> Maybe Natural
sizeInMBs) (\s :: BufferingHints
s@BufferingHints' {} Maybe Natural
a -> BufferingHints
s {$sel:sizeInMBs:BufferingHints' :: Maybe Natural
sizeInMBs = Maybe Natural
a} :: BufferingHints)

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

instance Prelude.Hashable BufferingHints where
  hashWithSalt :: Int -> BufferingHints -> Int
hashWithSalt Int
_salt BufferingHints' {Maybe Natural
sizeInMBs :: Maybe Natural
intervalInSeconds :: Maybe Natural
$sel:sizeInMBs:BufferingHints' :: BufferingHints -> Maybe Natural
$sel:intervalInSeconds:BufferingHints' :: BufferingHints -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
intervalInSeconds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
sizeInMBs

instance Prelude.NFData BufferingHints where
  rnf :: BufferingHints -> ()
rnf BufferingHints' {Maybe Natural
sizeInMBs :: Maybe Natural
intervalInSeconds :: Maybe Natural
$sel:sizeInMBs:BufferingHints' :: BufferingHints -> Maybe Natural
$sel:intervalInSeconds:BufferingHints' :: BufferingHints -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
intervalInSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
sizeInMBs

instance Data.ToJSON BufferingHints where
  toJSON :: BufferingHints -> Value
toJSON BufferingHints' {Maybe Natural
sizeInMBs :: Maybe Natural
intervalInSeconds :: Maybe Natural
$sel:sizeInMBs:BufferingHints' :: BufferingHints -> Maybe Natural
$sel:intervalInSeconds:BufferingHints' :: BufferingHints -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"IntervalInSeconds" 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 Natural
intervalInSeconds,
            (Key
"SizeInMBs" 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 Natural
sizeInMBs
          ]
      )