{-# 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.SparkConnectorSource
-- 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.SparkConnectorSource 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.GlueSchema
import qualified Amazonka.Prelude as Prelude

-- | Specifies a connector to an Apache Spark data source.
--
-- /See:/ 'newSparkConnectorSource' smart constructor.
data SparkConnectorSource = SparkConnectorSource'
  { -- | Additional connection options for the connector.
    SparkConnectorSource -> Maybe (HashMap Text Text)
additionalOptions :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Specifies data schema for the custom spark source.
    SparkConnectorSource -> Maybe [GlueSchema]
outputSchemas :: Prelude.Maybe [GlueSchema],
    -- | The name of the data source.
    SparkConnectorSource -> Text
name :: Prelude.Text,
    -- | The name of the connection that is associated with the connector.
    SparkConnectorSource -> Text
connectionName :: Prelude.Text,
    -- | The name of a connector that assists with accessing the data store in
    -- Glue Studio.
    SparkConnectorSource -> Text
connectorName :: Prelude.Text,
    -- | The type of connection, such as marketplace.spark or custom.spark,
    -- designating a connection to an Apache Spark data store.
    SparkConnectorSource -> Text
connectionType :: Prelude.Text
  }
  deriving (SparkConnectorSource -> SparkConnectorSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SparkConnectorSource -> SparkConnectorSource -> Bool
$c/= :: SparkConnectorSource -> SparkConnectorSource -> Bool
== :: SparkConnectorSource -> SparkConnectorSource -> Bool
$c== :: SparkConnectorSource -> SparkConnectorSource -> Bool
Prelude.Eq, ReadPrec [SparkConnectorSource]
ReadPrec SparkConnectorSource
Int -> ReadS SparkConnectorSource
ReadS [SparkConnectorSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SparkConnectorSource]
$creadListPrec :: ReadPrec [SparkConnectorSource]
readPrec :: ReadPrec SparkConnectorSource
$creadPrec :: ReadPrec SparkConnectorSource
readList :: ReadS [SparkConnectorSource]
$creadList :: ReadS [SparkConnectorSource]
readsPrec :: Int -> ReadS SparkConnectorSource
$creadsPrec :: Int -> ReadS SparkConnectorSource
Prelude.Read, Int -> SparkConnectorSource -> ShowS
[SparkConnectorSource] -> ShowS
SparkConnectorSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SparkConnectorSource] -> ShowS
$cshowList :: [SparkConnectorSource] -> ShowS
show :: SparkConnectorSource -> String
$cshow :: SparkConnectorSource -> String
showsPrec :: Int -> SparkConnectorSource -> ShowS
$cshowsPrec :: Int -> SparkConnectorSource -> ShowS
Prelude.Show, forall x. Rep SparkConnectorSource x -> SparkConnectorSource
forall x. SparkConnectorSource -> Rep SparkConnectorSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SparkConnectorSource x -> SparkConnectorSource
$cfrom :: forall x. SparkConnectorSource -> Rep SparkConnectorSource x
Prelude.Generic)

-- |
-- Create a value of 'SparkConnectorSource' 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:
--
-- 'additionalOptions', 'sparkConnectorSource_additionalOptions' - Additional connection options for the connector.
--
-- 'outputSchemas', 'sparkConnectorSource_outputSchemas' - Specifies data schema for the custom spark source.
--
-- 'name', 'sparkConnectorSource_name' - The name of the data source.
--
-- 'connectionName', 'sparkConnectorSource_connectionName' - The name of the connection that is associated with the connector.
--
-- 'connectorName', 'sparkConnectorSource_connectorName' - The name of a connector that assists with accessing the data store in
-- Glue Studio.
--
-- 'connectionType', 'sparkConnectorSource_connectionType' - The type of connection, such as marketplace.spark or custom.spark,
-- designating a connection to an Apache Spark data store.
newSparkConnectorSource ::
  -- | 'name'
  Prelude.Text ->
  -- | 'connectionName'
  Prelude.Text ->
  -- | 'connectorName'
  Prelude.Text ->
  -- | 'connectionType'
  Prelude.Text ->
  SparkConnectorSource
newSparkConnectorSource :: Text -> Text -> Text -> Text -> SparkConnectorSource
newSparkConnectorSource
  Text
pName_
  Text
pConnectionName_
  Text
pConnectorName_
  Text
