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

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

instance Prelude.NFData RetryOptions

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