{-# 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.Glacier.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.Glacier.Types.OutputSerialization where

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

-- | Describes how the select output is serialized.
--
-- /See:/ 'newOutputSerialization' smart constructor.
data OutputSerialization = OutputSerialization'
  { -- | Describes the serialization of CSV-encoded query results.
    OutputSerialization -> Maybe CSVOutput
csv :: Prelude.Maybe CSVOutput
  }
  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 query results.
newOutputSerialization ::
  OutputSerialization
newOutputSerialization :: OutputSerialization
newOutputSerialization =
  OutputSerialization' {$sel:csv:OutputSerialization' :: Maybe CSVOutput
csv = forall a. Maybe a
Prelude.Nothing}

-- | Describes the serialization of CSV-encoded query 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)

instance Data.FromJSON OutputSerialization where
  parseJSON :: Value -> Parser OutputSerialization
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OutputSerialization"
      ( \Object
x ->
          Maybe CSVOutput -> OutputSerialization
OutputSerialization' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"csv")
      )

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

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

instance Data.ToJSON OutputSerialization where
  toJSON :: OutputSerialization -> Value
toJSON OutputSerialization' {Maybe CSVOutput
csv :: Maybe CSVOutput
$sel:csv:OutputSerialization' :: OutputSerialization -> Maybe CSVOutput
..} =
    [Pair] -> Value
Data.object
      (forall a. [Maybe a] -> [a]
Prelude.catMaybes [(Key
"csv" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CSVOutput
csv])