{-# 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.FinSpaceData.Types.SchemaUnion
-- 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.FinSpaceData.Types.SchemaUnion where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FinSpaceData.Types.SchemaDefinition
import qualified Amazonka.Prelude as Prelude

-- | A union of schema types.
--
-- /See:/ 'newSchemaUnion' smart constructor.
data SchemaUnion = SchemaUnion'
  { -- | The configuration for a schema on a tabular Dataset.
    SchemaUnion -> Maybe SchemaDefinition
tabularSchemaConfig :: Prelude.Maybe SchemaDefinition
  }
  deriving (SchemaUnion -> SchemaUnion -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SchemaUnion -> SchemaUnion -> Bool
$c/= :: SchemaUnion -> SchemaUnion -> Bool
== :: SchemaUnion -> SchemaUnion -> Bool
$c== :: SchemaUnion -> SchemaUnion -> Bool
Prelude.Eq, ReadPrec [SchemaUnion]
ReadPrec SchemaUnion
Int -> ReadS SchemaUnion
ReadS [SchemaUnion]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SchemaUnion]
$creadListPrec :: ReadPrec [SchemaUnion]
readPrec :: ReadPrec SchemaUnion
$creadPrec :: ReadPrec SchemaUnion
readList :: ReadS [SchemaUnion]
$creadList :: ReadS [SchemaUnion]
readsPrec :: Int -> ReadS SchemaUnion
$creadsPrec :: Int -> ReadS SchemaUnion
Prelude.Read, Int -> SchemaUnion -> ShowS
[SchemaUnion] -> ShowS
SchemaUnion -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SchemaUnion] -> ShowS
$cshowList :: [SchemaUnion] -> ShowS
show :: SchemaUnion -> String
$cshow :: SchemaUnion -> String
showsPrec :: Int -> SchemaUnion -> ShowS
$cshowsPrec :: Int -> SchemaUnion -> ShowS
Prelude.Show, forall x. Rep SchemaUnion x -> SchemaUnion
forall x. SchemaUnion -> Rep SchemaUnion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SchemaUnion x -> SchemaUnion
$cfrom :: forall x. SchemaUnion -> Rep SchemaUnion x
Prelude.Generic)

-- |
-- Create a value of 'SchemaUnion' 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:
--
-- 'tabularSchemaConfig', 'schemaUnion_tabularSchemaConfig' - The configuration for a schema on a tabular Dataset.
newSchemaUnion ::
  SchemaUnion
newSchemaUnion :: SchemaUnion
newSchemaUnion =
  SchemaUnion' {$sel:tabularSchemaConfig:SchemaUnion' :: Maybe SchemaDefinition
tabularSchemaConfig = forall a. Maybe a
Prelude.Nothing}

-- | The configuration for a schema on a tabular Dataset.
schemaUnion_tabularSchemaConfig :: Lens.Lens' SchemaUnion (Prelude.Maybe SchemaDefinition)
schemaUnion_tabularSchemaConfig :: Lens' SchemaUnion (Maybe SchemaDefinition)
schemaUnion_tabularSchemaConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaUnion' {Maybe SchemaDefinition
tabularSchemaConfig :: Maybe SchemaDefinition
$sel:tabularSchemaConfig:SchemaUnion' :: SchemaUnion -> Maybe SchemaDefinition
tabularSchemaConfig} -> Maybe SchemaDefinition
tabularSchemaConfig) (\s :: SchemaUnion
s@SchemaUnion' {} Maybe SchemaDefinition
a -> SchemaUnion
s {$sel:tabularSchemaConfig:SchemaUnion' :: Maybe SchemaDefinition
tabularSchemaConfig = Maybe SchemaDefinition
a} :: SchemaUnion)

instance Data.FromJSON SchemaUnion where
  parseJSON :: Value -> Parser SchemaUnion
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SchemaUnion"
      ( \Object
x ->
          Maybe SchemaDefinition -> SchemaUnion
SchemaUnion'
            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
"tabularSchemaConfig")
      )

instance Prelude.Hashable SchemaUnion where
  hashWithSalt :: Int -> SchemaUnion -> Int
hashWithSalt Int
_salt SchemaUnion' {Maybe SchemaDefinition
tabularSchemaConfig :: Maybe SchemaDefinition
$sel:tabularSchemaConfig:SchemaUnion' :: SchemaUnion -> Maybe SchemaDefinition
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SchemaDefinition
tabularSchemaConfig

instance Prelude.NFData SchemaUnion where
  rnf :: SchemaUnion -> ()
rnf SchemaUnion' {Maybe SchemaDefinition
tabularSchemaConfig :: Maybe SchemaDefinition
$sel:tabularSchemaConfig:SchemaUnion' :: SchemaUnion -> Maybe SchemaDefinition
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SchemaDefinition
tabularSchemaConfig

instance Data.ToJSON SchemaUnion where
  toJSON :: SchemaUnion -> Value
toJSON SchemaUnion' {Maybe SchemaDefinition
tabularSchemaConfig :: Maybe SchemaDefinition
$sel:tabularSchemaConfig:SchemaUnion' :: SchemaUnion -> Maybe SchemaDefinition
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"tabularSchemaConfig" 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 SchemaDefinition
tabularSchemaConfig
          ]
      )