{-# 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.S3.Types.InputSerialization
-- 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.S3.Types.InputSerialization where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal
import Amazonka.S3.Types.CSVInput
import Amazonka.S3.Types.CompressionType
import Amazonka.S3.Types.JSONInput
import Amazonka.S3.Types.ParquetInput

-- | Describes the serialization format of the object.
--
-- /See:/ 'newInputSerialization' smart constructor.
data InputSerialization = InputSerialization'
  { -- | Specifies JSON as object\'s input serialization format.
    InputSerialization -> Maybe JSONInput
json :: Prelude.Maybe JSONInput,
    -- | Describes the serialization of a CSV-encoded object.
    InputSerialization -> Maybe CSVInput
csv :: Prelude.Maybe CSVInput,
    -- | Specifies Parquet as object\'s input serialization format.
    InputSerialization -> Maybe ParquetInput
parquet :: Prelude.Maybe ParquetInput,
    -- | Specifies object\'s compression format. Valid values: NONE, GZIP, BZIP2.
    -- Default Value: NONE.
    InputSerialization -> Maybe CompressionType
compressionType :: Prelude.Maybe CompressionType
  }
  deriving (InputSerialization -> InputSerialization -> Bool
(InputSerialization -> InputSerialization -> Bool)
-> (InputSerialization -> InputSerialization -> Bool)
-> Eq InputSerialization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputSerialization -> InputSerialization -> Bool
$c/= :: InputSerialization -> InputSerialization -> Bool
== :: InputSerialization -> InputSerialization -> Bool
$c== :: InputSerialization -> InputSerialization -> Bool
Prelude.Eq, ReadPrec [InputSerialization]
ReadPrec InputSerialization
Int -> ReadS InputSerialization
ReadS [InputSerialization]
(Int -> ReadS InputSerialization)
-> ReadS [InputSerialization]
-> ReadPrec InputSerialization
-> ReadPrec [InputSerialization]
-> Read InputSerialization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputSerialization]
$creadListPrec :: ReadPrec [InputSerialization]
readPrec :: ReadPrec InputSerialization
$creadPrec :: ReadPrec InputSerialization
readList :: ReadS [InputSerialization]
$creadList :: ReadS [InputSerialization]
readsPrec :: Int -> ReadS InputSerialization
$creadsPrec :: Int -> ReadS InputSerialization
Prelude.Read, Int -> InputSerialization -> ShowS
[InputSerialization] -> ShowS
InputSerialization -> String
(Int -> InputSerialization -> ShowS)
-> (InputSerialization -> String)
-> ([InputSerialization] -> ShowS)
-> Show InputSerialization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputSerialization] -> ShowS
$cshowList :: [InputSerialization] -> ShowS
show :: InputSerialization -> String
$cshow :: InputSerialization -> String
showsPrec :: Int -> InputSerialization -> ShowS
$cshowsPrec :: Int -> InputSerialization -> ShowS
Prelude.Show, (forall x. InputSerialization -> Rep InputSerialization x)
-> (forall x. Rep InputSerialization x -> InputSerialization)
-> Generic InputSerialization
forall x. Rep InputSerialization x -> InputSerialization
forall x. InputSerialization -> Rep InputSerialization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputSerialization x -> InputSerialization
$cfrom :: forall x. InputSerialization -> Rep InputSerialization x
Prelude.Generic)

-- |
-- Create a value of 'InputSerialization' 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:
--
-- 'json', 'inputSerialization_json' - Specifies JSON as object\'s input serialization format.
--
-- 'csv', 'inputSerialization_csv' - Describes the serialization of a CSV-encoded object.
--
-- 'parquet', 'inputSerialization_parquet' - Specifies Parquet as object\'s input serialization format.
--
-- 'compressionType', 'inputSerialization_compressionType' - Specifies object\'s compression format. Valid values: NONE, GZIP, BZIP2.
-- Default Value: NONE.
newInputSerialization ::
  InputSerialization
newInputSerialization :: InputSerialization
newInputSerialization =
  InputSerialization' :: Maybe JSONInput
-> Maybe CSVInput
-> Maybe ParquetInput
-> Maybe CompressionType
-> InputSerialization
InputSerialization'
    { $sel:json:InputSerialization' :: Maybe JSONInput
json = Maybe JSONInput
forall a. Maybe a
Prelude.Nothing,
      $sel:csv:InputSerialization' :: Maybe CSVInput
csv = Maybe CSVInput
forall a. Maybe a
Prelude.Nothing,
      $sel:parquet:InputSerialization' :: Maybe ParquetInput
parquet = Maybe ParquetInput
forall a. Maybe a
Prelude.Nothing,
      $sel:compressionType:InputSerialization' :: Maybe CompressionType
compressionType = Maybe CompressionType
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies JSON as object\'s input serialization format.
inputSerialization_json :: Lens.Lens' InputSerialization (Prelude.Maybe JSONInput)
inputSerialization_json :: (Maybe JSONInput -> f (Maybe JSONInput))
-> InputSerialization -> f InputSerialization
inputSerialization_json = (InputSerialization -> Maybe JSONInput)
-> (InputSerialization -> Maybe JSONInput -> InputSerialization)
-> Lens
     InputSerialization
     InputSerialization
     (Maybe JSONInput)
     (Maybe JSONInput)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSerialization' {Maybe JSONInput
json :: Maybe JSONInput
$sel:json:InputSerialization' :: InputSerialization -> Maybe JSONInput
json} -> Maybe JSONInput
json) (\s :: InputSerialization
s@InputSerialization' {} Maybe JSONInput
a -> InputSerialization
s {$sel:json:InputSerialization' :: Maybe JSONInput
json = Maybe JSONInput
a} :: InputSerialization)

