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

import qualified Amazonka.Core as Core
import Amazonka.Glacier.Types.CSVInput
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes how the archive is serialized.
--
-- /See:/ 'newInputSerialization' smart constructor.
data InputSerialization = InputSerialization'
  { -- | Describes the serialization of a CSV-encoded object.
    InputSerialization -> Maybe CSVInput
csv :: Prelude.Maybe CSVInput
  }
  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:
--
-- 'csv', 'inputSerialization_csv' - Describes the serialization of a CSV-encoded object.
newInputSerialization ::
  InputSerialization
newInputSerialization :: InputSerialization
newInputSerialization =
  InputSerialization' :: Maybe CSVInput -> InputSerialization
InputSerialization' {$sel:csv:InputSerialization' :: Maybe CSVInput
csv = Maybe CSVInput
forall a. Maybe a
Prelude.Nothing}

-- | 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)

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

instance Prelude.Hashable InputSerialization

instance Prelude.NFData InputSerialization

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