{-# 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.SplunkRetryOptions
-- 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.SplunkRetryOptions 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 Splunk, or if it doesn\'t receive an acknowledgment
-- from Splunk.
--
-- /See:/ 'newSplunkRetryOptions' smart constructor.
data SplunkRetryOptions = SplunkRetryOptions'
  { -- | The total amount of time that Kinesis Data Firehose spends on retries.
    -- This duration starts after the initial attempt to send data to Splunk
    -- fails. It doesn\'t include the periods during which Kinesis Data
    -- Firehose waits for acknowledgment from Splunk after each attempt.
    SplunkRetryOptions -> Maybe Natural
durationInSeconds :: Prelude.Maybe Prelude.Natural
  }
  deriving (SplunkRetryOptions -> SplunkRetryOptions -> Bool
(SplunkRetryOptions -> SplunkRetryOptions -> Bool)
-> (SplunkRetryOptions -> SplunkRetryOptions -> Bool)
-> Eq SplunkRetryOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SplunkRetryOptions -> SplunkRetryOptions -> Bool
$c/= :: SplunkRetryOptions -> SplunkRetryOptions -> Bool
== :: SplunkRetryOptions -> SplunkRetryOptions -> Bool
$c== :: SplunkRetryOptions -> SplunkRetryOptions -> Bool
Prelude.Eq, ReadPrec [SplunkRetryOptions]
ReadPrec SplunkRetryOptions
Int -> ReadS SplunkRetryOptions
ReadS [SplunkRetryOptions]
(Int -> ReadS SplunkRetryOptions)
-> ReadS [SplunkRetryOptions]
-> ReadPrec SplunkRetryOptions
-> ReadPrec [SplunkRetryOptions]
-> Read SplunkRetryOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SplunkRetryOptions]
$creadListPrec :: ReadPrec [SplunkRetryOptions]
readPrec :: ReadPrec SplunkRetryOptions
$creadPrec :: ReadPrec SplunkRetryOptions
readList :: ReadS [SplunkRetryOptions]
$creadList :: ReadS [SplunkRetryOptions]
readsPrec :: Int -> ReadS SplunkRetryOptions
$creadsPrec :: Int -> ReadS SplunkRetryOptions
Prelude.Read, Int -> SplunkRetryOptions -> ShowS
[SplunkRetryOptions] -> ShowS
SplunkRetryOptions -> String
(Int -> SplunkRetryOptions -> ShowS)
-> (SplunkRetryOptions -> String)
-> ([SplunkRetryOptions] -> ShowS)
-> Show SplunkRetryOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SplunkRetryOptions] -> ShowS
$cshowList :: [SplunkRetryOptions] -> ShowS
show :: SplunkRetryOptions -> String
$cshow :: SplunkRetryOptions -> String
showsPrec :: Int -> SplunkRetryOptions -> ShowS
$cshowsPrec :: Int -> SplunkRetryOptions -> ShowS
Prelude.Show, (forall x. SplunkRetryOptions -> Rep SplunkRetryOptions x)
-> (forall x. Rep SplunkRetryOptions x -> SplunkRetryOptions)
-> Generic SplunkRetryOptions
forall x. Rep SplunkRetryOptions x -> SplunkRetryOptions
forall x. SplunkRetryOptions -> Rep SplunkRetryOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SplunkRetryOptions x -> SplunkRetryOptions
$cfrom :: forall x. SplunkRetryOptions -> Rep SplunkRetryOptions x
Prelude.Generic)

-- |
-- Create a value of 'SplunkRetryOptions' 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', 'splunkRetryOptions_durationInSeconds' - The total amount of time that Kinesis Data Firehose spends on retries.
-- This duration starts after the initial attempt to send data to Splunk
-- fails. It doesn\'t include the periods during which Kinesis Data
-- Firehose waits for acknowledgment from Splunk after each attempt.
newSplunkRetryOptions ::
  SplunkRetryOptions
newSplunkRetryOptions :: SplunkRetryOptions
newSplunkRetryOptions =
  SplunkRetryOptions' :: Maybe Natural -> SplunkRetryOptions
SplunkRetryOptions'
    { $sel:durationInSeconds:SplunkRetryOptions' :: 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 Splunk
-- fails. It doesn\'t include the periods during which Kinesis Data
-- Firehose waits for acknowledgment from Splunk after each attempt.
splunkRetryOptions_durationInSeconds :: Lens.Lens' SplunkRetryOptions (Prelude.Maybe Prelude.Natural)
splunkRetryOptions_durationInSeconds :: (Maybe Natural -> f (Maybe Natural))
-> SplunkRetryOptions -> f SplunkRetryOptions
splunkRetryOptions_durationInSeconds = (SplunkRetryOptions -> Maybe Natural)
-> (SplunkRetryOptions -> Maybe Natural -> SplunkRetryOptions)
-> Lens
     SplunkRetryOptions
     SplunkRetryOptions
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SplunkRetryOptions' {Maybe Natural
durationInSeconds :: Maybe Natural
$sel:durationInSeconds:SplunkRetryOptions' :: SplunkRetryOptions -> Maybe Natural
durationInSeconds} -> Maybe Natural
durationInSeconds) (\s :: SplunkRetryOptions
s@SplunkRetryOptions' {} Maybe Natural
a -> SplunkRetryOptions
s {$sel:durationInSeconds:SplunkRetryOptions' :: Maybe Natural
durationInSeconds = Maybe Natural
a} :: SplunkRetryOptions)

instance Core.FromJSON SplunkRetryOptions where
  parseJSON :: Value -> Parser SplunkRetryOptions
parseJSON =
    String
-> (Object -> Parser SplunkRetryOptions)
-> Value
-> Parser SplunkRetryOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SplunkRetryOptions"
      ( \Object
x ->
          Maybe Natural -> SplunkRetryOptions
SplunkRetryOptions'
            (Maybe Natural -> SplunkRetryOptions)
-> Parser (Maybe Natural) -> Parser SplunkRetryOptions
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 SplunkRetryOptions

instance Prelude.NFData SplunkRetryOptions

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