{-# 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.UpsolverS3OutputFormatConfig
-- 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.UpsolverS3OutputFormatConfig 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 formats the flow
-- output data when Upsolver is used as the destination.
--
-- /See:/ 'newUpsolverS3OutputFormatConfig' smart constructor.
data UpsolverS3OutputFormatConfig = UpsolverS3OutputFormatConfig'
  { -- | Indicates the file type that Amazon AppFlow places in the Upsolver
    -- Amazon S3 bucket.
    UpsolverS3OutputFormatConfig -> Maybe FileType
fileType :: Prelude.Maybe FileType,
    UpsolverS3OutputFormatConfig -> Maybe AggregationConfig
aggregationConfig :: Prelude.Maybe AggregationConfig,
    UpsolverS3OutputFormatConfig -> PrefixConfig
prefixConfig :: PrefixConfig
  }
  deriving (UpsolverS3OutputFormatConfig
-> UpsolverS3OutputFormatConfig -> Bool
(UpsolverS3OutputFormatConfig
 -> UpsolverS3OutputFormatConfig -> Bool)
-> (UpsolverS3OutputFormatConfig
    -> UpsolverS3OutputFormatConfig -> Bool)
-> Eq UpsolverS3OutputFormatConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpsolverS3OutputFormatConfig
-> UpsolverS3OutputFormatConfig -> Bool
$c/= :: UpsolverS3OutputFormatConfig
-> UpsolverS3OutputFormatConfig -> Bool
== :: UpsolverS3OutputFormatConfig
-> UpsolverS3OutputFormatConfig -> Bool
$c== :: UpsolverS3OutputFormatConfig
-> UpsolverS3OutputFormatConfig -> Bool
Prelude.Eq, ReadPrec [UpsolverS3OutputFormatConfig]
ReadPrec UpsolverS3OutputFormatConfig
Int -> ReadS UpsolverS3OutputFormatConfig
ReadS [UpsolverS3OutputFormatConfig]
(Int -> ReadS UpsolverS3OutputFormatConfig)
-> ReadS [UpsolverS3OutputFormatConfig]
-> ReadPrec UpsolverS3OutputFormatConfig
-> ReadPrec [UpsolverS3OutputFormatConfig]
-> Read UpsolverS3OutputFormatConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpsolverS3OutputFormatConfig]
$creadListPrec :: ReadPrec [UpsolverS3OutputFormatConfig]
readPrec :: ReadPrec UpsolverS3OutputFormatConfig
$creadPrec :: ReadPrec UpsolverS3OutputFormatConfig
readList :: ReadS [UpsolverS3OutputFormatConfig]
$creadList :: ReadS [UpsolverS3OutputFormatConfig]
readsPrec :: Int -> ReadS UpsolverS3OutputFormatConfig
$creadsPrec :: Int -> ReadS UpsolverS3OutputFormatConfig
Prelude.Read, Int -> UpsolverS3OutputFormatConfig -> ShowS
[UpsolverS3OutputFormatConfig] -> ShowS
UpsolverS3OutputFormatConfig -> String
(Int -> UpsolverS3OutputFormatConfig -> ShowS)
-> (UpsolverS3OutputFormatConfig -> String)
-> ([UpsolverS3OutputFormatConfig] -> ShowS)
-> Show UpsolverS3OutputFormatConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpsolverS3OutputFormatConfig] -> ShowS
$cshowList :: [UpsolverS3OutputFormatConfig] -> ShowS
show :: UpsolverS3OutputFormatConfig -> String
$cshow :: UpsolverS3OutputFormatConfig -> String
showsPrec :: Int -> UpsolverS3OutputFormatConfig -> ShowS
$cshowsPrec :: Int -> UpsolverS3OutputFormatConfig -> ShowS
Prelude.Show, (forall x.
 UpsolverS3OutputFormatConfig -> Rep UpsolverS3OutputFormatConfig x)
-> (forall x.
    Rep UpsolverS3OutputFormatConfig x -> UpsolverS3OutputFormatConfig)
-> Generic UpsolverS3OutputFormatConfig
forall x.
Rep UpsolverS3OutputFormatConfig x -> UpsolverS3OutputFormatConfig
forall x.
UpsolverS3OutputFormatConfig -> Rep UpsolverS3OutputFormatConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpsolverS3OutputFormatConfig x -> UpsolverS3OutputFormatConfig
$cfrom :: forall x.
UpsolverS3OutputFormatConfig -> Rep UpsolverS3OutputFormatConfig x
Prelude.Generic)

-- |
-- Create a value of 'UpsolverS3OutputFormatConfig' 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:
--
-- 'fileType', 'upsolverS3OutputFormatConfig_fileType' - Indicates the file type that Amazon AppFlow places in the Upsolver
-- Amazon S3 bucket.
--
-- 'aggregationConfig', 'upsolverS3OutputFormatConfig_aggregationConfig' - Undocumented member.
--
-- 'prefixConfig', 'upsolverS3OutputFormatConfig_prefixConfig' - Undocumented member.
newUpsolverS3OutputFormatConfig ::
  -- | 'prefixConfig'
  PrefixConfig ->
  UpsolverS3OutputFormatConfig
