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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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
  }
  deriving (BufferingHints -> BufferingHints -> Bool
(BufferingHints -> BufferingHints -> Bool)
-> (BufferingHints -> BufferingHints -> Bool) -> Eq BufferingHints
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]
(Int -> ReadS BufferingHints)
-> ReadS [BufferingHints]
-> ReadPrec BufferingHints
-> ReadPrec [BufferingHints]
-> Read 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
(Int -> BufferingHints -> ShowS)
-> (BufferingHints -> String)
-> ([BufferingHints] -> ShowS)
-> Show BufferingHints
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. BufferingHints -> Rep BufferingHints x)
-> (forall x. Rep BufferingHints x -> BufferingHints)
-> Generic BufferingHints
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:
--
-- '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.
--
-- '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.
newBufferingHints ::
  BufferingHints
newBufferingHints :: BufferingHints
newBufferingHints =
  BufferingHints' :: Maybe Natural -> Maybe Natural -> BufferingHints
BufferingHints'
    { $sel:sizeInMBs:BufferingHints' :: Maybe Natural
sizeInMBs = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:intervalInSeconds:BufferingHints' :: Maybe Natural
intervalInSeconds = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> BufferingHints -> f BufferingHints
bufferingHints_sizeInMBs = (BufferingHints -> Maybe Natural)
-> (BufferingHints -> Maybe Natural -> BufferingHints)
-> Lens
     BufferingHints BufferingHints (Maybe Natural) (Maybe Natural)
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)

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> BufferingHints -> f BufferingHints
bufferingHints_intervalInSeconds = (BufferingHints -> Maybe Natural)
-> (BufferingHints -> Maybe Natural -> BufferingHints)
-> Lens
     BufferingHints BufferingHints (Maybe Natural) (Maybe Natural)
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)

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

instance Prelude.NFData BufferingHints

instance Core.ToJSON BufferingHints where
  toJSON :: BufferingHints -> Value
toJSON BufferingHints' {Maybe Natural
intervalInSeconds :: Maybe Natural
sizeInMBs :: Maybe Natural
$sel:intervalInSeconds:BufferingHints' :: BufferingHints -> Maybe Natural
$sel:sizeInMBs:BufferingHints' :: BufferingHints -> 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
          ]
      )