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

import Amazonka.AppFlow.Types.AggregationConfig
import Amazonka.AppFlow.Types.FileType
import Amazonka.AppFlow.Types.PrefixConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The configuration that determines how Amazon AppFlow should format the
-- flow output data when Amazon S3 is used as the destination.
--
-- /See:/ 'newS3OutputFormatConfig' smart constructor.
data S3OutputFormatConfig = S3OutputFormatConfig'
  { -- | Determines the prefix that Amazon AppFlow applies to the folder name in
    -- the Amazon S3 bucket. You can name folders according to the flow
    -- frequency and date.
    S3OutputFormatConfig -> Maybe PrefixConfig
prefixConfig :: Prelude.Maybe PrefixConfig,
    -- | Indicates the file type that Amazon AppFlow places in the Amazon S3
    -- bucket.
    S3OutputFormatConfig -> Maybe FileType
fileType :: Prelude.Maybe FileType,
    S3OutputFormatConfig -> Maybe AggregationConfig
aggregationConfig :: Prelude.Maybe AggregationConfig
  }
  deriving (S3OutputFormatConfig -> S3OutputFormatConfig -> Bool
(S3OutputFormatConfig -> S3OutputFormatConfig -> Bool)
-> (S3OutputFormatConfig -> S3OutputFormatConfig -> Bool)
-> Eq S3OutputFormatConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3OutputFormatConfig -> S3OutputFormatConfig -> Bool
$c/= :: S3OutputFormatConfig -> S3OutputFormatConfig -> Bool
== :: S3OutputFormatConfig -> S3OutputFormatConfig -> Bool
$c== :: S3OutputFormatConfig -> S3OutputFormatConfig -> Bool
Prelude.Eq, ReadPrec [S3OutputFormatConfig]
ReadPrec S3OutputFormatConfig
Int -> ReadS S3OutputFormatConfig
ReadS [S3OutputFormatConfig]
(Int -> ReadS S3OutputFormatConfig)
-> ReadS [S3OutputFormatConfig]
-> ReadPrec S3OutputFormatConfig
-> ReadPrec [S3OutputFormatConfig]
-> Read S3OutputFormatConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3OutputFormatConfig]
$creadListPrec :: ReadPrec [S3OutputFormatConfig]
readPrec :: ReadPrec S3OutputFormatConfig
$creadPrec :: ReadPrec S3OutputFormatConfig
readList :: ReadS [S3OutputFormatConfig]
$creadList :: ReadS [S3OutputFormatConfig]
readsPrec :: Int -> ReadS S3OutputFormatConfig
$creadsPrec :: Int -> ReadS S3OutputFormatConfig
Prelude.Read, Int -> S3OutputFormatConfig -> ShowS
[S3OutputFormatConfig] -> ShowS
S3OutputFormatConfig -> String
(Int -> S3OutputFormatConfig -> ShowS)
-> (S3OutputFormatConfig -> String)
-> ([S3OutputFormatConfig] -> ShowS)
-> Show S3OutputFormatConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3OutputFormatConfig] -> ShowS
$cshowList :: [S3OutputFormatConfig] -> ShowS
show :: S3OutputFormatConfig -> String
$cshow :: S3OutputFormatConfig -> String
showsPrec :: Int -> S3OutputFormatConfig -> ShowS
$cshowsPrec :: Int -> S3OutputFormatConfig -> ShowS
Prelude.Show, (forall x. S3OutputFormatConfig -> Rep S3OutputFormatConfig x)
-> (forall x. Rep S3OutputFormatConfig x -> S3OutputFormatConfig)
-> Generic S3OutputFormatConfig
forall x. Rep S3OutputFormatConfig x -> S3OutputFormatConfig
forall x. S3OutputFormatConfig -> Rep S3OutputFormatConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3OutputFormatConfig x -> S3OutputFormatConfig
$cfrom :: forall x. S3OutputFormatConfig -> Rep S3OutputFormatConfig x
Prelude.Generic)

-- |
-- Create a value of 'S3OutputFormatConfig' 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:
--
-- 'prefixConfig', 's3OutputFormatConfig_prefixConfig' - Determines the prefix that Amazon AppFlow applies to the folder name in
-- the Amazon S3 bucket. You can name folders according to the flow
-- frequency and date.
--
-- 'fileType', 's3OutputFormatConfig_fileType' - Indicates the file type that Amazon AppFlow places in the Amazon S3
-- bucket.
--
-- 'aggregationConfig', 's3OutputFormatConfig_aggregationConfig' - Undocumented member.
newS3OutputFormatConfig ::
  S3OutputFormatConfig
newS3OutputFormatConfig :: S3OutputFormatConfig
newS3OutputFormatConfig =
  S3OutputFormatConfig' :: Maybe PrefixConfig
-> Maybe FileType
-> Maybe AggregationConfig
-> S3OutputFormatConfig
S3OutputFormatConfig'
    { $sel:prefixConfig:S3OutputFormatConfig' :: Maybe PrefixConfig
prefixConfig =
        Maybe PrefixConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:fileType:S3OutputFormatConfig' :: Maybe FileType
fileType = Maybe FileType
forall a. Maybe a
Prelude.Nothing,
      $sel:aggregationConfig:S3OutputFormatConfig' :: Maybe AggregationConfig
aggregationConfig = Maybe AggregationConfig
forall a. Maybe a
Prelude.Nothing
    }

