{-# 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.Glue.Types.DataSource
-- 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.Glue.Types.DataSource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.GlueTable
import qualified Amazonka.Prelude as Prelude

-- | A data source (an Glue table) for which you want data quality results.
--
-- /See:/ 'newDataSource' smart constructor.
data DataSource = DataSource'
  { -- | An Glue table.
    DataSource -> GlueTable
glueTable :: GlueTable
  }
  deriving (DataSource -> DataSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataSource -> DataSource -> Bool
$c/= :: DataSource -> DataSource -> Bool
== :: DataSource -> DataSource -> Bool
$c== :: DataSource -> DataSource -> Bool
Prelude.Eq, ReadPrec [DataSource]
ReadPrec DataSource
Int -> ReadS DataSource
ReadS [DataSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataSource]
$creadListPrec :: ReadPrec [DataSource]
readPrec :: ReadPrec DataSource
$creadPrec :: ReadPrec DataSource
readList :: ReadS [DataSource]
$creadList :: ReadS [DataSource]
readsPrec :: Int -> ReadS DataSource
$creadsPrec :: Int -> ReadS DataSource
Prelude.Read, Int -> DataSource -> ShowS
[DataSource] -> ShowS
DataSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataSource] -> ShowS
$cshowList :: [DataSource] -> ShowS
show :: DataSource -> String
$cshow :: DataSource -> String
showsPrec :: Int -> DataSource -> ShowS
$cshowsPrec :: Int -> DataSource -> ShowS
Prelude.Show, forall x. Rep DataSource x -> DataSource
forall x. DataSource -> Rep DataSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataSource x -> DataSource
$cfrom :: forall x. DataSource -> Rep DataSource x
Prelude.Generic)

-- |
-- Create a value of 'DataSource' 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:
--
-- 'glueTable', 'dataSource_glueTable' - An Glue table.
newDataSource ::
  -- | 'glueTable'
  GlueTable ->
  DataSource
newDataSource :: GlueTable -> DataSource
newDataSource GlueTable
pGlueTable_ =
  DataSource' {$sel:glueTable:DataSource' :: GlueTable
glueTable = GlueTable
pGlueTable_}

-- | An Glue table.
dataSource_glueTable :: Lens.Lens' DataSource GlueTable
dataSource_glueTable :: Lens' DataSource GlueTable
dataSource_glueTable = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSource' {GlueTable
glueTable :: GlueTable
$sel:glueTable:DataSource' :: DataSource -> GlueTable
glueTable} -> GlueTable
glueTable) (\s :: DataSource
s@DataSource' {} GlueTable
a -> DataSource
s {$sel:glueTable:DataSource' :: GlueTable
glueTable = GlueTable
a} :: DataSource)

instance Data.FromJSON DataSource where
  parseJSON :: Value -> Parser DataSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataSource"
      ( \Object
x ->
          GlueTable -> DataSource
DataSource' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"GlueTable")
      )

instance Prelude.Hashable DataSource where
  hashWithSalt :: Int -> DataSource -> Int
hashWithSalt Int
_salt DataSource' {GlueTable
glueTable :: GlueTable
$sel:glueTable:DataSource' :: DataSource -> GlueTable
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` GlueTable
glueTable

instance Prelude.NFData DataSource where
  rnf :: DataSource -> ()
rnf DataSource' {GlueTable
glueTable :: GlueTable
$sel:glueTable:DataSource' :: DataSource -> GlueTable
..} = forall a. NFData a => a -> ()
Prelude.rnf GlueTable
glueTable

instance Data.ToJSON DataSource where
  toJSON :: DataSource -> Value
toJSON DataSource' {GlueTable
glueTable :: GlueTable
$sel:glueTable:DataSource' :: DataSource -> GlueTable
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"GlueTable" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= GlueTable
glueTable)]
      )