pConnectionType_ =
    SparkConnectorSource'
      { $sel:additionalOptions:SparkConnectorSource' :: Maybe (HashMap Text Text)
additionalOptions =
          forall a. Maybe a
Prelude.Nothing,
        $sel:outputSchemas:SparkConnectorSource' :: Maybe [GlueSchema]
outputSchemas = forall a. Maybe a
Prelude.Nothing,
        $sel:name:SparkConnectorSource' :: Text
name = Text
pName_,
        $sel:connectionName:SparkConnectorSource' :: Text
connectionName = Text
pConnectionName_,
        $sel:connectorName:SparkConnectorSource' :: Text
connectorName = Text
pConnectorName_,
        $sel:connectionType:SparkConnectorSource' :: Text
connectionType = Text
pConnectionType_
      }

-- | Additional connection options for the connector.
sparkConnectorSource_additionalOptions :: Lens.Lens' SparkConnectorSource (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
sparkConnectorSource_additionalOptions :: Lens' SparkConnectorSource (Maybe (HashMap Text Text))
sparkConnectorSource_additionalOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkConnectorSource' {Maybe (HashMap Text Text)
additionalOptions :: Maybe (HashMap Text Text)
$sel:additionalOptions:SparkConnectorSource' :: SparkConnectorSource -> Maybe (HashMap Text Text)
additionalOptions} -> Maybe (HashMap Text Text)
additionalOptions) (\s :: SparkConnectorSource
s@SparkConnectorSource' {} Maybe (HashMap Text Text)
a -> SparkConnectorSource
s {$sel:additionalOptions:SparkConnectorSource' :: Maybe (HashMap Text Text)
additionalOptions = Maybe (HashMap Text Text)
a} :: SparkConnectorSource) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies data schema for the custom spark source.
sparkConnectorSource_outputSchemas :: Lens.Lens' SparkConnectorSource (Prelude.Maybe [GlueSchema])
sparkConnectorSource_outputSchemas :: Lens' SparkConnectorSource (Maybe [GlueSchema])
sparkConnectorSource_outputSchemas = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkConnectorSource' {Maybe [GlueSchema]
outputSchemas :: Maybe [GlueSchema]
$sel:outputSchemas:SparkConnectorSource' :: SparkConnectorSource -> Maybe [GlueSchema]
outputSchemas} -> Maybe [GlueSchema]
outputSchemas) (\s :: SparkConnectorSource
s@SparkConnectorSource' {} Maybe [GlueSchema]
a -> SparkConnectorSource
s {$sel:outputSchemas:SparkConnectorSource' :: Maybe [GlueSchema]
outputSchemas = Maybe [GlueSchema]
a} :: SparkConnectorSource) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the data source.
sparkConnectorSource_name :: Lens.Lens' SparkConnectorSource Prelude.Text
sparkConnectorSource_name :: Lens' SparkConnectorSource Text
sparkConnectorSource_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkConnectorSource' {Text
name :: Text
$sel:name:SparkConnectorSource' :: SparkConnectorSource -> Text
name} -> Text
name) (\s :: SparkConnectorSource
s@SparkConnectorSource' {} Text
a -> SparkConnectorSource
s {$sel:name:SparkConnectorSource' :: Text
name = Text
a} :: SparkConnectorSource)

-- | The name of the connection that is associated with the connector.
sparkConnectorSource_connectionName :: Lens.Lens' SparkConnectorSource Prelude.Text
sparkConnectorSource_connectionName :: Lens' SparkConnectorSource Text
sparkConnectorSource_connectionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkConnectorSource' {Text
connectionName :: Text
$sel:connectionName:SparkConnectorSource' :: SparkConnectorSource -> Text
connectionName} -> Text
connectionName) (\s :: SparkConnectorSource
s@SparkConnectorSource' {} Text
a -> SparkConnectorSource
s {$sel:connectionName:SparkConnectorSource' :: Text
connectionName = Text
a} :: SparkConnectorSource)

-- | The name of a connector that assists with accessing the data store in
-- Glue Studio.
sparkConnectorSource_connectorName :: Lens.Lens' SparkConnectorSource Prelude.Text
sparkConnectorSource_connectorName :: Lens' SparkConnectorSource Text
sparkConnectorSource_connectorName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkConnectorSource' {Text
connectorName :: Text
$sel:connectorName:SparkConnectorSource' :: SparkConnectorSource -> Text
connectorName} -> Text
connectorName) (\s :: SparkConnectorSource
s@SparkConnectorSource' {} Text
a -> SparkConnectorSource
s {$sel:connectorName:SparkConnectorSource' :: Text
connectorName = Text
a} :: SparkConnectorSource)

