{-# 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.IoTSiteWise.Types.FileFormat
-- 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.IoTSiteWise.Types.FileFormat where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTSiteWise.Types.Csv
import qualified Amazonka.Prelude as Prelude

-- | The file format of the data.
--
-- /See:/ 'newFileFormat' smart constructor.
data FileFormat = FileFormat'
  { -- | The .csv file format.
    FileFormat -> Maybe Csv
csv :: Prelude.Maybe Csv
  }
  deriving (FileFormat -> FileFormat -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileFormat -> FileFormat -> Bool
$c/= :: FileFormat -> FileFormat -> Bool
== :: FileFormat -> FileFormat -> Bool
$c== :: FileFormat -> FileFormat -> Bool
Prelude.Eq, ReadPrec [FileFormat]
ReadPrec FileFormat
Int -> ReadS FileFormat
ReadS [FileFormat]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FileFormat]
$creadListPrec :: ReadPrec [FileFormat]
readPrec :: ReadPrec FileFormat
$creadPrec :: ReadPrec FileFormat
readList :: ReadS [FileFormat]
$creadList :: ReadS [FileFormat]
readsPrec :: Int -> ReadS FileFormat
$creadsPrec :: Int -> ReadS FileFormat
Prelude.Read, Int -> FileFormat -> ShowS
[FileFormat] -> ShowS
FileFormat -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileFormat] -> ShowS
$cshowList :: [FileFormat] -> ShowS
show :: FileFormat -> String
$cshow :: FileFormat -> String
showsPrec :: Int -> FileFormat -> ShowS
$cshowsPrec :: Int -> FileFormat -> ShowS
Prelude.Show, forall x. Rep FileFormat x -> FileFormat
forall x. FileFormat -> Rep FileFormat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FileFormat x -> FileFormat
$cfrom :: forall x. FileFormat -> Rep FileFormat x
Prelude.Generic)

-- |
-- Create a value of 'FileFormat' 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', 'fileFormat_csv' - The .csv file format.
newFileFormat ::
  FileFormat
newFileFormat :: FileFormat
newFileFormat = FileFormat' {$sel:csv:FileFormat' :: Maybe Csv
csv = forall a. Maybe a
Prelude.Nothing}

-- | The .csv file format.
fileFormat_csv :: Lens.Lens' FileFormat (Prelude.Maybe Csv)
fileFormat_csv :: Lens' FileFormat (Maybe Csv)
fileFormat_csv = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileFormat' {Maybe Csv
csv :: Maybe Csv
$sel:csv:FileFormat' :: FileFormat -> Maybe Csv
csv} -> Maybe Csv
csv) (\s :: FileFormat
s@FileFormat' {} Maybe Csv
a -> FileFormat
s {$sel:csv:FileFormat' :: Maybe Csv
csv = Maybe Csv
a} :: FileFormat)

instance Data.FromJSON FileFormat where
  parseJSON :: Value -> Parser FileFormat
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FileFormat"
      (\Object
x -> Maybe Csv -> FileFormat
FileFormat' 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 FileFormat where
  hashWithSalt :: Int -> FileFormat -> Int
hashWithSalt Int
_salt FileFormat' {Maybe Csv
csv :: Maybe Csv
$sel:csv:FileFormat' :: FileFormat -> Maybe Csv
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Csv
csv

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

instance Data.ToJSON FileFormat where
  toJSON :: FileFormat -> Value
toJSON FileFormat' {Maybe Csv
csv :: Maybe Csv
$sel:csv:FileFormat' :: FileFormat -> Maybe Csv
..} =
    [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 Csv
csv])