newUpsolverS3OutputFormatConfig :: PrefixConfig -> UpsolverS3OutputFormatConfig
newUpsolverS3OutputFormatConfig PrefixConfig
pPrefixConfig_ =
  UpsolverS3OutputFormatConfig' :: Maybe FileType
-> Maybe AggregationConfig
-> PrefixConfig
-> UpsolverS3OutputFormatConfig
UpsolverS3OutputFormatConfig'
    { $sel:fileType:UpsolverS3OutputFormatConfig' :: Maybe FileType
fileType =
        Maybe FileType
forall a. Maybe a
Prelude.Nothing,
      $sel:aggregationConfig:UpsolverS3OutputFormatConfig' :: Maybe AggregationConfig
aggregationConfig = Maybe AggregationConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:prefixConfig:UpsolverS3OutputFormatConfig' :: PrefixConfig
prefixConfig = PrefixConfig
pPrefixConfig_
    }

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

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

-- | Undocumented member.
upsolverS3OutputFormatConfig_prefixConfig :: Lens.Lens' UpsolverS3OutputFormatConfig PrefixConfig
upsolverS3OutputFormatConfig_prefixConfig :: (PrefixConfig -> f PrefixConfig)
-> UpsolverS3OutputFormatConfig -> f UpsolverS3OutputFormatConfig
upsolverS3OutputFormatConfig_prefixConfig = (UpsolverS3OutputFormatConfig -> PrefixConfig)
-> (UpsolverS3OutputFormatConfig
    -> PrefixConfig -> UpsolverS3OutputFormatConfig)
-> Lens
     UpsolverS3OutputFormatConfig
     UpsolverS3OutputFormatConfig
     PrefixConfig
     PrefixConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpsolverS3OutputFormatConfig' {PrefixConfig
prefixConfig :: PrefixConfig
$sel:prefixConfig:UpsolverS3OutputFormatConfig' :: UpsolverS3OutputFormatConfig -> PrefixConfig
prefixConfig} -> PrefixConfig
prefixConfig) (\s :: UpsolverS3OutputFormatConfig
s@UpsolverS3OutputFormatConfig' {} PrefixConfig
a -> UpsolverS3OutputFormatConfig
s {$sel:prefixConfig:UpsolverS3OutputFormatConfig' :: PrefixConfig
prefixConfig = PrefixConfig
a} :: UpsolverS3OutputFormatConfig)

instance Core.FromJSON UpsolverS3OutputFormatConfig where
  parseJSON :: Value -> Parser UpsolverS3OutputFormatConfig
parseJSON =
    String
-> (Object -> Parser UpsolverS3OutputFormatConfig)
-> Value
-> Parser UpsolverS3OutputFormatConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UpsolverS3OutputFormatConfig"
      ( \Object
x ->
          Maybe FileType
-> Maybe AggregationConfig
-> PrefixConfig
-> UpsolverS3OutputFormatConfig
UpsolverS3OutputFormatConfig'
            (Maybe FileType
 -> Maybe AggregationConfig
 -> PrefixConfig
 -> UpsolverS3OutputFormatConfig)
-> Parser (Maybe FileType)
-> Parser
     (Maybe AggregationConfig
      -> PrefixConfig -> UpsolverS3OutputFormatConfig)
forall (f :: * -> *) a b. Functor 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
   -> PrefixConfig -> UpsolverS3OutputFormatConfig)
-> Parser (Maybe AggregationConfig)
-> Parser (PrefixConfig -> UpsolverS3OutputFormatConfig)
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")
            Parser (PrefixConfig -> UpsolverS3OutputFormatConfig)
-> Parser PrefixConfig -> Parser UpsolverS3OutputFormatConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PrefixConfig
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"prefixConfig")
      )

instance
  Prelude.Hashable
    UpsolverS3OutputFormatConfig

instance Prelude.NFData UpsolverS3OutputFormatConfig

instance Core.ToJSON UpsolverS3OutputFormatConfig where
  toJSON :: UpsolverS3OutputFormatConfig -> Value
toJSON UpsolverS3OutputFormatConfig' {Maybe AggregationConfig
Maybe FileType
PrefixConfig
prefixConfig :: PrefixConfig
aggregationConfig :: Maybe AggregationConfig
fileType :: Maybe FileType
$sel:prefixConfig:UpsolverS3OutputFormatConfig' :: UpsolverS3OutputFormatConfig -> PrefixConfig
$sel:aggregationConfig:UpsolverS3OutputFormatConfig' :: UpsolverS3OutputFormatConfig -> Maybe AggregationConfig
$sel:fileType:UpsolverS3OutputFormatConfig' :: UpsolverS3OutputFormatConfig -> Maybe FileType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"prefixConfig" Text -> PrefixConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PrefixConfig
prefixConfig)
          ]
      )