-- | Determines the prefix that Amazon AppFlow applies to the folder name in
-- the Amazon S3 bucket. You can name folders according to the flow
-- frequency and date.
s3OutputFormatConfig_prefixConfig :: Lens.Lens' S3OutputFormatConfig (Prelude.Maybe PrefixConfig)
s3OutputFormatConfig_prefixConfig :: (Maybe PrefixConfig -> f (Maybe PrefixConfig))
-> S3OutputFormatConfig -> f S3OutputFormatConfig
s3OutputFormatConfig_prefixConfig = (S3OutputFormatConfig -> Maybe PrefixConfig)
-> (S3OutputFormatConfig
    -> Maybe PrefixConfig -> S3OutputFormatConfig)
-> Lens
     S3OutputFormatConfig
     S3OutputFormatConfig
     (Maybe PrefixConfig)
     (Maybe PrefixConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3OutputFormatConfig' {Maybe PrefixConfig
prefixConfig :: Maybe PrefixConfig
$sel:prefixConfig:S3OutputFormatConfig' :: S3OutputFormatConfig -> Maybe PrefixConfig
prefixConfig} -> Maybe PrefixConfig
prefixConfig) (\s :: S3OutputFormatConfig
s@S3OutputFormatConfig' {} Maybe PrefixConfig
a -> S3OutputFormatConfig
s {$sel:prefixConfig:S3OutputFormatConfig' :: Maybe PrefixConfig
prefixConfig = Maybe PrefixConfig
a} :: S3OutputFormatConfig)

-- | Indicates the file type that Amazon AppFlow places in the Amazon S3
-- bucket.
s3OutputFormatConfig_fileType :: Lens.Lens' S3OutputFormatConfig (Prelude.Maybe FileType)
s3OutputFormatConfig_fileType :: (Maybe FileType -> f (Maybe FileType))
-> S3OutputFormatConfig -> f S3OutputFormatConfig
s3OutputFormatConfig_fileType = (S3OutputFormatConfig -> Maybe FileType)
-> (S3OutputFormatConfig -> Maybe FileType -> S3OutputFormatConfig)
-> Lens
     S3OutputFormatConfig
     S3OutputFormatConfig
     (Maybe FileType)
     (Maybe FileType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3OutputFormatConfig' {Maybe FileType
fileType :: Maybe FileType
$sel:fileType:S3OutputFormatConfig' :: S3OutputFormatConfig -> Maybe FileType
fileType} -> Maybe FileType
fileType) (\s :: S3OutputFormatConfig
s@S3OutputFormatConfig' {} Maybe FileType
a -> S3OutputFormatConfig
s {$sel:fileType:S3OutputFormatConfig' :: Maybe FileType
fileType = Maybe FileType
a} :: S3OutputFormatConfig)

-- | Undocumented member.
s3OutputFormatConfig_aggregationConfig :: Lens.Lens' S3OutputFormatConfig (Prelude.Maybe AggregationConfig)
s3OutputFormatConfig_aggregationConfig :: (Maybe AggregationConfig -> f (Maybe AggregationConfig))
-> S3OutputFormatConfig -> f S3OutputFormatConfig
s3OutputFormatConfig_aggregationConfig = (S3OutputFormatConfig -> Maybe AggregationConfig)
-> (S3OutputFormatConfig
    -> Maybe AggregationConfig -> S3OutputFormatConfig)
-> Lens
     S3OutputFormatConfig
     S3OutputFormatConfig
     (Maybe AggregationConfig)
     (Maybe AggregationConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3OutputFormatConfig' {Maybe AggregationConfig
aggregationConfig :: Maybe AggregationConfig
$sel:aggregationConfig:S3OutputFormatConfig' :: S3OutputFormatConfig -> Maybe AggregationConfig
aggregationConfig} -> Maybe AggregationConfig
aggregationConfig) (\s :: S3OutputFormatConfig
s@S3OutputFormatConfig' {} Maybe AggregationConfig
a -> S3OutputFormatConfig
s {$sel:aggregationConfig:S3OutputFormatConfig' :: Maybe AggregationConfig
aggregationConfig = Maybe AggregationConfig
a} :: S3OutputFormatConfig)

instance Core.FromJSON S3OutputFormatConfig where
  parseJSON :: Value -> Parser S3OutputFormatConfig
parseJSON =
    String
-> (Object -> Parser S3OutputFormatConfig)
-> Value
-> Parser S3OutputFormatConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3OutputFormatConfig"
      ( \Object
x ->
          Maybe PrefixConfig
-> Maybe FileType
-> Maybe AggregationConfig
-> S3OutputFormatConfig
S3OutputFormatConfig'
            (Maybe PrefixConfig
 -> Maybe FileType
 -> Maybe AggregationConfig
 -> S3OutputFormatConfig)
-> Parser (Maybe PrefixConfig)
-> Parser
     (Maybe FileType -> Maybe AggregationConfig -> S3OutputFormatConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe PrefixConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"prefixConfig")
            Parser
  (Maybe FileType -> Maybe AggregationConfig -> S3OutputFormatConfig)
-> Parser (Maybe FileType)
-> Parser (Maybe AggregationConfig -> S3OutputFormatConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FileType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"fileType")
            Parser (Maybe AggregationConfig -> S3OutputFormatConfig)
-> Parser (Maybe AggregationConfig) -> Parser S3OutputFormatConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AggregationConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"aggregationConfig")
      )

instance Prelude.Hashable S3OutputFormatConfig

instance Prelude.NFData S3OutputFormatConfig

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