{-# 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.RetryOptions
-- 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.RetryOptions 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

-- | The retry behavior in case Kinesis Data Firehose is unable to deliver
-- data to an Amazon S3 prefix.
--
-- /See:/ 'newRetryOptions' smart constructor.
data RetryOptions = RetryOptions'
  { -- | The period of time during which Kinesis Data Firehose retries to deliver
    -- data to the specified Amazon S3 prefix.
    RetryOptions -> Maybe Natural
durationInSeconds :: Prelude.Maybe Prelude.Natural
  }
  deriving (RetryOptions -> RetryOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetryOptions -> RetryOptions -> Bool
$c/= :: RetryOptions -> RetryOptions -> Bool
== :: RetryOptions -> RetryOptions -> Bool
$c== :: RetryOptions -> RetryOptions -> Bool
Prelude.Eq, ReadPrec [RetryOptions]
ReadPrec RetryOptions
Int -> ReadS RetryOptions
ReadS [RetryOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RetryOptions]
$creadListPrec :: ReadPrec [RetryOptions]
readPrec :: ReadPrec RetryOptions
$creadPrec :: ReadPrec RetryOptions
readList :: ReadS [RetryOptions]
$creadList :: ReadS [RetryOptions]
readsPrec :: Int -> ReadS RetryOptions
$creadsPrec :: Int -> ReadS RetryOptions
Prelude.Read, Int -> RetryOptions -> ShowS
[RetryOptions] -> ShowS
RetryOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetryOptions] -> ShowS
$cshowList :: [RetryOptions] -> ShowS
show :: RetryOptions -> String
$cshow :: RetryOptions -> String
showsPrec :: Int -> RetryOptions -> ShowS
$cshowsPrec :: Int -> RetryOptions -> ShowS
Prelude.Show, forall x. Rep RetryOptions x -> RetryOptions
forall x. RetryOptions -> Rep RetryOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RetryOptions x -> RetryOptions
$cfrom :: forall x. RetryOptions -> Rep RetryOptions x
Prelude.Generic)

-- |
-- Create a value of 'RetryOptions' 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', 'retryOptions_durationInSeconds' - The period of time during which Kinesis Data Firehose retries to deliver
-- data to the specified Amazon S3 prefix.
newRetryOptions ::
  RetryOptions
newRetryOptions :: RetryOptions
newRetryOptions =
  RetryOptions' {$sel:durationInSeconds:RetryOptions' :: Maybe Natural
durationInSeconds = forall a. Maybe a
Prelude.Nothing}

-- | The period of time during which Kinesis Data Firehose retries to deliver
-- data to the specified Amazon S3 prefix.
retryOptions_durationInSeconds :: Lens.Lens' RetryOptions (Prelude.Maybe Prelude.Natural)
retryOptions_durationInSeconds :: Lens' RetryOptions (Maybe Natural)
retryOptions_durationInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetryOptions' {Maybe Natural
durationInSeconds :: Maybe Natural
$sel:durationInSeconds:RetryOptions' :: RetryOptions -> Maybe Natural
durationInSeconds} -> Maybe Natural
durationInSeconds) (\s :: RetryOptions
s@RetryOptions' {} Maybe Natural
a -> RetryOptions
s {$sel:durationInSeconds:RetryOptions' :: Maybe Natural
durationInSeconds = Maybe Natural
a} :: RetryOptions)

instance Data.FromJSON RetryOptions where
  parseJSON :: Value -> Parser RetryOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RetryOptions"
      ( \Object
x ->
          Maybe Natural -> RetryOptions
RetryOptions'
            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 RetryOptions where
  hashWithSalt :: Int -> RetryOptions -> Int
hashWithSalt Int
_salt RetryOptions' {Maybe Natural
durationInSeconds :: Maybe Natural
$sel:durationInSeconds:RetryOptions' :: RetryOptions -> Maybe Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
durationInSeconds

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

instance Data.ToJSON RetryOptions where
  toJSON :: RetryOptions -> Value
toJSON RetryOptions' {Maybe Natural
durationInSeconds :: Maybe Natural
$sel:durationInSeconds:RetryOptions' :: RetryOptions -> 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
          ]
      )