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

import qualified Amazonka.Core as Core
import Amazonka.Firehose.Types.RetryOptions
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The configuration of the dynamic partitioning mechanism that creates
-- smaller data sets from the streaming data by partitioning it based on
-- partition keys. Currently, dynamic partitioning is only supported for
-- Amazon S3 destinations. For more information, see
-- <https://docs.aws.amazon.com/firehose/latest/dev/dynamic-partitioning.html>
--
-- /See:/ 'newDynamicPartitioningConfiguration' smart constructor.
data DynamicPartitioningConfiguration = DynamicPartitioningConfiguration'
  { -- | Specifies that the dynamic partitioning is enabled for this Kinesis Data
    -- Firehose delivery stream.
    DynamicPartitioningConfiguration -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The retry behavior in case Kinesis Data Firehose is unable to deliver
    -- data to an Amazon S3 prefix.
    DynamicPartitioningConfiguration -> Maybe RetryOptions
retryOptions :: Prelude.Maybe RetryOptions
  }
  deriving (DynamicPartitioningConfiguration
-> DynamicPartitioningConfiguration -> Bool
(DynamicPartitioningConfiguration
 -> DynamicPartitioningConfiguration -> Bool)
-> (DynamicPartitioningConfiguration
    -> DynamicPartitioningConfiguration -> Bool)
-> Eq DynamicPartitioningConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DynamicPartitioningConfiguration
-> DynamicPartitioningConfiguration -> Bool
$c/= :: DynamicPartitioningConfiguration
-> DynamicPartitioningConfiguration -> Bool
== :: DynamicPartitioningConfiguration
-> DynamicPartitioningConfiguration -> Bool
$c== :: DynamicPartitioningConfiguration
-> DynamicPartitioningConfiguration -> Bool
Prelude.Eq, ReadPrec [DynamicPartitioningConfiguration]
ReadPrec DynamicPartitioningConfiguration
Int -> ReadS DynamicPartitioningConfiguration
ReadS [DynamicPartitioningConfiguration]
(Int -> ReadS DynamicPartitioningConfiguration)
-> ReadS [DynamicPartitioningConfiguration]
-> ReadPrec DynamicPartitioningConfiguration
-> ReadPrec [DynamicPartitioningConfiguration]
-> Read DynamicPartitioningConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DynamicPartitioningConfiguration]
$creadListPrec :: ReadPrec [DynamicPartitioningConfiguration]
readPrec :: ReadPrec DynamicPartitioningConfiguration
$creadPrec :: ReadPrec DynamicPartitioningConfiguration
readList :: ReadS [DynamicPartitioningConfiguration]
$creadList :: ReadS [DynamicPartitioningConfiguration]
readsPrec :: Int -> ReadS DynamicPartitioningConfiguration
$creadsPrec :: Int -> ReadS DynamicPartitioningConfiguration
Prelude.Read, Int -> DynamicPartitioningConfiguration -> ShowS
[DynamicPartitioningConfiguration] -> ShowS
DynamicPartitioningConfiguration -> String
(Int -> DynamicPartitioningConfiguration -> ShowS)
-> (DynamicPartitioningConfiguration -> String)
-> ([DynamicPartitioningConfiguration] -> ShowS)
-> Show DynamicPartitioningConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DynamicPartitioningConfiguration] -> ShowS
$cshowList :: [DynamicPartitioningConfiguration] -> ShowS
show :: DynamicPartitioningConfiguration -> String
$cshow :: DynamicPartitioningConfiguration -> String
showsPrec :: Int -> DynamicPartitioningConfiguration -> ShowS
$cshowsPrec :: Int -> DynamicPartitioningConfiguration -> ShowS
Prelude.Show, (forall x.
 DynamicPartitioningConfiguration
 -> Rep DynamicPartitioningConfiguration x)
-> (forall x.
    Rep DynamicPartitioningConfiguration x
    -> DynamicPartitioningConfiguration)
-> Generic DynamicPartitioningConfiguration
forall x.
Rep DynamicPartitioningConfiguration x
-> DynamicPartitioningConfiguration
forall x.
DynamicPartitioningConfiguration
-> Rep DynamicPartitioningConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DynamicPartitioningConfiguration x
-> DynamicPartitioningConfiguration
$cfrom :: forall x.
DynamicPartitioningConfiguration
-> Rep DynamicPartitioningConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'DynamicPartitioningConfiguration' 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:
--
-- 'enabled', 'dynamicPartitioningConfiguration_enabled' - Specifies that the dynamic partitioning is enabled for this Kinesis Data
-- Firehose delivery stream.
--
-- 'retryOptions', 'dynamicPartitioningConfiguration_retryOptions' - The retry behavior in case Kinesis Data Firehose is unable to deliver
-- data to an Amazon S3 prefix.
newDynamicPartitioningConfiguration ::
  DynamicPartitioningConfiguration
newDynamicPartitioningConfiguration :: DynamicPartitioningConfiguration
newDynamicPartitioningConfiguration =
  DynamicPartitioningConfiguration' :: Maybe Bool
