salesforce-data-customcode 6.1.0.dev3__py3-none-any.whl → 6.1.0.dev5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. datacustomcode/__init__.py +5 -0
  2. datacustomcode/cli.py +30 -5
  3. datacustomcode/client.py +267 -192
  4. datacustomcode/config.py +5 -0
  5. datacustomcode/config.yaml +0 -6
  6. datacustomcode/constants.py +9 -1
  7. datacustomcode/deploy.py +58 -24
  8. datacustomcode/function/runtime.py +0 -16
  9. datacustomcode/io/reader/base.py +42 -0
  10. datacustomcode/io/writer/base.py +45 -0
  11. datacustomcode/io/writer/csv.py +8 -0
  12. datacustomcode/io/writer/print.py +7 -0
  13. datacustomcode/run.py +11 -7
  14. datacustomcode/scan.py +164 -29
  15. datacustomcode/template.py +13 -1
  16. datacustomcode/templates/script/examples/streaming_deltas/entrypoint.py +62 -0
  17. datacustomcode/templates/script/jupyterlab.sh +18 -4
  18. {salesforce_data_customcode-6.1.0.dev3.dist-info → salesforce_data_customcode-6.1.0.dev5.dist-info}/METADATA +42 -5
  19. {salesforce_data_customcode-6.1.0.dev3.dist-info → salesforce_data_customcode-6.1.0.dev5.dist-info}/RECORD +22 -44
  20. datacustomcode/named_credential/__init__.py +0 -28
  21. datacustomcode/named_credential/base.py +0 -54
  22. datacustomcode/named_credential/default.py +0 -93
  23. datacustomcode/named_credential/direct/__init__.py +0 -19
  24. datacustomcode/named_credential/direct/auth.py +0 -63
  25. datacustomcode/named_credential/direct/credentials.py +0 -121
  26. datacustomcode/named_credential/direct/transport.py +0 -110
  27. datacustomcode/named_credential/direct/url_resolver.py +0 -112
  28. datacustomcode/named_credential/errors.py +0 -36
  29. datacustomcode/named_credential/spark_base.py +0 -93
  30. datacustomcode/named_credential/spark_default.py +0 -154
  31. datacustomcode/named_credential/types/__init__.py +0 -14
  32. datacustomcode/named_credential/types/http_method.py +0 -29
  33. datacustomcode/named_credential/types/http_request.py +0 -63
  34. datacustomcode/named_credential/types/http_request_builder.py +0 -55
  35. datacustomcode/named_credential/types/http_response.py +0 -43
  36. datacustomcode/named_credential/types/http_response_builder.py +0 -24
  37. datacustomcode/named_credential_config.py +0 -105
  38. datacustomcode/templates/function/example/chunking_with_external_callout/README.md +0 -119
  39. datacustomcode/templates/function/example/chunking_with_external_callout/config.json +0 -3
  40. datacustomcode/templates/function/example/chunking_with_external_callout/entrypoint.py +0 -161
  41. datacustomcode/templates/function/example/chunking_with_external_callout/external_callout_config.json +0 -11
  42. datacustomcode/templates/function/example/chunking_with_external_callout/tests/test.json +0 -16
  43. {salesforce_data_customcode-6.1.0.dev3.dist-info → salesforce_data_customcode-6.1.0.dev5.dist-info}/WHEEL +0 -0
  44. {salesforce_data_customcode-6.1.0.dev3.dist-info → salesforce_data_customcode-6.1.0.dev5.dist-info}/entry_points.txt +0 -0
  45. {salesforce_data_customcode-6.1.0.dev3.dist-info → salesforce_data_customcode-6.1.0.dev5.dist-info}/licenses/LICENSE.txt +0 -0
