ibm-watsonx-data-integration 0.0.1b0__tar.gz
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.
- ibm_watsonx_data_integration-0.0.1b0/LICENSE +190 -0
- ibm_watsonx_data_integration-0.0.1b0/PKG-INFO +31 -0
- ibm_watsonx_data_integration-0.0.1b0/README.rst +10 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/__init__.py +10 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/__version__.py +7 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/common/__init__.py +5 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/common/auth.py +114 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/common/constants.py +34 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/common/json_patch_format.py +214 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/common/models.py +338 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/common/utils.py +148 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/__init__.py +34 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/access_groups_api.py +104 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/account_api.py +59 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/adapters.py +73 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/base.py +234 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/connections_api.py +346 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/engine_api.py +74 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/environment_api.py +157 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/global_catalog_api.py +46 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/job_api.py +192 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/metering_api.py +74 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/project_api.py +196 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/resource_controller_api.py +112 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/role_api.py +106 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_api/user_api.py +127 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_models/__init__.py +57 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_models/access_groups_model.py +35 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_models/account_model.py +163 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_models/account_owner_model.py +40 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_models/connections_model.py +655 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_models/engine_model.py +131 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_models/environment_model.py +193 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_models/job_model.py +455 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_models/project_model.py +734 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_models/role_model.py +125 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_models/service_model.py +128 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/cpd_models/user_model.py +194 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/platform.py +565 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/services/__init__.py +5 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/services/streamsets/__init__.py +5 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/services/streamsets/api/__init__.py +11 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/services/streamsets/api/flow_api.py +143 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/services/streamsets/api/sdc_api.py +74 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/services/streamsets/exceptions.py +17 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/services/streamsets/models/__init__.py +17 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/services/streamsets/models/configuration.py +228 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration/services/streamsets/models/flow_model.py +1407 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration.egg-info/PKG-INFO +31 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration.egg-info/SOURCES.txt +53 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration.egg-info/dependency_links.txt +1 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration.egg-info/requires.txt +4 -0
- ibm_watsonx_data_integration-0.0.1b0/ibm_watsonx_data_integration.egg-info/top_level.txt +1 -0
- ibm_watsonx_data_integration-0.0.1b0/pyproject.toml +85 -0
- ibm_watsonx_data_integration-0.0.1b0/setup.cfg +4 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 IBM Corp.
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ibm-watsonx-data-integration
|
|
3
|
+
Version: 0.0.1b0
|
|
4
|
+
Summary: A Python SDK for watsonx.data integration.
|
|
5
|
+
Author: IBM
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Documentation, https://ibm.github.io/ibm-watsonx-data-integration-sdk/
|
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/x-rst
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: inflection~=0.5.1
|
|
17
|
+
Requires-Dist: requests>=2.32.3
|
|
18
|
+
Requires-Dist: pydantic~=2.10.6
|
|
19
|
+
Requires-Dist: jsondiff>=2.2.1
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
Welcome to ibm-watsonx-data-integration
|
|
23
|
+
|
|
24
|
+
`ibm-watsonx-data-integration` is a Python SDK that enables developers and data engineers to programmatically interact with the watsonx.data integration service, IBM's next-generation data integration platform built to support modern, hybrid-cloud data pipelines.
|
|
25
|
+
With this SDK, users can automate and manage Flow lifecycles such as creating, configuring, starting, stopping, and monitoring Flows directly in code.
|
|
26
|
+
|
|
27
|
+
Package documentation
|
|
28
|
+
=====================
|
|
29
|
+
|
|
30
|
+
Full documentation is available at:
|
|
31
|
+
`https://ibm.github.io/ibm-watsonx-data-integration-sdk <https://ibm.github.io/ibm-watsonx-data-integration-sdk>`_
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Welcome to ibm-watsonx-data-integration
|
|
2
|
+
|
|
3
|
+
`ibm-watsonx-data-integration` is a Python SDK that enables developers and data engineers to programmatically interact with the watsonx.data integration service, IBM's next-generation data integration platform built to support modern, hybrid-cloud data pipelines.
|
|
4
|
+
With this SDK, users can automate and manage Flow lifecycles such as creating, configuring, starting, stopping, and monitoring Flows directly in code.
|
|
5
|
+
|
|
6
|
+
Package documentation
|
|
7
|
+
=====================
|
|
8
|
+
|
|
9
|
+
Full documentation is available at:
|
|
10
|
+
`https://ibm.github.io/ibm-watsonx-data-integration-sdk <https://ibm.github.io/ibm-watsonx-data-integration-sdk>`_
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# IBM Confidential
|
|
2
|
+
# PID 5900-BAF
|
|
3
|
+
# Copyright StreamSets Inc., an IBM Company 2025
|
|
4
|
+
|
|
5
|
+
"""This package contains API Clients, models and abstractions for WatsonX Data Integration Services."""
|
|
6
|
+
|
|
7
|
+
from ibm_watsonx_data_integration.__version__ import __version__ # noqa: F401
|
|
8
|
+
from ibm_watsonx_data_integration.platform import Platform
|
|
9
|
+
|
|
10
|
+
__all__ = ["Platform"]
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# IBM Confidential
|
|
2
|
+
# PID 5900-BAF
|
|
3
|
+
# Copyright StreamSets Inc., an IBM Company 2025
|
|
4
|
+
|
|
5
|
+
"""Authentication module."""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
import requests
|
|
9
|
+
import time
|
|
10
|
+
from abc import ABC, abstractmethod
|
|
11
|
+
from urllib.parse import urlparse, urlunparse
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class BaseAuthenticator(ABC):
|
|
17
|
+
"""Base Authenticator classes to be inherited by other authenticators."""
|
|
18
|
+
|
|
19
|
+
@abstractmethod
|
|
20
|
+
def get_authorization_header(self) -> str:
|
|
21
|
+
"""Returns the token formatted to be plugged into the Authorization header of a request.
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
A :py:obj:`str` ready to be used as an Authorization header.
|
|
25
|
+
"""
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class IAMAuthenticator(BaseAuthenticator):
|
|
30
|
+
"""Authenticator class to authenticate using an IBM Cloud IBM API Key.
|
|
31
|
+
|
|
32
|
+
Attributes:
|
|
33
|
+
api_key: API key being used to authenticate.
|
|
34
|
+
token_url: URL being used to authenticate against.
|
|
35
|
+
iam_token: The token generated using the api_key and url.
|
|
36
|
+
token_expiry_time: UNIX time in seconds for when the token will expire.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
# give a time buffer for expiration, to have ample time to make a request without the token being expired.
|
|
40
|
+
EXPIRATION_TIME_BUFFER = 5
|
|
41
|
+
|
|
42
|
+
def __init__(self, api_key: str, base_auth_url: str = "https://cloud.ibm.com") -> None:
|
|
43
|
+
"""Initializes IAM Authenticator.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
api_key: The API key to be used for authentication.
|
|
47
|
+
base_auth_url: The base URL of the IBM cloud instance to be used for authentication.
|
|
48
|
+
|
|
49
|
+
Raises:
|
|
50
|
+
TypeError: If api_key or base_auth_url are not of type str.
|
|
51
|
+
ValueError: If api_key or base_auth_url are an empty str or if base_auth_url is not a valid url.
|
|
52
|
+
requests.exceptions.HTTPError: If there is an error getting a valid token.
|
|
53
|
+
"""
|
|
54
|
+
if not isinstance(api_key, str):
|
|
55
|
+
raise TypeError("api_key should be of type str.")
|
|
56
|
+
if not api_key:
|
|
57
|
+
raise ValueError("api_key should not be an empty str.")
|
|
58
|
+
|
|
59
|
+
if not isinstance(base_auth_url, str):
|
|
60
|
+
raise TypeError("base_auth_url should be of type str.")
|
|
61
|
+
if not base_auth_url:
|
|
62
|
+
raise ValueError("base_auth_url should not be an empty str.")
|
|
63
|
+
|
|
64
|
+
self.api_key = api_key
|
|
65
|
+
|
|
66
|
+
# base_auth_url looks like: "https://cloud.ibm.com"
|
|
67
|
+
# token url looks like: "https://iam.cloud.ibm.com/identity/token"
|
|
68
|
+
parsed_url = urlparse(url=base_auth_url)
|
|
69
|
+
new_netloc = "iam." + parsed_url.netloc
|
|
70
|
+
new_path = parsed_url.path + "/identity/token"
|
|
71
|
+
self.token_url = urlunparse((parsed_url.scheme, new_netloc, new_path, "", "", ""))
|
|
72
|
+
|
|
73
|
+
self.iam_token = None
|
|
74
|
+
self.token_expiry_time = None
|
|
75
|
+
self.request_token()
|
|
76
|
+
|
|
77
|
+
def request_token(self) -> None:
|
|
78
|
+
"""Request a token from the servers using the API key.
|
|
79
|
+
|
|
80
|
+
Raises:
|
|
81
|
+
requests.exceptions.HTTPError: If there is an error getting a valid token.
|
|
82
|
+
"""
|
|
83
|
+
headers = {"Content-Type": "application/x-www-form-urlencoded"}
|
|
84
|
+
data = {"apikey": self.api_key, "grant_type": "urn:ibm:params:oauth:grant-type:apikey"}
|
|
85
|
+
|
|
86
|
+
response = requests.post(self.token_url, headers=headers, data=data)
|
|
87
|
+
response.raise_for_status()
|
|
88
|
+
|
|
89
|
+
self.iam_token = response.json()["access_token"]
|
|
90
|
+
self.token_expiry_time = response.json()["expiration"]
|
|
91
|
+
|
|
92
|
+
def get_token(self) -> str:
|
|
93
|
+
"""Get existing token, or request a new one if the current token is expired.
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
A :py:obj:`str` containing the current token.
|
|
97
|
+
"""
|
|
98
|
+
current_time = int(time.time())
|
|
99
|
+
if self.iam_token is None:
|
|
100
|
+
logger.debug("Getting first token.")
|
|
101
|
+
self.request_token()
|
|
102
|
+
elif (current_time + self.EXPIRATION_TIME_BUFFER) >= self.token_expiry_time:
|
|
103
|
+
logger.debug("Previous token expired, refreshing.")
|
|
104
|
+
self.request_token()
|
|
105
|
+
|
|
106
|
+
return self.iam_token
|
|
107
|
+
|
|
108
|
+
def get_authorization_header(self) -> str:
|
|
109
|
+
"""Returns the token formatted to be plugged into the Authorization header of a request.
|
|
110
|
+
|
|
111
|
+
Returns:
|
|
112
|
+
A :py:obj:`str` ready to be used as an Authorization header.
|
|
113
|
+
"""
|
|
114
|
+
return f"Bearer {self.get_token()}"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# IBM Confidential
|
|
2
|
+
# PID 5900-BAF
|
|
3
|
+
# Copyright StreamSets Inc., an IBM Company 2025
|
|
4
|
+
|
|
5
|
+
"""This module contains project-wide constants."""
|
|
6
|
+
|
|
7
|
+
from enum import Enum
|
|
8
|
+
|
|
9
|
+
DATASTAGE = "datastage"
|
|
10
|
+
|
|
11
|
+
RESOURCE_PLAN_ID_MAP = {DATASTAGE: "aaa6e83e-27df-4393-9a55-63feec09c685"}
|
|
12
|
+
DEFAULT_RESOURCE_REGION_ID_MAP = {DATASTAGE: "us-south"}
|
|
13
|
+
|
|
14
|
+
# BASE MODEL VARS
|
|
15
|
+
HIDDEN_DICTIONARY = "_hidden_key_paths"
|
|
16
|
+
EXPOSE_SUB_CLASS = "_expose"
|
|
17
|
+
|
|
18
|
+
# PROD URLS
|
|
19
|
+
GLOBAL_CATALOG_URL = "https://globalcatalog.cloud.ibm.com/api"
|
|
20
|
+
RESOURCE_CONTROLLER_URL = "https://resource-controller.cloud.ibm.com"
|
|
21
|
+
PROD_BASE_URL = "https://api.dataplatform.cloud.ibm.com"
|
|
22
|
+
ACCOUNT_MANAGEMENT_URL = "https://accounts.cloud.ibm.com"
|
|
23
|
+
USER_MANAGEMENT_URL = "https://user-management.cloud.ibm.com"
|
|
24
|
+
IAM_URL = "https://iam.cloud.ibm.com"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class DataActions(str, Enum):
|
|
28
|
+
"""Actions supported in EXPOSED_DATH_PATH."""
|
|
29
|
+
|
|
30
|
+
IGNORE = "IGNORE"
|
|
31
|
+
EXPOSE = "EXPOSE" # Shouldn't be used on the base level
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
SUPPORTED_FLOWS = {"streamsets"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# IBM Confidential
|
|
2
|
+
# PID 5900-BAF
|
|
3
|
+
# Copyright StreamSets Inc., an IBM Company 2025
|
|
4
|
+
|
|
5
|
+
"""This module defines a utility function to create JSON Patch format payloads.
|
|
6
|
+
|
|
7
|
+
Implementation is limited to the following use cases:
|
|
8
|
+
1. Changing property values.
|
|
9
|
+
2. Removing entries from a collection list.
|
|
10
|
+
3. Adding entries to a collection list.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import json
|
|
14
|
+
import jsondiff
|
|
15
|
+
from abc import ABC, abstractmethod
|
|
16
|
+
from collections.abc import MutableMapping
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def prepare_json_patch_payload(origin: dict, updated: dict, exclude_properties: list[str] | None = None) -> str:
|
|
20
|
+
"""Entrypoint function for creating a JSON Patch format-compliant payload.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
origin: Dictionary with original data before changes.
|
|
24
|
+
updated: Dictionary after applying changes and updates.
|
|
25
|
+
exclude_properties: List of flatten keys for properties to not include in payload.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
A JSON string compliant with the JSON Patch format standard.
|
|
29
|
+
"""
|
|
30
|
+
difference = jsondiff.diff(origin, updated, syntax="explicit")
|
|
31
|
+
flatten = flatten_jsondiff_explicit_result(difference)
|
|
32
|
+
return create_json_patch_document(flatten, exclude_properties=exclude_properties)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def flatten_jsondiff_explicit_result(
|
|
36
|
+
dictionary: MutableMapping, parent_key: str = "", separator: str = "/", last_operation: str = ""
|
|
37
|
+
) -> dict:
|
|
38
|
+
"""Flattens key paths from the result of ``jsondiff.diff``.
|
|
39
|
+
|
|
40
|
+
This function is tightly coupled with the 3rd party library ``jsondiff``.
|
|
41
|
+
It will work correctly for results returned by the ``explicit`` flag for the ``syntax`` argument.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
dictionary: A result from ``jsondiff.diff`` execution.
|
|
45
|
+
parent_key: Parent key from the perspective of the current processing key.
|
|
46
|
+
separator: Character that will be used to delimit keys.
|
|
47
|
+
last_operation: Operations mean keys starting with the ``$`` character.
|
|
48
|
+
This parameter holds the last one in the current traversable path.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
A dictionary with flattened paths as keys and the original values as values.
|
|
52
|
+
"""
|
|
53
|
+
items = []
|
|
54
|
+
|
|
55
|
+
for key, value in dictionary.items():
|
|
56
|
+
if str(key).startswith("$"):
|
|
57
|
+
last_operation = key
|
|
58
|
+
new_key = f"{parent_key}" if parent_key else ""
|
|
59
|
+
else:
|
|
60
|
+
new_key = f"{parent_key}{separator}{key}" if parent_key else key
|
|
61
|
+
|
|
62
|
+
if isinstance(value, MutableMapping):
|
|
63
|
+
items.extend(
|
|
64
|
+
flatten_jsondiff_explicit_result(
|
|
65
|
+
value, new_key, separator=separator, last_operation=last_operation
|
|
66
|
+
).items()
|
|
67
|
+
)
|
|
68
|
+
else:
|
|
69
|
+
items.append((f"{last_operation}{separator}{new_key}", value))
|
|
70
|
+
return dict(items)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def create_json_patch_document(flatten_dict: dict, exclude_properties: list[str] | None = None) -> str:
|
|
74
|
+
"""Creates JSON document compliant with JSON Path format standard.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
flatten_dict: Dictionary with flatted keys to values returned by ``flatten_jsondiff_explicit_result``.
|
|
78
|
+
exclude_properties: List of flatten key paths for properties to exclude from patch document.
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
A string representing JSON Path format document.
|
|
82
|
+
"""
|
|
83
|
+
if exclude_properties is None:
|
|
84
|
+
exclude_properties = list()
|
|
85
|
+
|
|
86
|
+
exclude_properties_lower = list(map(lambda s: s.lower(), exclude_properties))
|
|
87
|
+
operations = []
|
|
88
|
+
|
|
89
|
+
for k, v in flatten_dict.items():
|
|
90
|
+
path = k[k.find("/") :]
|
|
91
|
+
|
|
92
|
+
if path.lower() in exclude_properties_lower:
|
|
93
|
+
continue
|
|
94
|
+
|
|
95
|
+
operation = map_operations(k[: k.find("/")], path, v)
|
|
96
|
+
operations.extend(operation.value)
|
|
97
|
+
|
|
98
|
+
return json.dumps(sorted(operations, key=operation_weight_sort_key))
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class Operation(ABC):
|
|
102
|
+
"""Represent single operation acceptable by JSON Patch Format."""
|
|
103
|
+
|
|
104
|
+
def __init__(self, path: str, raw_data: list | dict | object) -> None:
|
|
105
|
+
"""Initialize Operation class with private attributes.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
path: Flatten key path.
|
|
109
|
+
raw_data: Value for given key, format defined by ``json.diff``.
|
|
110
|
+
"""
|
|
111
|
+
self._path = path
|
|
112
|
+
self._raw_data = raw_data
|
|
113
|
+
|
|
114
|
+
@property
|
|
115
|
+
@abstractmethod
|
|
116
|
+
def value(self) -> list[dict]:
|
|
117
|
+
"""Returns list with JSON Path format operation objects."""
|
|
118
|
+
raise NotImplementedError
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class AddOperation(Operation):
|
|
122
|
+
"""Creates operations for adding objects."""
|
|
123
|
+
|
|
124
|
+
@property
|
|
125
|
+
def value(self) -> list[dict]:
|
|
126
|
+
"""Returns list with JSON Path format operation objects."""
|
|
127
|
+
result = []
|
|
128
|
+
if isinstance(self._raw_data, list):
|
|
129
|
+
for add_object in self._raw_data:
|
|
130
|
+
index = add_object[0]
|
|
131
|
+
value = add_object[1]
|
|
132
|
+
result.append({"op": "add", "path": f"{self._path}/{index}", "value": value})
|
|
133
|
+
else:
|
|
134
|
+
result.append(
|
|
135
|
+
{
|
|
136
|
+
"op": "add",
|
|
137
|
+
"path": self._path,
|
|
138
|
+
"value": self._raw_data,
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
return result
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class RemoveOperation(Operation):
|
|
145
|
+
"""Creates operations for removing objects."""
|
|
146
|
+
|
|
147
|
+
@property
|
|
148
|
+
def value(self) -> list[dict]:
|
|
149
|
+
"""Returns list with JSON Path format operation objects."""
|
|
150
|
+
result = []
|
|
151
|
+
if isinstance(self._raw_data, list):
|
|
152
|
+
for index in self._raw_data:
|
|
153
|
+
result.append({"op": "remove", "path": f"{self._path}/{index}"})
|
|
154
|
+
else:
|
|
155
|
+
result.append(
|
|
156
|
+
{
|
|
157
|
+
"op": "remove",
|
|
158
|
+
"path": self._path,
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
return result
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class ReplaceOperation(Operation):
|
|
165
|
+
"""Creates operations for replacing objects."""
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
def value(self) -> list[dict]:
|
|
169
|
+
"""Returns list with JSON Path format operation objects."""
|
|
170
|
+
result = [{"op": "replace", "path": self._path, "value": self._raw_data}]
|
|
171
|
+
return result
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def map_operations(op_name: str, path: str, raw_data: dict | list | object) -> Operation:
|
|
175
|
+
"""Maps an operation from the ``jsondiff`` library to corresponding in the JSON Path format specification.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
op_name: Operation name used in ``jsondiff`` library, prefixed with ``$``.
|
|
179
|
+
path: Flatten key path.
|
|
180
|
+
raw_data: Operation related information created by ``jsondiff`` library.
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
An Operation object that performs the creation of the appropriate operation object.
|
|
184
|
+
|
|
185
|
+
Raises:
|
|
186
|
+
ValueError: If an undefined operation is provided.
|
|
187
|
+
"""
|
|
188
|
+
op_name_lower = op_name.lower()
|
|
189
|
+
|
|
190
|
+
if op_name_lower == "$update":
|
|
191
|
+
return ReplaceOperation(path, raw_data)
|
|
192
|
+
elif op_name_lower == "$insert":
|
|
193
|
+
return AddOperation(path, raw_data)
|
|
194
|
+
elif op_name_lower == "$delete":
|
|
195
|
+
return RemoveOperation(path, raw_data)
|
|
196
|
+
else:
|
|
197
|
+
raise ValueError("Undefined operation!")
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def operation_weight_sort_key(operation: dict) -> int:
|
|
201
|
+
"""Controls the order of operation execution.
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
operation: A JSON Path format operation dictionary.
|
|
205
|
+
|
|
206
|
+
Returns:
|
|
207
|
+
A weight for the given operation, which will be used when sorting.
|
|
208
|
+
"""
|
|
209
|
+
op_weight_map = {
|
|
210
|
+
"remove": 1,
|
|
211
|
+
"add": 2,
|
|
212
|
+
"replace": 3,
|
|
213
|
+
}
|
|
214
|
+
return op_weight_map[operation["op"]]
|