{-# 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.AppFlow.Types.AggregationConfig
-- 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.AppFlow.Types.AggregationConfig where

import Amazonka.AppFlow.Types.AggregationType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The aggregation settings that you can use to customize the output format
-- of your flow data.
--
-- /See:/ 'newAggregationConfig' smart constructor.
data AggregationConfig = AggregationConfig'
  { -- | Specifies whether Amazon AppFlow aggregates the flow records into a
    -- single file, or leave them unaggregated.
    AggregationConfig -> Maybe AggregationType
aggregationType :: Prelude.Maybe AggregationType
  }
  deriving (AggregationConfig -> AggregationConfig -> Bool
(AggregationConfig -> AggregationConfig -> Bool)
-> (AggregationConfig -> AggregationConfig -> Bool)
-> Eq AggregationConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AggregationConfig -> AggregationConfig -> Bool
$c/= :: AggregationConfig -> AggregationConfig -> Bool
== :: AggregationConfig -> AggregationConfig -> Bool
$c== :: AggregationConfig -> AggregationConfig -> Bool
Prelude.Eq, ReadPrec [AggregationConfig]
ReadPrec AggregationConfig
Int -> ReadS AggregationConfig
ReadS [AggregationConfig]
(Int -> ReadS AggregationConfig)
-> ReadS [AggregationConfig]
-> ReadPrec AggregationConfig
-> ReadPrec [AggregationConfig]
-> Read AggregationConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AggregationConfig]
$creadListPrec :: ReadPrec [AggregationConfig]
readPrec :: ReadPrec AggregationConfig
$creadPrec :: ReadPrec AggregationConfig
readList :: ReadS [AggregationConfig]
$creadList :: ReadS [AggregationConfig]
readsPrec :: Int -> ReadS AggregationConfig
$creadsPrec :: Int -> ReadS AggregationConfig
Prelude.Read, Int -> AggregationConfig -> ShowS
[AggregationConfig] -> ShowS
AggregationConfig -> String
(Int -> AggregationConfig -> ShowS)
-> (AggregationConfig -> String)
-> ([AggregationConfig] -> ShowS)
-> Show AggregationConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AggregationConfig] -> ShowS
$cshowList :: [AggregationConfig] -> ShowS
show :: AggregationConfig -> String
$cshow :: AggregationConfig -> String
showsPrec :: Int -> AggregationConfig -> ShowS
$cshowsPrec :: Int -> AggregationConfig -> ShowS
Prelude.Show, (forall x. AggregationConfig -> Rep AggregationConfig x)
-> (forall x. Rep AggregationConfig x -> AggregationConfig)
-> Generic AggregationConfig
forall x. Rep AggregationConfig x -> AggregationConfig
forall x. AggregationConfig -> Rep AggregationConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AggregationConfig x -> AggregationConfig
$cfrom :: forall x. AggregationConfig -> Rep AggregationConfig x
Prelude.Generic)

-- |
-- Create a value of 'AggregationConfig' 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:
--
-- 'aggregationType', 'aggregationConfig_aggregationType' - Specifies whether Amazon AppFlow aggregates the flow records into a
-- single file, or leave them unaggregated.
newAggregationConfig ::
  AggregationConfig
newAggregationConfig :: AggregationConfig
newAggregationConfig =
  AggregationConfig' :: Maybe AggregationType -> AggregationConfig
AggregationConfig'
    { $sel:aggregationType:AggregationConfig' :: Maybe AggregationType
aggregationType =
        Maybe AggregationType
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether Amazon AppFlow aggregates the flow records into a
-- single file, or leave them unaggregated.
aggregationConfig_aggregationType :: Lens.Lens' AggregationConfig (Prelude.Maybe AggregationType)
aggregationConfig_aggregationType :: (Maybe AggregationType -> f (Maybe AggregationType))
-> AggregationConfig -> f AggregationConfig
aggregationConfig_aggregationType = (AggregationConfig -> Maybe AggregationType)
-> (AggregationConfig
    -> Maybe AggregationType -> AggregationConfig)
-> Lens
     AggregationConfig
     AggregationConfig
     (Maybe AggregationType)
     (Maybe AggregationType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregationConfig' {Maybe AggregationType
aggregationType :: Maybe AggregationType
$sel:aggregationType:AggregationConfig' :: AggregationConfig -> Maybe AggregationType
aggregationType} -> Maybe AggregationType
aggregationType) (\s :: AggregationConfig
s@AggregationConfig' {} Maybe AggregationType
a -> AggregationConfig
s {$sel:aggregationType:AggregationConfig' :: Maybe AggregationType
aggregationType = Maybe AggregationType
a} :: AggregationConfig)

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

instance Prelude.Hashable AggregationConfig

instance Prelude.NFData AggregationConfig

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