{-# 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.Omics.Types.FormatOptions
-- 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.Omics.Types.FormatOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Omics.Types.TsvOptions
import Amazonka.Omics.Types.VcfOptions
import qualified Amazonka.Prelude as Prelude

-- | Formatting options for a file.
--
-- /See:/ 'newFormatOptions' smart constructor.
data FormatOptions = FormatOptions'
  { -- | Options for a TSV file.
    FormatOptions -> Maybe TsvOptions
tsvOptions :: Prelude.Maybe TsvOptions,
    -- | Options for a VCF file.
    FormatOptions -> Maybe VcfOptions
vcfOptions :: Prelude.Maybe VcfOptions
  }
  deriving (FormatOptions -> FormatOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FormatOptions -> FormatOptions -> Bool
$c/= :: FormatOptions -> FormatOptions -> Bool
== :: FormatOptions -> FormatOptions -> Bool
$c== :: FormatOptions -> FormatOptions -> Bool
Prelude.Eq, ReadPrec [FormatOptions]
ReadPrec FormatOptions
Int -> ReadS FormatOptions
ReadS [FormatOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FormatOptions]
$creadListPrec :: ReadPrec [FormatOptions]
readPrec :: ReadPrec FormatOptions
$creadPrec :: ReadPrec FormatOptions
readList :: ReadS [FormatOptions]
$creadList :: ReadS [FormatOptions]
readsPrec :: Int -> ReadS FormatOptions
$creadsPrec :: Int -> ReadS FormatOptions
Prelude.Read, Int -> FormatOptions -> ShowS
[FormatOptions] -> ShowS
FormatOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FormatOptions] -> ShowS
$cshowList :: [FormatOptions] -> ShowS
show :: FormatOptions -> String
$cshow :: FormatOptions -> String
showsPrec :: Int -> FormatOptions -> ShowS
$cshowsPrec :: Int -> FormatOptions -> ShowS
Prelude.Show, forall x. Rep FormatOptions x -> FormatOptions
forall x. FormatOptions -> Rep FormatOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FormatOptions x -> FormatOptions
$cfrom :: forall x. FormatOptions -> Rep FormatOptions x
Prelude.Generic)

-- |
-- Create a value of 'FormatOptions' 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:
--
-- 'tsvOptions', 'formatOptions_tsvOptions' - Options for a TSV file.
--
-- 'vcfOptions', 'formatOptions_vcfOptions' - Options for a VCF file.
newFormatOptions ::
  FormatOptions
newFormatOptions :: FormatOptions
newFormatOptions =
  FormatOptions'
    { $sel:tsvOptions:FormatOptions' :: Maybe TsvOptions
tsvOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:vcfOptions:FormatOptions' :: Maybe VcfOptions
vcfOptions = forall a. Maybe a
Prelude.Nothing
    }

-- | Options for a TSV file.
formatOptions_tsvOptions :: Lens.Lens' FormatOptions (Prelude.Maybe TsvOptions)
formatOptions_tsvOptions :: Lens' FormatOptions (Maybe TsvOptions)
formatOptions_tsvOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormatOptions' {Maybe TsvOptions
tsvOptions :: Maybe TsvOptions
$sel:tsvOptions:FormatOptions' :: FormatOptions -> Maybe TsvOptions
tsvOptions} -> Maybe TsvOptions
tsvOptions) (\s :: FormatOptions
s@FormatOptions' {} Maybe TsvOptions
a -> FormatOptions
s {$sel:tsvOptions:FormatOptions' :: Maybe TsvOptions
tsvOptions = Maybe TsvOptions
a} :: FormatOptions)

-- | Options for a VCF file.
formatOptions_vcfOptions :: Lens.Lens' FormatOptions (Prelude.Maybe VcfOptions)
formatOptions_vcfOptions :: Lens' FormatOptions (Maybe VcfOptions)
formatOptions_vcfOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormatOptions' {Maybe VcfOptions
vcfOptions :: Maybe VcfOptions
$sel:vcfOptions:FormatOptions' :: FormatOptions -> Maybe VcfOptions
vcfOptions} -> Maybe VcfOptions
vcfOptions) (\s :: FormatOptions
s@FormatOptions' {} Maybe VcfOptions
a -> FormatOptions
s {$sel:vcfOptions:FormatOptions' :: Maybe VcfOptions
vcfOptions = Maybe VcfOptions
a} :: FormatOptions)

instance Data.FromJSON FormatOptions where
  parseJSON :: Value -> Parser FormatOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FormatOptions"
      ( \Object
x ->
          Maybe TsvOptions -> Maybe VcfOptions -> FormatOptions
FormatOptions'
            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
"tsvOptions")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"vcfOptions")
      )

instance Prelude.Hashable FormatOptions where
  hashWithSalt :: Int -> FormatOptions -> Int
hashWithSalt Int
_salt FormatOptions' {Maybe TsvOptions
Maybe VcfOptions
vcfOptions :: Maybe VcfOptions
tsvOptions :: Maybe TsvOptions
$sel:vcfOptions:FormatOptions' :: FormatOptions -> Maybe VcfOptions
$sel:tsvOptions:FormatOptions' :: FormatOptions -> Maybe TsvOptions
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TsvOptions
tsvOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VcfOptions
vcfOptions

instance Prelude.NFData FormatOptions where
  rnf :: FormatOptions -> ()
rnf FormatOptions' {Maybe TsvOptions
Maybe VcfOptions
vcfOptions :: Maybe VcfOptions
tsvOptions :: Maybe TsvOptions
$sel:vcfOptions:FormatOptions' :: FormatOptions -> Maybe VcfOptions
$sel:tsvOptions:FormatOptions' :: FormatOptions -> Maybe TsvOptions
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe TsvOptions
tsvOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VcfOptions
vcfOptions

instance Data.ToJSON FormatOptions where
  toJSON :: FormatOptions -> Value
toJSON FormatOptions' {Maybe TsvOptions
Maybe VcfOptions
vcfOptions :: Maybe VcfOptions
tsvOptions :: Maybe TsvOptions
$sel:vcfOptions:FormatOptions' :: FormatOptions -> Maybe VcfOptions
$sel:tsvOptions:FormatOptions' :: FormatOptions -> Maybe TsvOptions
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"tsvOptions" 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 TsvOptions
tsvOptions,
            (Key
"vcfOptions" 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 VcfOptions
vcfOptions
          ]
      )