{-# 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.SparkConnectorTarget
-- 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.SparkConnectorTarget 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 target that uses an Apache Spark connector.
--
-- /See:/ 'newSparkConnectorTarget' smart constructor.
data SparkConnectorTarget = SparkConnectorTarget'
  { -- | Additional connection options for the connector.
    SparkConnectorTarget -> Maybe (HashMap Text Text)
additionalOptions :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Specifies the data schema for the custom spark target.
    SparkConnectorTarget -> Maybe [GlueSchema]
outputSchemas :: Prelude.Maybe [GlueSchema],
    -- | The name of the data target.
    SparkConnectorTarget -> Text
name :: Prelude.Text,
    -- | The nodes that are inputs to the data target.
    SparkConnectorTarget -> NonEmpty Text
inputs :: Prelude.NonEmpty Prelude.Text,
    -- | The name of a connection for an Apache Spark connector.
    SparkConnectorTarget -> Text
connectionName :: Prelude.Text,
    -- | The name of an Apache Spark connector.
    SparkConnectorTarget -> Text
connectorName :: Prelude.Text,
    -- | The type of connection, such as marketplace.spark or custom.spark,
    -- designating a connection to an Apache Spark data store.
    SparkConnectorTarget -> Text
connectionType :: Prelude.Text
  }
  deriving (SparkConnectorTarget -> SparkConnectorTarget -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SparkConnectorTarget -> SparkConnectorTarget -> Bool
$c/= :: SparkConnectorTarget -> SparkConnectorTarget -> Bool
== :: SparkConnectorTarget -> SparkConnectorTarget -> Bool
$c== :: SparkConnectorTarget -> SparkConnectorTarget -> Bool
Prelude.Eq, ReadPrec [SparkConnectorTarget]
ReadPrec SparkConnectorTarget
Int -> ReadS SparkConnectorTarget
ReadS [SparkConnectorTarget]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SparkConnectorTarget]
$creadListPrec :: ReadPrec [SparkConnectorTarget]
readPrec :: ReadPrec SparkConnectorTarget
$creadPrec :: ReadPrec SparkConnectorTarget
readList :: ReadS [SparkConnectorTarget]
$creadList :: ReadS [SparkConnectorTarget]
readsPrec :: Int -> ReadS SparkConnectorTarget
$creadsPrec :: Int -> ReadS SparkConnectorTarget
Prelude.Read, Int -> SparkConnectorTarget -> ShowS
[SparkConnectorTarget] -> ShowS
SparkConnectorTarget -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SparkConnectorTarget] -> ShowS
$cshowList :: [SparkConnectorTarget] -> ShowS
show :: SparkConnectorTarget -> String
$cshow :: SparkConnectorTarget -> String
showsPrec :: Int -> SparkConnectorTarget -> ShowS
$cshowsPrec :: Int -> SparkConnectorTarget -> ShowS
Prelude.Show, forall x. Rep SparkConnectorTarget x -> SparkConnectorTarget
forall x. SparkConnectorTarget -> Rep SparkConnectorTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SparkConnectorTarget x -> SparkConnectorTarget
$cfrom :: forall x. SparkConnectorTarget -> Rep SparkConnectorTarget x
Prelude.Generic)

-- |
-- Create a value of 'SparkConnectorTarget' 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', 'sparkConnectorTarget_additionalOptions' - Additional connection options for the connector.
--
-- 'outputSchemas', 'sparkConnectorTarget_outputSchemas' - Specifies the data schema for the custom spark target.
--
-- 'name', 'sparkConnectorTarget_name' - The name of the data target.
--
-- 'inputs', 'sparkConnectorTarget_inputs' - The nodes that are inputs to the data target.
--
-- 'connectionName', 'sparkConnectorTarget_connectionName' - The name of a connection for an Apache Spark connector.
--
-- 'connectorName', 'sparkConnectorTarget_connectorName' - The name of an Apache Spark connector.
--
-- 'connectionType', 'sparkConnectorTarget_connectionType' - The type of connection, such as marketplace.spark or custom.spark,
-- designating a connection to an Apache Spark data store.
newSparkConnectorTarget ::
  -- | 'name'
  Prelude.Text ->
  -- | 'inputs'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'connectionName'
  Prelude.Text ->
  -- | 'connectorName'
  Prelude.Text ->
  -- | 'connectionType'
  Prelude.Text ->
  SparkConnectorTarget
newSparkConnectorTarget :: Text
-> NonEmpty Text -> Text -> Text -> Text -> SparkConnectorTarget
newSparkConnectorTarget
  Text
pName_
  NonEmpty Text
pInputs_
  Text
pConnectionName_
  Text
pConnectorName_
  Text
