{-# 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.LookoutMetrics.Types.FileFormatDescriptor where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LookoutMetrics.Types.CsvFormatDescriptor
import Amazonka.LookoutMetrics.Types.JsonFormatDescriptor
import qualified Amazonka.Prelude as Prelude
data FileFormatDescriptor = FileFormatDescriptor'
{
FileFormatDescriptor -> Maybe JsonFormatDescriptor
jsonFormatDescriptor :: Prelude.Maybe JsonFormatDescriptor,
FileFormatDescriptor -> Maybe CsvFormatDescriptor
csvFormatDescriptor :: Prelude.Maybe CsvFormatDescriptor
}
deriving (FileFormatDescriptor -> FileFormatDescriptor -> Bool
(FileFormatDescriptor -> FileFormatDescriptor -> Bool)
-> (FileFormatDescriptor -> FileFormatDescriptor -> Bool)
-> Eq FileFormatDescriptor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileFormatDescriptor -> FileFormatDescriptor -> Bool
$c/= :: FileFormatDescriptor -> FileFormatDescriptor -> Bool
== :: FileFormatDescriptor -> FileFormatDescriptor -> Bool
$c== :: FileFormatDescriptor -> FileFormatDescriptor -> Bool
Prelude.Eq, ReadPrec [FileFormatDescriptor]
ReadPrec FileFormatDescriptor
Int -> ReadS FileFormatDescriptor
ReadS [FileFormatDescriptor]
(Int -> ReadS FileFormatDescriptor)
-> ReadS [FileFormatDescriptor]
-> ReadPrec FileFormatDescriptor
-> ReadPrec [FileFormatDescriptor]
-> Read FileFormatDescriptor
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FileFormatDescriptor]
$creadListPrec :: ReadPrec [FileFormatDescriptor]
readPrec :: ReadPrec FileFormatDescriptor
$creadPrec :: ReadPrec FileFormatDescriptor
readList :: ReadS [FileFormatDescriptor]
$creadList :: ReadS [FileFormatDescriptor]
readsPrec :: Int -> ReadS FileFormatDescriptor
$creadsPrec :: Int -> ReadS FileFormatDescriptor
Prelude.Read, Int -> FileFormatDescriptor -> ShowS
[FileFormatDescriptor] -> ShowS
FileFormatDescriptor -> String
(Int -> FileFormatDescriptor -> ShowS)
-> (FileFormatDescriptor -> String)
-> ([FileFormatDescriptor] -> ShowS)
-> Show FileFormatDescriptor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileFormatDescriptor] -> ShowS
$cshowList :: [FileFormatDescriptor] -> ShowS
show :: FileFormatDescriptor -> String
$cshow :: FileFormatDescriptor -> String
showsPrec :: Int -> FileFormatDescriptor -> ShowS
$cshowsPrec :: Int -> FileFormatDescriptor -> ShowS
Prelude.Show, (forall x. FileFormatDescriptor -> Rep FileFormatDescriptor x)
-> (forall x. Rep FileFormatDescriptor x -> FileFormatDescriptor)
-> Generic FileFormatDescriptor
forall x. Rep FileFormatDescriptor x -> FileFormatDescriptor
forall x. FileFormatDescriptor -> Rep FileFormatDescriptor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FileFormatDescriptor x -> FileFormatDescriptor
$cfrom :: forall x. FileFormatDescriptor -> Rep FileFormatDescriptor x
Prelude.Generic)
newFileFormatDescriptor ::
FileFormatDescriptor
newFileFormatDescriptor :: FileFormatDescriptor
newFileFormatDescriptor =
FileFormatDescriptor' :: Maybe JsonFormatDescriptor
-> Maybe CsvFormatDescriptor -> FileFormatDescriptor
FileFormatDescriptor'
{ $sel:jsonFormatDescriptor:FileFormatDescriptor' :: Maybe JsonFormatDescriptor
jsonFormatDescriptor =
Maybe JsonFormatDescriptor
forall a. Maybe a
Prelude.Nothing,
$sel:csvFormatDescriptor:FileFormatDescriptor' :: Maybe CsvFormatDescriptor
csvFormatDescriptor = Maybe CsvFormatDescriptor
forall a. Maybe a
Prelude.Nothing
}
fileFormatDescriptor_jsonFormatDescriptor :: Lens.Lens' FileFormatDescriptor (Prelude.Maybe JsonFormatDescriptor)
fileFormatDescriptor_jsonFormatDescriptor :: (Maybe JsonFormatDescriptor -> f (Maybe JsonFormatDescriptor))
-> FileFormatDescriptor -> f FileFormatDescriptor
fileFormatDescriptor_jsonFormatDescriptor = (FileFormatDescriptor -> Maybe JsonFormatDescriptor)
-> (FileFormatDescriptor
-> Maybe JsonFormatDescriptor -> FileFormatDescriptor)
-> Lens
FileFormatDescriptor
FileFormatDescriptor
(Maybe JsonFormatDescriptor)
(Maybe JsonFormatDescriptor)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileFormatDescriptor' {Maybe JsonFormatDescriptor
jsonFormatDescriptor :: Maybe JsonFormatDescriptor
$sel:jsonFormatDescriptor:FileFormatDescriptor' :: FileFormatDescriptor -> Maybe JsonFormatDescriptor
jsonFormatDescriptor} -> Maybe JsonFormatDescriptor
jsonFormatDescriptor) (\s :: FileFormatDescriptor
s@FileFormatDescriptor' {} Maybe JsonFormatDescriptor
a -> FileFormatDescriptor
s {$sel:jsonFormatDescriptor:FileFormatDescriptor' :: Maybe JsonFormatDescriptor
jsonFormatDescriptor = Maybe JsonFormatDescriptor
a} :: FileFormatDescriptor)
fileFormatDescriptor_csvFormatDescriptor :: Lens.Lens' FileFormatDescriptor (Prelude.Maybe CsvFormatDescriptor)
fileFormatDescriptor_csvFormatDescriptor :: (Maybe CsvFormatDescriptor -> f (Maybe CsvFormatDescriptor))
-> FileFormatDescriptor -> f FileFormatDescriptor
fileFormatDescriptor_csvFormatDescriptor = (FileFormatDescriptor -> Maybe CsvFormatDescriptor)
-> (FileFormatDescriptor
-> Maybe CsvFormatDescriptor -> FileFormatDescriptor)
-> Lens
FileFormatDescriptor
FileFormatDescriptor
(Maybe CsvFormatDescriptor)
(Maybe CsvFormatDescriptor)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileFormatDescriptor' {Maybe CsvFormatDescriptor
csvFormatDescriptor :: Maybe CsvFormatDescriptor
$sel:csvFormatDescriptor:FileFormatDescriptor' :: FileFormatDescriptor -> Maybe CsvFormatDescriptor
csvFormatDescriptor} -> Maybe CsvFormatDescriptor
csvFormatDescriptor) (\s :: FileFormatDescriptor
s@FileFormatDescriptor' {} Maybe CsvFormatDescriptor
a -> FileFormatDescriptor
s {$sel:csvFormatDescriptor:FileFormatDescriptor' :: Maybe CsvFormatDescriptor
csvFormatDescriptor = Maybe CsvFormatDescriptor
a} :: FileFormatDescriptor)
instance Core.FromJSON FileFormatDescriptor where
parseJSON :: Value -> Parser FileFormatDescriptor
parseJSON =
String
-> (Object -> Parser FileFormatDescriptor)
-> Value
-> Parser FileFormatDescriptor
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"FileFormatDescriptor"
( \Object
x ->
Maybe JsonFormatDescriptor
-> Maybe CsvFormatDescriptor -> FileFormatDescriptor
FileFormatDescriptor'
(Maybe JsonFormatDescriptor
-> Maybe CsvFormatDescriptor -> FileFormatDescriptor)
-> Parser (Maybe JsonFormatDescriptor)
-> Parser (Maybe CsvFormatDescriptor -> FileFormatDescriptor)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe JsonFormatDescriptor)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"JsonFormatDescriptor")
Parser (Maybe CsvFormatDescriptor -> FileFormatDescriptor)
-> Parser (Maybe CsvFormatDescriptor)
-> Parser FileFormatDescriptor
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CsvFormatDescriptor)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CsvFormatDescriptor")
)
instance Prelude.Hashable FileFormatDescriptor
instance Prelude.NFData FileFormatDescriptor
instance Core.ToJSON FileFormatDescriptor where
toJSON :: FileFormatDescriptor -> Value
toJSON FileFormatDescriptor' {Maybe CsvFormatDescriptor
Maybe JsonFormatDescriptor
csvFormatDescriptor :: Maybe CsvFormatDescriptor
jsonFormatDescriptor :: Maybe JsonFormatDescriptor
$sel:csvFormatDescriptor:FileFormatDescriptor' :: FileFormatDescriptor -> Maybe CsvFormatDescriptor
$sel:jsonFormatDescriptor:FileFormatDescriptor' :: FileFormatDescriptor -> Maybe JsonFormatDescriptor
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"JsonFormatDescriptor" Text -> JsonFormatDescriptor -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(JsonFormatDescriptor -> Pair)
-> Maybe JsonFormatDescriptor -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JsonFormatDescriptor
jsonFormatDescriptor,
(Text
"CsvFormatDescriptor" Text -> CsvFormatDescriptor -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(CsvFormatDescriptor -> Pair)
-> Maybe CsvFormatDescriptor -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CsvFormatDescriptor
csvFormatDescriptor
]
)