-> Maybe RetryOptions -> DynamicPartitioningConfiguration
DynamicPartitioningConfiguration'
    { $sel:enabled:DynamicPartitioningConfiguration' :: Maybe Bool
enabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:retryOptions:DynamicPartitioningConfiguration' :: Maybe RetryOptions
retryOptions = Maybe RetryOptions
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies that the dynamic partitioning is enabled for this Kinesis Data
-- Firehose delivery stream.
dynamicPartitioningConfiguration_enabled :: Lens.Lens' DynamicPartitioningConfiguration (Prelude.Maybe Prelude.Bool)
dynamicPartitioningConfiguration_enabled :: (Maybe Bool -> f (Maybe Bool))
-> DynamicPartitioningConfiguration
-> f DynamicPartitioningConfiguration
dynamicPartitioningConfiguration_enabled = (DynamicPartitioningConfiguration -> Maybe Bool)
-> (DynamicPartitioningConfiguration
    -> Maybe Bool -> DynamicPartitioningConfiguration)
-> Lens
     DynamicPartitioningConfiguration
     DynamicPartitioningConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamicPartitioningConfiguration' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:DynamicPartitioningConfiguration' :: DynamicPartitioningConfiguration -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: DynamicPartitioningConfiguration
s@DynamicPartitioningConfiguration' {} Maybe Bool
a -> DynamicPartitioningConfiguration
s {$sel:enabled:DynamicPartitioningConfiguration' :: Maybe Bool
enabled = Maybe Bool
a} :: DynamicPartitioningConfiguration)

-- | The retry behavior in case Kinesis Data Firehose is unable to deliver
-- data to an Amazon S3 prefix.
dynamicPartitioningConfiguration_retryOptions :: Lens.Lens' DynamicPartitioningConfiguration (Prelude.Maybe RetryOptions)
dynamicPartitioningConfiguration_retryOptions :: (Maybe RetryOptions -> f (Maybe RetryOptions))
-> DynamicPartitioningConfiguration
-> f DynamicPartitioningConfiguration
dynamicPartitioningConfiguration_retryOptions = (DynamicPartitioningConfiguration -> Maybe RetryOptions)
-> (DynamicPartitioningConfiguration
    -> Maybe RetryOptions -> DynamicPartitioningConfiguration)
-> Lens
     DynamicPartitioningConfiguration
     DynamicPartitioningConfiguration
     (Maybe RetryOptions)
     (Maybe RetryOptions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamicPartitioningConfiguration' {Maybe RetryOptions
retryOptions :: Maybe RetryOptions
$sel:retryOptions:DynamicPartitioningConfiguration' :: DynamicPartitioningConfiguration -> Maybe RetryOptions
retryOptions} -> Maybe RetryOptions
retryOptions) (\s :: DynamicPartitioningConfiguration
s@DynamicPartitioningConfiguration' {} Maybe RetryOptions
a -> DynamicPartitioningConfiguration
s {$sel:retryOptions:DynamicPartitioningConfiguration' :: Maybe RetryOptions
retryOptions = Maybe RetryOptions
a} :: DynamicPartitioningConfiguration)

instance
  Core.FromJSON
    DynamicPartitioningConfiguration
  where
  parseJSON :: Value -> Parser DynamicPartitioningConfiguration
parseJSON =
    String
-> (Object -> Parser DynamicPartitioningConfiguration)
-> Value
-> Parser DynamicPartitioningConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DynamicPartitioningConfiguration"
      ( \Object
x ->
          Maybe Bool
-> Maybe RetryOptions -> DynamicPartitioningConfiguration
DynamicPartitioningConfiguration'
            (Maybe Bool
 -> Maybe RetryOptions -> DynamicPartitioningConfiguration)
-> Parser (Maybe Bool)
-> Parser (Maybe RetryOptions -> DynamicPartitioningConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Enabled")
            Parser (Maybe RetryOptions -> DynamicPartitioningConfiguration)
-> Parser (Maybe RetryOptions)
-> Parser DynamicPartitioningConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RetryOptions)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RetryOptions")
      )

instance
  Prelude.Hashable
    DynamicPartitioningConfiguration

instance
  Prelude.NFData
    DynamicPartitioningConfiguration

instance Core.ToJSON DynamicPartitioningConfiguration where
  toJSON :: DynamicPartitioningConfiguration -> Value
toJSON DynamicPartitioningConfiguration' {Maybe Bool
Maybe RetryOptions
retryOptions :: Maybe RetryOptions
enabled :: Maybe Bool
$sel:retryOptions:DynamicPartitioningConfiguration' :: DynamicPartitioningConfiguration -> Maybe RetryOptions
$sel:enabled:DynamicPartitioningConfiguration' :: DynamicPartitioningConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (Text
"RetryOptions" Text -> RetryOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RetryOptions -> Pair) -> Maybe RetryOptions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RetryOptions
retryOptions
          ]
      )