pConnectionType_ =
    SparkConnectorTarget'
      { $sel:additionalOptions:SparkConnectorTarget' :: Maybe (HashMap Text Text)
additionalOptions =
          forall a. Maybe a
Prelude.Nothing,
        $sel:outputSchemas:SparkConnectorTarget' :: Maybe [GlueSchema]
outputSchemas = forall a. Maybe a
Prelude.Nothing,
        $sel:name:SparkConnectorTarget' :: Text
name = Text
pName_,
        $sel:inputs:SparkConnectorTarget' :: NonEmpty Text
inputs = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pInputs_,
        $sel:connectionName:SparkConnectorTarget' :: Text
connectionName = Text
pConnectionName_,
        $sel:connectorName:SparkConnectorTarget' :: Text
connectorName = Text
pConnectorName_,
        $sel:connectionType:SparkConnectorTarget' :: Text
connectionType = Text
pConnectionType_
      }

-- | Additional connection options for the connector.
sparkConnectorTarget_additionalOptions :: Lens.Lens' SparkConnectorTarget (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
sparkConnectorTarget_additionalOptions :: Lens' SparkConnectorTarget (Maybe (HashMap Text Text))
sparkConnectorTarget_additionalOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkConnectorTarget' {Maybe (HashMap Text Text)
additionalOptions :: Maybe (HashMap Text Text)
$sel:additionalOptions:SparkConnectorTarget' :: SparkConnectorTarget -> Maybe (HashMap Text Text)
additionalOptions} -> Maybe (HashMap Text Text)
additionalOptions) (\s :: SparkConnectorTarget
s@SparkConnectorTarget' {} Maybe (HashMap Text Text)
a -> SparkConnectorTarget
s {$sel:additionalOptions:SparkConnectorTarget' :: Maybe (HashMap Text Text)
additionalOptions = Maybe (HashMap Text Text)
a} :: SparkConnectorTarget) 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 the data schema for the custom spark target.
sparkConnectorTarget_outputSchemas :: Lens.Lens' SparkConnectorTarget (Prelude.Maybe [GlueSchema])
sparkConnectorTarget_outputSchemas :: Lens' SparkConnectorTarget (Maybe [GlueSchema])
sparkConnectorTarget_outputSchemas = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkConnectorTarget' {Maybe [GlueSchema]
outputSchemas :: Maybe [GlueSchema]
$sel:outputSchemas:SparkConnectorTarget' :: SparkConnectorTarget -> Maybe [GlueSchema]
outputSchemas} -> Maybe [GlueSchema]
outputSchemas) (\s :: SparkConnectorTarget
s@SparkConnectorTarget' {} Maybe [GlueSchema]
a -> SparkConnectorTarget
s {$sel:outputSchemas:SparkConnectorTarget' :: Maybe [GlueSchema]
outputSchemas = Maybe [GlueSchema]
a} :: SparkConnectorTarget) 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 target.
sparkConnectorTarget_name :: Lens.Lens' SparkConnectorTarget Prelude.Text
sparkConnectorTarget_name :: Lens' SparkConnectorTarget Text
sparkConnectorTarget_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkConnectorTarget' {Text
name :: Text
$sel:name:SparkConnectorTarget' :: SparkConnectorTarget -> Text
name} -> Text
name) (\s :: SparkConnectorTarget
s@SparkConnectorTarget' {} Text
a -> SparkConnectorTarget
s {$sel:name:SparkConnectorTarget' :: Text
name = Text
a} :: SparkConnectorTarget)

-- | The nodes that are inputs to the data target.
sparkConnectorTarget_inputs :: Lens.Lens' SparkConnectorTarget (Prelude.NonEmpty Prelude.Text)
sparkConnectorTarget_inputs :: Lens' SparkConnectorTarget (NonEmpty Text)
sparkConnectorTarget_inputs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkConnectorTarget' {NonEmpty Text
inputs :: NonEmpty Text
$sel:inputs:SparkConnectorTarget' :: SparkConnectorTarget -> NonEmpty Text
inputs} -> NonEmpty Text
inputs) (\s :: SparkConnectorTarget
s@SparkConnectorTarget' {} NonEmpty Text
a -> SparkConnectorTarget
s {$sel:inputs:SparkConnectorTarget' :: NonEmpty Text
inputs = NonEmpty Text
a} :: SparkConnectorTarget) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of a connection for an Apache Spark connector.
sparkConnectorTarget_connectionName :: Lens.Lens' SparkConnectorTarget Prelude.Text
sparkConnectorTarget_connectionName :: Lens' SparkConnectorTarget Text
sparkConnectorTarget_connectionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkConnectorTarget' {Text
connectionName :: Text
$sel:connectionName:SparkConnectorTarget' :: SparkConnectorTarget -> Text
connectionName} -> Text
connectionName) (\s :: SparkConnectorTarget
s@SparkConnectorTarget' {} Text
a -> SparkConnectorTarget
s {$sel:connectionName:SparkConnectorTarget' :: Text
connectionName = Text
a} :: SparkConnectorTarget)

