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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(HttpEndpointRetryOptions -> HttpEndpointRetryOptions -> Bool)
-> (HttpEndpointRetryOptions -> HttpEndpointRetryOptions -> Bool)
-> Eq HttpEndpointRetryOptions
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]
(Int -> ReadS HttpEndpointRetryOptions)
-> ReadS [HttpEndpointRetryOptions]
-> ReadPrec HttpEndpointRetryOptions
-> ReadPrec [HttpEndpointRetryOptions]
-> Read 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
(Int -> HttpEndpointRetryOptions -> ShowS)
-> (HttpEndpointRetryOptions -> String)
-> ([HttpEndpointRetryOptions] -> ShowS)
-> Show HttpEndpointRetryOptions
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.
 HttpEndpointRetryOptions -> Rep HttpEndpointRetryOptions x)
-> (forall x.
    Rep HttpEndpointRetryOptions x -> HttpEndpointRetryOptions)
-> Generic HttpEndpointRetryOptions
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' :: Maybe Natural -> HttpEndpointRetryOptions
HttpEndpointRetryOptions'
    { $sel:durationInSeconds:HttpEndpointRetryOptions' :: Maybe Natural
durationInSeconds =
        Maybe Natural
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 :: (Maybe Natural -> f (Maybe Natural))
-> HttpEndpointRetryOptions -> f HttpEndpointRetryOptions
httpEndpointRetryOptions_durationInSeconds = (HttpEndpointRetryOptions -> Maybe Natural)
-> (HttpEndpointRetryOptions
    -> Maybe Natural -> HttpEndpointRetryOptions)
-> Lens
     HttpEndpointRetryOptions
     HttpEndpointRetryOptions
     (Maybe Natural)
     (Maybe Natural)
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 Core.FromJSON HttpEndpointRetryOptions where
  parseJSON :: Value -> Parser HttpEndpointRetryOptions
parseJSON =
    String
-> (Object -> Parser HttpEndpointRetryOptions)
-> Value
-> Parser HttpEndpointRetryOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HttpEndpointRetryOptions"
      ( \Object
x ->
          Maybe Natural -> HttpEndpointRetryOptions
HttpEndpointRetryOptions'
            (Maybe Natural -> HttpEndpointRetryOptions)
-> Parser (Maybe Natural) -> Parser HttpEndpointRetryOptions
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
"DurationInSeconds")
      )

instance Prelude.Hashable HttpEndpointRetryOptions

instance Prelude.NFData HttpEndpointRetryOptions

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