{-# 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.AmazonOpenSearchServerlessRetryOptions
-- 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.AmazonOpenSearchServerlessRetryOptions 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 the Serverless offering for Amazon OpenSearch
-- Service.
--
-- /See:/ 'newAmazonOpenSearchServerlessRetryOptions' smart constructor.
data AmazonOpenSearchServerlessRetryOptions = AmazonOpenSearchServerlessRetryOptions'
  { -- | After an initial failure to deliver to the Serverless offering for
    -- Amazon OpenSearch Service, the total amount of time during which Kinesis
    -- Data Firehose retries delivery (including the first attempt). After this
    -- time has elapsed, the failed documents are written to Amazon S3. Default
    -- value is 300 seconds (5 minutes). A value of 0 (zero) results in no
    -- retries.
    AmazonOpenSearchServerlessRetryOptions -> Maybe Natural
durationInSeconds :: Prelude.Maybe Prelude.Natural
  }
  deriving (AmazonOpenSearchServerlessRetryOptions
-> AmazonOpenSearchServerlessRetryOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AmazonOpenSearchServerlessRetryOptions
-> AmazonOpenSearchServerlessRetryOptions -> Bool
$c/= :: AmazonOpenSearchServerlessRetryOptions
-> AmazonOpenSearchServerlessRetryOptions -> Bool
== :: AmazonOpenSearchServerlessRetryOptions
-> AmazonOpenSearchServerlessRetryOptions -> Bool
$c== :: AmazonOpenSearchServerlessRetryOptions
-> AmazonOpenSearchServerlessRetryOptions -> Bool
Prelude.Eq, ReadPrec [AmazonOpenSearchServerlessRetryOptions]
ReadPrec AmazonOpenSearchServerlessRetryOptions
Int -> ReadS AmazonOpenSearchServerlessRetryOptions
ReadS [AmazonOpenSearchServerlessRetryOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AmazonOpenSearchServerlessRetryOptions]
$creadListPrec :: ReadPrec [AmazonOpenSearchServerlessRetryOptions]
readPrec :: ReadPrec AmazonOpenSearchServerlessRetryOptions
$creadPrec :: ReadPrec AmazonOpenSearchServerlessRetryOptions
readList :: ReadS [AmazonOpenSearchServerlessRetryOptions]
$creadList :: ReadS [AmazonOpenSearchServerlessRetryOptions]
readsPrec :: Int -> ReadS AmazonOpenSearchServerlessRetryOptions
$creadsPrec :: Int -> ReadS AmazonOpenSearchServerlessRetryOptions
Prelude.Read, Int -> AmazonOpenSearchServerlessRetryOptions -> ShowS
[AmazonOpenSearchServerlessRetryOptions] -> ShowS
AmazonOpenSearchServerlessRetryOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AmazonOpenSearchServerlessRetryOptions] -> ShowS
$cshowList :: [AmazonOpenSearchServerlessRetryOptions] -> ShowS
show :: AmazonOpenSearchServerlessRetryOptions -> String
$cshow :: AmazonOpenSearchServerlessRetryOptions -> String
showsPrec :: Int -> AmazonOpenSearchServerlessRetryOptions -> ShowS
$cshowsPrec :: Int -> AmazonOpenSearchServerlessRetryOptions -> ShowS
Prelude.Show, forall x.
Rep AmazonOpenSearchServerlessRetryOptions x
-> AmazonOpenSearchServerlessRetryOptions
forall x.
AmazonOpenSearchServerlessRetryOptions
-> Rep AmazonOpenSearchServerlessRetryOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AmazonOpenSearchServerlessRetryOptions x
-> AmazonOpenSearchServerlessRetryOptions
$cfrom :: forall x.
AmazonOpenSearchServerlessRetryOptions
-> Rep AmazonOpenSearchServerlessRetryOptions x
Prelude.Generic)

-- |
-- Create a value of 'AmazonOpenSearchServerlessRetryOptions' 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', 'amazonOpenSearchServerlessRetryOptions_durationInSeconds' - After an initial failure to deliver to the Serverless offering for
-- Amazon OpenSearch Service, the total amount of time during which Kinesis
-- Data Firehose retries delivery (including the first attempt). After this
-- time has elapsed, the failed documents are written to Amazon S3. Default
-- value is 300 seconds (5 minutes). A value of 0 (zero) results in no
-- retries.
newAmazonOpenSearchServerlessRetryOptions ::
  AmazonOpenSearchServerlessRetryOptions
newAmazonOpenSearchServerlessRetryOptions :: AmazonOpenSearchServerlessRetryOptions
newAmazonOpenSearchServerlessRetryOptions =
  AmazonOpenSearchServerlessRetryOptions'
    { $sel:durationInSeconds:AmazonOpenSearchServerlessRetryOptions' :: Maybe Natural
durationInSeconds =
        forall a. Maybe a
Prelude.Nothing
    }

-- | After an initial failure to deliver to the Serverless offering for
-- Amazon OpenSearch Service, the total amount of time during which Kinesis
-- Data Firehose retries delivery (including the first attempt). After this
-- time has elapsed, the failed documents are written to Amazon S3. Default
-- value is 300 seconds (5 minutes). A value of 0 (zero) results in no
-- retries.
amazonOpenSearchServerlessRetryOptions_durationInSeconds :: Lens.Lens' AmazonOpenSearchServerlessRetryOptions (Prelude.Maybe Prelude.Natural)
amazonOpenSearchServerlessRetryOptions_durationInSeconds :: Lens' AmazonOpenSearchServerlessRetryOptions (Maybe Natural)
amazonOpenSearchServerlessRetryOptions_durationInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AmazonOpenSearchServerlessRetryOptions' {Maybe Natural
durationInSeconds :: Maybe Natural
$sel:durationInSeconds:AmazonOpenSearchServerlessRetryOptions' :: AmazonOpenSearchServerlessRetryOptions -> Maybe Natural
durationInSeconds} -> Maybe Natural
durationInSeconds) (\s :: AmazonOpenSearchServerlessRetryOptions
s@AmazonOpenSearchServerlessRetryOptions' {} Maybe Natural
a -> AmazonOpenSearchServerlessRetryOptions
s {$sel:durationInSeconds:AmazonOpenSearchServerlessRetryOptions' :: Maybe Natural
durationInSeconds = Maybe Natural
a} :: AmazonOpenSearchServerlessRetryOptions)

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

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

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