@@ -1,93 +0,0 @@
1
- # Copyright (c) 2025, Salesforce, Inc.
2
- # SPDX-License-Identifier: Apache-2
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- from __future__ import annotations
16
-
17
- from abc import ABC, abstractmethod
18
- from typing import (
19
- TYPE_CHECKING,
20
- Any,
21
- Optional,
22
- )
23
-
24
- from datacustomcode.mixin import UserExtendableNamedConfigMixin
25
-
26
- if TYPE_CHECKING:
27
- from pyspark.sql import Column
28
-
29
- from datacustomcode.named_credential.types.http_request import HTTPRequest
30
- from datacustomcode.named_credential.types.http_response import HTTPResponse
31
-
32
-
33
- class SparkNamedCredential(ABC, UserExtendableNamedConfigMixin):
34
- """Named Credential external callout for script (Spark) code.
35
-
36
- The callout is a one-shot request that runs on the driver. The endpoint and
37
- its authentication are resolved from the Named Credential referenced by
38
- ``request.url``.
39
- """
40
-
41
- CONFIG_NAME: str
42
-
43
- def __init__(self, **kwargs: Any) -> None:
44
- pass
45
-
46
- @abstractmethod
47
- def request(
48
- self,
49
- request: HTTPRequest,
50
- body: Optional[str] = None,
51
- ) -> HTTPResponse:
52
- """Make an external callout through a Named Credential.
53
-
54
- Args:
55
- request: The callout request
56
- body: Optional request body. Set the
57
- ``Content-Type`` header yourself; the SDK does not assume one.
58
-
59
- Returns:
60
- The external service's response.
61
- """
62
- ...
63
-
64
- @abstractmethod
65
- def request_col(
66
- self,
67
- request: HTTPRequest,
68
- body: Optional["Column"] = None,
69
- ) -> "Column":
70
- """Build a Spark ``Column`` that makes one external callout per row.
71
-
72
- The endpoint, method, and headers are fixed for the call (taken from
73
- ``request``); only ``body`` varies per row. Use this instead of
74
- :meth:`request` when the callout runs across a DataFrame so each row is
75
- dispatched independently rather than one-shot on the driver.
76
-
77
- Args:
78
- request: The callout template
79
- body: Optional per-row ``Column`` holding the request body as a
80
- string, sent verbatim (or null for no body).
81
-
82
- Returns:
83
- A ``Column`` yielding a struct
84
- ``{status, response, error_code, error_message}``. ``response`` is
85
- itself a struct ``{status_code, body, headers}`` carrying the callout
86
- response. Select a field with ``[...]``, e.g.
87
- ``request_col(...)["response"]["status_code"]``. Returning a struct
88
- means a single failing row does not abort the Spark job — a transport
89
- failure sets ``status`` to ``ERROR`` with ``error_message``, while a
90
- non-2xx HTTP response stays ``SUCCESS`` with its code in
91
- ``response.status_code``.
92
- """
93
- ...
@@ -1,154 +0,0 @@
1
- # Copyright (c) 2025, Salesforce, Inc.
2
- # SPDX-License-Identifier: Apache-2
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- from __future__ import annotations
16
-
17
- from typing import (
18
- TYPE_CHECKING,
19
- Any,
20
- Dict,
21
- Optional,
22
- )
23
-
24
- from datacustomcode.named_credential.spark_base import SparkNamedCredential
25
-
26
- if TYPE_CHECKING:
27
- from pyspark.sql import Column
28
-
29
- from datacustomcode.named_credential.base import NamedCredential
30
- from datacustomcode.named_credential.types.http_request import HTTPRequest
31
- from datacustomcode.named_credential.types.http_response import HTTPResponse
32
-
33
-
34
- _STATUS_SUCCESS = "SUCCESS"
35
- _STATUS_ERROR = "ERROR"
36
-
37
-
38
- def _build_underlying_named_credential() -> "NamedCredential":
39
- """Build the callout object from the configured ``named_credential_config``.
40
-
41
- Raises ``RuntimeError`` if no ``named_credential_config`` section is set.
42
- """
43
- from datacustomcode.named_credential_config import named_credential_config
44
-
45
- cfg = named_credential_config.named_credential_config
46
- if cfg is None:
47
- raise RuntimeError(
48
- "named_credential_config is not configured. Add a "
49
- "'named_credential_config' section to config.yaml."
50
- )
51
- return cfg.to_object()
52
-
53
-
54
- class DefaultSparkNamedCredential(SparkNamedCredential):
55
- """
56
- Callout for Spark, delegating to the shared implementation.
57
- """
58
-
59
- CONFIG_NAME = "DefaultSparkNamedCredential"
60
-
61
- def __init__(
62
- self,
63
- named_credential: Optional["NamedCredential"] = None,
64
- **kwargs: Any,
65
- ) -> None:
66
- super().__init__(**kwargs)
67
- if named_credential is None:
68
- named_credential = _build_underlying_named_credential()
69
- self._named_credential: "NamedCredential" = named_credential
70
-
71
- def request(
72
- self,
73
- request: "HTTPRequest",
74
- body: Optional[str] = None,
75
- ) -> "HTTPResponse":
76
- return self._named_credential.request(request, body)
77
-
78
- def request_col(
79
- self,
80
- request: "HTTPRequest",
81
- body: Optional["Column"] = None,
82
- ) -> "Column":
83
- """Per-row callout via a client-side Spark UDF.
84
-
85
- Returns a struct ``{status, response, error_code, error_message}`` where
86
- ``response`` is itself a struct
87
- ``{status_code, body, headers}`` carrying the callout's HTTP response, so
88
- a script that selects ``request_col(...)["response"]["status_code"]``
89
- behaves the same during development and in the Data Cloud runtime. Per-row
90
- failures populate the error fields instead of aborting the Spark job.
91
- """
92
- from pyspark.sql.functions import lit, udf
93
- from pyspark.sql.types import (
94
- IntegerType,
95
- MapType,
96
- StringType,
97
- StructField,
98
- StructType,
99
- )
100
-
101
- http_response_schema = StructType(
102
- [
103
- StructField("status_code", IntegerType(), True),
104
- StructField("body", StringType(), True),
105
- StructField("headers", MapType(StringType(), StringType()), True),
106
- ]
107
- )
108
- result_schema = StructType(
109
- [
110
- StructField("status", StringType(), True),
111
- StructField("response", http_response_schema, True),
112
- StructField("error_code", StringType(), True),
113
- StructField("error_message", StringType(), True),
114
- ]
115
- )
116
-
117
- def _callout(body_str: Optional[str]) -> Dict[str, Any]:
118
- return _invoke_callout_as_struct(self._named_credential, request, body_str)
119
-
120
- body_col = body if body is not None else lit(None).cast(StringType())
121
- return udf(_callout, result_schema)(body_col)
122
-
123
-
124
- def _invoke_callout_as_struct(
125
- named_credential: "NamedCredential",
126
- request: "HTTPRequest",
127
- body_str: Optional[str],
128
- ) -> Dict[str, Any]:
129
- """Run one callout and shape it into the shared result struct.
130
-
131
- ``response`` is a nested struct ``{status_code, body, headers}`` where
132
- ``body`` is the external response verbatim. Transport errors become per-row
133
- ERROR structs rather than aborting the job.
134
- """
135
- try:
136
- response = named_credential.request(request, body_str)
137
- except Exception as exc: # surface any transport error per row
138
- return {
139
- "status": _STATUS_ERROR,
140
- "response": None,
141
- "error_code": None,
142
- "error_message": str(exc),
143
- }
144
-
145
- return {
146
- "status": _STATUS_SUCCESS,
147
- "response": {
148
- "status_code": response.status_code,
149
- "body": response.body,
150
- "headers": response.headers,
151
- },
152
- "error_code": None,
153
- "error_message": None,
154
- }
@@ -1,14 +0,0 @@
1
- # Copyright (c) 2025, Salesforce, Inc.
2
- # SPDX-License-Identifier: Apache-2
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
@@ -1,29 +0,0 @@
1
- # Copyright (c) 2025, Salesforce, Inc.
2
- # SPDX-License-Identifier: Apache-2
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- from enum import Enum
17
-
18
-
19
- class HTTPMethod(str, Enum):
20
- """Callout methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS); usable on
21
- Python 3.10 where ``http.HTTPMethod`` is unavailable."""
22
-
23
- GET = "GET"
24
- POST = "POST"
25
- PUT = "PUT"
26
- DELETE = "DELETE"
27
- PATCH = "PATCH"
28
- HEAD = "HEAD"
29
- OPTIONS = "OPTIONS"
@@ -1,63 +0,0 @@
1
- # Copyright (c) 2025, Salesforce, Inc.
2
- # SPDX-License-Identifier: Apache-2
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- from enum import Enum
17
- from typing import Dict
18
-
19
- from pydantic import (
20
- BaseModel,
21
- ConfigDict,
22
- Field,
23
- field_validator,
24
- )
25
-
26
- from datacustomcode.named_credential.types.http_method import HTTPMethod
27
-
28
-
29
- class HTTPRequest(BaseModel):
30
- """External callout request. The endpoint and its auth are resolved
31
- server-side from the Named Credential referenced by ``url``, which uses
32
- ``callout:<NamedCredential>/<path>`` syntax."""
33
-
34
- model_config = ConfigDict(populate_by_name=True)
35
-
36
- url: str = Field(
37
- ...,
38
- min_length=1,
39
- description="Symbolic Named Credential reference, "
40
- "e.g. 'callout:<NamedCredential>/<path>'",
41
- )
42
- method: str = Field(
43
- default="GET",
44
- description="HTTP method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)",
45
- )
46
- headers: Dict[str, str] = Field(default_factory=dict, description="Request headers")
47
-
48
- @field_validator("method", mode="before")
49
- @classmethod
50
- def _normalize_method(cls, value: object) -> str:
51
- # Accept str, this module's HTTPMethod, or http.HTTPMethod (3.11+).
52
- if isinstance(value, Enum):
53
- method = str(value.value)
54
- else:
55
- method = str(value)
56
- method = method.upper()
57
- if method not in {m.value for m in HTTPMethod}:
58
- supported = ", ".join(m.value for m in HTTPMethod)
59
- raise ValueError(
60
- f"Unsupported HTTP method '{method}'. "
61
- f"Named Credential callouts support {supported}."
62
- )
63
- return method
@@ -1,55 +0,0 @@
1
- # Copyright (c) 2025, Salesforce, Inc.
2
- # SPDX-License-Identifier: Apache-2
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- from typing import Dict, Union
17
-
18
- from datacustomcode.named_credential.types.http_method import HTTPMethod
19
- from datacustomcode.named_credential.types.http_request import HTTPRequest
20
-
21
-
22
- class HTTPRequestBuilder:
23
- def __init__(self) -> None:
24
- self._url = ""
25
- self._method: Union[str, HTTPMethod] = HTTPMethod.GET
26
- self._headers: Dict[str, str] = {}
27
-
28
- def set_url(self, url: str) -> "HTTPRequestBuilder":
29
- """Set the symbolic Named Credential reference.
30
-
31
- Args:
32
- url: e.g. 'callout:<NamedCredential>/<path>'
33
- """
34
- self._url = url
35
- return self
36
-
37
- def set_method(self, method: Union[str, HTTPMethod]) -> "HTTPRequestBuilder":
38
- """Set the HTTP method.
39
-
40
- Accepts this module's ``HTTPMethod``, ``http.HTTPMethod`` (Python 3.11+),
41
- or a plain string such as ``"GET"``.
42
- """
43
- self._method = method
44
- return self
45
-
46
- def set_headers(self, headers: Dict[str, str]) -> "HTTPRequestBuilder":
47
- self._headers = headers
48
- return self
49
-
50
- def build(self) -> HTTPRequest:
51
- return HTTPRequest(
52
- url=self._url,
53
- method=self._method, # type: ignore[arg-type]
54
- headers=self._headers,
55
- )
@@ -1,43 +0,0 @@
1
- # Copyright (c) 2025, Salesforce, Inc.
2
- # SPDX-License-Identifier: Apache-2
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- from typing import Dict
17
-
18
- from pydantic import BaseModel, Field
19
-
20
-
21
- class HTTPResponse(BaseModel):
22
- """Response from a Named Credential external callout."""
23
-
24
- status_code: int = Field(..., description="HTTP status code", ge=0)
25
- headers: Dict[str, str] = Field(
26
- default_factory=dict, description="Response headers"
27
- )
28
- body: str = Field(
29
- default="",
30
- description="Raw response body, verbatim (any format). The SDK does not "
31
- "parse it; the caller decodes as needed (e.g. json.loads). Empty string "
32
- "if the response had no body.",
33
- )
34
-
35
- @property
36
- def is_success(self) -> bool:
37
- """Check if the request succeeded (2xx)."""
38
- return 200 <= self.status_code < 300
39
-
40
- @property
41
- def is_error(self) -> bool:
42
- """Check if the request failed."""
43
- return not self.is_success
@@ -1,24 +0,0 @@
1
- # Copyright (c) 2025, Salesforce, Inc.
2
- # SPDX-License-Identifier: Apache-2
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- from typing import Any, Dict
17
-
18
- from datacustomcode.named_credential.types.http_response import HTTPResponse
19
-
20
-
21
- class HTTPResponseBuilder:
22
- @staticmethod
23
- def build(response_dict: Dict[str, Any]) -> HTTPResponse:
24
- return HTTPResponse.model_validate(response_dict)
@@ -1,105 +0,0 @@
1
- # Copyright (c) 2025, Salesforce, Inc.
2
- # SPDX-License-Identifier: Apache-2
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- from typing import (
17
- ClassVar,
18
- Generic,
19
- Type,
20
- TypeVar,
21
- Union,
22
- )
23
-
24
- from datacustomcode.common_config import (
25
- BaseConfig,
26
- BaseObjectConfig,
27
- default_config_file,
28
- )
29
- from datacustomcode.named_credential.base import NamedCredential
30
- from datacustomcode.named_credential.spark_base import SparkNamedCredential
31
-
32
- _N = TypeVar("_N", bound=NamedCredential)
33
- _S = TypeVar("_S", bound=SparkNamedCredential)
34
-
35
-
36
- class NamedCredentialObjectConfig(BaseObjectConfig, Generic[_N]):
37
- type_to_create: ClassVar[Type[NamedCredential]] = NamedCredential # type: ignore[type-abstract]
38
-
39
- def to_object(self) -> NamedCredential:
40
- type_ = self.type_to_create.subclass_from_config_name(self.type_config_name)
41
- return type_(**self.options)
42
-
43
-
44
- class NamedCredentialConfig(BaseConfig):
45
- named_credential_config: Union[
46
- NamedCredentialObjectConfig[NamedCredential], None
47
- ] = None
48
-
49
- def update(self, other: "NamedCredentialConfig") -> "NamedCredentialConfig":
50
- def merge(
51
- config_a: Union[NamedCredentialObjectConfig, None],
52
- config_b: Union[NamedCredentialObjectConfig, None],
53
- ) -> Union[NamedCredentialObjectConfig, None]:
54
- if config_a is not None and config_a.force:
55
- return config_a
56
- if config_b:
57
- return config_b
58
- return config_a
59
-
60
- self.named_credential_config = merge(
61
- self.named_credential_config, other.named_credential_config
62
- )
63
- return self
64
-
65
-
66
- class SparkNamedCredentialObjectConfig(BaseObjectConfig, Generic[_S]):
67
- type_to_create: ClassVar[Type[SparkNamedCredential]] = SparkNamedCredential # type: ignore[type-abstract]
68
-
69
- def to_object(self) -> SparkNamedCredential:
70
- type_ = self.type_to_create.subclass_from_config_name(self.type_config_name)
71
- return type_(**self.options)
72
-
73
-
74
- class SparkNamedCredentialConfig(BaseConfig):
75
- spark_named_credential_config: Union[
76
- SparkNamedCredentialObjectConfig[SparkNamedCredential], None
77
- ] = None
78
-
79
- def update(
80
- self, other: "SparkNamedCredentialConfig"
81
- ) -> "SparkNamedCredentialConfig":
82
- def merge(
83
- config_a: Union[SparkNamedCredentialObjectConfig, None],
84
- config_b: Union[SparkNamedCredentialObjectConfig, None],
85
- ) -> Union[SparkNamedCredentialObjectConfig, None]:
86
- if config_a is not None and config_a.force:
87
- return config_a
88
- if config_b:
89
- return config_b
90
- return config_a
91
-
92
- self.spark_named_credential_config = merge(
93
- self.spark_named_credential_config, other.spark_named_credential_config
94
- )
95
- return self
96
-
97
-
98
- # Global Named Credential config instance
99
- named_credential_config = NamedCredentialConfig()
100
- named_credential_config.load(default_config_file())
101
-
102
-
103
- # Global Spark Named Credential config instance
104
- spark_named_credential_config = SparkNamedCredentialConfig()
105
- spark_named_credential_config.load(default_config_file())