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

-- | Configures retry behavior in case Kinesis Data Firehose is unable to
-- deliver documents to Amazon Redshift.
--
-- /See:/ 'newRedshiftRetryOptions' smart constructor.
data RedshiftRetryOptions = RedshiftRetryOptions'
  { -- | The length of time during which Kinesis Data Firehose retries delivery
    -- after a failure, starting from the initial request and including the
    -- first attempt. The default value is 3600 seconds (60 minutes). Kinesis
    -- Data Firehose does not retry if the value of @DurationInSeconds@ is 0
    -- (zero) or if the first delivery attempt takes longer than the current
    -- value.
    RedshiftRetryOptions -> Maybe Natural
durationInSeconds :: Prelude.Maybe Prelude.Natural
  }
  deriving (RedshiftRetryOptions -> RedshiftRetryOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RedshiftRetryOptions -> RedshiftRetryOptions -> Bool
$c/= :: RedshiftRetryOptions -> RedshiftRetryOptions -> Bool
== :: RedshiftRetryOptions -> RedshiftRetryOptions -> Bool
$c== :: RedshiftRetryOptions -> RedshiftRetryOptions -> Bool
Prelude.Eq, ReadPrec [RedshiftRetryOptions]
ReadPrec RedshiftRetryOptions
Int -> ReadS RedshiftRetryOptions
ReadS [RedshiftRetryOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RedshiftRetryOptions]
$creadListPrec :: ReadPrec [RedshiftRetryOptions]
readPrec :: ReadPrec RedshiftRetryOptions
$creadPrec :: ReadPrec RedshiftRetryOptions
readList :: ReadS [RedshiftRetryOptions]
$creadList :: ReadS [RedshiftRetryOptions]
readsPrec :: Int -> ReadS RedshiftRetryOptions
$creadsPrec :: Int -> ReadS RedshiftRetryOptions
Prelude.Read, Int -> RedshiftRetryOptions -> ShowS
[RedshiftRetryOptions] -> ShowS
RedshiftRetryOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RedshiftRetryOptions] -> ShowS
$cshowList :: [RedshiftRetryOptions] -> ShowS
show :: RedshiftRetryOptions -> String
$cshow :: RedshiftRetryOptions -> String
showsPrec :: Int -> RedshiftRetryOptions -> ShowS
$cshowsPrec :: Int -> RedshiftRetryOptions -> ShowS
Prelude.Show, forall x. Rep RedshiftRetryOptions x -> RedshiftRetryOptions
forall x. RedshiftRetryOptions -> Rep RedshiftRetryOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RedshiftRetryOptions x -> RedshiftRetryOptions
$cfrom :: forall x. RedshiftRetryOptions -> Rep RedshiftRetryOptions x
Prelude.Generic)

-- |
-- Create a value of 'RedshiftRetryOptions' 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', 'redshiftRetryOptions_durationInSeconds' - The length of time during which Kinesis Data Firehose retries delivery
-- after a failure, starting from the initial request and including the
-- first attempt. The default value is 3600 seconds (60 minutes). Kinesis
-- Data Firehose does not retry if the value of @DurationInSeconds@ is 0
-- (zero) or if the first delivery attempt takes longer than the current
-- value.
newRedshiftRetryOptions ::
  RedshiftRetryOptions
newRedshiftRetryOptions :: RedshiftRetryOptions
newRedshiftRetryOptions =
  RedshiftRetryOptions'
    { $sel:durationInSeconds:RedshiftRetryOptions' :: Maybe Natural
durationInSeconds =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The length of time during which Kinesis Data Firehose retries delivery
-- after a failure, starting from the initial request and including the
-- first attempt. The default value is 3600 seconds (60 minutes). Kinesis
-- Data Firehose does not retry if the value of @DurationInSeconds@ is 0
-- (zero) or if the first delivery attempt takes longer than the current
-- value.
redshiftRetryOptions_durationInSeconds :: Lens.Lens' RedshiftRetryOptions (Prelude.Maybe Prelude.Natural)
redshiftRetryOptions_durationInSeconds :: Lens' RedshiftRetryOptions (Maybe Natural)
redshiftRetryOptions_durationInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftRetryOptions' {Maybe Natural
durationInSeconds :: Maybe Natural
$sel:durationInSeconds:RedshiftRetryOptions' :: RedshiftRetryOptions -> Maybe Natural
durationInSeconds} -> Maybe Natural
durationInSeconds) (\s :: RedshiftRetryOptions
s@RedshiftRetryOptions' {} Maybe Natural
a -> RedshiftRetryOptions
s {$sel:durationInSeconds:RedshiftRetryOptions' :: Maybe Natural
durationInSeconds = Maybe Natural
a} :: RedshiftRetryOptions)

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

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

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