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

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

instance Prelude.NFData RedshiftRetryOptions

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