-- | The type of connection, such as marketplace.spark or custom.spark,
-- designating a connection to an Apache Spark data store.
sparkConnectorSource_connectionType :: Lens.Lens' SparkConnectorSource Prelude.Text
sparkConnectorSource_connectionType :: Lens' SparkConnectorSource Text
sparkConnectorSource_connectionType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkConnectorSource' {Text
connectionType :: Text
$sel:connectionType:SparkConnectorSource' :: SparkConnectorSource -> Text
connectionType} -> Text
connectionType) (\s :: SparkConnectorSource
s@SparkConnectorSource' {} Text
a -> SparkConnectorSource
s {$sel:connectionType:SparkConnectorSource' :: Text
connectionType = Text
a} :: SparkConnectorSource)

instance Data.FromJSON SparkConnectorSource where
  parseJSON :: Value -> Parser SparkConnectorSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SparkConnectorSource"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe [GlueSchema]
-> Text
-> Text
-> Text
-> Text
-> SparkConnectorSource
SparkConnectorSource'
            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
"AdditionalOptions"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"OutputSchemas" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ConnectionName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ConnectorName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ConnectionType")
      )

instance Prelude.Hashable SparkConnectorSource where
  hashWithSalt :: Int -> SparkConnectorSource -> Int
hashWithSalt Int
_salt SparkConnectorSource' {Maybe [GlueSchema]
Maybe (HashMap Text Text)
Text
connectionType :: Text
connectorName :: Text
connectionName :: Text
name :: Text
outputSchemas :: Maybe [GlueSchema]
additionalOptions :: Maybe (HashMap Text Text)
$sel:connectionType:SparkConnectorSource' :: SparkConnectorSource -> Text
$sel:connectorName:SparkConnectorSource' :: SparkConnectorSource -> Text
$sel:connectionName:SparkConnectorSource' :: SparkConnectorSource -> Text
$sel:name:SparkConnectorSource' :: SparkConnectorSource -> Text
$sel:outputSchemas:SparkConnectorSource' :: SparkConnectorSource -> Maybe [GlueSchema]
$sel:additionalOptions:SparkConnectorSource' :: SparkConnectorSource -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
additionalOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [GlueSchema]
outputSchemas
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectionName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectorName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectionType

instance Prelude.NFData SparkConnectorSource where
  rnf :: SparkConnectorSource -> ()
rnf SparkConnectorSource' {Maybe [GlueSchema]
Maybe (HashMap Text Text)
Text
connectionType :: Text
connectorName :: Text
connectionName :: Text
name :: Text
outputSchemas :: Maybe [GlueSchema]
additionalOptions :: Maybe (HashMap Text Text)
$sel:connectionType:SparkConnectorSource' :: SparkConnectorSource -> Text
$sel:connectorName:SparkConnectorSource' :: SparkConnectorSource -> Text
$sel:connectionName:SparkConnectorSource' :: SparkConnectorSource -> Text
$sel:name:SparkConnectorSource' :: SparkConnectorSource -> Text
$sel:outputSchemas:SparkConnectorSource' :: SparkConnectorSource -> Maybe [GlueSchema]
$sel:additionalOptions:SparkConnectorSource' :: SparkConnectorSource -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
additionalOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [GlueSchema]
outputSchemas
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
connectionName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
connectorName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
connectionType

instance Data.ToJSON SparkConnectorSource where
  toJSON :: SparkConnectorSource -> Value
toJSON SparkConnectorSource' {Maybe [GlueSchema]
Maybe (HashMap Text Text)
Text
connectionType :: Text
connectorName :: Text
connectionName :: Text
name :: Text
outputSchemas :: Maybe [GlueSchema]
additionalOptions :: Maybe (HashMap Text Text)
$sel:connectionType:SparkConnectorSource' :: SparkConnectorSource -> Text
$sel:connectorName:SparkConnectorSource' :: SparkConnectorSource -> Text
$sel:connectionName:SparkConnectorSource' :: SparkConnectorSource -> Text
$sel:name:SparkConnectorSource' :: SparkConnectorSource -> Text
$sel:outputSchemas:SparkConnectorSource' :: SparkConnectorSource -> Maybe [GlueSchema]
$sel:additionalOptions:SparkConnectorSource' :: SparkConnectorSource -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AdditionalOptions" 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 (HashMap Text Text)
additionalOptions,
            (Key
"OutputSchemas" 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 [GlueSchema]
outputSchemas,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ConnectionName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
connectionName),
            forall a. a -> Maybe a
Prelude.Just (Key
"ConnectorName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
connectorName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ConnectionType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
connectionType)
          ]
      )