{-# 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 #-}
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
data InputSerialization = InputSerialization'
{
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)
newInputSerialization ::
InputSerialization
newInputSerialization :: InputSerialization
newInputSerialization =
InputSerialization' :: Maybe CSVInput -> InputSerialization
InputSerialization' {$sel:csv:InputSerialization' :: Maybe CSVInput
csv = Maybe CSVInput
forall a. Maybe a
Prelude.Nothing}
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])