-- | Describes the serialization of a CSV-encoded object.
inputSerialization_csv :: Lens.Lens' InputSerialization (Prelude.Maybe CSVInput)
inputSerialization_csv :: (Maybe CSVInput -> f (Maybe CSVInput))
-> InputSerialization -> f InputSerialization
inputSerialization_csv = (InputSerialization -> Maybe CSVInput)
-> (InputSerialization -> Maybe CSVInput -> InputSerialization)
-> Lens
     InputSerialization
     InputSerialization
     (Maybe CSVInput)
     (Maybe CSVInput)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSerialization' {Maybe CSVInput
csv :: Maybe CSVInput
$sel:csv:InputSerialization' :: InputSerialization -> Maybe CSVInput
csv} -> Maybe CSVInput
csv) (\s :: InputSerialization
s@InputSerialization' {} Maybe CSVInput
a -> InputSerialization
s {$sel:csv:InputSerialization' :: Maybe CSVInput
csv = Maybe CSVInput
a} :: InputSerialization)

-- | Specifies Parquet as object\'s input serialization format.
inputSerialization_parquet :: Lens.Lens' InputSerialization (Prelude.Maybe ParquetInput)
inputSerialization_parquet :: (Maybe ParquetInput -> f (Maybe ParquetInput))
-> InputSerialization -> f InputSerialization
inputSerialization_parquet = (InputSerialization -> Maybe ParquetInput)
-> (InputSerialization -> Maybe ParquetInput -> InputSerialization)
-> Lens
     InputSerialization
     InputSerialization
     (Maybe ParquetInput)
     (Maybe ParquetInput)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSerialization' {Maybe ParquetInput
parquet :: Maybe ParquetInput
$sel:parquet:InputSerialization' :: InputSerialization -> Maybe ParquetInput
parquet} -> Maybe ParquetInput
parquet) (\s :: InputSerialization
s@InputSerialization' {} Maybe ParquetInput
a -> InputSerialization
s {$sel:parquet:InputSerialization' :: Maybe ParquetInput
parquet = Maybe ParquetInput
a} :: InputSerialization)

-- | Specifies object\'s compression format. Valid values: NONE, GZIP, BZIP2.
-- Default Value: NONE.
inputSerialization_compressionType :: Lens.Lens' InputSerialization (Prelude.Maybe CompressionType)
inputSerialization_compressionType :: (Maybe CompressionType -> f (Maybe CompressionType))
-> InputSerialization -> f InputSerialization
inputSerialization_compressionType = (InputSerialization -> Maybe CompressionType)
-> (InputSerialization
    -> Maybe CompressionType -> InputSerialization)
-> Lens
     InputSerialization
     InputSerialization
     (Maybe CompressionType)
     (Maybe CompressionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSerialization' {Maybe CompressionType
compressionType :: Maybe CompressionType
$sel:compressionType:InputSerialization' :: InputSerialization -> Maybe CompressionType
compressionType} -> Maybe CompressionType
compressionType) (\s :: InputSerialization
s@InputSerialization' {} Maybe CompressionType
a -> InputSerialization
s {$sel:compressionType:InputSerialization' :: Maybe CompressionType
compressionType = Maybe CompressionType
a} :: InputSerialization)

instance Prelude.Hashable InputSerialization

instance Prelude.NFData InputSerialization

instance Core.ToXML InputSerialization where
  toXML :: InputSerialization -> XML
toXML InputSerialization' {Maybe CompressionType
Maybe CSVInput
Maybe JSONInput
Maybe ParquetInput
compressionType :: Maybe CompressionType
parquet :: Maybe ParquetInput
csv :: Maybe CSVInput
json :: Maybe JSONInput
$sel:compressionType:InputSerialization' :: InputSerialization -> Maybe CompressionType
$sel:parquet:InputSerialization' :: InputSerialization -> Maybe ParquetInput
$sel:csv:InputSerialization' :: InputSerialization -> Maybe CSVInput
$sel:json:InputSerialization' :: InputSerialization -> Maybe JSONInput
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"JSON" Name -> Maybe JSONInput -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe JSONInput
json,
        Name
"CSV" Name -> Maybe CSVInput -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe CSVInput
csv,
        Name
"Parquet" Name -> Maybe ParquetInput -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe ParquetInput
parquet,
        Name
"CompressionType" Name -> Maybe CompressionType -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe CompressionType
compressionType
      ]