{-# 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.OutputSerialization
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.S3.Types.OutputSerialization where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal
import Amazonka.S3.Types.CSVOutput
import Amazonka.S3.Types.JSONOutput

-- | Describes how results of the Select job are serialized.
--
-- /See:/ 'newOutputSerialization' smart constructor.
data OutputSerialization = OutputSerialization'
  { -- | Describes the serialization of CSV-encoded Select results.
    OutputSerialization -> Maybe CSVOutput
csv :: Prelude.Maybe CSVOutput,
    -- | Specifies JSON as request\'s output serialization format.
    OutputSerialization -> Maybe JSONOutput
json :: Prelude.Maybe JSONOutput
  }
  deriving (OutputSerialization -> OutputSerialization -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputSerialization -> OutputSerialization -> Bool
$c/= :: OutputSerialization -> OutputSerialization -> Bool
== :: OutputSerialization -> OutputSerialization -> Bool
$c== :: OutputSerialization -> OutputSerialization -> Bool
Prelude.Eq, ReadPrec [OutputSerialization]
ReadPrec OutputSerialization
Int -> ReadS OutputSerialization
ReadS [OutputSerialization]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OutputSerialization]
$creadListPrec :: ReadPrec [OutputSerialization]
readPrec :: ReadPrec OutputSerialization
$creadPrec :: ReadPrec OutputSerialization
readList :: ReadS [OutputSerialization]
$creadList :: ReadS [OutputSerialization]
readsPrec :: Int -> ReadS OutputSerialization
$creadsPrec :: Int -> ReadS OutputSerialization
Prelude.Read, Int -> OutputSerialization -> ShowS
[OutputSerialization] -> ShowS
OutputSerialization -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputSerialization] -> ShowS
$cshowList :: [OutputSerialization] -> ShowS
show :: OutputSerialization -> String
$cshow :: OutputSerialization -> String
showsPrec :: Int -> OutputSerialization -> ShowS
$cshowsPrec :: Int -> OutputSerialization -> ShowS
Prelude.Show, forall x. Rep OutputSerialization x -> OutputSerialization
forall x. OutputSerialization -> Rep OutputSerialization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OutputSerialization x -> OutputSerialization
$cfrom :: forall x. OutputSerialization -> Rep OutputSerialization x
Prelude.Generic)

-- |
-- Create a value of 'OutputSerialization' 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:
--
-- 'csv', 'outputSerialization_csv' - Describes the serialization of CSV-encoded Select results.
--
-- 'json', 'outputSerialization_json' - Specifies JSON as request\'s output serialization format.
newOutputSerialization ::
  OutputSerialization
newOutputSerialization :: OutputSerialization
newOutputSerialization =
  OutputSerialization'
    { $sel:csv:OutputSerialization' :: Maybe CSVOutput
csv = forall a. Maybe a
Prelude.Nothing,
      $sel:json:OutputSerialization' :: Maybe JSONOutput
json = forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the serialization of CSV-encoded Select results.
outputSerialization_csv :: Lens.Lens' OutputSerialization (Prelude.Maybe CSVOutput)
outputSerialization_csv :: Lens' OutputSerialization (Maybe CSVOutput)
outputSerialization_csv = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputSerialization' {Maybe CSVOutput
csv :: Maybe CSVOutput
$sel:csv:OutputSerialization' :: OutputSerialization -> Maybe CSVOutput
csv} -> Maybe CSVOutput
csv) (\s :: OutputSerialization
s@OutputSerialization' {} Maybe CSVOutput
a -> OutputSerialization
s {$sel:csv:OutputSerialization' :: Maybe CSVOutput
csv = Maybe CSVOutput
a} :: OutputSerialization)

-- | Specifies JSON as request\'s output serialization format.
outputSerialization_json :: Lens.Lens' OutputSerialization (Prelude.Maybe JSONOutput)
outputSerialization_json :: Lens' OutputSerialization (Maybe JSONOutput)
outputSerialization_json = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputSerialization' {Maybe JSONOutput
json :: Maybe JSONOutput
$sel:json:OutputSerialization' :: OutputSerialization -> Maybe JSONOutput
json} -> Maybe JSONOutput
json) (\s :: OutputSerialization
s@OutputSerialization' {} Maybe JSONOutput
a -> OutputSerialization
s {$sel:json:OutputSerialization' :: Maybe JSONOutput
json = Maybe JSONOutput
a} :: OutputSerialization)

instance Prelude.Hashable OutputSerialization where
  hashWithSalt :: Int -> OutputSerialization -> Int
hashWithSalt Int
_salt OutputSerialization' {Maybe JSONOutput
Maybe CSVOutput
json :: Maybe JSONOutput
csv :: Maybe CSVOutput
$sel:json:OutputSerialization' :: OutputSerialization -> Maybe JSONOutput
$sel:csv:OutputSerialization' :: OutputSerialization -> Maybe CSVOutput
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CSVOutput
csv
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe JSONOutput
json

instance Prelude.NFData OutputSerialization where
  rnf :: OutputSerialization -> ()
rnf OutputSerialization' {Maybe JSONOutput
Maybe CSVOutput
json :: Maybe JSONOutput
csv :: Maybe CSVOutput
$sel:json:OutputSerialization' :: OutputSerialization -> Maybe JSONOutput
$sel:csv:OutputSerialization' :: OutputSerialization -> Maybe CSVOutput
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CSVOutput
csv seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe JSONOutput
json

instance Data.ToXML OutputSerialization where
  toXML :: OutputSerialization -> XML
toXML OutputSerialization' {Maybe JSONOutput
Maybe CSVOutput
json :: Maybe JSONOutput
csv :: Maybe CSVOutput
$sel:json:OutputSerialization' :: OutputSerialization -> Maybe JSONOutput
$sel:csv:OutputSerialization' :: OutputSerialization -> Maybe CSVOutput
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [Name
"CSV" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe CSVOutput
csv, Name
"JSON" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe JSONOutput
json]