{-# 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.HttpEndpointRetryOptions
-- 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.HttpEndpointRetryOptions 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 retry behavior in case Kinesis Data Firehose is unable to
-- deliver data to the specified HTTP endpoint destination, or if it
-- doesn\'t receive a valid acknowledgment of receipt from the specified
-- HTTP endpoint destination.
--
-- /See:/ 'newHttpEndpointRetryOptions' smart constructor.
data HttpEndpointRetryOptions = HttpEndpointRetryOptions'
  { -- | The total amount of time that Kinesis Data Firehose spends on retries.
    -- This duration starts after the initial attempt to send data to the
    -- custom destination via HTTPS endpoint fails. It doesn\'t include the
    -- periods during which Kinesis Data Firehose waits for acknowledgment from
    -- the specified destination after each attempt.
    HttpEndpointRetryOptions -> Maybe Natural
durationInSeconds :: Prelude.Maybe Prelude.Natural
  }
  deriving (HttpEndpointRetryOptions -> HttpEndpointRetryOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpEndpointRetryOptions -> HttpEndpointRetryOptions -> Bool
$c/= :: HttpEndpointRetryOptions -> HttpEndpointRetryOptions -> Bool
== :: HttpEndpointRetryOptions -> HttpEndpointRetryOptions -> Bool
$c== :: HttpEndpointRetryOptions -> HttpEndpointRetryOptions -> Bool
Prelude.Eq, ReadPrec [HttpEndpointRetryOptions]
ReadPrec HttpEndpointRetryOptions
Int -> ReadS HttpEndpointRetryOptions
ReadS [HttpEndpointRetryOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HttpEndpointRetryOptions]
$creadListPrec :: ReadPrec [HttpEndpointRetryOptions]
readPrec :: ReadPrec HttpEndpointRetryOptions
$creadPrec :: ReadPrec HttpEndpointRetryOptions
readList :: ReadS [HttpEndpointRetryOptions]
$creadList :: ReadS [HttpEndpointRetryOptions]
readsPrec :: Int -> ReadS HttpEndpointRetryOptions
$creadsPrec :: Int -> ReadS HttpEndpointRetryOptions
Prelude.Read, Int -> HttpEndpointRetryOptions -> ShowS
[HttpEndpointRetryOptions] -> ShowS
HttpEndpointRetryOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpEndpointRetryOptions] -> ShowS
$cshowList :: [HttpEndpointRetryOptions] -> ShowS
show :: HttpEndpointRetryOptions -> String
$cshow :: HttpEndpointRetryOptions -> String
showsPrec :: Int -> HttpEndpointRetryOptions -> ShowS
$cshowsPrec :: Int -> HttpEndpointRetryOptions -> ShowS
Prelude.Show, forall x.
Rep HttpEndpointRetryOptions x -> HttpEndpointRetryOptions
forall x.
HttpEndpointRetryOptions -> Rep HttpEndpointRetryOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep HttpEndpointRetryOptions x -> HttpEndpointRetryOptions
$cfrom :: forall x.
HttpEndpointRetryOptions -> Rep HttpEndpointRetryOptions x
Prelude.Generic)

-- |
-- Create a value of 'HttpEndpointRetryOptions' 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:
--
-- 'durationInSeconds', 'httpEndpointRetryOptions_durationInSeconds' - The total amount of time that Kinesis Data Firehose spends on retries.
-- This duration starts after the initial attempt to send data to the
-- custom destination via HTTPS endpoint fails. It doesn\'t include the
-- periods during which Kinesis Data Firehose waits for acknowledgment from
-- the specified destination after each attempt.
newHttpEndpointRetryOptions ::
  HttpEndpointRetryOptions
newHttpEndpointRetryOptions :: HttpEndpointRetryOptions
newHttpEndpointRetryOptions =
  HttpEndpointRetryOptions'
    { $sel:durationInSeconds:HttpEndpointRetryOptions' :: Maybe Natural
durationInSeconds =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The total amount of time that Kinesis Data Firehose spends on retries.
-- This duration starts after the initial attempt to send data to the
-- custom destination via HTTPS endpoint fails. It doesn\'t include the
-- periods during which Kinesis Data Firehose waits for acknowledgment from
-- the specified destination after each attempt.
httpEndpointRetryOptions_durationInSeconds :: Lens.Lens' HttpEndpointRetryOptions (Prelude.Maybe Prelude.Natural)
httpEndpointRetryOptions_durationInSeconds :: Lens' HttpEndpointRetryOptions (Maybe Natural)
httpEndpointRetryOptions_durationInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpEndpointRetryOptions' {Maybe Natural
durationInSeconds :: Maybe Natural
$sel:durationInSeconds:HttpEndpointRetryOptions' :: HttpEndpointRetryOptions -> Maybe Natural
durationInSeconds} -> Maybe Natural
durationInSeconds) (\s :: HttpEndpointRetryOptions
s@HttpEndpointRetryOptions' {} Maybe Natural
a -> HttpEndpointRetryOptions
s {$sel:durationInSeconds:HttpEndpointRetryOptions' :: Maybe Natural
durationInSeconds = Maybe Natural
a} :: HttpEndpointRetryOptions)

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

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

instance Prelude.NFData HttpEndpointRetryOptions where
  rnf :: HttpEndpointRetryOptions -> ()
rnf HttpEndpointRetryOptions' {Maybe Natural
durationInSeconds :: Maybe Natural
$sel:durationInSeconds:HttpEndpointRetryOptions' :: HttpEndpointRetryOptions -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
durationInSeconds

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