-- | The name of an Apache Spark connector.
sparkConnectorTarget_connectorName :: Lens.Lens' SparkConnectorTarget Prelude.Text
sparkConnectorTarget_connectorName :: Lens' SparkConnectorTarget Text
sparkConnectorTarget_connectorName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SparkConnectorTarget' {Text
connectorName :: Text
$sel:connectorName:SparkConnectorTarget' :: SparkConnectorTarget -> Text
connectorName} -> Text
connectorName) (\s :: SparkConnectorTarget
s@SparkConnectorTarget' {} Text
a -> SparkConnectorTarget
s {$sel:connectorName:SparkConnectorTarget' :: Text
connectorName = Text
a} :: SparkConnectorTarget)

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

instance Data.FromJSON SparkConnectorTarget where
  parseJSON :: Value -> Parser SparkConnectorTarget
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SparkConnectorTarget"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe [GlueSchema]
-> Text
-> NonEmpty Text
-> Text
-> Text
-> Text
-> SparkConnectorTarget
SparkConnectorTarget'
            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
"Inputs")
            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 SparkConnectorTarget where
  hashWithSalt :: Int -> SparkConnectorTarget -> Int
hashWithSalt Int
_salt SparkConnectorTarget' {Maybe [GlueSchema]
Maybe (HashMap Text Text)
NonEmpty Text
Text
connectionType :: Text
connectorName :: Text
connectionName :: Text
inputs :: NonEmpty Text
name :: Text
outputSchemas :: Maybe [GlueSchema]
additionalOptions :: Maybe (HashMap Text Text)
$sel:connectionType:SparkConnectorTarget' :: SparkConnectorTarget -> Text
$sel:connectorName:SparkConnectorTarget' :: SparkConnectorTarget -> Text
$sel:connectionName:SparkConnectorTarget' :: SparkConnectorTarget -> Text
$sel:inputs:SparkConnectorTarget' :: SparkConnectorTarget -> NonEmpty Text
$sel:name:SparkConnectorTarget' :: SparkConnectorTarget -> Text
$sel:outputSchemas:SparkConnectorTarget' :: SparkConnectorTarget -> Maybe [GlueSchema]
$sel:additionalOptions:SparkConnectorTarget' :: SparkConnectorTarget -> 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` NonEmpty Text
inputs
      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 SparkConnectorTarget where
  rnf :: SparkConnectorTarget -> ()
rnf SparkConnectorTarget' {Maybe [GlueSchema]
Maybe (HashMap Text Text)
NonEmpty Text
Text
connectionType :: Text
connectorName :: Text
connectionName :: Text
inputs :: NonEmpty Text
name :: Text
outputSchemas :: Maybe [GlueSchema]
additionalOptions :: Maybe (HashMap Text Text)
$sel:connectionType:SparkConnectorTarget' :: SparkConnectorTarget -> Text
$sel:connectorName:SparkConnectorTarget' :: SparkConnectorTarget -> Text
$sel:connectionName:SparkConnectorTarget' :: SparkConnectorTarget -> Text
$sel:inputs:SparkConnectorTarget' :: SparkConnectorTarget -> NonEmpty Text
$sel:name:SparkConnectorTarget' :: SparkConnectorTarget -> Text
$sel:outputSchemas:SparkConnectorTarget' :: SparkConnectorTarget -> Maybe [GlueSchema]
$sel:additionalOptions:SparkConnectorTarget' :: SparkConnectorTarget -> 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 NonEmpty Text
inputs
      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 SparkConnectorTarget where
  toJSON :: SparkConnectorTarget -> Value
toJSON SparkConnectorTarget' {Maybe [GlueSchema]
Maybe (HashMap Text Text)
NonEmpty Text
Text
connectionType :: Text
connectorName :: Text
connectionName :: Text
inputs :: NonEmpty Text
name :: Text
outputSchemas :: Maybe [GlueSchema]
additionalOptions :: Maybe (HashMap Text Text)
$sel:connectionType:SparkConnectorTarget' :: SparkConnectorTarget -> Text
$sel:connectorName:SparkConnectorTarget' :: SparkConnectorTarget -> Text
$sel:connectionName:SparkConnectorTarget' :: SparkConnectorTarget -> Text
$sel:inputs:SparkConnectorTarget' :: SparkConnectorTarget -> NonEmpty Text
$sel:name:SparkConnectorTarget' :: SparkConnectorTarget -> Text
$sel:outputSchemas:SparkConnectorTarget' :: SparkConnectorTarget -> Maybe [GlueSchema]
$sel:additionalOptions:SparkConnectorTarget' :: SparkConnectorTarget -> 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
"Inputs" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
inputs),
            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)
          ]
      )