{-# 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.HttpEndpointBufferingHints
-- 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.HttpEndpointBufferingHints 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 the buffering options that can be applied before data is
-- delivered to the HTTP endpoint destination. Kinesis Data Firehose treats
-- these options as hints, and it might choose to use more optimal values.
-- 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:/ 'newHttpEndpointBufferingHints' smart constructor.
data HttpEndpointBufferingHints = HttpEndpointBufferingHints'
  { -- | Buffer incoming data for the specified period of time, in seconds,
    -- before delivering it to the destination. The default value is 300 (5
    -- minutes).
    HttpEndpointBufferingHints -> Maybe Natural
intervalInSeconds :: Prelude.Maybe Prelude.Natural,
    -- | 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.
    HttpEndpointBufferingHints -> Maybe Natural
sizeInMBs :: Prelude.Maybe Prelude.Natural
  }
  deriving (HttpEndpointBufferingHints -> HttpEndpointBufferingHints -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpEndpointBufferingHints -> HttpEndpointBufferingHints -> Bool
$c/= :: HttpEndpointBufferingHints -> HttpEndpointBufferingHints -> Bool
== :: HttpEndpointBufferingHints -> HttpEndpointBufferingHints -> Bool
$c== :: HttpEndpointBufferingHints -> HttpEndpointBufferingHints -> Bool
Prelude.Eq, ReadPrec [HttpEndpointBufferingHints]
ReadPrec HttpEndpointBufferingHints
Int -> ReadS HttpEndpointBufferingHints
ReadS [HttpEndpointBufferingHints]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HttpEndpointBufferingHints]
$creadListPrec :: ReadPrec [HttpEndpointBufferingHints]
readPrec :: ReadPrec HttpEndpointBufferingHints
$creadPrec :: ReadPrec HttpEndpointBufferingHints
readList :: ReadS [HttpEndpointBufferingHints]
$creadList :: ReadS [HttpEndpointBufferingHints]
readsPrec :: Int -> ReadS HttpEndpointBufferingHints
$creadsPrec :: Int -> ReadS HttpEndpointBufferingHints
Prelude.Read, Int -> HttpEndpointBufferingHints -> ShowS
[HttpEndpointBufferingHints] -> ShowS
HttpEndpointBufferingHints -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpEndpointBufferingHints] -> ShowS
$cshowList :: [HttpEndpointBufferingHints] -> ShowS
show :: HttpEndpointBufferingHints -> String
$cshow :: HttpEndpointBufferingHints -> String
showsPrec :: Int -> HttpEndpointBufferingHints -> ShowS
$cshowsPrec :: Int -> HttpEndpointBufferingHints -> ShowS
Prelude.Show, forall x.
Rep HttpEndpointBufferingHints x -> HttpEndpointBufferingHints
forall x.
HttpEndpointBufferingHints -> Rep HttpEndpointBufferingHints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep HttpEndpointBufferingHints x -> HttpEndpointBufferingHints
$cfrom :: forall x.
HttpEndpointBufferingHints -> Rep HttpEndpointBufferingHints x
Prelude.Generic)

-- |
-- Create a value of 'HttpEndpointBufferingHints' 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', 'httpEndpointBufferingHints_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).
--
-- 'sizeInMBs', 'httpEndpointBufferingHints_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.
newHttpEndpointBufferingHints ::
  HttpEndpointBufferingHints
newHttpEndpointBufferingHints :: HttpEndpointBufferingHints
newHttpEndpointBufferingHints =
  HttpEndpointBufferingHints'
    { $sel:intervalInSeconds:HttpEndpointBufferingHints' :: Maybe Natural
intervalInSeconds =
        forall a. Maybe a
Prelude.Nothing,
      $sel:sizeInMBs:HttpEndpointBufferingHints' :: 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 (5
-- minutes).
httpEndpointBufferingHints_intervalInSeconds :: Lens.Lens' HttpEndpointBufferingHints (Prelude.Maybe Prelude.Natural)
httpEndpointBufferingHints_intervalInSeconds :: Lens' HttpEndpointBufferingHints (Maybe Natural)
httpEndpointBufferingHints_intervalInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpEndpointBufferingHints' {Maybe Natural
intervalInSeconds :: Maybe Natural
$sel:intervalInSeconds:HttpEndpointBufferingHints' :: HttpEndpointBufferingHints -> Maybe Natural
intervalInSeconds} -> Maybe Natural
intervalInSeconds) (\s :: HttpEndpointBufferingHints
s@HttpEndpointBufferingHints' {} Maybe Natural
a -> HttpEndpointBufferingHints
s {$sel:intervalInSeconds:HttpEndpointBufferingHints' :: Maybe Natural
intervalInSeconds = Maybe Natural
a} :: HttpEndpointBufferingHints)

-- | 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.
httpEndpointBufferingHints_sizeInMBs :: Lens.Lens' HttpEndpointBufferingHints (Prelude.Maybe Prelude.Natural)
httpEndpointBufferingHints_sizeInMBs :: Lens' HttpEndpointBufferingHints (Maybe Natural)
httpEndpointBufferingHints_sizeInMBs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpEndpointBufferingHints' {Maybe Natural
sizeInMBs :: Maybe Natural
$sel:sizeInMBs:HttpEndpointBufferingHints' :: HttpEndpointBufferingHints -> Maybe Natural
sizeInMBs} -> Maybe Natural
sizeInMBs) (\s :: HttpEndpointBufferingHints
s@HttpEndpointBufferingHints' {} Maybe Natural
a -> HttpEndpointBufferingHints
s {$sel:sizeInMBs:HttpEndpointBufferingHints' :: Maybe Natural
sizeInMBs = Maybe Natural
a} :: HttpEndpointBufferingHints)

instance Data.FromJSON HttpEndpointBufferingHints where
  parseJSON :: Value -> Parser HttpEndpointBufferingHints
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HttpEndpointBufferingHints"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> HttpEndpointBufferingHints
HttpEndpointBufferingHints'
            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 HttpEndpointBufferingHints where
  hashWithSalt :: Int -> HttpEndpointBufferingHints -> Int
hashWithSalt Int
_salt HttpEndpointBufferingHints' {Maybe Natural
sizeInMBs :: Maybe Natural
intervalInSeconds :: Maybe Natural
$sel:sizeInMBs:HttpEndpointBufferingHints' :: HttpEndpointBufferingHints -> Maybe Natural
$sel:intervalInSeconds:HttpEndpointBufferingHints' :: HttpEndpointBufferingHints -> 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 HttpEndpointBufferingHints where
  rnf :: HttpEndpointBufferingHints -> ()
rnf HttpEndpointBufferingHints' {Maybe Natural
sizeInMBs :: Maybe Natural
intervalInSeconds :: Maybe Natural
$sel:sizeInMBs:HttpEndpointBufferingHints' :: HttpEndpointBufferingHints -> Maybe Natural
$sel:intervalInSeconds:HttpEndpointBufferingHints' :: HttpEndpointBufferingHints -> 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 HttpEndpointBufferingHints where
  toJSON :: HttpEndpointBufferingHints -> Value
toJSON HttpEndpointBufferingHints' {Maybe Natural
sizeInMBs :: Maybe Natural
intervalInSeconds :: Maybe Natural
$sel:sizeInMBs:HttpEndpointBufferingHints' :: HttpEndpointBufferingHints -> Maybe Natural
$sel:intervalInSeconds:HttpEndpointBufferingHints' :: HttpEndpointBufferingHints -> 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
          ]
      )