acryl-datahub-cloud 0.3.8.3__py3-none-any.whl → 0.3.9__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.
Potentially problematic release.
This version of acryl-datahub-cloud might be problematic. Click here for more details.
- acryl_datahub_cloud/_codegen_config.json +1 -1
- acryl_datahub_cloud/acryl_cs_issues/acryl_customer.py +1 -1
- acryl_datahub_cloud/action_request/__init__.py +0 -0
- acryl_datahub_cloud/action_request/action_request_owner_source.py +174 -0
- acryl_datahub_cloud/api/__init__.py +1 -1
- acryl_datahub_cloud/api/client.py +2 -2
- acryl_datahub_cloud/datahub_reporting/datahub_dataset.py +6 -6
- acryl_datahub_cloud/datahub_reporting/datahub_form_reporting.py +69 -35
- acryl_datahub_cloud/datahub_reporting/extract_sql.py +4 -4
- acryl_datahub_cloud/datahub_usage_reporting/usage_feature_patch_builder.py +21 -21
- acryl_datahub_cloud/datahub_usage_reporting/usage_feature_reporter.py +14 -13
- acryl_datahub_cloud/metadata/_urns/urn_defs.py +1130 -484
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/actionrequest/__init__.py +6 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/dataplatforminstance/__init__.py +2 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/dataset/__init__.py +2 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/executorglobalconfig/__init__.py +15 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/executorpool/__init__.py +4 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/metadata/key/__init__.py +4 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/metric/__init__.py +29 -0
- acryl_datahub_cloud/metadata/schema.avsc +839 -49
- acryl_datahub_cloud/metadata/schema_classes.py +1286 -63
- acryl_datahub_cloud/metadata/schemas/ActionRequestInfo.avsc +422 -12
- acryl_datahub_cloud/metadata/schemas/ActionRequestStatus.avsc +12 -0
- acryl_datahub_cloud/metadata/schemas/AssertionAnalyticsRunEvent.avsc +5 -3
- acryl_datahub_cloud/metadata/schemas/AssertionInfo.avsc +5 -3
- acryl_datahub_cloud/metadata/schemas/AssertionRunEvent.avsc +5 -3
- acryl_datahub_cloud/metadata/schemas/BusinessAttributeInfo.avsc +6 -2
- acryl_datahub_cloud/metadata/schemas/BusinessAttributes.avsc +6 -0
- acryl_datahub_cloud/metadata/schemas/ChartInfo.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/ChartKey.avsc +3 -3
- acryl_datahub_cloud/metadata/schemas/ContainerKey.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/CorpGroupKey.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/DashboardKey.avsc +3 -3
- acryl_datahub_cloud/metadata/schemas/DataFlowKey.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/DataHubActionInfo.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/DataHubConnectionKey.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/DataHubIngestionSourceInfo.avsc +9 -4
- acryl_datahub_cloud/metadata/schemas/DataHubMetricCubeDefinition.avsc +185 -0
- acryl_datahub_cloud/metadata/schemas/DataHubMetricCubeEvent.avsc +184 -0
- acryl_datahub_cloud/metadata/schemas/DataHubMetricCubeKey.avsc +22 -0
- acryl_datahub_cloud/metadata/schemas/DataJobKey.avsc +4 -4
- acryl_datahub_cloud/metadata/schemas/DataPlatformInstanceKey.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/DataProcessInstanceInput.avsc +132 -2
- acryl_datahub_cloud/metadata/schemas/DataProcessInstanceOutput.avsc +131 -1
- acryl_datahub_cloud/metadata/schemas/DatasetKey.avsc +14 -13
- acryl_datahub_cloud/metadata/schemas/EditableSchemaMetadata.avsc +6 -2
- acryl_datahub_cloud/metadata/schemas/ExecutionRequestInput.avsc +6 -1
- acryl_datahub_cloud/metadata/schemas/ExecutionRequestSignal.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/FormInfo.avsc +5 -0
- acryl_datahub_cloud/metadata/schemas/GlossaryTerms.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/IcebergCatalogInfo.avsc +28 -0
- acryl_datahub_cloud/metadata/schemas/IcebergWarehouseInfo.avsc +96 -0
- acryl_datahub_cloud/metadata/schemas/IncidentActivityEvent.avsc +4 -1
- acryl_datahub_cloud/metadata/schemas/IncidentInfo.avsc +4 -1
- acryl_datahub_cloud/metadata/schemas/InputFields.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/MLFeatureKey.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/MLFeatureTableKey.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/MLModelGroupKey.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/MLModelKey.avsc +3 -3
- acryl_datahub_cloud/metadata/schemas/MLPrimaryKeyKey.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/MetadataChangeEvent.avsc +399 -176
- acryl_datahub_cloud/metadata/schemas/MonitorInfo.avsc +6 -4
- acryl_datahub_cloud/metadata/schemas/NotebookKey.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/Operation.avsc +4 -2
- acryl_datahub_cloud/metadata/schemas/RemoteExecutorGlobalConfigKey.avsc +21 -0
- acryl_datahub_cloud/metadata/schemas/RemoteExecutorPoolGlobalConfig.avsc +16 -0
- acryl_datahub_cloud/metadata/schemas/RemoteExecutorPoolInfo.avsc +85 -0
- acryl_datahub_cloud/metadata/schemas/RemoteExecutorPoolKey.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/RemoteExecutorStatus.avsc +5 -5
- acryl_datahub_cloud/metadata/schemas/SchemaFieldKey.avsc +2 -2
- acryl_datahub_cloud/metadata/schemas/SchemaMetadata.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/VersionProperties.avsc +18 -0
- acryl_datahub_cloud/metadata/schemas/VersionSetProperties.avsc +5 -0
- {acryl_datahub_cloud-0.3.8.3.dist-info → acryl_datahub_cloud-0.3.9.dist-info}/METADATA +42 -42
- {acryl_datahub_cloud-0.3.8.3.dist-info → acryl_datahub_cloud-0.3.9.dist-info}/RECORD +78 -68
- {acryl_datahub_cloud-0.3.8.3.dist-info → acryl_datahub_cloud-0.3.9.dist-info}/entry_points.txt +1 -0
- acryl_datahub_cloud/api/entity_versioning.py +0 -167
- {acryl_datahub_cloud-0.3.8.3.dist-info → acryl_datahub_cloud-0.3.9.dist-info}/WHEEL +0 -0
- {acryl_datahub_cloud-0.3.8.3.dist-info → acryl_datahub_cloud-0.3.9.dist-info}/top_level.txt +0 -0
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
# This file contains classes corresponding to entity URNs.
|
|
12
12
|
|
|
13
|
-
from typing import ClassVar, List, Optional, Type, TYPE_CHECKING
|
|
13
|
+
from typing import ClassVar, List, Optional, Type, TYPE_CHECKING, Union, Literal
|
|
14
14
|
|
|
15
15
|
import functools
|
|
16
16
|
from deprecated.sphinx import deprecated as _sphinx_deprecated
|
|
@@ -25,17 +25,28 @@ if TYPE_CHECKING:
|
|
|
25
25
|
from datahub.metadata.schema_classes import DataProductKeyClass
|
|
26
26
|
|
|
27
27
|
class DataProductUrn(_SpecificUrn):
|
|
28
|
-
ENTITY_TYPE: ClassVar[
|
|
29
|
-
|
|
28
|
+
ENTITY_TYPE: ClassVar[Literal["dataProduct"]] = "dataProduct"
|
|
29
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
30
30
|
|
|
31
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
31
|
+
def __init__(self, id: Union["DataProductUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
32
32
|
if _allow_coercion:
|
|
33
33
|
# Field coercion logic (if any is required).
|
|
34
|
-
|
|
34
|
+
if isinstance(id, str):
|
|
35
|
+
if id.startswith('urn:li:'):
|
|
36
|
+
try:
|
|
37
|
+
id = DataProductUrn.from_string(id)
|
|
38
|
+
except InvalidUrnError:
|
|
39
|
+
raise InvalidUrnError(f'Expecting a DataProductUrn but got {id}')
|
|
40
|
+
else:
|
|
41
|
+
id = UrnEncoder.encode_string(id)
|
|
35
42
|
|
|
36
43
|
# Validation logic.
|
|
37
44
|
if not id:
|
|
38
45
|
raise InvalidUrnError("DataProductUrn id cannot be empty")
|
|
46
|
+
if isinstance(id, DataProductUrn):
|
|
47
|
+
id = id.id
|
|
48
|
+
elif isinstance(id, Urn):
|
|
49
|
+
raise InvalidUrnError(f'Expecting a DataProductUrn but got {id}')
|
|
39
50
|
if UrnEncoder.contains_reserved_char(id):
|
|
40
51
|
raise InvalidUrnError(f'DataProductUrn id contains reserved characters')
|
|
41
52
|
|
|
@@ -43,8 +54,8 @@ class DataProductUrn(_SpecificUrn):
|
|
|
43
54
|
|
|
44
55
|
@classmethod
|
|
45
56
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataProductUrn":
|
|
46
|
-
if len(entity_ids) != cls.
|
|
47
|
-
raise InvalidUrnError(f"DataProductUrn should have {cls.
|
|
57
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
58
|
+
raise InvalidUrnError(f"DataProductUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
48
59
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
49
60
|
|
|
50
61
|
@classmethod
|
|
@@ -64,23 +75,34 @@ class DataProductUrn(_SpecificUrn):
|
|
|
64
75
|
|
|
65
76
|
@property
|
|
66
77
|
def id(self) -> str:
|
|
67
|
-
return self.
|
|
78
|
+
return self._entity_ids[0]
|
|
68
79
|
|
|
69
80
|
if TYPE_CHECKING:
|
|
70
81
|
from datahub.metadata.schema_classes import StructuredPropertyKeyClass
|
|
71
82
|
|
|
72
83
|
class StructuredPropertyUrn(_SpecificUrn):
|
|
73
|
-
ENTITY_TYPE: ClassVar[
|
|
74
|
-
|
|
84
|
+
ENTITY_TYPE: ClassVar[Literal["structuredProperty"]] = "structuredProperty"
|
|
85
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
75
86
|
|
|
76
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
87
|
+
def __init__(self, id: Union["StructuredPropertyUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
77
88
|
if _allow_coercion:
|
|
78
89
|
# Field coercion logic (if any is required).
|
|
79
|
-
|
|
90
|
+
if isinstance(id, str):
|
|
91
|
+
if id.startswith('urn:li:'):
|
|
92
|
+
try:
|
|
93
|
+
id = StructuredPropertyUrn.from_string(id)
|
|
94
|
+
except InvalidUrnError:
|
|
95
|
+
raise InvalidUrnError(f'Expecting a StructuredPropertyUrn but got {id}')
|
|
96
|
+
else:
|
|
97
|
+
id = UrnEncoder.encode_string(id)
|
|
80
98
|
|
|
81
99
|
# Validation logic.
|
|
82
100
|
if not id:
|
|
83
101
|
raise InvalidUrnError("StructuredPropertyUrn id cannot be empty")
|
|
102
|
+
if isinstance(id, StructuredPropertyUrn):
|
|
103
|
+
id = id.id
|
|
104
|
+
elif isinstance(id, Urn):
|
|
105
|
+
raise InvalidUrnError(f'Expecting a StructuredPropertyUrn but got {id}')
|
|
84
106
|
if UrnEncoder.contains_reserved_char(id):
|
|
85
107
|
raise InvalidUrnError(f'StructuredPropertyUrn id contains reserved characters')
|
|
86
108
|
|
|
@@ -88,8 +110,8 @@ class StructuredPropertyUrn(_SpecificUrn):
|
|
|
88
110
|
|
|
89
111
|
@classmethod
|
|
90
112
|
def _parse_ids(cls, entity_ids: List[str]) -> "StructuredPropertyUrn":
|
|
91
|
-
if len(entity_ids) != cls.
|
|
92
|
-
raise InvalidUrnError(f"StructuredPropertyUrn should have {cls.
|
|
113
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
114
|
+
raise InvalidUrnError(f"StructuredPropertyUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
93
115
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
94
116
|
|
|
95
117
|
@classmethod
|
|
@@ -109,23 +131,34 @@ class StructuredPropertyUrn(_SpecificUrn):
|
|
|
109
131
|
|
|
110
132
|
@property
|
|
111
133
|
def id(self) -> str:
|
|
112
|
-
return self.
|
|
134
|
+
return self._entity_ids[0]
|
|
113
135
|
|
|
114
136
|
if TYPE_CHECKING:
|
|
115
137
|
from datahub.metadata.schema_classes import EntityTypeKeyClass
|
|
116
138
|
|
|
117
139
|
class EntityTypeUrn(_SpecificUrn):
|
|
118
|
-
ENTITY_TYPE: ClassVar[
|
|
119
|
-
|
|
140
|
+
ENTITY_TYPE: ClassVar[Literal["entityType"]] = "entityType"
|
|
141
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
120
142
|
|
|
121
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
143
|
+
def __init__(self, id: Union["EntityTypeUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
122
144
|
if _allow_coercion:
|
|
123
145
|
# Field coercion logic (if any is required).
|
|
124
|
-
|
|
146
|
+
if isinstance(id, str):
|
|
147
|
+
if id.startswith('urn:li:'):
|
|
148
|
+
try:
|
|
149
|
+
id = EntityTypeUrn.from_string(id)
|
|
150
|
+
except InvalidUrnError:
|
|
151
|
+
raise InvalidUrnError(f'Expecting a EntityTypeUrn but got {id}')
|
|
152
|
+
else:
|
|
153
|
+
id = UrnEncoder.encode_string(id)
|
|
125
154
|
|
|
126
155
|
# Validation logic.
|
|
127
156
|
if not id:
|
|
128
157
|
raise InvalidUrnError("EntityTypeUrn id cannot be empty")
|
|
158
|
+
if isinstance(id, EntityTypeUrn):
|
|
159
|
+
id = id.id
|
|
160
|
+
elif isinstance(id, Urn):
|
|
161
|
+
raise InvalidUrnError(f'Expecting a EntityTypeUrn but got {id}')
|
|
129
162
|
if UrnEncoder.contains_reserved_char(id):
|
|
130
163
|
raise InvalidUrnError(f'EntityTypeUrn id contains reserved characters')
|
|
131
164
|
|
|
@@ -133,8 +166,8 @@ class EntityTypeUrn(_SpecificUrn):
|
|
|
133
166
|
|
|
134
167
|
@classmethod
|
|
135
168
|
def _parse_ids(cls, entity_ids: List[str]) -> "EntityTypeUrn":
|
|
136
|
-
if len(entity_ids) != cls.
|
|
137
|
-
raise InvalidUrnError(f"EntityTypeUrn should have {cls.
|
|
169
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
170
|
+
raise InvalidUrnError(f"EntityTypeUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
138
171
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
139
172
|
|
|
140
173
|
@classmethod
|
|
@@ -154,23 +187,34 @@ class EntityTypeUrn(_SpecificUrn):
|
|
|
154
187
|
|
|
155
188
|
@property
|
|
156
189
|
def id(self) -> str:
|
|
157
|
-
return self.
|
|
190
|
+
return self._entity_ids[0]
|
|
158
191
|
|
|
159
192
|
if TYPE_CHECKING:
|
|
160
193
|
from datahub.metadata.schema_classes import PlatformResourceKeyClass
|
|
161
194
|
|
|
162
195
|
class PlatformResourceUrn(_SpecificUrn):
|
|
163
|
-
ENTITY_TYPE: ClassVar[
|
|
164
|
-
|
|
196
|
+
ENTITY_TYPE: ClassVar[Literal["platformResource"]] = "platformResource"
|
|
197
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
165
198
|
|
|
166
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
199
|
+
def __init__(self, id: Union["PlatformResourceUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
167
200
|
if _allow_coercion:
|
|
168
201
|
# Field coercion logic (if any is required).
|
|
169
|
-
|
|
202
|
+
if isinstance(id, str):
|
|
203
|
+
if id.startswith('urn:li:'):
|
|
204
|
+
try:
|
|
205
|
+
id = PlatformResourceUrn.from_string(id)
|
|
206
|
+
except InvalidUrnError:
|
|
207
|
+
raise InvalidUrnError(f'Expecting a PlatformResourceUrn but got {id}')
|
|
208
|
+
else:
|
|
209
|
+
id = UrnEncoder.encode_string(id)
|
|
170
210
|
|
|
171
211
|
# Validation logic.
|
|
172
212
|
if not id:
|
|
173
213
|
raise InvalidUrnError("PlatformResourceUrn id cannot be empty")
|
|
214
|
+
if isinstance(id, PlatformResourceUrn):
|
|
215
|
+
id = id.id
|
|
216
|
+
elif isinstance(id, Urn):
|
|
217
|
+
raise InvalidUrnError(f'Expecting a PlatformResourceUrn but got {id}')
|
|
174
218
|
if UrnEncoder.contains_reserved_char(id):
|
|
175
219
|
raise InvalidUrnError(f'PlatformResourceUrn id contains reserved characters')
|
|
176
220
|
|
|
@@ -178,8 +222,8 @@ class PlatformResourceUrn(_SpecificUrn):
|
|
|
178
222
|
|
|
179
223
|
@classmethod
|
|
180
224
|
def _parse_ids(cls, entity_ids: List[str]) -> "PlatformResourceUrn":
|
|
181
|
-
if len(entity_ids) != cls.
|
|
182
|
-
raise InvalidUrnError(f"PlatformResourceUrn should have {cls.
|
|
225
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
226
|
+
raise InvalidUrnError(f"PlatformResourceUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
183
227
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
184
228
|
|
|
185
229
|
@classmethod
|
|
@@ -199,23 +243,34 @@ class PlatformResourceUrn(_SpecificUrn):
|
|
|
199
243
|
|
|
200
244
|
@property
|
|
201
245
|
def id(self) -> str:
|
|
202
|
-
return self.
|
|
246
|
+
return self._entity_ids[0]
|
|
203
247
|
|
|
204
248
|
if TYPE_CHECKING:
|
|
205
249
|
from datahub.metadata.schema_classes import BusinessAttributeKeyClass
|
|
206
250
|
|
|
207
251
|
class BusinessAttributeUrn(_SpecificUrn):
|
|
208
|
-
ENTITY_TYPE: ClassVar[
|
|
209
|
-
|
|
252
|
+
ENTITY_TYPE: ClassVar[Literal["businessAttribute"]] = "businessAttribute"
|
|
253
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
210
254
|
|
|
211
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
255
|
+
def __init__(self, id: Union["BusinessAttributeUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
212
256
|
if _allow_coercion:
|
|
213
257
|
# Field coercion logic (if any is required).
|
|
214
|
-
|
|
258
|
+
if isinstance(id, str):
|
|
259
|
+
if id.startswith('urn:li:'):
|
|
260
|
+
try:
|
|
261
|
+
id = BusinessAttributeUrn.from_string(id)
|
|
262
|
+
except InvalidUrnError:
|
|
263
|
+
raise InvalidUrnError(f'Expecting a BusinessAttributeUrn but got {id}')
|
|
264
|
+
else:
|
|
265
|
+
id = UrnEncoder.encode_string(id)
|
|
215
266
|
|
|
216
267
|
# Validation logic.
|
|
217
268
|
if not id:
|
|
218
269
|
raise InvalidUrnError("BusinessAttributeUrn id cannot be empty")
|
|
270
|
+
if isinstance(id, BusinessAttributeUrn):
|
|
271
|
+
id = id.id
|
|
272
|
+
elif isinstance(id, Urn):
|
|
273
|
+
raise InvalidUrnError(f'Expecting a BusinessAttributeUrn but got {id}')
|
|
219
274
|
if UrnEncoder.contains_reserved_char(id):
|
|
220
275
|
raise InvalidUrnError(f'BusinessAttributeUrn id contains reserved characters')
|
|
221
276
|
|
|
@@ -223,8 +278,8 @@ class BusinessAttributeUrn(_SpecificUrn):
|
|
|
223
278
|
|
|
224
279
|
@classmethod
|
|
225
280
|
def _parse_ids(cls, entity_ids: List[str]) -> "BusinessAttributeUrn":
|
|
226
|
-
if len(entity_ids) != cls.
|
|
227
|
-
raise InvalidUrnError(f"BusinessAttributeUrn should have {cls.
|
|
281
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
282
|
+
raise InvalidUrnError(f"BusinessAttributeUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
228
283
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
229
284
|
|
|
230
285
|
@classmethod
|
|
@@ -244,23 +299,34 @@ class BusinessAttributeUrn(_SpecificUrn):
|
|
|
244
299
|
|
|
245
300
|
@property
|
|
246
301
|
def id(self) -> str:
|
|
247
|
-
return self.
|
|
302
|
+
return self._entity_ids[0]
|
|
248
303
|
|
|
249
304
|
if TYPE_CHECKING:
|
|
250
305
|
from datahub.metadata.schema_classes import DataTypeKeyClass
|
|
251
306
|
|
|
252
307
|
class DataTypeUrn(_SpecificUrn):
|
|
253
|
-
ENTITY_TYPE: ClassVar[
|
|
254
|
-
|
|
308
|
+
ENTITY_TYPE: ClassVar[Literal["dataType"]] = "dataType"
|
|
309
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
255
310
|
|
|
256
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
311
|
+
def __init__(self, id: Union["DataTypeUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
257
312
|
if _allow_coercion:
|
|
258
313
|
# Field coercion logic (if any is required).
|
|
259
|
-
|
|
314
|
+
if isinstance(id, str):
|
|
315
|
+
if id.startswith('urn:li:'):
|
|
316
|
+
try:
|
|
317
|
+
id = DataTypeUrn.from_string(id)
|
|
318
|
+
except InvalidUrnError:
|
|
319
|
+
raise InvalidUrnError(f'Expecting a DataTypeUrn but got {id}')
|
|
320
|
+
else:
|
|
321
|
+
id = UrnEncoder.encode_string(id)
|
|
260
322
|
|
|
261
323
|
# Validation logic.
|
|
262
324
|
if not id:
|
|
263
325
|
raise InvalidUrnError("DataTypeUrn id cannot be empty")
|
|
326
|
+
if isinstance(id, DataTypeUrn):
|
|
327
|
+
id = id.id
|
|
328
|
+
elif isinstance(id, Urn):
|
|
329
|
+
raise InvalidUrnError(f'Expecting a DataTypeUrn but got {id}')
|
|
264
330
|
if UrnEncoder.contains_reserved_char(id):
|
|
265
331
|
raise InvalidUrnError(f'DataTypeUrn id contains reserved characters')
|
|
266
332
|
|
|
@@ -268,8 +334,8 @@ class DataTypeUrn(_SpecificUrn):
|
|
|
268
334
|
|
|
269
335
|
@classmethod
|
|
270
336
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataTypeUrn":
|
|
271
|
-
if len(entity_ids) != cls.
|
|
272
|
-
raise InvalidUrnError(f"DataTypeUrn should have {cls.
|
|
337
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
338
|
+
raise InvalidUrnError(f"DataTypeUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
273
339
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
274
340
|
|
|
275
341
|
@classmethod
|
|
@@ -289,23 +355,34 @@ class DataTypeUrn(_SpecificUrn):
|
|
|
289
355
|
|
|
290
356
|
@property
|
|
291
357
|
def id(self) -> str:
|
|
292
|
-
return self.
|
|
358
|
+
return self._entity_ids[0]
|
|
293
359
|
|
|
294
360
|
if TYPE_CHECKING:
|
|
295
361
|
from datahub.metadata.schema_classes import InviteTokenKeyClass
|
|
296
362
|
|
|
297
363
|
class InviteTokenUrn(_SpecificUrn):
|
|
298
|
-
ENTITY_TYPE: ClassVar[
|
|
299
|
-
|
|
364
|
+
ENTITY_TYPE: ClassVar[Literal["inviteToken"]] = "inviteToken"
|
|
365
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
300
366
|
|
|
301
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
367
|
+
def __init__(self, id: Union["InviteTokenUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
302
368
|
if _allow_coercion:
|
|
303
369
|
# Field coercion logic (if any is required).
|
|
304
|
-
|
|
370
|
+
if isinstance(id, str):
|
|
371
|
+
if id.startswith('urn:li:'):
|
|
372
|
+
try:
|
|
373
|
+
id = InviteTokenUrn.from_string(id)
|
|
374
|
+
except InvalidUrnError:
|
|
375
|
+
raise InvalidUrnError(f'Expecting a InviteTokenUrn but got {id}')
|
|
376
|
+
else:
|
|
377
|
+
id = UrnEncoder.encode_string(id)
|
|
305
378
|
|
|
306
379
|
# Validation logic.
|
|
307
380
|
if not id:
|
|
308
381
|
raise InvalidUrnError("InviteTokenUrn id cannot be empty")
|
|
382
|
+
if isinstance(id, InviteTokenUrn):
|
|
383
|
+
id = id.id
|
|
384
|
+
elif isinstance(id, Urn):
|
|
385
|
+
raise InvalidUrnError(f'Expecting a InviteTokenUrn but got {id}')
|
|
309
386
|
if UrnEncoder.contains_reserved_char(id):
|
|
310
387
|
raise InvalidUrnError(f'InviteTokenUrn id contains reserved characters')
|
|
311
388
|
|
|
@@ -313,8 +390,8 @@ class InviteTokenUrn(_SpecificUrn):
|
|
|
313
390
|
|
|
314
391
|
@classmethod
|
|
315
392
|
def _parse_ids(cls, entity_ids: List[str]) -> "InviteTokenUrn":
|
|
316
|
-
if len(entity_ids) != cls.
|
|
317
|
-
raise InvalidUrnError(f"InviteTokenUrn should have {cls.
|
|
393
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
394
|
+
raise InvalidUrnError(f"InviteTokenUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
318
395
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
319
396
|
|
|
320
397
|
@classmethod
|
|
@@ -334,23 +411,34 @@ class InviteTokenUrn(_SpecificUrn):
|
|
|
334
411
|
|
|
335
412
|
@property
|
|
336
413
|
def id(self) -> str:
|
|
337
|
-
return self.
|
|
414
|
+
return self._entity_ids[0]
|
|
338
415
|
|
|
339
416
|
if TYPE_CHECKING:
|
|
340
417
|
from datahub.metadata.schema_classes import AssertionKeyClass
|
|
341
418
|
|
|
342
419
|
class AssertionUrn(_SpecificUrn):
|
|
343
|
-
ENTITY_TYPE: ClassVar[
|
|
344
|
-
|
|
420
|
+
ENTITY_TYPE: ClassVar[Literal["assertion"]] = "assertion"
|
|
421
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
345
422
|
|
|
346
|
-
def __init__(self, assertion_id: str, *, _allow_coercion: bool = True) -> None:
|
|
423
|
+
def __init__(self, assertion_id: Union["AssertionUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
347
424
|
if _allow_coercion:
|
|
348
425
|
# Field coercion logic (if any is required).
|
|
349
|
-
|
|
426
|
+
if isinstance(assertion_id, str):
|
|
427
|
+
if assertion_id.startswith('urn:li:'):
|
|
428
|
+
try:
|
|
429
|
+
assertion_id = AssertionUrn.from_string(assertion_id)
|
|
430
|
+
except InvalidUrnError:
|
|
431
|
+
raise InvalidUrnError(f'Expecting a AssertionUrn but got {assertion_id}')
|
|
432
|
+
else:
|
|
433
|
+
assertion_id = UrnEncoder.encode_string(assertion_id)
|
|
350
434
|
|
|
351
435
|
# Validation logic.
|
|
352
436
|
if not assertion_id:
|
|
353
437
|
raise InvalidUrnError("AssertionUrn assertion_id cannot be empty")
|
|
438
|
+
if isinstance(assertion_id, AssertionUrn):
|
|
439
|
+
assertion_id = assertion_id.assertion_id
|
|
440
|
+
elif isinstance(assertion_id, Urn):
|
|
441
|
+
raise InvalidUrnError(f'Expecting a AssertionUrn but got {assertion_id}')
|
|
354
442
|
if UrnEncoder.contains_reserved_char(assertion_id):
|
|
355
443
|
raise InvalidUrnError(f'AssertionUrn assertion_id contains reserved characters')
|
|
356
444
|
|
|
@@ -358,8 +446,8 @@ class AssertionUrn(_SpecificUrn):
|
|
|
358
446
|
|
|
359
447
|
@classmethod
|
|
360
448
|
def _parse_ids(cls, entity_ids: List[str]) -> "AssertionUrn":
|
|
361
|
-
if len(entity_ids) != cls.
|
|
362
|
-
raise InvalidUrnError(f"AssertionUrn should have {cls.
|
|
449
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
450
|
+
raise InvalidUrnError(f"AssertionUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
363
451
|
return cls(assertion_id=entity_ids[0], _allow_coercion=False)
|
|
364
452
|
|
|
365
453
|
@classmethod
|
|
@@ -379,24 +467,32 @@ class AssertionUrn(_SpecificUrn):
|
|
|
379
467
|
|
|
380
468
|
@property
|
|
381
469
|
def assertion_id(self) -> str:
|
|
382
|
-
return self.
|
|
470
|
+
return self._entity_ids[0]
|
|
383
471
|
|
|
384
472
|
if TYPE_CHECKING:
|
|
385
473
|
from datahub.metadata.schema_classes import SchemaFieldKeyClass
|
|
386
474
|
|
|
387
475
|
class SchemaFieldUrn(_SpecificUrn):
|
|
388
|
-
ENTITY_TYPE: ClassVar[
|
|
389
|
-
|
|
476
|
+
ENTITY_TYPE: ClassVar[Literal["schemaField"]] = "schemaField"
|
|
477
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
390
478
|
|
|
391
|
-
def __init__(self, parent: str, field_path: str, *, _allow_coercion: bool = True) -> None:
|
|
479
|
+
def __init__(self, parent: Union["Urn", str], field_path: str, *, _allow_coercion: bool = True) -> None:
|
|
392
480
|
if _allow_coercion:
|
|
393
481
|
# Field coercion logic (if any is required).
|
|
482
|
+
if isinstance(parent, str):
|
|
483
|
+
if parent.startswith('urn:li:'):
|
|
484
|
+
try:
|
|
485
|
+
parent = Urn.from_string(parent)
|
|
486
|
+
except InvalidUrnError:
|
|
487
|
+
raise InvalidUrnError(f'Expecting a Urn but got {parent}')
|
|
488
|
+
else:
|
|
489
|
+
parent = UrnEncoder.encode_string(parent)
|
|
394
490
|
field_path = UrnEncoder.encode_string(field_path)
|
|
395
491
|
|
|
396
492
|
# Validation logic.
|
|
397
493
|
if not parent:
|
|
398
494
|
raise InvalidUrnError("SchemaFieldUrn parent cannot be empty")
|
|
399
|
-
parent = str(parent)
|
|
495
|
+
parent = str(parent) # convert urn type to str
|
|
400
496
|
assert Urn.from_string(parent)
|
|
401
497
|
if not field_path:
|
|
402
498
|
raise InvalidUrnError("SchemaFieldUrn field_path cannot be empty")
|
|
@@ -407,8 +503,8 @@ class SchemaFieldUrn(_SpecificUrn):
|
|
|
407
503
|
|
|
408
504
|
@classmethod
|
|
409
505
|
def _parse_ids(cls, entity_ids: List[str]) -> "SchemaFieldUrn":
|
|
410
|
-
if len(entity_ids) != cls.
|
|
411
|
-
raise InvalidUrnError(f"SchemaFieldUrn should have {cls.
|
|
506
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
507
|
+
raise InvalidUrnError(f"SchemaFieldUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
412
508
|
return cls(parent=entity_ids[0], field_path=entity_ids[1], _allow_coercion=False)
|
|
413
509
|
|
|
414
510
|
@classmethod
|
|
@@ -428,27 +524,38 @@ class SchemaFieldUrn(_SpecificUrn):
|
|
|
428
524
|
|
|
429
525
|
@property
|
|
430
526
|
def parent(self) -> str:
|
|
431
|
-
return self.
|
|
527
|
+
return self._entity_ids[0]
|
|
432
528
|
|
|
433
529
|
@property
|
|
434
530
|
def field_path(self) -> str:
|
|
435
|
-
return self.
|
|
531
|
+
return self._entity_ids[1]
|
|
436
532
|
|
|
437
533
|
if TYPE_CHECKING:
|
|
438
534
|
from datahub.metadata.schema_classes import CorpGroupKeyClass
|
|
439
535
|
|
|
440
536
|
class CorpGroupUrn(_SpecificUrn):
|
|
441
|
-
ENTITY_TYPE: ClassVar[
|
|
442
|
-
|
|
537
|
+
ENTITY_TYPE: ClassVar[Literal["corpGroup"]] = "corpGroup"
|
|
538
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
443
539
|
|
|
444
|
-
def __init__(self, name: str, *, _allow_coercion: bool = True) -> None:
|
|
540
|
+
def __init__(self, name: Union["CorpGroupUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
445
541
|
if _allow_coercion:
|
|
446
542
|
# Field coercion logic (if any is required).
|
|
447
|
-
|
|
543
|
+
if isinstance(name, str):
|
|
544
|
+
if name.startswith('urn:li:'):
|
|
545
|
+
try:
|
|
546
|
+
name = CorpGroupUrn.from_string(name)
|
|
547
|
+
except InvalidUrnError:
|
|
548
|
+
raise InvalidUrnError(f'Expecting a CorpGroupUrn but got {name}')
|
|
549
|
+
else:
|
|
550
|
+
name = UrnEncoder.encode_string(name)
|
|
448
551
|
|
|
449
552
|
# Validation logic.
|
|
450
553
|
if not name:
|
|
451
554
|
raise InvalidUrnError("CorpGroupUrn name cannot be empty")
|
|
555
|
+
if isinstance(name, CorpGroupUrn):
|
|
556
|
+
name = name.name
|
|
557
|
+
elif isinstance(name, Urn):
|
|
558
|
+
raise InvalidUrnError(f'Expecting a CorpGroupUrn but got {name}')
|
|
452
559
|
if UrnEncoder.contains_reserved_char(name):
|
|
453
560
|
raise InvalidUrnError(f'CorpGroupUrn name contains reserved characters')
|
|
454
561
|
|
|
@@ -456,8 +563,8 @@ class CorpGroupUrn(_SpecificUrn):
|
|
|
456
563
|
|
|
457
564
|
@classmethod
|
|
458
565
|
def _parse_ids(cls, entity_ids: List[str]) -> "CorpGroupUrn":
|
|
459
|
-
if len(entity_ids) != cls.
|
|
460
|
-
raise InvalidUrnError(f"CorpGroupUrn should have {cls.
|
|
566
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
567
|
+
raise InvalidUrnError(f"CorpGroupUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
461
568
|
return cls(name=entity_ids[0], _allow_coercion=False)
|
|
462
569
|
|
|
463
570
|
@classmethod
|
|
@@ -482,23 +589,34 @@ class CorpGroupUrn(_SpecificUrn):
|
|
|
482
589
|
|
|
483
590
|
@property
|
|
484
591
|
def name(self) -> str:
|
|
485
|
-
return self.
|
|
592
|
+
return self._entity_ids[0]
|
|
486
593
|
|
|
487
594
|
if TYPE_CHECKING:
|
|
488
595
|
from datahub.metadata.schema_classes import RoleKeyClass
|
|
489
596
|
|
|
490
597
|
class RoleUrn(_SpecificUrn):
|
|
491
|
-
ENTITY_TYPE: ClassVar[
|
|
492
|
-
|
|
598
|
+
ENTITY_TYPE: ClassVar[Literal["role"]] = "role"
|
|
599
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
493
600
|
|
|
494
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
601
|
+
def __init__(self, id: Union["RoleUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
495
602
|
if _allow_coercion:
|
|
496
603
|
# Field coercion logic (if any is required).
|
|
497
|
-
|
|
604
|
+
if isinstance(id, str):
|
|
605
|
+
if id.startswith('urn:li:'):
|
|
606
|
+
try:
|
|
607
|
+
id = RoleUrn.from_string(id)
|
|
608
|
+
except InvalidUrnError:
|
|
609
|
+
raise InvalidUrnError(f'Expecting a RoleUrn but got {id}')
|
|
610
|
+
else:
|
|
611
|
+
id = UrnEncoder.encode_string(id)
|
|
498
612
|
|
|
499
613
|
# Validation logic.
|
|
500
614
|
if not id:
|
|
501
615
|
raise InvalidUrnError("RoleUrn id cannot be empty")
|
|
616
|
+
if isinstance(id, RoleUrn):
|
|
617
|
+
id = id.id
|
|
618
|
+
elif isinstance(id, Urn):
|
|
619
|
+
raise InvalidUrnError(f'Expecting a RoleUrn but got {id}')
|
|
502
620
|
if UrnEncoder.contains_reserved_char(id):
|
|
503
621
|
raise InvalidUrnError(f'RoleUrn id contains reserved characters')
|
|
504
622
|
|
|
@@ -506,8 +624,8 @@ class RoleUrn(_SpecificUrn):
|
|
|
506
624
|
|
|
507
625
|
@classmethod
|
|
508
626
|
def _parse_ids(cls, entity_ids: List[str]) -> "RoleUrn":
|
|
509
|
-
if len(entity_ids) != cls.
|
|
510
|
-
raise InvalidUrnError(f"RoleUrn should have {cls.
|
|
627
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
628
|
+
raise InvalidUrnError(f"RoleUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
511
629
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
512
630
|
|
|
513
631
|
@classmethod
|
|
@@ -527,23 +645,34 @@ class RoleUrn(_SpecificUrn):
|
|
|
527
645
|
|
|
528
646
|
@property
|
|
529
647
|
def id(self) -> str:
|
|
530
|
-
return self.
|
|
648
|
+
return self._entity_ids[0]
|
|
531
649
|
|
|
532
650
|
if TYPE_CHECKING:
|
|
533
651
|
from datahub.metadata.schema_classes import DataProcessInstanceKeyClass
|
|
534
652
|
|
|
535
653
|
class DataProcessInstanceUrn(_SpecificUrn):
|
|
536
|
-
ENTITY_TYPE: ClassVar[
|
|
537
|
-
|
|
654
|
+
ENTITY_TYPE: ClassVar[Literal["dataProcessInstance"]] = "dataProcessInstance"
|
|
655
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
538
656
|
|
|
539
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
657
|
+
def __init__(self, id: Union["DataProcessInstanceUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
540
658
|
if _allow_coercion:
|
|
541
659
|
# Field coercion logic (if any is required).
|
|
542
|
-
|
|
660
|
+
if isinstance(id, str):
|
|
661
|
+
if id.startswith('urn:li:'):
|
|
662
|
+
try:
|
|
663
|
+
id = DataProcessInstanceUrn.from_string(id)
|
|
664
|
+
except InvalidUrnError:
|
|
665
|
+
raise InvalidUrnError(f'Expecting a DataProcessInstanceUrn but got {id}')
|
|
666
|
+
else:
|
|
667
|
+
id = UrnEncoder.encode_string(id)
|
|
543
668
|
|
|
544
669
|
# Validation logic.
|
|
545
670
|
if not id:
|
|
546
671
|
raise InvalidUrnError("DataProcessInstanceUrn id cannot be empty")
|
|
672
|
+
if isinstance(id, DataProcessInstanceUrn):
|
|
673
|
+
id = id.id
|
|
674
|
+
elif isinstance(id, Urn):
|
|
675
|
+
raise InvalidUrnError(f'Expecting a DataProcessInstanceUrn but got {id}')
|
|
547
676
|
if UrnEncoder.contains_reserved_char(id):
|
|
548
677
|
raise InvalidUrnError(f'DataProcessInstanceUrn id contains reserved characters')
|
|
549
678
|
|
|
@@ -551,8 +680,8 @@ class DataProcessInstanceUrn(_SpecificUrn):
|
|
|
551
680
|
|
|
552
681
|
@classmethod
|
|
553
682
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataProcessInstanceUrn":
|
|
554
|
-
if len(entity_ids) != cls.
|
|
555
|
-
raise InvalidUrnError(f"DataProcessInstanceUrn should have {cls.
|
|
683
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
684
|
+
raise InvalidUrnError(f"DataProcessInstanceUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
556
685
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
557
686
|
|
|
558
687
|
@classmethod
|
|
@@ -581,23 +710,34 @@ class DataProcessInstanceUrn(_SpecificUrn):
|
|
|
581
710
|
|
|
582
711
|
@property
|
|
583
712
|
def id(self) -> str:
|
|
584
|
-
return self.
|
|
713
|
+
return self._entity_ids[0]
|
|
585
714
|
|
|
586
715
|
if TYPE_CHECKING:
|
|
587
716
|
from datahub.metadata.schema_classes import DataHubSecretKeyClass
|
|
588
717
|
|
|
589
718
|
class DataHubSecretUrn(_SpecificUrn):
|
|
590
|
-
ENTITY_TYPE: ClassVar[
|
|
591
|
-
|
|
719
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubSecret"]] = "dataHubSecret"
|
|
720
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
592
721
|
|
|
593
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
722
|
+
def __init__(self, id: Union["DataHubSecretUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
594
723
|
if _allow_coercion:
|
|
595
724
|
# Field coercion logic (if any is required).
|
|
596
|
-
|
|
725
|
+
if isinstance(id, str):
|
|
726
|
+
if id.startswith('urn:li:'):
|
|
727
|
+
try:
|
|
728
|
+
id = DataHubSecretUrn.from_string(id)
|
|
729
|
+
except InvalidUrnError:
|
|
730
|
+
raise InvalidUrnError(f'Expecting a DataHubSecretUrn but got {id}')
|
|
731
|
+
else:
|
|
732
|
+
id = UrnEncoder.encode_string(id)
|
|
597
733
|
|
|
598
734
|
# Validation logic.
|
|
599
735
|
if not id:
|
|
600
736
|
raise InvalidUrnError("DataHubSecretUrn id cannot be empty")
|
|
737
|
+
if isinstance(id, DataHubSecretUrn):
|
|
738
|
+
id = id.id
|
|
739
|
+
elif isinstance(id, Urn):
|
|
740
|
+
raise InvalidUrnError(f'Expecting a DataHubSecretUrn but got {id}')
|
|
601
741
|
if UrnEncoder.contains_reserved_char(id):
|
|
602
742
|
raise InvalidUrnError(f'DataHubSecretUrn id contains reserved characters')
|
|
603
743
|
|
|
@@ -605,8 +745,8 @@ class DataHubSecretUrn(_SpecificUrn):
|
|
|
605
745
|
|
|
606
746
|
@classmethod
|
|
607
747
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubSecretUrn":
|
|
608
|
-
if len(entity_ids) != cls.
|
|
609
|
-
raise InvalidUrnError(f"DataHubSecretUrn should have {cls.
|
|
748
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
749
|
+
raise InvalidUrnError(f"DataHubSecretUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
610
750
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
611
751
|
|
|
612
752
|
@classmethod
|
|
@@ -626,23 +766,34 @@ class DataHubSecretUrn(_SpecificUrn):
|
|
|
626
766
|
|
|
627
767
|
@property
|
|
628
768
|
def id(self) -> str:
|
|
629
|
-
return self.
|
|
769
|
+
return self._entity_ids[0]
|
|
630
770
|
|
|
631
771
|
if TYPE_CHECKING:
|
|
632
772
|
from datahub.metadata.schema_classes import DataHubPersonaKeyClass
|
|
633
773
|
|
|
634
774
|
class DataHubPersonaUrn(_SpecificUrn):
|
|
635
|
-
ENTITY_TYPE: ClassVar[
|
|
636
|
-
|
|
775
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubPersona"]] = "dataHubPersona"
|
|
776
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
637
777
|
|
|
638
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
778
|
+
def __init__(self, id: Union["DataHubPersonaUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
639
779
|
if _allow_coercion:
|
|
640
780
|
# Field coercion logic (if any is required).
|
|
641
|
-
|
|
781
|
+
if isinstance(id, str):
|
|
782
|
+
if id.startswith('urn:li:'):
|
|
783
|
+
try:
|
|
784
|
+
id = DataHubPersonaUrn.from_string(id)
|
|
785
|
+
except InvalidUrnError:
|
|
786
|
+
raise InvalidUrnError(f'Expecting a DataHubPersonaUrn but got {id}')
|
|
787
|
+
else:
|
|
788
|
+
id = UrnEncoder.encode_string(id)
|
|
642
789
|
|
|
643
790
|
# Validation logic.
|
|
644
791
|
if not id:
|
|
645
792
|
raise InvalidUrnError("DataHubPersonaUrn id cannot be empty")
|
|
793
|
+
if isinstance(id, DataHubPersonaUrn):
|
|
794
|
+
id = id.id
|
|
795
|
+
elif isinstance(id, Urn):
|
|
796
|
+
raise InvalidUrnError(f'Expecting a DataHubPersonaUrn but got {id}')
|
|
646
797
|
if UrnEncoder.contains_reserved_char(id):
|
|
647
798
|
raise InvalidUrnError(f'DataHubPersonaUrn id contains reserved characters')
|
|
648
799
|
|
|
@@ -650,8 +801,8 @@ class DataHubPersonaUrn(_SpecificUrn):
|
|
|
650
801
|
|
|
651
802
|
@classmethod
|
|
652
803
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubPersonaUrn":
|
|
653
|
-
if len(entity_ids) != cls.
|
|
654
|
-
raise InvalidUrnError(f"DataHubPersonaUrn should have {cls.
|
|
804
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
805
|
+
raise InvalidUrnError(f"DataHubPersonaUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
655
806
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
656
807
|
|
|
657
808
|
@classmethod
|
|
@@ -671,16 +822,16 @@ class DataHubPersonaUrn(_SpecificUrn):
|
|
|
671
822
|
|
|
672
823
|
@property
|
|
673
824
|
def id(self) -> str:
|
|
674
|
-
return self.
|
|
825
|
+
return self._entity_ids[0]
|
|
675
826
|
|
|
676
827
|
if TYPE_CHECKING:
|
|
677
828
|
from datahub.metadata.schema_classes import MLFeatureTableKeyClass
|
|
678
829
|
|
|
679
830
|
class MlFeatureTableUrn(_SpecificUrn):
|
|
680
|
-
ENTITY_TYPE: ClassVar[
|
|
681
|
-
|
|
831
|
+
ENTITY_TYPE: ClassVar[Literal["mlFeatureTable"]] = "mlFeatureTable"
|
|
832
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
682
833
|
|
|
683
|
-
def __init__(self, platform: str, name: str, *, _allow_coercion: bool = True) -> None:
|
|
834
|
+
def __init__(self, platform: Union["DataPlatformUrn", str], name: str, *, _allow_coercion: bool = True) -> None:
|
|
684
835
|
if _allow_coercion:
|
|
685
836
|
# Field coercion logic (if any is required).
|
|
686
837
|
platform = DataPlatformUrn(platform).urn()
|
|
@@ -689,7 +840,7 @@ class MlFeatureTableUrn(_SpecificUrn):
|
|
|
689
840
|
# Validation logic.
|
|
690
841
|
if not platform:
|
|
691
842
|
raise InvalidUrnError("MlFeatureTableUrn platform cannot be empty")
|
|
692
|
-
platform = str(platform)
|
|
843
|
+
platform = str(platform) # convert urn type to str
|
|
693
844
|
assert DataPlatformUrn.from_string(platform)
|
|
694
845
|
if not name:
|
|
695
846
|
raise InvalidUrnError("MlFeatureTableUrn name cannot be empty")
|
|
@@ -700,8 +851,8 @@ class MlFeatureTableUrn(_SpecificUrn):
|
|
|
700
851
|
|
|
701
852
|
@classmethod
|
|
702
853
|
def _parse_ids(cls, entity_ids: List[str]) -> "MlFeatureTableUrn":
|
|
703
|
-
if len(entity_ids) != cls.
|
|
704
|
-
raise InvalidUrnError(f"MlFeatureTableUrn should have {cls.
|
|
854
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
855
|
+
raise InvalidUrnError(f"MlFeatureTableUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
705
856
|
return cls(platform=entity_ids[0], name=entity_ids[1], _allow_coercion=False)
|
|
706
857
|
|
|
707
858
|
@classmethod
|
|
@@ -721,27 +872,38 @@ class MlFeatureTableUrn(_SpecificUrn):
|
|
|
721
872
|
|
|
722
873
|
@property
|
|
723
874
|
def platform(self) -> str:
|
|
724
|
-
return self.
|
|
875
|
+
return self._entity_ids[0]
|
|
725
876
|
|
|
726
877
|
@property
|
|
727
878
|
def name(self) -> str:
|
|
728
|
-
return self.
|
|
879
|
+
return self._entity_ids[1]
|
|
729
880
|
|
|
730
881
|
if TYPE_CHECKING:
|
|
731
882
|
from datahub.metadata.schema_classes import GlossaryTermKeyClass
|
|
732
883
|
|
|
733
884
|
class GlossaryTermUrn(_SpecificUrn):
|
|
734
|
-
ENTITY_TYPE: ClassVar[
|
|
735
|
-
|
|
885
|
+
ENTITY_TYPE: ClassVar[Literal["glossaryTerm"]] = "glossaryTerm"
|
|
886
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
736
887
|
|
|
737
|
-
def __init__(self, name: str, *, _allow_coercion: bool = True) -> None:
|
|
888
|
+
def __init__(self, name: Union["GlossaryTermUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
738
889
|
if _allow_coercion:
|
|
739
890
|
# Field coercion logic (if any is required).
|
|
740
|
-
|
|
891
|
+
if isinstance(name, str):
|
|
892
|
+
if name.startswith('urn:li:'):
|
|
893
|
+
try:
|
|
894
|
+
name = GlossaryTermUrn.from_string(name)
|
|
895
|
+
except InvalidUrnError:
|
|
896
|
+
raise InvalidUrnError(f'Expecting a GlossaryTermUrn but got {name}')
|
|
897
|
+
else:
|
|
898
|
+
name = UrnEncoder.encode_string(name)
|
|
741
899
|
|
|
742
900
|
# Validation logic.
|
|
743
901
|
if not name:
|
|
744
902
|
raise InvalidUrnError("GlossaryTermUrn name cannot be empty")
|
|
903
|
+
if isinstance(name, GlossaryTermUrn):
|
|
904
|
+
name = name.name
|
|
905
|
+
elif isinstance(name, Urn):
|
|
906
|
+
raise InvalidUrnError(f'Expecting a GlossaryTermUrn but got {name}')
|
|
745
907
|
if UrnEncoder.contains_reserved_char(name):
|
|
746
908
|
raise InvalidUrnError(f'GlossaryTermUrn name contains reserved characters')
|
|
747
909
|
|
|
@@ -749,8 +911,8 @@ class GlossaryTermUrn(_SpecificUrn):
|
|
|
749
911
|
|
|
750
912
|
@classmethod
|
|
751
913
|
def _parse_ids(cls, entity_ids: List[str]) -> "GlossaryTermUrn":
|
|
752
|
-
if len(entity_ids) != cls.
|
|
753
|
-
raise InvalidUrnError(f"GlossaryTermUrn should have {cls.
|
|
914
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
915
|
+
raise InvalidUrnError(f"GlossaryTermUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
754
916
|
return cls(name=entity_ids[0], _allow_coercion=False)
|
|
755
917
|
|
|
756
918
|
@classmethod
|
|
@@ -770,14 +932,14 @@ class GlossaryTermUrn(_SpecificUrn):
|
|
|
770
932
|
|
|
771
933
|
@property
|
|
772
934
|
def name(self) -> str:
|
|
773
|
-
return self.
|
|
935
|
+
return self._entity_ids[0]
|
|
774
936
|
|
|
775
937
|
if TYPE_CHECKING:
|
|
776
938
|
from datahub.metadata.schema_classes import RecommendationModuleKeyClass
|
|
777
939
|
|
|
778
940
|
class RecommendationModuleUrn(_SpecificUrn):
|
|
779
|
-
ENTITY_TYPE: ClassVar[
|
|
780
|
-
|
|
941
|
+
ENTITY_TYPE: ClassVar[Literal["recommendationModule"]] = "recommendationModule"
|
|
942
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
781
943
|
|
|
782
944
|
def __init__(self, module_id: str, identifier: str, *, _allow_coercion: bool = True) -> None:
|
|
783
945
|
if _allow_coercion:
|
|
@@ -799,8 +961,8 @@ class RecommendationModuleUrn(_SpecificUrn):
|
|
|
799
961
|
|
|
800
962
|
@classmethod
|
|
801
963
|
def _parse_ids(cls, entity_ids: List[str]) -> "RecommendationModuleUrn":
|
|
802
|
-
if len(entity_ids) != cls.
|
|
803
|
-
raise InvalidUrnError(f"RecommendationModuleUrn should have {cls.
|
|
964
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
965
|
+
raise InvalidUrnError(f"RecommendationModuleUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
804
966
|
return cls(module_id=entity_ids[0], identifier=entity_ids[1], _allow_coercion=False)
|
|
805
967
|
|
|
806
968
|
@classmethod
|
|
@@ -820,27 +982,38 @@ class RecommendationModuleUrn(_SpecificUrn):
|
|
|
820
982
|
|
|
821
983
|
@property
|
|
822
984
|
def module_id(self) -> str:
|
|
823
|
-
return self.
|
|
985
|
+
return self._entity_ids[0]
|
|
824
986
|
|
|
825
987
|
@property
|
|
826
988
|
def identifier(self) -> str:
|
|
827
|
-
return self.
|
|
989
|
+
return self._entity_ids[1]
|
|
828
990
|
|
|
829
991
|
if TYPE_CHECKING:
|
|
830
992
|
from datahub.metadata.schema_classes import PostKeyClass
|
|
831
993
|
|
|
832
994
|
class PostUrn(_SpecificUrn):
|
|
833
|
-
ENTITY_TYPE: ClassVar[
|
|
834
|
-
|
|
995
|
+
ENTITY_TYPE: ClassVar[Literal["post"]] = "post"
|
|
996
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
835
997
|
|
|
836
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
998
|
+
def __init__(self, id: Union["PostUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
837
999
|
if _allow_coercion:
|
|
838
1000
|
# Field coercion logic (if any is required).
|
|
839
|
-
|
|
1001
|
+
if isinstance(id, str):
|
|
1002
|
+
if id.startswith('urn:li:'):
|
|
1003
|
+
try:
|
|
1004
|
+
id = PostUrn.from_string(id)
|
|
1005
|
+
except InvalidUrnError:
|
|
1006
|
+
raise InvalidUrnError(f'Expecting a PostUrn but got {id}')
|
|
1007
|
+
else:
|
|
1008
|
+
id = UrnEncoder.encode_string(id)
|
|
840
1009
|
|
|
841
1010
|
# Validation logic.
|
|
842
1011
|
if not id:
|
|
843
1012
|
raise InvalidUrnError("PostUrn id cannot be empty")
|
|
1013
|
+
if isinstance(id, PostUrn):
|
|
1014
|
+
id = id.id
|
|
1015
|
+
elif isinstance(id, Urn):
|
|
1016
|
+
raise InvalidUrnError(f'Expecting a PostUrn but got {id}')
|
|
844
1017
|
if UrnEncoder.contains_reserved_char(id):
|
|
845
1018
|
raise InvalidUrnError(f'PostUrn id contains reserved characters')
|
|
846
1019
|
|
|
@@ -848,8 +1021,8 @@ class PostUrn(_SpecificUrn):
|
|
|
848
1021
|
|
|
849
1022
|
@classmethod
|
|
850
1023
|
def _parse_ids(cls, entity_ids: List[str]) -> "PostUrn":
|
|
851
|
-
if len(entity_ids) != cls.
|
|
852
|
-
raise InvalidUrnError(f"PostUrn should have {cls.
|
|
1024
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1025
|
+
raise InvalidUrnError(f"PostUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
853
1026
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
854
1027
|
|
|
855
1028
|
@classmethod
|
|
@@ -869,14 +1042,14 @@ class PostUrn(_SpecificUrn):
|
|
|
869
1042
|
|
|
870
1043
|
@property
|
|
871
1044
|
def id(self) -> str:
|
|
872
|
-
return self.
|
|
1045
|
+
return self._entity_ids[0]
|
|
873
1046
|
|
|
874
1047
|
if TYPE_CHECKING:
|
|
875
1048
|
from datahub.metadata.schema_classes import MLPrimaryKeyKeyClass
|
|
876
1049
|
|
|
877
1050
|
class MlPrimaryKeyUrn(_SpecificUrn):
|
|
878
|
-
ENTITY_TYPE: ClassVar[
|
|
879
|
-
|
|
1051
|
+
ENTITY_TYPE: ClassVar[Literal["mlPrimaryKey"]] = "mlPrimaryKey"
|
|
1052
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
880
1053
|
|
|
881
1054
|
def __init__(self, feature_namespace: str, name: str, *, _allow_coercion: bool = True) -> None:
|
|
882
1055
|
if _allow_coercion:
|
|
@@ -898,8 +1071,8 @@ class MlPrimaryKeyUrn(_SpecificUrn):
|
|
|
898
1071
|
|
|
899
1072
|
@classmethod
|
|
900
1073
|
def _parse_ids(cls, entity_ids: List[str]) -> "MlPrimaryKeyUrn":
|
|
901
|
-
if len(entity_ids) != cls.
|
|
902
|
-
raise InvalidUrnError(f"MlPrimaryKeyUrn should have {cls.
|
|
1074
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1075
|
+
raise InvalidUrnError(f"MlPrimaryKeyUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
903
1076
|
return cls(feature_namespace=entity_ids[0], name=entity_ids[1], _allow_coercion=False)
|
|
904
1077
|
|
|
905
1078
|
@classmethod
|
|
@@ -919,20 +1092,20 @@ class MlPrimaryKeyUrn(_SpecificUrn):
|
|
|
919
1092
|
|
|
920
1093
|
@property
|
|
921
1094
|
def feature_namespace(self) -> str:
|
|
922
|
-
return self.
|
|
1095
|
+
return self._entity_ids[0]
|
|
923
1096
|
|
|
924
1097
|
@property
|
|
925
1098
|
def name(self) -> str:
|
|
926
|
-
return self.
|
|
1099
|
+
return self._entity_ids[1]
|
|
927
1100
|
|
|
928
1101
|
if TYPE_CHECKING:
|
|
929
1102
|
from datahub.metadata.schema_classes import DataPlatformInstanceKeyClass
|
|
930
1103
|
|
|
931
1104
|
class DataPlatformInstanceUrn(_SpecificUrn):
|
|
932
|
-
ENTITY_TYPE: ClassVar[
|
|
933
|
-
|
|
1105
|
+
ENTITY_TYPE: ClassVar[Literal["dataPlatformInstance"]] = "dataPlatformInstance"
|
|
1106
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
934
1107
|
|
|
935
|
-
def __init__(self, platform: str, instance: str, *, _allow_coercion: bool = True) -> None:
|
|
1108
|
+
def __init__(self, platform: Union["DataPlatformUrn", str], instance: str, *, _allow_coercion: bool = True) -> None:
|
|
936
1109
|
if _allow_coercion:
|
|
937
1110
|
# Field coercion logic (if any is required).
|
|
938
1111
|
platform = DataPlatformUrn(platform).urn()
|
|
@@ -941,7 +1114,7 @@ class DataPlatformInstanceUrn(_SpecificUrn):
|
|
|
941
1114
|
# Validation logic.
|
|
942
1115
|
if not platform:
|
|
943
1116
|
raise InvalidUrnError("DataPlatformInstanceUrn platform cannot be empty")
|
|
944
|
-
platform = str(platform)
|
|
1117
|
+
platform = str(platform) # convert urn type to str
|
|
945
1118
|
assert DataPlatformUrn.from_string(platform)
|
|
946
1119
|
if not instance:
|
|
947
1120
|
raise InvalidUrnError("DataPlatformInstanceUrn instance cannot be empty")
|
|
@@ -952,8 +1125,8 @@ class DataPlatformInstanceUrn(_SpecificUrn):
|
|
|
952
1125
|
|
|
953
1126
|
@classmethod
|
|
954
1127
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataPlatformInstanceUrn":
|
|
955
|
-
if len(entity_ids) != cls.
|
|
956
|
-
raise InvalidUrnError(f"DataPlatformInstanceUrn should have {cls.
|
|
1128
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1129
|
+
raise InvalidUrnError(f"DataPlatformInstanceUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
957
1130
|
return cls(platform=entity_ids[0], instance=entity_ids[1], _allow_coercion=False)
|
|
958
1131
|
|
|
959
1132
|
@classmethod
|
|
@@ -973,27 +1146,94 @@ class DataPlatformInstanceUrn(_SpecificUrn):
|
|
|
973
1146
|
|
|
974
1147
|
@property
|
|
975
1148
|
def platform(self) -> str:
|
|
976
|
-
return self.
|
|
1149
|
+
return self._entity_ids[0]
|
|
977
1150
|
|
|
978
1151
|
@property
|
|
979
1152
|
def instance(self) -> str:
|
|
980
|
-
return self.
|
|
1153
|
+
return self._entity_ids[1]
|
|
1154
|
+
|
|
1155
|
+
if TYPE_CHECKING:
|
|
1156
|
+
from datahub.metadata.schema_classes import DataHubMetricCubeKeyClass
|
|
1157
|
+
|
|
1158
|
+
class DataHubMetricCubeUrn(_SpecificUrn):
|
|
1159
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubMetricCube"]] = "dataHubMetricCube"
|
|
1160
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1161
|
+
|
|
1162
|
+
def __init__(self, id: Union["DataHubMetricCubeUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1163
|
+
if _allow_coercion:
|
|
1164
|
+
# Field coercion logic (if any is required).
|
|
1165
|
+
if isinstance(id, str):
|
|
1166
|
+
if id.startswith('urn:li:'):
|
|
1167
|
+
try:
|
|
1168
|
+
id = DataHubMetricCubeUrn.from_string(id)
|
|
1169
|
+
except InvalidUrnError:
|
|
1170
|
+
raise InvalidUrnError(f'Expecting a DataHubMetricCubeUrn but got {id}')
|
|
1171
|
+
else:
|
|
1172
|
+
id = UrnEncoder.encode_string(id)
|
|
1173
|
+
|
|
1174
|
+
# Validation logic.
|
|
1175
|
+
if not id:
|
|
1176
|
+
raise InvalidUrnError("DataHubMetricCubeUrn id cannot be empty")
|
|
1177
|
+
if isinstance(id, DataHubMetricCubeUrn):
|
|
1178
|
+
id = id.id
|
|
1179
|
+
elif isinstance(id, Urn):
|
|
1180
|
+
raise InvalidUrnError(f'Expecting a DataHubMetricCubeUrn but got {id}')
|
|
1181
|
+
if UrnEncoder.contains_reserved_char(id):
|
|
1182
|
+
raise InvalidUrnError(f'DataHubMetricCubeUrn id contains reserved characters')
|
|
1183
|
+
|
|
1184
|
+
super().__init__(self.ENTITY_TYPE, [id])
|
|
1185
|
+
|
|
1186
|
+
@classmethod
|
|
1187
|
+
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubMetricCubeUrn":
|
|
1188
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1189
|
+
raise InvalidUrnError(f"DataHubMetricCubeUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1190
|
+
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1191
|
+
|
|
1192
|
+
@classmethod
|
|
1193
|
+
def underlying_key_aspect_type(cls) -> Type["DataHubMetricCubeKeyClass"]:
|
|
1194
|
+
from datahub.metadata.schema_classes import DataHubMetricCubeKeyClass
|
|
1195
|
+
|
|
1196
|
+
return DataHubMetricCubeKeyClass
|
|
1197
|
+
|
|
1198
|
+
def to_key_aspect(self) -> "DataHubMetricCubeKeyClass":
|
|
1199
|
+
from datahub.metadata.schema_classes import DataHubMetricCubeKeyClass
|
|
1200
|
+
|
|
1201
|
+
return DataHubMetricCubeKeyClass(id=self.id)
|
|
1202
|
+
|
|
1203
|
+
@classmethod
|
|
1204
|
+
def from_key_aspect(cls, key_aspect: "DataHubMetricCubeKeyClass") -> "DataHubMetricCubeUrn":
|
|
1205
|
+
return cls(id=key_aspect.id)
|
|
1206
|
+
|
|
1207
|
+
@property
|
|
1208
|
+
def id(self) -> str:
|
|
1209
|
+
return self._entity_ids[0]
|
|
981
1210
|
|
|
982
1211
|
if TYPE_CHECKING:
|
|
983
1212
|
from datahub.metadata.schema_classes import QueryKeyClass
|
|
984
1213
|
|
|
985
1214
|
class QueryUrn(_SpecificUrn):
|
|
986
|
-
ENTITY_TYPE: ClassVar[
|
|
987
|
-
|
|
1215
|
+
ENTITY_TYPE: ClassVar[Literal["query"]] = "query"
|
|
1216
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
988
1217
|
|
|
989
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
1218
|
+
def __init__(self, id: Union["QueryUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
990
1219
|
if _allow_coercion:
|
|
991
1220
|
# Field coercion logic (if any is required).
|
|
992
|
-
|
|
1221
|
+
if isinstance(id, str):
|
|
1222
|
+
if id.startswith('urn:li:'):
|
|
1223
|
+
try:
|
|
1224
|
+
id = QueryUrn.from_string(id)
|
|
1225
|
+
except InvalidUrnError:
|
|
1226
|
+
raise InvalidUrnError(f'Expecting a QueryUrn but got {id}')
|
|
1227
|
+
else:
|
|
1228
|
+
id = UrnEncoder.encode_string(id)
|
|
993
1229
|
|
|
994
1230
|
# Validation logic.
|
|
995
1231
|
if not id:
|
|
996
1232
|
raise InvalidUrnError("QueryUrn id cannot be empty")
|
|
1233
|
+
if isinstance(id, QueryUrn):
|
|
1234
|
+
id = id.id
|
|
1235
|
+
elif isinstance(id, Urn):
|
|
1236
|
+
raise InvalidUrnError(f'Expecting a QueryUrn but got {id}')
|
|
997
1237
|
if UrnEncoder.contains_reserved_char(id):
|
|
998
1238
|
raise InvalidUrnError(f'QueryUrn id contains reserved characters')
|
|
999
1239
|
|
|
@@ -1001,8 +1241,8 @@ class QueryUrn(_SpecificUrn):
|
|
|
1001
1241
|
|
|
1002
1242
|
@classmethod
|
|
1003
1243
|
def _parse_ids(cls, entity_ids: List[str]) -> "QueryUrn":
|
|
1004
|
-
if len(entity_ids) != cls.
|
|
1005
|
-
raise InvalidUrnError(f"QueryUrn should have {cls.
|
|
1244
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1245
|
+
raise InvalidUrnError(f"QueryUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1006
1246
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1007
1247
|
|
|
1008
1248
|
@classmethod
|
|
@@ -1022,27 +1262,26 @@ class QueryUrn(_SpecificUrn):
|
|
|
1022
1262
|
|
|
1023
1263
|
@property
|
|
1024
1264
|
def id(self) -> str:
|
|
1025
|
-
return self.
|
|
1265
|
+
return self._entity_ids[0]
|
|
1026
1266
|
|
|
1027
1267
|
if TYPE_CHECKING:
|
|
1028
1268
|
from datahub.metadata.schema_classes import DatasetKeyClass
|
|
1029
1269
|
|
|
1030
1270
|
class DatasetUrn(_SpecificUrn):
|
|
1031
|
-
ENTITY_TYPE: ClassVar[
|
|
1032
|
-
|
|
1271
|
+
ENTITY_TYPE: ClassVar[Literal["dataset"]] = "dataset"
|
|
1272
|
+
_URN_PARTS: ClassVar[int] = 3
|
|
1033
1273
|
|
|
1034
|
-
def __init__(self, platform: str, name: str, env: str = "PROD", *, _allow_coercion: bool = True) -> None:
|
|
1274
|
+
def __init__(self, platform: Union["DataPlatformUrn", str], name: str, env: str = "PROD", *, _allow_coercion: bool = True) -> None:
|
|
1035
1275
|
if _allow_coercion:
|
|
1036
1276
|
# Field coercion logic (if any is required).
|
|
1037
1277
|
platform = DataPlatformUrn(platform).urn()
|
|
1038
1278
|
name = UrnEncoder.encode_string(name)
|
|
1039
1279
|
env = env.upper()
|
|
1040
|
-
env = UrnEncoder.encode_string(env)
|
|
1041
1280
|
|
|
1042
1281
|
# Validation logic.
|
|
1043
1282
|
if not platform:
|
|
1044
1283
|
raise InvalidUrnError("DatasetUrn platform cannot be empty")
|
|
1045
|
-
platform = str(platform)
|
|
1284
|
+
platform = str(platform) # convert urn type to str
|
|
1046
1285
|
assert DataPlatformUrn.from_string(platform)
|
|
1047
1286
|
if not name:
|
|
1048
1287
|
raise InvalidUrnError("DatasetUrn name cannot be empty")
|
|
@@ -1057,8 +1296,8 @@ class DatasetUrn(_SpecificUrn):
|
|
|
1057
1296
|
|
|
1058
1297
|
@classmethod
|
|
1059
1298
|
def _parse_ids(cls, entity_ids: List[str]) -> "DatasetUrn":
|
|
1060
|
-
if len(entity_ids) != cls.
|
|
1061
|
-
raise InvalidUrnError(f"DatasetUrn should have {cls.
|
|
1299
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1300
|
+
raise InvalidUrnError(f"DatasetUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1062
1301
|
return cls(platform=entity_ids[0], name=entity_ids[1], env=entity_ids[2], _allow_coercion=False)
|
|
1063
1302
|
|
|
1064
1303
|
@classmethod
|
|
@@ -1107,31 +1346,42 @@ class DatasetUrn(_SpecificUrn):
|
|
|
1107
1346
|
|
|
1108
1347
|
@property
|
|
1109
1348
|
def platform(self) -> str:
|
|
1110
|
-
return self.
|
|
1349
|
+
return self._entity_ids[0]
|
|
1111
1350
|
|
|
1112
1351
|
@property
|
|
1113
1352
|
def name(self) -> str:
|
|
1114
|
-
return self.
|
|
1353
|
+
return self._entity_ids[1]
|
|
1115
1354
|
|
|
1116
1355
|
@property
|
|
1117
1356
|
def env(self) -> str:
|
|
1118
|
-
return self.
|
|
1357
|
+
return self._entity_ids[2]
|
|
1119
1358
|
|
|
1120
1359
|
if TYPE_CHECKING:
|
|
1121
1360
|
from datahub.metadata.schema_classes import ExecutionRequestKeyClass
|
|
1122
1361
|
|
|
1123
1362
|
class DataHubExecutionRequestUrn(_SpecificUrn):
|
|
1124
|
-
ENTITY_TYPE: ClassVar[
|
|
1125
|
-
|
|
1363
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubExecutionRequest"]] = "dataHubExecutionRequest"
|
|
1364
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1126
1365
|
|
|
1127
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
1366
|
+
def __init__(self, id: Union["DataHubExecutionRequestUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1128
1367
|
if _allow_coercion:
|
|
1129
1368
|
# Field coercion logic (if any is required).
|
|
1130
|
-
|
|
1369
|
+
if isinstance(id, str):
|
|
1370
|
+
if id.startswith('urn:li:'):
|
|
1371
|
+
try:
|
|
1372
|
+
id = DataHubExecutionRequestUrn.from_string(id)
|
|
1373
|
+
except InvalidUrnError:
|
|
1374
|
+
raise InvalidUrnError(f'Expecting a DataHubExecutionRequestUrn but got {id}')
|
|
1375
|
+
else:
|
|
1376
|
+
id = UrnEncoder.encode_string(id)
|
|
1131
1377
|
|
|
1132
1378
|
# Validation logic.
|
|
1133
1379
|
if not id:
|
|
1134
1380
|
raise InvalidUrnError("DataHubExecutionRequestUrn id cannot be empty")
|
|
1381
|
+
if isinstance(id, DataHubExecutionRequestUrn):
|
|
1382
|
+
id = id.id
|
|
1383
|
+
elif isinstance(id, Urn):
|
|
1384
|
+
raise InvalidUrnError(f'Expecting a DataHubExecutionRequestUrn but got {id}')
|
|
1135
1385
|
if UrnEncoder.contains_reserved_char(id):
|
|
1136
1386
|
raise InvalidUrnError(f'DataHubExecutionRequestUrn id contains reserved characters')
|
|
1137
1387
|
|
|
@@ -1139,8 +1389,8 @@ class DataHubExecutionRequestUrn(_SpecificUrn):
|
|
|
1139
1389
|
|
|
1140
1390
|
@classmethod
|
|
1141
1391
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubExecutionRequestUrn":
|
|
1142
|
-
if len(entity_ids) != cls.
|
|
1143
|
-
raise InvalidUrnError(f"DataHubExecutionRequestUrn should have {cls.
|
|
1392
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1393
|
+
raise InvalidUrnError(f"DataHubExecutionRequestUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1144
1394
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1145
1395
|
|
|
1146
1396
|
@classmethod
|
|
@@ -1160,14 +1410,14 @@ class DataHubExecutionRequestUrn(_SpecificUrn):
|
|
|
1160
1410
|
|
|
1161
1411
|
@property
|
|
1162
1412
|
def id(self) -> str:
|
|
1163
|
-
return self.
|
|
1413
|
+
return self._entity_ids[0]
|
|
1164
1414
|
|
|
1165
1415
|
if TYPE_CHECKING:
|
|
1166
1416
|
from datahub.metadata.schema_classes import ChartKeyClass
|
|
1167
1417
|
|
|
1168
1418
|
class ChartUrn(_SpecificUrn):
|
|
1169
|
-
ENTITY_TYPE: ClassVar[
|
|
1170
|
-
|
|
1419
|
+
ENTITY_TYPE: ClassVar[Literal["chart"]] = "chart"
|
|
1420
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
1171
1421
|
|
|
1172
1422
|
def __init__(self, dashboard_tool: str, chart_id: str, *, _allow_coercion: bool = True) -> None:
|
|
1173
1423
|
if _allow_coercion:
|
|
@@ -1189,8 +1439,8 @@ class ChartUrn(_SpecificUrn):
|
|
|
1189
1439
|
|
|
1190
1440
|
@classmethod
|
|
1191
1441
|
def _parse_ids(cls, entity_ids: List[str]) -> "ChartUrn":
|
|
1192
|
-
if len(entity_ids) != cls.
|
|
1193
|
-
raise InvalidUrnError(f"ChartUrn should have {cls.
|
|
1442
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1443
|
+
raise InvalidUrnError(f"ChartUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1194
1444
|
return cls(dashboard_tool=entity_ids[0], chart_id=entity_ids[1], _allow_coercion=False)
|
|
1195
1445
|
|
|
1196
1446
|
@classmethod
|
|
@@ -1210,31 +1460,30 @@ class ChartUrn(_SpecificUrn):
|
|
|
1210
1460
|
|
|
1211
1461
|
@property
|
|
1212
1462
|
def dashboard_tool(self) -> str:
|
|
1213
|
-
return self.
|
|
1463
|
+
return self._entity_ids[0]
|
|
1214
1464
|
|
|
1215
1465
|
@property
|
|
1216
1466
|
def chart_id(self) -> str:
|
|
1217
|
-
return self.
|
|
1467
|
+
return self._entity_ids[1]
|
|
1218
1468
|
|
|
1219
1469
|
if TYPE_CHECKING:
|
|
1220
1470
|
from datahub.metadata.schema_classes import MLModelGroupKeyClass
|
|
1221
1471
|
|
|
1222
1472
|
class MlModelGroupUrn(_SpecificUrn):
|
|
1223
|
-
ENTITY_TYPE: ClassVar[
|
|
1224
|
-
|
|
1473
|
+
ENTITY_TYPE: ClassVar[Literal["mlModelGroup"]] = "mlModelGroup"
|
|
1474
|
+
_URN_PARTS: ClassVar[int] = 3
|
|
1225
1475
|
|
|
1226
|
-
def __init__(self, platform: str, name: str, env: str = "PROD", *, _allow_coercion: bool = True) -> None:
|
|
1476
|
+
def __init__(self, platform: Union["DataPlatformUrn", str], name: str, env: str = "PROD", *, _allow_coercion: bool = True) -> None:
|
|
1227
1477
|
if _allow_coercion:
|
|
1228
1478
|
# Field coercion logic (if any is required).
|
|
1229
1479
|
platform = DataPlatformUrn(platform).urn()
|
|
1230
1480
|
name = UrnEncoder.encode_string(name)
|
|
1231
1481
|
env = env.upper()
|
|
1232
|
-
env = UrnEncoder.encode_string(env)
|
|
1233
1482
|
|
|
1234
1483
|
# Validation logic.
|
|
1235
1484
|
if not platform:
|
|
1236
1485
|
raise InvalidUrnError("MlModelGroupUrn platform cannot be empty")
|
|
1237
|
-
platform = str(platform)
|
|
1486
|
+
platform = str(platform) # convert urn type to str
|
|
1238
1487
|
assert DataPlatformUrn.from_string(platform)
|
|
1239
1488
|
if not name:
|
|
1240
1489
|
raise InvalidUrnError("MlModelGroupUrn name cannot be empty")
|
|
@@ -1249,8 +1498,8 @@ class MlModelGroupUrn(_SpecificUrn):
|
|
|
1249
1498
|
|
|
1250
1499
|
@classmethod
|
|
1251
1500
|
def _parse_ids(cls, entity_ids: List[str]) -> "MlModelGroupUrn":
|
|
1252
|
-
if len(entity_ids) != cls.
|
|
1253
|
-
raise InvalidUrnError(f"MlModelGroupUrn should have {cls.
|
|
1501
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1502
|
+
raise InvalidUrnError(f"MlModelGroupUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1254
1503
|
return cls(platform=entity_ids[0], name=entity_ids[1], env=entity_ids[2], _allow_coercion=False)
|
|
1255
1504
|
|
|
1256
1505
|
@classmethod
|
|
@@ -1270,31 +1519,42 @@ class MlModelGroupUrn(_SpecificUrn):
|
|
|
1270
1519
|
|
|
1271
1520
|
@property
|
|
1272
1521
|
def platform(self) -> str:
|
|
1273
|
-
return self.
|
|
1522
|
+
return self._entity_ids[0]
|
|
1274
1523
|
|
|
1275
1524
|
@property
|
|
1276
1525
|
def name(self) -> str:
|
|
1277
|
-
return self.
|
|
1526
|
+
return self._entity_ids[1]
|
|
1278
1527
|
|
|
1279
1528
|
@property
|
|
1280
1529
|
def env(self) -> str:
|
|
1281
|
-
return self.
|
|
1530
|
+
return self._entity_ids[2]
|
|
1282
1531
|
|
|
1283
1532
|
if TYPE_CHECKING:
|
|
1284
1533
|
from datahub.metadata.schema_classes import SubscriptionKeyClass
|
|
1285
1534
|
|
|
1286
1535
|
class SubscriptionUrn(_SpecificUrn):
|
|
1287
|
-
ENTITY_TYPE: ClassVar[
|
|
1288
|
-
|
|
1536
|
+
ENTITY_TYPE: ClassVar[Literal["subscription"]] = "subscription"
|
|
1537
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1289
1538
|
|
|
1290
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
1539
|
+
def __init__(self, id: Union["SubscriptionUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1291
1540
|
if _allow_coercion:
|
|
1292
1541
|
# Field coercion logic (if any is required).
|
|
1293
|
-
|
|
1542
|
+
if isinstance(id, str):
|
|
1543
|
+
if id.startswith('urn:li:'):
|
|
1544
|
+
try:
|
|
1545
|
+
id = SubscriptionUrn.from_string(id)
|
|
1546
|
+
except InvalidUrnError:
|
|
1547
|
+
raise InvalidUrnError(f'Expecting a SubscriptionUrn but got {id}')
|
|
1548
|
+
else:
|
|
1549
|
+
id = UrnEncoder.encode_string(id)
|
|
1294
1550
|
|
|
1295
1551
|
# Validation logic.
|
|
1296
1552
|
if not id:
|
|
1297
1553
|
raise InvalidUrnError("SubscriptionUrn id cannot be empty")
|
|
1554
|
+
if isinstance(id, SubscriptionUrn):
|
|
1555
|
+
id = id.id
|
|
1556
|
+
elif isinstance(id, Urn):
|
|
1557
|
+
raise InvalidUrnError(f'Expecting a SubscriptionUrn but got {id}')
|
|
1298
1558
|
if UrnEncoder.contains_reserved_char(id):
|
|
1299
1559
|
raise InvalidUrnError(f'SubscriptionUrn id contains reserved characters')
|
|
1300
1560
|
|
|
@@ -1302,8 +1562,8 @@ class SubscriptionUrn(_SpecificUrn):
|
|
|
1302
1562
|
|
|
1303
1563
|
@classmethod
|
|
1304
1564
|
def _parse_ids(cls, entity_ids: List[str]) -> "SubscriptionUrn":
|
|
1305
|
-
if len(entity_ids) != cls.
|
|
1306
|
-
raise InvalidUrnError(f"SubscriptionUrn should have {cls.
|
|
1565
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1566
|
+
raise InvalidUrnError(f"SubscriptionUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1307
1567
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1308
1568
|
|
|
1309
1569
|
@classmethod
|
|
@@ -1323,23 +1583,34 @@ class SubscriptionUrn(_SpecificUrn):
|
|
|
1323
1583
|
|
|
1324
1584
|
@property
|
|
1325
1585
|
def id(self) -> str:
|
|
1326
|
-
return self.
|
|
1586
|
+
return self._entity_ids[0]
|
|
1327
1587
|
|
|
1328
1588
|
if TYPE_CHECKING:
|
|
1329
1589
|
from datahub.metadata.schema_classes import AnomalyKeyClass
|
|
1330
1590
|
|
|
1331
1591
|
class AnomalyUrn(_SpecificUrn):
|
|
1332
|
-
ENTITY_TYPE: ClassVar[
|
|
1333
|
-
|
|
1592
|
+
ENTITY_TYPE: ClassVar[Literal["anomaly"]] = "anomaly"
|
|
1593
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1334
1594
|
|
|
1335
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
1595
|
+
def __init__(self, id: Union["AnomalyUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1336
1596
|
if _allow_coercion:
|
|
1337
1597
|
# Field coercion logic (if any is required).
|
|
1338
|
-
|
|
1598
|
+
if isinstance(id, str):
|
|
1599
|
+
if id.startswith('urn:li:'):
|
|
1600
|
+
try:
|
|
1601
|
+
id = AnomalyUrn.from_string(id)
|
|
1602
|
+
except InvalidUrnError:
|
|
1603
|
+
raise InvalidUrnError(f'Expecting a AnomalyUrn but got {id}')
|
|
1604
|
+
else:
|
|
1605
|
+
id = UrnEncoder.encode_string(id)
|
|
1339
1606
|
|
|
1340
1607
|
# Validation logic.
|
|
1341
1608
|
if not id:
|
|
1342
1609
|
raise InvalidUrnError("AnomalyUrn id cannot be empty")
|
|
1610
|
+
if isinstance(id, AnomalyUrn):
|
|
1611
|
+
id = id.id
|
|
1612
|
+
elif isinstance(id, Urn):
|
|
1613
|
+
raise InvalidUrnError(f'Expecting a AnomalyUrn but got {id}')
|
|
1343
1614
|
if UrnEncoder.contains_reserved_char(id):
|
|
1344
1615
|
raise InvalidUrnError(f'AnomalyUrn id contains reserved characters')
|
|
1345
1616
|
|
|
@@ -1347,8 +1618,8 @@ class AnomalyUrn(_SpecificUrn):
|
|
|
1347
1618
|
|
|
1348
1619
|
@classmethod
|
|
1349
1620
|
def _parse_ids(cls, entity_ids: List[str]) -> "AnomalyUrn":
|
|
1350
|
-
if len(entity_ids) != cls.
|
|
1351
|
-
raise InvalidUrnError(f"AnomalyUrn should have {cls.
|
|
1621
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1622
|
+
raise InvalidUrnError(f"AnomalyUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1352
1623
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1353
1624
|
|
|
1354
1625
|
@classmethod
|
|
@@ -1368,33 +1639,44 @@ class AnomalyUrn(_SpecificUrn):
|
|
|
1368
1639
|
|
|
1369
1640
|
@property
|
|
1370
1641
|
def id(self) -> str:
|
|
1371
|
-
return self.
|
|
1642
|
+
return self._entity_ids[0]
|
|
1372
1643
|
|
|
1373
1644
|
if TYPE_CHECKING:
|
|
1374
1645
|
from datahub.metadata.schema_classes import RemoteExecutorPoolKeyClass
|
|
1375
1646
|
|
|
1376
1647
|
class DataHubRemoteExecutorPoolUrn(_SpecificUrn):
|
|
1377
|
-
ENTITY_TYPE: ClassVar[
|
|
1378
|
-
|
|
1648
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubRemoteExecutorPool"]] = "dataHubRemoteExecutorPool"
|
|
1649
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1379
1650
|
|
|
1380
|
-
def __init__(self,
|
|
1651
|
+
def __init__(self, id: Union["DataHubRemoteExecutorPoolUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1381
1652
|
if _allow_coercion:
|
|
1382
1653
|
# Field coercion logic (if any is required).
|
|
1383
|
-
|
|
1654
|
+
if isinstance(id, str):
|
|
1655
|
+
if id.startswith('urn:li:'):
|
|
1656
|
+
try:
|
|
1657
|
+
id = DataHubRemoteExecutorPoolUrn.from_string(id)
|
|
1658
|
+
except InvalidUrnError:
|
|
1659
|
+
raise InvalidUrnError(f'Expecting a DataHubRemoteExecutorPoolUrn but got {id}')
|
|
1660
|
+
else:
|
|
1661
|
+
id = UrnEncoder.encode_string(id)
|
|
1384
1662
|
|
|
1385
1663
|
# Validation logic.
|
|
1386
|
-
if not
|
|
1387
|
-
raise InvalidUrnError("DataHubRemoteExecutorPoolUrn
|
|
1388
|
-
if
|
|
1389
|
-
|
|
1664
|
+
if not id:
|
|
1665
|
+
raise InvalidUrnError("DataHubRemoteExecutorPoolUrn id cannot be empty")
|
|
1666
|
+
if isinstance(id, DataHubRemoteExecutorPoolUrn):
|
|
1667
|
+
id = id.id
|
|
1668
|
+
elif isinstance(id, Urn):
|
|
1669
|
+
raise InvalidUrnError(f'Expecting a DataHubRemoteExecutorPoolUrn but got {id}')
|
|
1670
|
+
if UrnEncoder.contains_reserved_char(id):
|
|
1671
|
+
raise InvalidUrnError(f'DataHubRemoteExecutorPoolUrn id contains reserved characters')
|
|
1390
1672
|
|
|
1391
|
-
super().__init__(self.ENTITY_TYPE, [
|
|
1673
|
+
super().__init__(self.ENTITY_TYPE, [id])
|
|
1392
1674
|
|
|
1393
1675
|
@classmethod
|
|
1394
1676
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubRemoteExecutorPoolUrn":
|
|
1395
|
-
if len(entity_ids) != cls.
|
|
1396
|
-
raise InvalidUrnError(f"DataHubRemoteExecutorPoolUrn should have {cls.
|
|
1397
|
-
return cls(
|
|
1677
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1678
|
+
raise InvalidUrnError(f"DataHubRemoteExecutorPoolUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1679
|
+
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1398
1680
|
|
|
1399
1681
|
@classmethod
|
|
1400
1682
|
def underlying_key_aspect_type(cls) -> Type["RemoteExecutorPoolKeyClass"]:
|
|
@@ -1405,32 +1687,40 @@ class DataHubRemoteExecutorPoolUrn(_SpecificUrn):
|
|
|
1405
1687
|
def to_key_aspect(self) -> "RemoteExecutorPoolKeyClass":
|
|
1406
1688
|
from datahub.metadata.schema_classes import RemoteExecutorPoolKeyClass
|
|
1407
1689
|
|
|
1408
|
-
return RemoteExecutorPoolKeyClass(
|
|
1690
|
+
return RemoteExecutorPoolKeyClass(id=self.id)
|
|
1409
1691
|
|
|
1410
1692
|
@classmethod
|
|
1411
1693
|
def from_key_aspect(cls, key_aspect: "RemoteExecutorPoolKeyClass") -> "DataHubRemoteExecutorPoolUrn":
|
|
1412
|
-
return cls(
|
|
1694
|
+
return cls(id=key_aspect.id)
|
|
1413
1695
|
|
|
1414
1696
|
@property
|
|
1415
|
-
def
|
|
1416
|
-
return self.
|
|
1697
|
+
def id(self) -> str:
|
|
1698
|
+
return self._entity_ids[0]
|
|
1417
1699
|
|
|
1418
1700
|
if TYPE_CHECKING:
|
|
1419
1701
|
from datahub.metadata.schema_classes import DataJobKeyClass
|
|
1420
1702
|
|
|
1421
1703
|
class DataJobUrn(_SpecificUrn):
|
|
1422
|
-
ENTITY_TYPE: ClassVar[
|
|
1423
|
-
|
|
1704
|
+
ENTITY_TYPE: ClassVar[Literal["dataJob"]] = "dataJob"
|
|
1705
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
1424
1706
|
|
|
1425
|
-
def __init__(self, flow: str, job_id: str, *, _allow_coercion: bool = True) -> None:
|
|
1707
|
+
def __init__(self, flow: Union["DataFlowUrn", str], job_id: str, *, _allow_coercion: bool = True) -> None:
|
|
1426
1708
|
if _allow_coercion:
|
|
1427
1709
|
# Field coercion logic (if any is required).
|
|
1710
|
+
if isinstance(flow, str):
|
|
1711
|
+
if flow.startswith('urn:li:'):
|
|
1712
|
+
try:
|
|
1713
|
+
flow = DataFlowUrn.from_string(flow)
|
|
1714
|
+
except InvalidUrnError:
|
|
1715
|
+
raise InvalidUrnError(f'Expecting a DataFlowUrn but got {flow}')
|
|
1716
|
+
else:
|
|
1717
|
+
flow = UrnEncoder.encode_string(flow)
|
|
1428
1718
|
job_id = UrnEncoder.encode_string(job_id)
|
|
1429
1719
|
|
|
1430
1720
|
# Validation logic.
|
|
1431
1721
|
if not flow:
|
|
1432
1722
|
raise InvalidUrnError("DataJobUrn flow cannot be empty")
|
|
1433
|
-
flow = str(flow)
|
|
1723
|
+
flow = str(flow) # convert urn type to str
|
|
1434
1724
|
assert DataFlowUrn.from_string(flow)
|
|
1435
1725
|
if not job_id:
|
|
1436
1726
|
raise InvalidUrnError("DataJobUrn job_id cannot be empty")
|
|
@@ -1441,8 +1731,8 @@ class DataJobUrn(_SpecificUrn):
|
|
|
1441
1731
|
|
|
1442
1732
|
@classmethod
|
|
1443
1733
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataJobUrn":
|
|
1444
|
-
if len(entity_ids) != cls.
|
|
1445
|
-
raise InvalidUrnError(f"DataJobUrn should have {cls.
|
|
1734
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1735
|
+
raise InvalidUrnError(f"DataJobUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1446
1736
|
return cls(flow=entity_ids[0], job_id=entity_ids[1], _allow_coercion=False)
|
|
1447
1737
|
|
|
1448
1738
|
@classmethod
|
|
@@ -1473,27 +1763,38 @@ class DataJobUrn(_SpecificUrn):
|
|
|
1473
1763
|
|
|
1474
1764
|
@property
|
|
1475
1765
|
def flow(self) -> str:
|
|
1476
|
-
return self.
|
|
1766
|
+
return self._entity_ids[0]
|
|
1477
1767
|
|
|
1478
1768
|
@property
|
|
1479
1769
|
def job_id(self) -> str:
|
|
1480
|
-
return self.
|
|
1770
|
+
return self._entity_ids[1]
|
|
1481
1771
|
|
|
1482
1772
|
if TYPE_CHECKING:
|
|
1483
1773
|
from datahub.metadata.schema_classes import DomainKeyClass
|
|
1484
1774
|
|
|
1485
1775
|
class DomainUrn(_SpecificUrn):
|
|
1486
|
-
ENTITY_TYPE: ClassVar[
|
|
1487
|
-
|
|
1776
|
+
ENTITY_TYPE: ClassVar[Literal["domain"]] = "domain"
|
|
1777
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1488
1778
|
|
|
1489
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
1779
|
+
def __init__(self, id: Union["DomainUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1490
1780
|
if _allow_coercion:
|
|
1491
1781
|
# Field coercion logic (if any is required).
|
|
1492
|
-
|
|
1782
|
+
if isinstance(id, str):
|
|
1783
|
+
if id.startswith('urn:li:'):
|
|
1784
|
+
try:
|
|
1785
|
+
id = DomainUrn.from_string(id)
|
|
1786
|
+
except InvalidUrnError:
|
|
1787
|
+
raise InvalidUrnError(f'Expecting a DomainUrn but got {id}')
|
|
1788
|
+
else:
|
|
1789
|
+
id = UrnEncoder.encode_string(id)
|
|
1493
1790
|
|
|
1494
1791
|
# Validation logic.
|
|
1495
1792
|
if not id:
|
|
1496
1793
|
raise InvalidUrnError("DomainUrn id cannot be empty")
|
|
1794
|
+
if isinstance(id, DomainUrn):
|
|
1795
|
+
id = id.id
|
|
1796
|
+
elif isinstance(id, Urn):
|
|
1797
|
+
raise InvalidUrnError(f'Expecting a DomainUrn but got {id}')
|
|
1497
1798
|
if UrnEncoder.contains_reserved_char(id):
|
|
1498
1799
|
raise InvalidUrnError(f'DomainUrn id contains reserved characters')
|
|
1499
1800
|
|
|
@@ -1501,8 +1802,8 @@ class DomainUrn(_SpecificUrn):
|
|
|
1501
1802
|
|
|
1502
1803
|
@classmethod
|
|
1503
1804
|
def _parse_ids(cls, entity_ids: List[str]) -> "DomainUrn":
|
|
1504
|
-
if len(entity_ids) != cls.
|
|
1505
|
-
raise InvalidUrnError(f"DomainUrn should have {cls.
|
|
1805
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1806
|
+
raise InvalidUrnError(f"DomainUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1506
1807
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1507
1808
|
|
|
1508
1809
|
@classmethod
|
|
@@ -1527,23 +1828,34 @@ class DomainUrn(_SpecificUrn):
|
|
|
1527
1828
|
|
|
1528
1829
|
@property
|
|
1529
1830
|
def id(self) -> str:
|
|
1530
|
-
return self.
|
|
1831
|
+
return self._entity_ids[0]
|
|
1531
1832
|
|
|
1532
1833
|
if TYPE_CHECKING:
|
|
1533
1834
|
from datahub.metadata.schema_classes import ERModelRelationshipKeyClass
|
|
1534
1835
|
|
|
1535
1836
|
class ErModelRelationshipUrn(_SpecificUrn):
|
|
1536
|
-
ENTITY_TYPE: ClassVar[
|
|
1537
|
-
|
|
1837
|
+
ENTITY_TYPE: ClassVar[Literal["erModelRelationship"]] = "erModelRelationship"
|
|
1838
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1538
1839
|
|
|
1539
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
1840
|
+
def __init__(self, id: Union["ErModelRelationshipUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1540
1841
|
if _allow_coercion:
|
|
1541
1842
|
# Field coercion logic (if any is required).
|
|
1542
|
-
|
|
1843
|
+
if isinstance(id, str):
|
|
1844
|
+
if id.startswith('urn:li:'):
|
|
1845
|
+
try:
|
|
1846
|
+
id = ErModelRelationshipUrn.from_string(id)
|
|
1847
|
+
except InvalidUrnError:
|
|
1848
|
+
raise InvalidUrnError(f'Expecting a ErModelRelationshipUrn but got {id}')
|
|
1849
|
+
else:
|
|
1850
|
+
id = UrnEncoder.encode_string(id)
|
|
1543
1851
|
|
|
1544
1852
|
# Validation logic.
|
|
1545
1853
|
if not id:
|
|
1546
1854
|
raise InvalidUrnError("ErModelRelationshipUrn id cannot be empty")
|
|
1855
|
+
if isinstance(id, ErModelRelationshipUrn):
|
|
1856
|
+
id = id.id
|
|
1857
|
+
elif isinstance(id, Urn):
|
|
1858
|
+
raise InvalidUrnError(f'Expecting a ErModelRelationshipUrn but got {id}')
|
|
1547
1859
|
if UrnEncoder.contains_reserved_char(id):
|
|
1548
1860
|
raise InvalidUrnError(f'ErModelRelationshipUrn id contains reserved characters')
|
|
1549
1861
|
|
|
@@ -1551,8 +1863,8 @@ class ErModelRelationshipUrn(_SpecificUrn):
|
|
|
1551
1863
|
|
|
1552
1864
|
@classmethod
|
|
1553
1865
|
def _parse_ids(cls, entity_ids: List[str]) -> "ErModelRelationshipUrn":
|
|
1554
|
-
if len(entity_ids) != cls.
|
|
1555
|
-
raise InvalidUrnError(f"ErModelRelationshipUrn should have {cls.
|
|
1866
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1867
|
+
raise InvalidUrnError(f"ErModelRelationshipUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1556
1868
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1557
1869
|
|
|
1558
1870
|
@classmethod
|
|
@@ -1572,23 +1884,34 @@ class ErModelRelationshipUrn(_SpecificUrn):
|
|
|
1572
1884
|
|
|
1573
1885
|
@property
|
|
1574
1886
|
def id(self) -> str:
|
|
1575
|
-
return self.
|
|
1887
|
+
return self._entity_ids[0]
|
|
1576
1888
|
|
|
1577
1889
|
if TYPE_CHECKING:
|
|
1578
1890
|
from datahub.metadata.schema_classes import DataHubRoleKeyClass
|
|
1579
1891
|
|
|
1580
1892
|
class DataHubRoleUrn(_SpecificUrn):
|
|
1581
|
-
ENTITY_TYPE: ClassVar[
|
|
1582
|
-
|
|
1893
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubRole"]] = "dataHubRole"
|
|
1894
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1583
1895
|
|
|
1584
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
1896
|
+
def __init__(self, id: Union["DataHubRoleUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1585
1897
|
if _allow_coercion:
|
|
1586
1898
|
# Field coercion logic (if any is required).
|
|
1587
|
-
|
|
1899
|
+
if isinstance(id, str):
|
|
1900
|
+
if id.startswith('urn:li:'):
|
|
1901
|
+
try:
|
|
1902
|
+
id = DataHubRoleUrn.from_string(id)
|
|
1903
|
+
except InvalidUrnError:
|
|
1904
|
+
raise InvalidUrnError(f'Expecting a DataHubRoleUrn but got {id}')
|
|
1905
|
+
else:
|
|
1906
|
+
id = UrnEncoder.encode_string(id)
|
|
1588
1907
|
|
|
1589
1908
|
# Validation logic.
|
|
1590
1909
|
if not id:
|
|
1591
1910
|
raise InvalidUrnError("DataHubRoleUrn id cannot be empty")
|
|
1911
|
+
if isinstance(id, DataHubRoleUrn):
|
|
1912
|
+
id = id.id
|
|
1913
|
+
elif isinstance(id, Urn):
|
|
1914
|
+
raise InvalidUrnError(f'Expecting a DataHubRoleUrn but got {id}')
|
|
1592
1915
|
if UrnEncoder.contains_reserved_char(id):
|
|
1593
1916
|
raise InvalidUrnError(f'DataHubRoleUrn id contains reserved characters')
|
|
1594
1917
|
|
|
@@ -1596,8 +1919,8 @@ class DataHubRoleUrn(_SpecificUrn):
|
|
|
1596
1919
|
|
|
1597
1920
|
@classmethod
|
|
1598
1921
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubRoleUrn":
|
|
1599
|
-
if len(entity_ids) != cls.
|
|
1600
|
-
raise InvalidUrnError(f"DataHubRoleUrn should have {cls.
|
|
1922
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1923
|
+
raise InvalidUrnError(f"DataHubRoleUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1601
1924
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1602
1925
|
|
|
1603
1926
|
@classmethod
|
|
@@ -1617,23 +1940,34 @@ class DataHubRoleUrn(_SpecificUrn):
|
|
|
1617
1940
|
|
|
1618
1941
|
@property
|
|
1619
1942
|
def id(self) -> str:
|
|
1620
|
-
return self.
|
|
1943
|
+
return self._entity_ids[0]
|
|
1621
1944
|
|
|
1622
1945
|
if TYPE_CHECKING:
|
|
1623
1946
|
from datahub.metadata.schema_classes import FormKeyClass
|
|
1624
1947
|
|
|
1625
1948
|
class FormUrn(_SpecificUrn):
|
|
1626
|
-
ENTITY_TYPE: ClassVar[
|
|
1627
|
-
|
|
1949
|
+
ENTITY_TYPE: ClassVar[Literal["form"]] = "form"
|
|
1950
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1628
1951
|
|
|
1629
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
1952
|
+
def __init__(self, id: Union["FormUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1630
1953
|
if _allow_coercion:
|
|
1631
1954
|
# Field coercion logic (if any is required).
|
|
1632
|
-
|
|
1955
|
+
if isinstance(id, str):
|
|
1956
|
+
if id.startswith('urn:li:'):
|
|
1957
|
+
try:
|
|
1958
|
+
id = FormUrn.from_string(id)
|
|
1959
|
+
except InvalidUrnError:
|
|
1960
|
+
raise InvalidUrnError(f'Expecting a FormUrn but got {id}')
|
|
1961
|
+
else:
|
|
1962
|
+
id = UrnEncoder.encode_string(id)
|
|
1633
1963
|
|
|
1634
1964
|
# Validation logic.
|
|
1635
1965
|
if not id:
|
|
1636
1966
|
raise InvalidUrnError("FormUrn id cannot be empty")
|
|
1967
|
+
if isinstance(id, FormUrn):
|
|
1968
|
+
id = id.id
|
|
1969
|
+
elif isinstance(id, Urn):
|
|
1970
|
+
raise InvalidUrnError(f'Expecting a FormUrn but got {id}')
|
|
1637
1971
|
if UrnEncoder.contains_reserved_char(id):
|
|
1638
1972
|
raise InvalidUrnError(f'FormUrn id contains reserved characters')
|
|
1639
1973
|
|
|
@@ -1641,8 +1975,8 @@ class FormUrn(_SpecificUrn):
|
|
|
1641
1975
|
|
|
1642
1976
|
@classmethod
|
|
1643
1977
|
def _parse_ids(cls, entity_ids: List[str]) -> "FormUrn":
|
|
1644
|
-
if len(entity_ids) != cls.
|
|
1645
|
-
raise InvalidUrnError(f"FormUrn should have {cls.
|
|
1978
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
1979
|
+
raise InvalidUrnError(f"FormUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1646
1980
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1647
1981
|
|
|
1648
1982
|
@classmethod
|
|
@@ -1662,23 +1996,34 @@ class FormUrn(_SpecificUrn):
|
|
|
1662
1996
|
|
|
1663
1997
|
@property
|
|
1664
1998
|
def id(self) -> str:
|
|
1665
|
-
return self.
|
|
1999
|
+
return self._entity_ids[0]
|
|
1666
2000
|
|
|
1667
2001
|
if TYPE_CHECKING:
|
|
1668
2002
|
from datahub.metadata.schema_classes import DataHubAccessTokenKeyClass
|
|
1669
2003
|
|
|
1670
2004
|
class DataHubAccessTokenUrn(_SpecificUrn):
|
|
1671
|
-
ENTITY_TYPE: ClassVar[
|
|
1672
|
-
|
|
2005
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubAccessToken"]] = "dataHubAccessToken"
|
|
2006
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1673
2007
|
|
|
1674
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
2008
|
+
def __init__(self, id: Union["DataHubAccessTokenUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1675
2009
|
if _allow_coercion:
|
|
1676
2010
|
# Field coercion logic (if any is required).
|
|
1677
|
-
|
|
2011
|
+
if isinstance(id, str):
|
|
2012
|
+
if id.startswith('urn:li:'):
|
|
2013
|
+
try:
|
|
2014
|
+
id = DataHubAccessTokenUrn.from_string(id)
|
|
2015
|
+
except InvalidUrnError:
|
|
2016
|
+
raise InvalidUrnError(f'Expecting a DataHubAccessTokenUrn but got {id}')
|
|
2017
|
+
else:
|
|
2018
|
+
id = UrnEncoder.encode_string(id)
|
|
1678
2019
|
|
|
1679
2020
|
# Validation logic.
|
|
1680
2021
|
if not id:
|
|
1681
2022
|
raise InvalidUrnError("DataHubAccessTokenUrn id cannot be empty")
|
|
2023
|
+
if isinstance(id, DataHubAccessTokenUrn):
|
|
2024
|
+
id = id.id
|
|
2025
|
+
elif isinstance(id, Urn):
|
|
2026
|
+
raise InvalidUrnError(f'Expecting a DataHubAccessTokenUrn but got {id}')
|
|
1682
2027
|
if UrnEncoder.contains_reserved_char(id):
|
|
1683
2028
|
raise InvalidUrnError(f'DataHubAccessTokenUrn id contains reserved characters')
|
|
1684
2029
|
|
|
@@ -1686,8 +2031,8 @@ class DataHubAccessTokenUrn(_SpecificUrn):
|
|
|
1686
2031
|
|
|
1687
2032
|
@classmethod
|
|
1688
2033
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubAccessTokenUrn":
|
|
1689
|
-
if len(entity_ids) != cls.
|
|
1690
|
-
raise InvalidUrnError(f"DataHubAccessTokenUrn should have {cls.
|
|
2034
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2035
|
+
raise InvalidUrnError(f"DataHubAccessTokenUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1691
2036
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1692
2037
|
|
|
1693
2038
|
@classmethod
|
|
@@ -1707,23 +2052,34 @@ class DataHubAccessTokenUrn(_SpecificUrn):
|
|
|
1707
2052
|
|
|
1708
2053
|
@property
|
|
1709
2054
|
def id(self) -> str:
|
|
1710
|
-
return self.
|
|
2055
|
+
return self._entity_ids[0]
|
|
1711
2056
|
|
|
1712
2057
|
if TYPE_CHECKING:
|
|
1713
2058
|
from datahub.metadata.schema_classes import DataHubActionKeyClass
|
|
1714
2059
|
|
|
1715
2060
|
class DataHubActionUrn(_SpecificUrn):
|
|
1716
|
-
ENTITY_TYPE: ClassVar[
|
|
1717
|
-
|
|
2061
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubAction"]] = "dataHubAction"
|
|
2062
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1718
2063
|
|
|
1719
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
2064
|
+
def __init__(self, id: Union["DataHubActionUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1720
2065
|
if _allow_coercion:
|
|
1721
2066
|
# Field coercion logic (if any is required).
|
|
1722
|
-
|
|
2067
|
+
if isinstance(id, str):
|
|
2068
|
+
if id.startswith('urn:li:'):
|
|
2069
|
+
try:
|
|
2070
|
+
id = DataHubActionUrn.from_string(id)
|
|
2071
|
+
except InvalidUrnError:
|
|
2072
|
+
raise InvalidUrnError(f'Expecting a DataHubActionUrn but got {id}')
|
|
2073
|
+
else:
|
|
2074
|
+
id = UrnEncoder.encode_string(id)
|
|
1723
2075
|
|
|
1724
2076
|
# Validation logic.
|
|
1725
2077
|
if not id:
|
|
1726
2078
|
raise InvalidUrnError("DataHubActionUrn id cannot be empty")
|
|
2079
|
+
if isinstance(id, DataHubActionUrn):
|
|
2080
|
+
id = id.id
|
|
2081
|
+
elif isinstance(id, Urn):
|
|
2082
|
+
raise InvalidUrnError(f'Expecting a DataHubActionUrn but got {id}')
|
|
1727
2083
|
if UrnEncoder.contains_reserved_char(id):
|
|
1728
2084
|
raise InvalidUrnError(f'DataHubActionUrn id contains reserved characters')
|
|
1729
2085
|
|
|
@@ -1731,8 +2087,8 @@ class DataHubActionUrn(_SpecificUrn):
|
|
|
1731
2087
|
|
|
1732
2088
|
@classmethod
|
|
1733
2089
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubActionUrn":
|
|
1734
|
-
if len(entity_ids) != cls.
|
|
1735
|
-
raise InvalidUrnError(f"DataHubActionUrn should have {cls.
|
|
2090
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2091
|
+
raise InvalidUrnError(f"DataHubActionUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1736
2092
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1737
2093
|
|
|
1738
2094
|
@classmethod
|
|
@@ -1752,25 +2108,34 @@ class DataHubActionUrn(_SpecificUrn):
|
|
|
1752
2108
|
|
|
1753
2109
|
@property
|
|
1754
2110
|
def id(self) -> str:
|
|
1755
|
-
return self.
|
|
2111
|
+
return self._entity_ids[0]
|
|
1756
2112
|
|
|
1757
2113
|
if TYPE_CHECKING:
|
|
1758
2114
|
from datahub.metadata.schema_classes import DataPlatformKeyClass
|
|
1759
2115
|
|
|
1760
2116
|
class DataPlatformUrn(_SpecificUrn):
|
|
1761
|
-
ENTITY_TYPE: ClassVar[
|
|
1762
|
-
|
|
2117
|
+
ENTITY_TYPE: ClassVar[Literal["dataPlatform"]] = "dataPlatform"
|
|
2118
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1763
2119
|
|
|
1764
|
-
def __init__(self, platform_name: str, *, _allow_coercion: bool = True) -> None:
|
|
2120
|
+
def __init__(self, platform_name: Union["DataPlatformUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1765
2121
|
if _allow_coercion:
|
|
1766
2122
|
# Field coercion logic (if any is required).
|
|
1767
|
-
if platform_name
|
|
1768
|
-
platform_name
|
|
1769
|
-
|
|
2123
|
+
if isinstance(platform_name, str):
|
|
2124
|
+
if platform_name.startswith('urn:li:'):
|
|
2125
|
+
try:
|
|
2126
|
+
platform_name = DataPlatformUrn.from_string(platform_name)
|
|
2127
|
+
except InvalidUrnError:
|
|
2128
|
+
raise InvalidUrnError(f'Expecting a DataPlatformUrn but got {platform_name}')
|
|
2129
|
+
else:
|
|
2130
|
+
platform_name = UrnEncoder.encode_string(platform_name)
|
|
1770
2131
|
|
|
1771
2132
|
# Validation logic.
|
|
1772
2133
|
if not platform_name:
|
|
1773
2134
|
raise InvalidUrnError("DataPlatformUrn platform_name cannot be empty")
|
|
2135
|
+
if isinstance(platform_name, DataPlatformUrn):
|
|
2136
|
+
platform_name = platform_name.platform_name
|
|
2137
|
+
elif isinstance(platform_name, Urn):
|
|
2138
|
+
raise InvalidUrnError(f'Expecting a DataPlatformUrn but got {platform_name}')
|
|
1774
2139
|
if UrnEncoder.contains_reserved_char(platform_name):
|
|
1775
2140
|
raise InvalidUrnError(f'DataPlatformUrn platform_name contains reserved characters')
|
|
1776
2141
|
|
|
@@ -1778,8 +2143,8 @@ class DataPlatformUrn(_SpecificUrn):
|
|
|
1778
2143
|
|
|
1779
2144
|
@classmethod
|
|
1780
2145
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataPlatformUrn":
|
|
1781
|
-
if len(entity_ids) != cls.
|
|
1782
|
-
raise InvalidUrnError(f"DataPlatformUrn should have {cls.
|
|
2146
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2147
|
+
raise InvalidUrnError(f"DataPlatformUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1783
2148
|
return cls(platform_name=entity_ids[0], _allow_coercion=False)
|
|
1784
2149
|
|
|
1785
2150
|
@classmethod
|
|
@@ -1804,23 +2169,34 @@ class DataPlatformUrn(_SpecificUrn):
|
|
|
1804
2169
|
|
|
1805
2170
|
@property
|
|
1806
2171
|
def platform_name(self) -> str:
|
|
1807
|
-
return self.
|
|
2172
|
+
return self._entity_ids[0]
|
|
1808
2173
|
|
|
1809
2174
|
if TYPE_CHECKING:
|
|
1810
2175
|
from datahub.metadata.schema_classes import ContainerKeyClass
|
|
1811
2176
|
|
|
1812
2177
|
class ContainerUrn(_SpecificUrn):
|
|
1813
|
-
ENTITY_TYPE: ClassVar[
|
|
1814
|
-
|
|
2178
|
+
ENTITY_TYPE: ClassVar[Literal["container"]] = "container"
|
|
2179
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1815
2180
|
|
|
1816
|
-
def __init__(self, guid: str, *, _allow_coercion: bool = True) -> None:
|
|
2181
|
+
def __init__(self, guid: Union["ContainerUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1817
2182
|
if _allow_coercion:
|
|
1818
2183
|
# Field coercion logic (if any is required).
|
|
1819
|
-
|
|
2184
|
+
if isinstance(guid, str):
|
|
2185
|
+
if guid.startswith('urn:li:'):
|
|
2186
|
+
try:
|
|
2187
|
+
guid = ContainerUrn.from_string(guid)
|
|
2188
|
+
except InvalidUrnError:
|
|
2189
|
+
raise InvalidUrnError(f'Expecting a ContainerUrn but got {guid}')
|
|
2190
|
+
else:
|
|
2191
|
+
guid = UrnEncoder.encode_string(guid)
|
|
1820
2192
|
|
|
1821
2193
|
# Validation logic.
|
|
1822
2194
|
if not guid:
|
|
1823
2195
|
raise InvalidUrnError("ContainerUrn guid cannot be empty")
|
|
2196
|
+
if isinstance(guid, ContainerUrn):
|
|
2197
|
+
guid = guid.guid
|
|
2198
|
+
elif isinstance(guid, Urn):
|
|
2199
|
+
raise InvalidUrnError(f'Expecting a ContainerUrn but got {guid}')
|
|
1824
2200
|
if UrnEncoder.contains_reserved_char(guid):
|
|
1825
2201
|
raise InvalidUrnError(f'ContainerUrn guid contains reserved characters')
|
|
1826
2202
|
|
|
@@ -1828,8 +2204,8 @@ class ContainerUrn(_SpecificUrn):
|
|
|
1828
2204
|
|
|
1829
2205
|
@classmethod
|
|
1830
2206
|
def _parse_ids(cls, entity_ids: List[str]) -> "ContainerUrn":
|
|
1831
|
-
if len(entity_ids) != cls.
|
|
1832
|
-
raise InvalidUrnError(f"ContainerUrn should have {cls.
|
|
2207
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2208
|
+
raise InvalidUrnError(f"ContainerUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1833
2209
|
return cls(guid=entity_ids[0], _allow_coercion=False)
|
|
1834
2210
|
|
|
1835
2211
|
@classmethod
|
|
@@ -1849,23 +2225,34 @@ class ContainerUrn(_SpecificUrn):
|
|
|
1849
2225
|
|
|
1850
2226
|
@property
|
|
1851
2227
|
def guid(self) -> str:
|
|
1852
|
-
return self.
|
|
2228
|
+
return self._entity_ids[0]
|
|
1853
2229
|
|
|
1854
2230
|
if TYPE_CHECKING:
|
|
1855
2231
|
from datahub.metadata.schema_classes import TagKeyClass
|
|
1856
2232
|
|
|
1857
2233
|
class TagUrn(_SpecificUrn):
|
|
1858
|
-
ENTITY_TYPE: ClassVar[
|
|
1859
|
-
|
|
2234
|
+
ENTITY_TYPE: ClassVar[Literal["tag"]] = "tag"
|
|
2235
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1860
2236
|
|
|
1861
|
-
def __init__(self, name: str, *, _allow_coercion: bool = True) -> None:
|
|
2237
|
+
def __init__(self, name: Union["TagUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1862
2238
|
if _allow_coercion:
|
|
1863
2239
|
# Field coercion logic (if any is required).
|
|
1864
|
-
|
|
2240
|
+
if isinstance(name, str):
|
|
2241
|
+
if name.startswith('urn:li:'):
|
|
2242
|
+
try:
|
|
2243
|
+
name = TagUrn.from_string(name)
|
|
2244
|
+
except InvalidUrnError:
|
|
2245
|
+
raise InvalidUrnError(f'Expecting a TagUrn but got {name}')
|
|
2246
|
+
else:
|
|
2247
|
+
name = UrnEncoder.encode_string(name)
|
|
1865
2248
|
|
|
1866
2249
|
# Validation logic.
|
|
1867
2250
|
if not name:
|
|
1868
2251
|
raise InvalidUrnError("TagUrn name cannot be empty")
|
|
2252
|
+
if isinstance(name, TagUrn):
|
|
2253
|
+
name = name.name
|
|
2254
|
+
elif isinstance(name, Urn):
|
|
2255
|
+
raise InvalidUrnError(f'Expecting a TagUrn but got {name}')
|
|
1869
2256
|
if UrnEncoder.contains_reserved_char(name):
|
|
1870
2257
|
raise InvalidUrnError(f'TagUrn name contains reserved characters')
|
|
1871
2258
|
|
|
@@ -1873,8 +2260,8 @@ class TagUrn(_SpecificUrn):
|
|
|
1873
2260
|
|
|
1874
2261
|
@classmethod
|
|
1875
2262
|
def _parse_ids(cls, entity_ids: List[str]) -> "TagUrn":
|
|
1876
|
-
if len(entity_ids) != cls.
|
|
1877
|
-
raise InvalidUrnError(f"TagUrn should have {cls.
|
|
2263
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2264
|
+
raise InvalidUrnError(f"TagUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1878
2265
|
return cls(name=entity_ids[0], _allow_coercion=False)
|
|
1879
2266
|
|
|
1880
2267
|
@classmethod
|
|
@@ -1899,23 +2286,34 @@ class TagUrn(_SpecificUrn):
|
|
|
1899
2286
|
|
|
1900
2287
|
@property
|
|
1901
2288
|
def name(self) -> str:
|
|
1902
|
-
return self.
|
|
2289
|
+
return self._entity_ids[0]
|
|
1903
2290
|
|
|
1904
2291
|
if TYPE_CHECKING:
|
|
1905
2292
|
from datahub.metadata.schema_classes import DataHubPolicyKeyClass
|
|
1906
2293
|
|
|
1907
2294
|
class DataHubPolicyUrn(_SpecificUrn):
|
|
1908
|
-
ENTITY_TYPE: ClassVar[
|
|
1909
|
-
|
|
2295
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubPolicy"]] = "dataHubPolicy"
|
|
2296
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1910
2297
|
|
|
1911
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
2298
|
+
def __init__(self, id: Union["DataHubPolicyUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1912
2299
|
if _allow_coercion:
|
|
1913
2300
|
# Field coercion logic (if any is required).
|
|
1914
|
-
|
|
2301
|
+
if isinstance(id, str):
|
|
2302
|
+
if id.startswith('urn:li:'):
|
|
2303
|
+
try:
|
|
2304
|
+
id = DataHubPolicyUrn.from_string(id)
|
|
2305
|
+
except InvalidUrnError:
|
|
2306
|
+
raise InvalidUrnError(f'Expecting a DataHubPolicyUrn but got {id}')
|
|
2307
|
+
else:
|
|
2308
|
+
id = UrnEncoder.encode_string(id)
|
|
1915
2309
|
|
|
1916
2310
|
# Validation logic.
|
|
1917
2311
|
if not id:
|
|
1918
2312
|
raise InvalidUrnError("DataHubPolicyUrn id cannot be empty")
|
|
2313
|
+
if isinstance(id, DataHubPolicyUrn):
|
|
2314
|
+
id = id.id
|
|
2315
|
+
elif isinstance(id, Urn):
|
|
2316
|
+
raise InvalidUrnError(f'Expecting a DataHubPolicyUrn but got {id}')
|
|
1919
2317
|
if UrnEncoder.contains_reserved_char(id):
|
|
1920
2318
|
raise InvalidUrnError(f'DataHubPolicyUrn id contains reserved characters')
|
|
1921
2319
|
|
|
@@ -1923,8 +2321,8 @@ class DataHubPolicyUrn(_SpecificUrn):
|
|
|
1923
2321
|
|
|
1924
2322
|
@classmethod
|
|
1925
2323
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubPolicyUrn":
|
|
1926
|
-
if len(entity_ids) != cls.
|
|
1927
|
-
raise InvalidUrnError(f"DataHubPolicyUrn should have {cls.
|
|
2324
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2325
|
+
raise InvalidUrnError(f"DataHubPolicyUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1928
2326
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1929
2327
|
|
|
1930
2328
|
@classmethod
|
|
@@ -1944,23 +2342,34 @@ class DataHubPolicyUrn(_SpecificUrn):
|
|
|
1944
2342
|
|
|
1945
2343
|
@property
|
|
1946
2344
|
def id(self) -> str:
|
|
1947
|
-
return self.
|
|
2345
|
+
return self._entity_ids[0]
|
|
1948
2346
|
|
|
1949
2347
|
if TYPE_CHECKING:
|
|
1950
2348
|
from datahub.metadata.schema_classes import ConstraintKeyClass
|
|
1951
2349
|
|
|
1952
2350
|
class ConstraintUrn(_SpecificUrn):
|
|
1953
|
-
ENTITY_TYPE: ClassVar[
|
|
1954
|
-
|
|
2351
|
+
ENTITY_TYPE: ClassVar[Literal["constraint"]] = "constraint"
|
|
2352
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
1955
2353
|
|
|
1956
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
2354
|
+
def __init__(self, id: Union["ConstraintUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
1957
2355
|
if _allow_coercion:
|
|
1958
2356
|
# Field coercion logic (if any is required).
|
|
1959
|
-
|
|
2357
|
+
if isinstance(id, str):
|
|
2358
|
+
if id.startswith('urn:li:'):
|
|
2359
|
+
try:
|
|
2360
|
+
id = ConstraintUrn.from_string(id)
|
|
2361
|
+
except InvalidUrnError:
|
|
2362
|
+
raise InvalidUrnError(f'Expecting a ConstraintUrn but got {id}')
|
|
2363
|
+
else:
|
|
2364
|
+
id = UrnEncoder.encode_string(id)
|
|
1960
2365
|
|
|
1961
2366
|
# Validation logic.
|
|
1962
2367
|
if not id:
|
|
1963
2368
|
raise InvalidUrnError("ConstraintUrn id cannot be empty")
|
|
2369
|
+
if isinstance(id, ConstraintUrn):
|
|
2370
|
+
id = id.id
|
|
2371
|
+
elif isinstance(id, Urn):
|
|
2372
|
+
raise InvalidUrnError(f'Expecting a ConstraintUrn but got {id}')
|
|
1964
2373
|
if UrnEncoder.contains_reserved_char(id):
|
|
1965
2374
|
raise InvalidUrnError(f'ConstraintUrn id contains reserved characters')
|
|
1966
2375
|
|
|
@@ -1968,8 +2377,8 @@ class ConstraintUrn(_SpecificUrn):
|
|
|
1968
2377
|
|
|
1969
2378
|
@classmethod
|
|
1970
2379
|
def _parse_ids(cls, entity_ids: List[str]) -> "ConstraintUrn":
|
|
1971
|
-
if len(entity_ids) != cls.
|
|
1972
|
-
raise InvalidUrnError(f"ConstraintUrn should have {cls.
|
|
2380
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2381
|
+
raise InvalidUrnError(f"ConstraintUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
1973
2382
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
1974
2383
|
|
|
1975
2384
|
@classmethod
|
|
@@ -1989,23 +2398,34 @@ class ConstraintUrn(_SpecificUrn):
|
|
|
1989
2398
|
|
|
1990
2399
|
@property
|
|
1991
2400
|
def id(self) -> str:
|
|
1992
|
-
return self.
|
|
2401
|
+
return self._entity_ids[0]
|
|
1993
2402
|
|
|
1994
2403
|
if TYPE_CHECKING:
|
|
1995
2404
|
from datahub.metadata.schema_classes import GlossaryNodeKeyClass
|
|
1996
2405
|
|
|
1997
2406
|
class GlossaryNodeUrn(_SpecificUrn):
|
|
1998
|
-
ENTITY_TYPE: ClassVar[
|
|
1999
|
-
|
|
2407
|
+
ENTITY_TYPE: ClassVar[Literal["glossaryNode"]] = "glossaryNode"
|
|
2408
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
2000
2409
|
|
|
2001
|
-
def __init__(self, name: str, *, _allow_coercion: bool = True) -> None:
|
|
2410
|
+
def __init__(self, name: Union["GlossaryNodeUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
2002
2411
|
if _allow_coercion:
|
|
2003
2412
|
# Field coercion logic (if any is required).
|
|
2004
|
-
|
|
2413
|
+
if isinstance(name, str):
|
|
2414
|
+
if name.startswith('urn:li:'):
|
|
2415
|
+
try:
|
|
2416
|
+
name = GlossaryNodeUrn.from_string(name)
|
|
2417
|
+
except InvalidUrnError:
|
|
2418
|
+
raise InvalidUrnError(f'Expecting a GlossaryNodeUrn but got {name}')
|
|
2419
|
+
else:
|
|
2420
|
+
name = UrnEncoder.encode_string(name)
|
|
2005
2421
|
|
|
2006
2422
|
# Validation logic.
|
|
2007
2423
|
if not name:
|
|
2008
2424
|
raise InvalidUrnError("GlossaryNodeUrn name cannot be empty")
|
|
2425
|
+
if isinstance(name, GlossaryNodeUrn):
|
|
2426
|
+
name = name.name
|
|
2427
|
+
elif isinstance(name, Urn):
|
|
2428
|
+
raise InvalidUrnError(f'Expecting a GlossaryNodeUrn but got {name}')
|
|
2009
2429
|
if UrnEncoder.contains_reserved_char(name):
|
|
2010
2430
|
raise InvalidUrnError(f'GlossaryNodeUrn name contains reserved characters')
|
|
2011
2431
|
|
|
@@ -2013,8 +2433,8 @@ class GlossaryNodeUrn(_SpecificUrn):
|
|
|
2013
2433
|
|
|
2014
2434
|
@classmethod
|
|
2015
2435
|
def _parse_ids(cls, entity_ids: List[str]) -> "GlossaryNodeUrn":
|
|
2016
|
-
if len(entity_ids) != cls.
|
|
2017
|
-
raise InvalidUrnError(f"GlossaryNodeUrn should have {cls.
|
|
2436
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2437
|
+
raise InvalidUrnError(f"GlossaryNodeUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2018
2438
|
return cls(name=entity_ids[0], _allow_coercion=False)
|
|
2019
2439
|
|
|
2020
2440
|
@classmethod
|
|
@@ -2034,14 +2454,14 @@ class GlossaryNodeUrn(_SpecificUrn):
|
|
|
2034
2454
|
|
|
2035
2455
|
@property
|
|
2036
2456
|
def name(self) -> str:
|
|
2037
|
-
return self.
|
|
2457
|
+
return self._entity_ids[0]
|
|
2038
2458
|
|
|
2039
2459
|
if TYPE_CHECKING:
|
|
2040
2460
|
from datahub.metadata.schema_classes import DataProcessKeyClass
|
|
2041
2461
|
|
|
2042
2462
|
class DataProcessUrn(_SpecificUrn):
|
|
2043
|
-
ENTITY_TYPE: ClassVar[
|
|
2044
|
-
|
|
2463
|
+
ENTITY_TYPE: ClassVar[Literal["dataProcess"]] = "dataProcess"
|
|
2464
|
+
_URN_PARTS: ClassVar[int] = 3
|
|
2045
2465
|
|
|
2046
2466
|
def __init__(self, name: str, orchestrator: str, env: str = "PROD", *, _allow_coercion: bool = True) -> None:
|
|
2047
2467
|
if _allow_coercion:
|
|
@@ -2049,7 +2469,6 @@ class DataProcessUrn(_SpecificUrn):
|
|
|
2049
2469
|
name = UrnEncoder.encode_string(name)
|
|
2050
2470
|
orchestrator = UrnEncoder.encode_string(orchestrator)
|
|
2051
2471
|
env = env.upper()
|
|
2052
|
-
env = UrnEncoder.encode_string(env)
|
|
2053
2472
|
|
|
2054
2473
|
# Validation logic.
|
|
2055
2474
|
if not name:
|
|
@@ -2069,8 +2488,8 @@ class DataProcessUrn(_SpecificUrn):
|
|
|
2069
2488
|
|
|
2070
2489
|
@classmethod
|
|
2071
2490
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataProcessUrn":
|
|
2072
|
-
if len(entity_ids) != cls.
|
|
2073
|
-
raise InvalidUrnError(f"DataProcessUrn should have {cls.
|
|
2491
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2492
|
+
raise InvalidUrnError(f"DataProcessUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2074
2493
|
return cls(name=entity_ids[0], orchestrator=entity_ids[1], env=entity_ids[2], _allow_coercion=False)
|
|
2075
2494
|
|
|
2076
2495
|
@classmethod
|
|
@@ -2090,31 +2509,42 @@ class DataProcessUrn(_SpecificUrn):
|
|
|
2090
2509
|
|
|
2091
2510
|
@property
|
|
2092
2511
|
def name(self) -> str:
|
|
2093
|
-
return self.
|
|
2512
|
+
return self._entity_ids[0]
|
|
2094
2513
|
|
|
2095
2514
|
@property
|
|
2096
2515
|
def orchestrator(self) -> str:
|
|
2097
|
-
return self.
|
|
2516
|
+
return self._entity_ids[1]
|
|
2098
2517
|
|
|
2099
2518
|
@property
|
|
2100
2519
|
def env(self) -> str:
|
|
2101
|
-
return self.
|
|
2520
|
+
return self._entity_ids[2]
|
|
2102
2521
|
|
|
2103
2522
|
if TYPE_CHECKING:
|
|
2104
2523
|
from datahub.metadata.schema_classes import DataHubStepStateKeyClass
|
|
2105
2524
|
|
|
2106
2525
|
class DataHubStepStateUrn(_SpecificUrn):
|
|
2107
|
-
ENTITY_TYPE: ClassVar[
|
|
2108
|
-
|
|
2526
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubStepState"]] = "dataHubStepState"
|
|
2527
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
2109
2528
|
|
|
2110
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
2529
|
+
def __init__(self, id: Union["DataHubStepStateUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
2111
2530
|
if _allow_coercion:
|
|
2112
2531
|
# Field coercion logic (if any is required).
|
|
2113
|
-
|
|
2532
|
+
if isinstance(id, str):
|
|
2533
|
+
if id.startswith('urn:li:'):
|
|
2534
|
+
try:
|
|
2535
|
+
id = DataHubStepStateUrn.from_string(id)
|
|
2536
|
+
except InvalidUrnError:
|
|
2537
|
+
raise InvalidUrnError(f'Expecting a DataHubStepStateUrn but got {id}')
|
|
2538
|
+
else:
|
|
2539
|
+
id = UrnEncoder.encode_string(id)
|
|
2114
2540
|
|
|
2115
2541
|
# Validation logic.
|
|
2116
2542
|
if not id:
|
|
2117
2543
|
raise InvalidUrnError("DataHubStepStateUrn id cannot be empty")
|
|
2544
|
+
if isinstance(id, DataHubStepStateUrn):
|
|
2545
|
+
id = id.id
|
|
2546
|
+
elif isinstance(id, Urn):
|
|
2547
|
+
raise InvalidUrnError(f'Expecting a DataHubStepStateUrn but got {id}')
|
|
2118
2548
|
if UrnEncoder.contains_reserved_char(id):
|
|
2119
2549
|
raise InvalidUrnError(f'DataHubStepStateUrn id contains reserved characters')
|
|
2120
2550
|
|
|
@@ -2122,8 +2552,8 @@ class DataHubStepStateUrn(_SpecificUrn):
|
|
|
2122
2552
|
|
|
2123
2553
|
@classmethod
|
|
2124
2554
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubStepStateUrn":
|
|
2125
|
-
if len(entity_ids) != cls.
|
|
2126
|
-
raise InvalidUrnError(f"DataHubStepStateUrn should have {cls.
|
|
2555
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2556
|
+
raise InvalidUrnError(f"DataHubStepStateUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2127
2557
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
2128
2558
|
|
|
2129
2559
|
@classmethod
|
|
@@ -2143,14 +2573,14 @@ class DataHubStepStateUrn(_SpecificUrn):
|
|
|
2143
2573
|
|
|
2144
2574
|
@property
|
|
2145
2575
|
def id(self) -> str:
|
|
2146
|
-
return self.
|
|
2576
|
+
return self._entity_ids[0]
|
|
2147
2577
|
|
|
2148
2578
|
if TYPE_CHECKING:
|
|
2149
2579
|
from datahub.metadata.schema_classes import NotebookKeyClass
|
|
2150
2580
|
|
|
2151
2581
|
class NotebookUrn(_SpecificUrn):
|
|
2152
|
-
ENTITY_TYPE: ClassVar[
|
|
2153
|
-
|
|
2582
|
+
ENTITY_TYPE: ClassVar[Literal["notebook"]] = "notebook"
|
|
2583
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
2154
2584
|
|
|
2155
2585
|
def __init__(self, notebook_tool: str, notebook_id: str, *, _allow_coercion: bool = True) -> None:
|
|
2156
2586
|
if _allow_coercion:
|
|
@@ -2172,8 +2602,8 @@ class NotebookUrn(_SpecificUrn):
|
|
|
2172
2602
|
|
|
2173
2603
|
@classmethod
|
|
2174
2604
|
def _parse_ids(cls, entity_ids: List[str]) -> "NotebookUrn":
|
|
2175
|
-
if len(entity_ids) != cls.
|
|
2176
|
-
raise InvalidUrnError(f"NotebookUrn should have {cls.
|
|
2605
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2606
|
+
raise InvalidUrnError(f"NotebookUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2177
2607
|
return cls(notebook_tool=entity_ids[0], notebook_id=entity_ids[1], _allow_coercion=False)
|
|
2178
2608
|
|
|
2179
2609
|
@classmethod
|
|
@@ -2201,18 +2631,18 @@ class NotebookUrn(_SpecificUrn):
|
|
|
2201
2631
|
|
|
2202
2632
|
@property
|
|
2203
2633
|
def notebook_tool(self) -> str:
|
|
2204
|
-
return self.
|
|
2634
|
+
return self._entity_ids[0]
|
|
2205
2635
|
|
|
2206
2636
|
@property
|
|
2207
2637
|
def notebook_id(self) -> str:
|
|
2208
|
-
return self.
|
|
2638
|
+
return self._entity_ids[1]
|
|
2209
2639
|
|
|
2210
2640
|
if TYPE_CHECKING:
|
|
2211
2641
|
from datahub.metadata.schema_classes import MLFeatureKeyClass
|
|
2212
2642
|
|
|
2213
2643
|
class MlFeatureUrn(_SpecificUrn):
|
|
2214
|
-
ENTITY_TYPE: ClassVar[
|
|
2215
|
-
|
|
2644
|
+
ENTITY_TYPE: ClassVar[Literal["mlFeature"]] = "mlFeature"
|
|
2645
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
2216
2646
|
|
|
2217
2647
|
def __init__(self, feature_namespace: str, name: str, *, _allow_coercion: bool = True) -> None:
|
|
2218
2648
|
if _allow_coercion:
|
|
@@ -2234,8 +2664,8 @@ class MlFeatureUrn(_SpecificUrn):
|
|
|
2234
2664
|
|
|
2235
2665
|
@classmethod
|
|
2236
2666
|
def _parse_ids(cls, entity_ids: List[str]) -> "MlFeatureUrn":
|
|
2237
|
-
if len(entity_ids) != cls.
|
|
2238
|
-
raise InvalidUrnError(f"MlFeatureUrn should have {cls.
|
|
2667
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2668
|
+
raise InvalidUrnError(f"MlFeatureUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2239
2669
|
return cls(feature_namespace=entity_ids[0], name=entity_ids[1], _allow_coercion=False)
|
|
2240
2670
|
|
|
2241
2671
|
@classmethod
|
|
@@ -2255,27 +2685,38 @@ class MlFeatureUrn(_SpecificUrn):
|
|
|
2255
2685
|
|
|
2256
2686
|
@property
|
|
2257
2687
|
def feature_namespace(self) -> str:
|
|
2258
|
-
return self.
|
|
2688
|
+
return self._entity_ids[0]
|
|
2259
2689
|
|
|
2260
2690
|
@property
|
|
2261
2691
|
def name(self) -> str:
|
|
2262
|
-
return self.
|
|
2692
|
+
return self._entity_ids[1]
|
|
2263
2693
|
|
|
2264
2694
|
if TYPE_CHECKING:
|
|
2265
2695
|
from datahub.metadata.schema_classes import DataHubUpgradeKeyClass
|
|
2266
2696
|
|
|
2267
2697
|
class DataHubUpgradeUrn(_SpecificUrn):
|
|
2268
|
-
ENTITY_TYPE: ClassVar[
|
|
2269
|
-
|
|
2698
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubUpgrade"]] = "dataHubUpgrade"
|
|
2699
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
2270
2700
|
|
|
2271
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
2701
|
+
def __init__(self, id: Union["DataHubUpgradeUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
2272
2702
|
if _allow_coercion:
|
|
2273
2703
|
# Field coercion logic (if any is required).
|
|
2274
|
-
|
|
2704
|
+
if isinstance(id, str):
|
|
2705
|
+
if id.startswith('urn:li:'):
|
|
2706
|
+
try:
|
|
2707
|
+
id = DataHubUpgradeUrn.from_string(id)
|
|
2708
|
+
except InvalidUrnError:
|
|
2709
|
+
raise InvalidUrnError(f'Expecting a DataHubUpgradeUrn but got {id}')
|
|
2710
|
+
else:
|
|
2711
|
+
id = UrnEncoder.encode_string(id)
|
|
2275
2712
|
|
|
2276
2713
|
# Validation logic.
|
|
2277
2714
|
if not id:
|
|
2278
2715
|
raise InvalidUrnError("DataHubUpgradeUrn id cannot be empty")
|
|
2716
|
+
if isinstance(id, DataHubUpgradeUrn):
|
|
2717
|
+
id = id.id
|
|
2718
|
+
elif isinstance(id, Urn):
|
|
2719
|
+
raise InvalidUrnError(f'Expecting a DataHubUpgradeUrn but got {id}')
|
|
2279
2720
|
if UrnEncoder.contains_reserved_char(id):
|
|
2280
2721
|
raise InvalidUrnError(f'DataHubUpgradeUrn id contains reserved characters')
|
|
2281
2722
|
|
|
@@ -2283,8 +2724,8 @@ class DataHubUpgradeUrn(_SpecificUrn):
|
|
|
2283
2724
|
|
|
2284
2725
|
@classmethod
|
|
2285
2726
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubUpgradeUrn":
|
|
2286
|
-
if len(entity_ids) != cls.
|
|
2287
|
-
raise InvalidUrnError(f"DataHubUpgradeUrn should have {cls.
|
|
2727
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2728
|
+
raise InvalidUrnError(f"DataHubUpgradeUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2288
2729
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
2289
2730
|
|
|
2290
2731
|
@classmethod
|
|
@@ -2304,14 +2745,14 @@ class DataHubUpgradeUrn(_SpecificUrn):
|
|
|
2304
2745
|
|
|
2305
2746
|
@property
|
|
2306
2747
|
def id(self) -> str:
|
|
2307
|
-
return self.
|
|
2748
|
+
return self._entity_ids[0]
|
|
2308
2749
|
|
|
2309
2750
|
if TYPE_CHECKING:
|
|
2310
2751
|
from datahub.metadata.schema_classes import DashboardKeyClass
|
|
2311
2752
|
|
|
2312
2753
|
class DashboardUrn(_SpecificUrn):
|
|
2313
|
-
ENTITY_TYPE: ClassVar[
|
|
2314
|
-
|
|
2754
|
+
ENTITY_TYPE: ClassVar[Literal["dashboard"]] = "dashboard"
|
|
2755
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
2315
2756
|
|
|
2316
2757
|
def __init__(self, dashboard_tool: str, dashboard_id: str, *, _allow_coercion: bool = True) -> None:
|
|
2317
2758
|
if _allow_coercion:
|
|
@@ -2333,8 +2774,8 @@ class DashboardUrn(_SpecificUrn):
|
|
|
2333
2774
|
|
|
2334
2775
|
@classmethod
|
|
2335
2776
|
def _parse_ids(cls, entity_ids: List[str]) -> "DashboardUrn":
|
|
2336
|
-
if len(entity_ids) != cls.
|
|
2337
|
-
raise InvalidUrnError(f"DashboardUrn should have {cls.
|
|
2777
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2778
|
+
raise InvalidUrnError(f"DashboardUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2338
2779
|
return cls(dashboard_tool=entity_ids[0], dashboard_id=entity_ids[1], _allow_coercion=False)
|
|
2339
2780
|
|
|
2340
2781
|
@classmethod
|
|
@@ -2354,31 +2795,30 @@ class DashboardUrn(_SpecificUrn):
|
|
|
2354
2795
|
|
|
2355
2796
|
@property
|
|
2356
2797
|
def dashboard_tool(self) -> str:
|
|
2357
|
-
return self.
|
|
2798
|
+
return self._entity_ids[0]
|
|
2358
2799
|
|
|
2359
2800
|
@property
|
|
2360
2801
|
def dashboard_id(self) -> str:
|
|
2361
|
-
return self.
|
|
2802
|
+
return self._entity_ids[1]
|
|
2362
2803
|
|
|
2363
2804
|
if TYPE_CHECKING:
|
|
2364
2805
|
from datahub.metadata.schema_classes import MLModelKeyClass
|
|
2365
2806
|
|
|
2366
2807
|
class MlModelUrn(_SpecificUrn):
|
|
2367
|
-
ENTITY_TYPE: ClassVar[
|
|
2368
|
-
|
|
2808
|
+
ENTITY_TYPE: ClassVar[Literal["mlModel"]] = "mlModel"
|
|
2809
|
+
_URN_PARTS: ClassVar[int] = 3
|
|
2369
2810
|
|
|
2370
|
-
def __init__(self, platform: str, name: str, env: str = "PROD", *, _allow_coercion: bool = True) -> None:
|
|
2811
|
+
def __init__(self, platform: Union["DataPlatformUrn", str], name: str, env: str = "PROD", *, _allow_coercion: bool = True) -> None:
|
|
2371
2812
|
if _allow_coercion:
|
|
2372
2813
|
# Field coercion logic (if any is required).
|
|
2373
2814
|
platform = DataPlatformUrn(platform).urn()
|
|
2374
2815
|
name = UrnEncoder.encode_string(name)
|
|
2375
2816
|
env = env.upper()
|
|
2376
|
-
env = UrnEncoder.encode_string(env)
|
|
2377
2817
|
|
|
2378
2818
|
# Validation logic.
|
|
2379
2819
|
if not platform:
|
|
2380
2820
|
raise InvalidUrnError("MlModelUrn platform cannot be empty")
|
|
2381
|
-
platform = str(platform)
|
|
2821
|
+
platform = str(platform) # convert urn type to str
|
|
2382
2822
|
assert DataPlatformUrn.from_string(platform)
|
|
2383
2823
|
if not name:
|
|
2384
2824
|
raise InvalidUrnError("MlModelUrn name cannot be empty")
|
|
@@ -2393,8 +2833,8 @@ class MlModelUrn(_SpecificUrn):
|
|
|
2393
2833
|
|
|
2394
2834
|
@classmethod
|
|
2395
2835
|
def _parse_ids(cls, entity_ids: List[str]) -> "MlModelUrn":
|
|
2396
|
-
if len(entity_ids) != cls.
|
|
2397
|
-
raise InvalidUrnError(f"MlModelUrn should have {cls.
|
|
2836
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2837
|
+
raise InvalidUrnError(f"MlModelUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2398
2838
|
return cls(platform=entity_ids[0], name=entity_ids[1], env=entity_ids[2], _allow_coercion=False)
|
|
2399
2839
|
|
|
2400
2840
|
@classmethod
|
|
@@ -2414,31 +2854,42 @@ class MlModelUrn(_SpecificUrn):
|
|
|
2414
2854
|
|
|
2415
2855
|
@property
|
|
2416
2856
|
def platform(self) -> str:
|
|
2417
|
-
return self.
|
|
2857
|
+
return self._entity_ids[0]
|
|
2418
2858
|
|
|
2419
2859
|
@property
|
|
2420
2860
|
def name(self) -> str:
|
|
2421
|
-
return self.
|
|
2861
|
+
return self._entity_ids[1]
|
|
2422
2862
|
|
|
2423
2863
|
@property
|
|
2424
2864
|
def env(self) -> str:
|
|
2425
|
-
return self.
|
|
2865
|
+
return self._entity_ids[2]
|
|
2426
2866
|
|
|
2427
2867
|
if TYPE_CHECKING:
|
|
2428
2868
|
from datahub.metadata.schema_classes import IncidentKeyClass
|
|
2429
2869
|
|
|
2430
2870
|
class IncidentUrn(_SpecificUrn):
|
|
2431
|
-
ENTITY_TYPE: ClassVar[
|
|
2432
|
-
|
|
2871
|
+
ENTITY_TYPE: ClassVar[Literal["incident"]] = "incident"
|
|
2872
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
2433
2873
|
|
|
2434
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
2874
|
+
def __init__(self, id: Union["IncidentUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
2435
2875
|
if _allow_coercion:
|
|
2436
2876
|
# Field coercion logic (if any is required).
|
|
2437
|
-
|
|
2877
|
+
if isinstance(id, str):
|
|
2878
|
+
if id.startswith('urn:li:'):
|
|
2879
|
+
try:
|
|
2880
|
+
id = IncidentUrn.from_string(id)
|
|
2881
|
+
except InvalidUrnError:
|
|
2882
|
+
raise InvalidUrnError(f'Expecting a IncidentUrn but got {id}')
|
|
2883
|
+
else:
|
|
2884
|
+
id = UrnEncoder.encode_string(id)
|
|
2438
2885
|
|
|
2439
2886
|
# Validation logic.
|
|
2440
2887
|
if not id:
|
|
2441
2888
|
raise InvalidUrnError("IncidentUrn id cannot be empty")
|
|
2889
|
+
if isinstance(id, IncidentUrn):
|
|
2890
|
+
id = id.id
|
|
2891
|
+
elif isinstance(id, Urn):
|
|
2892
|
+
raise InvalidUrnError(f'Expecting a IncidentUrn but got {id}')
|
|
2442
2893
|
if UrnEncoder.contains_reserved_char(id):
|
|
2443
2894
|
raise InvalidUrnError(f'IncidentUrn id contains reserved characters')
|
|
2444
2895
|
|
|
@@ -2446,8 +2897,8 @@ class IncidentUrn(_SpecificUrn):
|
|
|
2446
2897
|
|
|
2447
2898
|
@classmethod
|
|
2448
2899
|
def _parse_ids(cls, entity_ids: List[str]) -> "IncidentUrn":
|
|
2449
|
-
if len(entity_ids) != cls.
|
|
2450
|
-
raise InvalidUrnError(f"IncidentUrn should have {cls.
|
|
2900
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2901
|
+
raise InvalidUrnError(f"IncidentUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2451
2902
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
2452
2903
|
|
|
2453
2904
|
@classmethod
|
|
@@ -2467,23 +2918,34 @@ class IncidentUrn(_SpecificUrn):
|
|
|
2467
2918
|
|
|
2468
2919
|
@property
|
|
2469
2920
|
def id(self) -> str:
|
|
2470
|
-
return self.
|
|
2921
|
+
return self._entity_ids[0]
|
|
2471
2922
|
|
|
2472
2923
|
if TYPE_CHECKING:
|
|
2473
2924
|
from datahub.metadata.schema_classes import GlobalSettingsKeyClass
|
|
2474
2925
|
|
|
2475
2926
|
class GlobalSettingsUrn(_SpecificUrn):
|
|
2476
|
-
ENTITY_TYPE: ClassVar[
|
|
2477
|
-
|
|
2927
|
+
ENTITY_TYPE: ClassVar[Literal["globalSettings"]] = "globalSettings"
|
|
2928
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
2478
2929
|
|
|
2479
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
2930
|
+
def __init__(self, id: Union["GlobalSettingsUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
2480
2931
|
if _allow_coercion:
|
|
2481
2932
|
# Field coercion logic (if any is required).
|
|
2482
|
-
|
|
2933
|
+
if isinstance(id, str):
|
|
2934
|
+
if id.startswith('urn:li:'):
|
|
2935
|
+
try:
|
|
2936
|
+
id = GlobalSettingsUrn.from_string(id)
|
|
2937
|
+
except InvalidUrnError:
|
|
2938
|
+
raise InvalidUrnError(f'Expecting a GlobalSettingsUrn but got {id}')
|
|
2939
|
+
else:
|
|
2940
|
+
id = UrnEncoder.encode_string(id)
|
|
2483
2941
|
|
|
2484
2942
|
# Validation logic.
|
|
2485
2943
|
if not id:
|
|
2486
2944
|
raise InvalidUrnError("GlobalSettingsUrn id cannot be empty")
|
|
2945
|
+
if isinstance(id, GlobalSettingsUrn):
|
|
2946
|
+
id = id.id
|
|
2947
|
+
elif isinstance(id, Urn):
|
|
2948
|
+
raise InvalidUrnError(f'Expecting a GlobalSettingsUrn but got {id}')
|
|
2487
2949
|
if UrnEncoder.contains_reserved_char(id):
|
|
2488
2950
|
raise InvalidUrnError(f'GlobalSettingsUrn id contains reserved characters')
|
|
2489
2951
|
|
|
@@ -2491,8 +2953,8 @@ class GlobalSettingsUrn(_SpecificUrn):
|
|
|
2491
2953
|
|
|
2492
2954
|
@classmethod
|
|
2493
2955
|
def _parse_ids(cls, entity_ids: List[str]) -> "GlobalSettingsUrn":
|
|
2494
|
-
if len(entity_ids) != cls.
|
|
2495
|
-
raise InvalidUrnError(f"GlobalSettingsUrn should have {cls.
|
|
2956
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
2957
|
+
raise InvalidUrnError(f"GlobalSettingsUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2496
2958
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
2497
2959
|
|
|
2498
2960
|
@classmethod
|
|
@@ -2512,23 +2974,34 @@ class GlobalSettingsUrn(_SpecificUrn):
|
|
|
2512
2974
|
|
|
2513
2975
|
@property
|
|
2514
2976
|
def id(self) -> str:
|
|
2515
|
-
return self.
|
|
2977
|
+
return self._entity_ids[0]
|
|
2516
2978
|
|
|
2517
2979
|
if TYPE_CHECKING:
|
|
2518
2980
|
from datahub.metadata.schema_classes import DataHubViewKeyClass
|
|
2519
2981
|
|
|
2520
2982
|
class DataHubViewUrn(_SpecificUrn):
|
|
2521
|
-
ENTITY_TYPE: ClassVar[
|
|
2522
|
-
|
|
2983
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubView"]] = "dataHubView"
|
|
2984
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
2523
2985
|
|
|
2524
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
2986
|
+
def __init__(self, id: Union["DataHubViewUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
2525
2987
|
if _allow_coercion:
|
|
2526
2988
|
# Field coercion logic (if any is required).
|
|
2527
|
-
|
|
2989
|
+
if isinstance(id, str):
|
|
2990
|
+
if id.startswith('urn:li:'):
|
|
2991
|
+
try:
|
|
2992
|
+
id = DataHubViewUrn.from_string(id)
|
|
2993
|
+
except InvalidUrnError:
|
|
2994
|
+
raise InvalidUrnError(f'Expecting a DataHubViewUrn but got {id}')
|
|
2995
|
+
else:
|
|
2996
|
+
id = UrnEncoder.encode_string(id)
|
|
2528
2997
|
|
|
2529
2998
|
# Validation logic.
|
|
2530
2999
|
if not id:
|
|
2531
3000
|
raise InvalidUrnError("DataHubViewUrn id cannot be empty")
|
|
3001
|
+
if isinstance(id, DataHubViewUrn):
|
|
3002
|
+
id = id.id
|
|
3003
|
+
elif isinstance(id, Urn):
|
|
3004
|
+
raise InvalidUrnError(f'Expecting a DataHubViewUrn but got {id}')
|
|
2532
3005
|
if UrnEncoder.contains_reserved_char(id):
|
|
2533
3006
|
raise InvalidUrnError(f'DataHubViewUrn id contains reserved characters')
|
|
2534
3007
|
|
|
@@ -2536,8 +3009,8 @@ class DataHubViewUrn(_SpecificUrn):
|
|
|
2536
3009
|
|
|
2537
3010
|
@classmethod
|
|
2538
3011
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubViewUrn":
|
|
2539
|
-
if len(entity_ids) != cls.
|
|
2540
|
-
raise InvalidUrnError(f"DataHubViewUrn should have {cls.
|
|
3012
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3013
|
+
raise InvalidUrnError(f"DataHubViewUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2541
3014
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
2542
3015
|
|
|
2543
3016
|
@classmethod
|
|
@@ -2557,14 +3030,14 @@ class DataHubViewUrn(_SpecificUrn):
|
|
|
2557
3030
|
|
|
2558
3031
|
@property
|
|
2559
3032
|
def id(self) -> str:
|
|
2560
|
-
return self.
|
|
3033
|
+
return self._entity_ids[0]
|
|
2561
3034
|
|
|
2562
3035
|
if TYPE_CHECKING:
|
|
2563
3036
|
from datahub.metadata.schema_classes import DataHubRetentionKeyClass
|
|
2564
3037
|
|
|
2565
3038
|
class DataHubRetentionUrn(_SpecificUrn):
|
|
2566
|
-
ENTITY_TYPE: ClassVar[
|
|
2567
|
-
|
|
3039
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubRetention"]] = "dataHubRetention"
|
|
3040
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
2568
3041
|
|
|
2569
3042
|
def __init__(self, entity_name: str, aspect_name: str, *, _allow_coercion: bool = True) -> None:
|
|
2570
3043
|
if _allow_coercion:
|
|
@@ -2586,8 +3059,8 @@ class DataHubRetentionUrn(_SpecificUrn):
|
|
|
2586
3059
|
|
|
2587
3060
|
@classmethod
|
|
2588
3061
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubRetentionUrn":
|
|
2589
|
-
if len(entity_ids) != cls.
|
|
2590
|
-
raise InvalidUrnError(f"DataHubRetentionUrn should have {cls.
|
|
3062
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3063
|
+
raise InvalidUrnError(f"DataHubRetentionUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2591
3064
|
return cls(entity_name=entity_ids[0], aspect_name=entity_ids[1], _allow_coercion=False)
|
|
2592
3065
|
|
|
2593
3066
|
@classmethod
|
|
@@ -2607,27 +3080,38 @@ class DataHubRetentionUrn(_SpecificUrn):
|
|
|
2607
3080
|
|
|
2608
3081
|
@property
|
|
2609
3082
|
def entity_name(self) -> str:
|
|
2610
|
-
return self.
|
|
3083
|
+
return self._entity_ids[0]
|
|
2611
3084
|
|
|
2612
3085
|
@property
|
|
2613
3086
|
def aspect_name(self) -> str:
|
|
2614
|
-
return self.
|
|
3087
|
+
return self._entity_ids[1]
|
|
2615
3088
|
|
|
2616
3089
|
if TYPE_CHECKING:
|
|
2617
3090
|
from datahub.metadata.schema_classes import OwnershipTypeKeyClass
|
|
2618
3091
|
|
|
2619
3092
|
class OwnershipTypeUrn(_SpecificUrn):
|
|
2620
|
-
ENTITY_TYPE: ClassVar[
|
|
2621
|
-
|
|
3093
|
+
ENTITY_TYPE: ClassVar[Literal["ownershipType"]] = "ownershipType"
|
|
3094
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
2622
3095
|
|
|
2623
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
3096
|
+
def __init__(self, id: Union["OwnershipTypeUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
2624
3097
|
if _allow_coercion:
|
|
2625
3098
|
# Field coercion logic (if any is required).
|
|
2626
|
-
|
|
3099
|
+
if isinstance(id, str):
|
|
3100
|
+
if id.startswith('urn:li:'):
|
|
3101
|
+
try:
|
|
3102
|
+
id = OwnershipTypeUrn.from_string(id)
|
|
3103
|
+
except InvalidUrnError:
|
|
3104
|
+
raise InvalidUrnError(f'Expecting a OwnershipTypeUrn but got {id}')
|
|
3105
|
+
else:
|
|
3106
|
+
id = UrnEncoder.encode_string(id)
|
|
2627
3107
|
|
|
2628
3108
|
# Validation logic.
|
|
2629
3109
|
if not id:
|
|
2630
3110
|
raise InvalidUrnError("OwnershipTypeUrn id cannot be empty")
|
|
3111
|
+
if isinstance(id, OwnershipTypeUrn):
|
|
3112
|
+
id = id.id
|
|
3113
|
+
elif isinstance(id, Urn):
|
|
3114
|
+
raise InvalidUrnError(f'Expecting a OwnershipTypeUrn but got {id}')
|
|
2631
3115
|
if UrnEncoder.contains_reserved_char(id):
|
|
2632
3116
|
raise InvalidUrnError(f'OwnershipTypeUrn id contains reserved characters')
|
|
2633
3117
|
|
|
@@ -2635,8 +3119,8 @@ class OwnershipTypeUrn(_SpecificUrn):
|
|
|
2635
3119
|
|
|
2636
3120
|
@classmethod
|
|
2637
3121
|
def _parse_ids(cls, entity_ids: List[str]) -> "OwnershipTypeUrn":
|
|
2638
|
-
if len(entity_ids) != cls.
|
|
2639
|
-
raise InvalidUrnError(f"OwnershipTypeUrn should have {cls.
|
|
3122
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3123
|
+
raise InvalidUrnError(f"OwnershipTypeUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2640
3124
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
2641
3125
|
|
|
2642
3126
|
@classmethod
|
|
@@ -2656,23 +3140,34 @@ class OwnershipTypeUrn(_SpecificUrn):
|
|
|
2656
3140
|
|
|
2657
3141
|
@property
|
|
2658
3142
|
def id(self) -> str:
|
|
2659
|
-
return self.
|
|
3143
|
+
return self._entity_ids[0]
|
|
2660
3144
|
|
|
2661
3145
|
if TYPE_CHECKING:
|
|
2662
3146
|
from datahub.metadata.schema_classes import ActionRequestKeyClass
|
|
2663
3147
|
|
|
2664
3148
|
class ActionRequestUrn(_SpecificUrn):
|
|
2665
|
-
ENTITY_TYPE: ClassVar[
|
|
2666
|
-
|
|
3149
|
+
ENTITY_TYPE: ClassVar[Literal["actionRequest"]] = "actionRequest"
|
|
3150
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
2667
3151
|
|
|
2668
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
3152
|
+
def __init__(self, id: Union["ActionRequestUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
2669
3153
|
if _allow_coercion:
|
|
2670
3154
|
# Field coercion logic (if any is required).
|
|
2671
|
-
|
|
3155
|
+
if isinstance(id, str):
|
|
3156
|
+
if id.startswith('urn:li:'):
|
|
3157
|
+
try:
|
|
3158
|
+
id = ActionRequestUrn.from_string(id)
|
|
3159
|
+
except InvalidUrnError:
|
|
3160
|
+
raise InvalidUrnError(f'Expecting a ActionRequestUrn but got {id}')
|
|
3161
|
+
else:
|
|
3162
|
+
id = UrnEncoder.encode_string(id)
|
|
2672
3163
|
|
|
2673
3164
|
# Validation logic.
|
|
2674
3165
|
if not id:
|
|
2675
3166
|
raise InvalidUrnError("ActionRequestUrn id cannot be empty")
|
|
3167
|
+
if isinstance(id, ActionRequestUrn):
|
|
3168
|
+
id = id.id
|
|
3169
|
+
elif isinstance(id, Urn):
|
|
3170
|
+
raise InvalidUrnError(f'Expecting a ActionRequestUrn but got {id}')
|
|
2676
3171
|
if UrnEncoder.contains_reserved_char(id):
|
|
2677
3172
|
raise InvalidUrnError(f'ActionRequestUrn id contains reserved characters')
|
|
2678
3173
|
|
|
@@ -2680,8 +3175,8 @@ class ActionRequestUrn(_SpecificUrn):
|
|
|
2680
3175
|
|
|
2681
3176
|
@classmethod
|
|
2682
3177
|
def _parse_ids(cls, entity_ids: List[str]) -> "ActionRequestUrn":
|
|
2683
|
-
if len(entity_ids) != cls.
|
|
2684
|
-
raise InvalidUrnError(f"ActionRequestUrn should have {cls.
|
|
3178
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3179
|
+
raise InvalidUrnError(f"ActionRequestUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2685
3180
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
2686
3181
|
|
|
2687
3182
|
@classmethod
|
|
@@ -2701,14 +3196,70 @@ class ActionRequestUrn(_SpecificUrn):
|
|
|
2701
3196
|
|
|
2702
3197
|
@property
|
|
2703
3198
|
def id(self) -> str:
|
|
2704
|
-
return self.
|
|
3199
|
+
return self._entity_ids[0]
|
|
3200
|
+
|
|
3201
|
+
if TYPE_CHECKING:
|
|
3202
|
+
from datahub.metadata.schema_classes import RemoteExecutorGlobalConfigKeyClass
|
|
3203
|
+
|
|
3204
|
+
class DataHubRemoteExecutorGlobalConfigUrn(_SpecificUrn):
|
|
3205
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubRemoteExecutorGlobalConfig"]] = "dataHubRemoteExecutorGlobalConfig"
|
|
3206
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
3207
|
+
|
|
3208
|
+
def __init__(self, id: Union["DataHubRemoteExecutorGlobalConfigUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
3209
|
+
if _allow_coercion:
|
|
3210
|
+
# Field coercion logic (if any is required).
|
|
3211
|
+
if isinstance(id, str):
|
|
3212
|
+
if id.startswith('urn:li:'):
|
|
3213
|
+
try:
|
|
3214
|
+
id = DataHubRemoteExecutorGlobalConfigUrn.from_string(id)
|
|
3215
|
+
except InvalidUrnError:
|
|
3216
|
+
raise InvalidUrnError(f'Expecting a DataHubRemoteExecutorGlobalConfigUrn but got {id}')
|
|
3217
|
+
else:
|
|
3218
|
+
id = UrnEncoder.encode_string(id)
|
|
3219
|
+
|
|
3220
|
+
# Validation logic.
|
|
3221
|
+
if not id:
|
|
3222
|
+
raise InvalidUrnError("DataHubRemoteExecutorGlobalConfigUrn id cannot be empty")
|
|
3223
|
+
if isinstance(id, DataHubRemoteExecutorGlobalConfigUrn):
|
|
3224
|
+
id = id.id
|
|
3225
|
+
elif isinstance(id, Urn):
|
|
3226
|
+
raise InvalidUrnError(f'Expecting a DataHubRemoteExecutorGlobalConfigUrn but got {id}')
|
|
3227
|
+
if UrnEncoder.contains_reserved_char(id):
|
|
3228
|
+
raise InvalidUrnError(f'DataHubRemoteExecutorGlobalConfigUrn id contains reserved characters')
|
|
3229
|
+
|
|
3230
|
+
super().__init__(self.ENTITY_TYPE, [id])
|
|
3231
|
+
|
|
3232
|
+
@classmethod
|
|
3233
|
+
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubRemoteExecutorGlobalConfigUrn":
|
|
3234
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3235
|
+
raise InvalidUrnError(f"DataHubRemoteExecutorGlobalConfigUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
3236
|
+
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
3237
|
+
|
|
3238
|
+
@classmethod
|
|
3239
|
+
def underlying_key_aspect_type(cls) -> Type["RemoteExecutorGlobalConfigKeyClass"]:
|
|
3240
|
+
from datahub.metadata.schema_classes import RemoteExecutorGlobalConfigKeyClass
|
|
3241
|
+
|
|
3242
|
+
return RemoteExecutorGlobalConfigKeyClass
|
|
3243
|
+
|
|
3244
|
+
def to_key_aspect(self) -> "RemoteExecutorGlobalConfigKeyClass":
|
|
3245
|
+
from datahub.metadata.schema_classes import RemoteExecutorGlobalConfigKeyClass
|
|
3246
|
+
|
|
3247
|
+
return RemoteExecutorGlobalConfigKeyClass(id=self.id)
|
|
3248
|
+
|
|
3249
|
+
@classmethod
|
|
3250
|
+
def from_key_aspect(cls, key_aspect: "RemoteExecutorGlobalConfigKeyClass") -> "DataHubRemoteExecutorGlobalConfigUrn":
|
|
3251
|
+
return cls(id=key_aspect.id)
|
|
3252
|
+
|
|
3253
|
+
@property
|
|
3254
|
+
def id(self) -> str:
|
|
3255
|
+
return self._entity_ids[0]
|
|
2705
3256
|
|
|
2706
3257
|
if TYPE_CHECKING:
|
|
2707
3258
|
from datahub.metadata.schema_classes import DataFlowKeyClass
|
|
2708
3259
|
|
|
2709
3260
|
class DataFlowUrn(_SpecificUrn):
|
|
2710
|
-
ENTITY_TYPE: ClassVar[
|
|
2711
|
-
|
|
3261
|
+
ENTITY_TYPE: ClassVar[Literal["dataFlow"]] = "dataFlow"
|
|
3262
|
+
_URN_PARTS: ClassVar[int] = 3
|
|
2712
3263
|
|
|
2713
3264
|
def __init__(self, orchestrator: str, flow_id: str, cluster: str, *, _allow_coercion: bool = True) -> None:
|
|
2714
3265
|
if _allow_coercion:
|
|
@@ -2735,8 +3286,8 @@ class DataFlowUrn(_SpecificUrn):
|
|
|
2735
3286
|
|
|
2736
3287
|
@classmethod
|
|
2737
3288
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataFlowUrn":
|
|
2738
|
-
if len(entity_ids) != cls.
|
|
2739
|
-
raise InvalidUrnError(f"DataFlowUrn should have {cls.
|
|
3289
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3290
|
+
raise InvalidUrnError(f"DataFlowUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2740
3291
|
return cls(orchestrator=entity_ids[0], flow_id=entity_ids[1], cluster=entity_ids[2], _allow_coercion=False)
|
|
2741
3292
|
|
|
2742
3293
|
@classmethod
|
|
@@ -2782,31 +3333,42 @@ class DataFlowUrn(_SpecificUrn):
|
|
|
2782
3333
|
|
|
2783
3334
|
@property
|
|
2784
3335
|
def orchestrator(self) -> str:
|
|
2785
|
-
return self.
|
|
3336
|
+
return self._entity_ids[0]
|
|
2786
3337
|
|
|
2787
3338
|
@property
|
|
2788
3339
|
def flow_id(self) -> str:
|
|
2789
|
-
return self.
|
|
3340
|
+
return self._entity_ids[1]
|
|
2790
3341
|
|
|
2791
3342
|
@property
|
|
2792
3343
|
def cluster(self) -> str:
|
|
2793
|
-
return self.
|
|
3344
|
+
return self._entity_ids[2]
|
|
2794
3345
|
|
|
2795
3346
|
if TYPE_CHECKING:
|
|
2796
3347
|
from datahub.metadata.schema_classes import DataContractKeyClass
|
|
2797
3348
|
|
|
2798
3349
|
class DataContractUrn(_SpecificUrn):
|
|
2799
|
-
ENTITY_TYPE: ClassVar[
|
|
2800
|
-
|
|
3350
|
+
ENTITY_TYPE: ClassVar[Literal["dataContract"]] = "dataContract"
|
|
3351
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
2801
3352
|
|
|
2802
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
3353
|
+
def __init__(self, id: Union["DataContractUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
2803
3354
|
if _allow_coercion:
|
|
2804
3355
|
# Field coercion logic (if any is required).
|
|
2805
|
-
|
|
3356
|
+
if isinstance(id, str):
|
|
3357
|
+
if id.startswith('urn:li:'):
|
|
3358
|
+
try:
|
|
3359
|
+
id = DataContractUrn.from_string(id)
|
|
3360
|
+
except InvalidUrnError:
|
|
3361
|
+
raise InvalidUrnError(f'Expecting a DataContractUrn but got {id}')
|
|
3362
|
+
else:
|
|
3363
|
+
id = UrnEncoder.encode_string(id)
|
|
2806
3364
|
|
|
2807
3365
|
# Validation logic.
|
|
2808
3366
|
if not id:
|
|
2809
3367
|
raise InvalidUrnError("DataContractUrn id cannot be empty")
|
|
3368
|
+
if isinstance(id, DataContractUrn):
|
|
3369
|
+
id = id.id
|
|
3370
|
+
elif isinstance(id, Urn):
|
|
3371
|
+
raise InvalidUrnError(f'Expecting a DataContractUrn but got {id}')
|
|
2810
3372
|
if UrnEncoder.contains_reserved_char(id):
|
|
2811
3373
|
raise InvalidUrnError(f'DataContractUrn id contains reserved characters')
|
|
2812
3374
|
|
|
@@ -2814,8 +3376,8 @@ class DataContractUrn(_SpecificUrn):
|
|
|
2814
3376
|
|
|
2815
3377
|
@classmethod
|
|
2816
3378
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataContractUrn":
|
|
2817
|
-
if len(entity_ids) != cls.
|
|
2818
|
-
raise InvalidUrnError(f"DataContractUrn should have {cls.
|
|
3379
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3380
|
+
raise InvalidUrnError(f"DataContractUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2819
3381
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
2820
3382
|
|
|
2821
3383
|
@classmethod
|
|
@@ -2835,23 +3397,34 @@ class DataContractUrn(_SpecificUrn):
|
|
|
2835
3397
|
|
|
2836
3398
|
@property
|
|
2837
3399
|
def id(self) -> str:
|
|
2838
|
-
return self.
|
|
3400
|
+
return self._entity_ids[0]
|
|
2839
3401
|
|
|
2840
3402
|
if TYPE_CHECKING:
|
|
2841
3403
|
from datahub.metadata.schema_classes import DataHubConnectionKeyClass
|
|
2842
3404
|
|
|
2843
3405
|
class DataHubConnectionUrn(_SpecificUrn):
|
|
2844
|
-
ENTITY_TYPE: ClassVar[
|
|
2845
|
-
|
|
3406
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubConnection"]] = "dataHubConnection"
|
|
3407
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
2846
3408
|
|
|
2847
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
3409
|
+
def __init__(self, id: Union["DataHubConnectionUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
2848
3410
|
if _allow_coercion:
|
|
2849
3411
|
# Field coercion logic (if any is required).
|
|
2850
|
-
|
|
3412
|
+
if isinstance(id, str):
|
|
3413
|
+
if id.startswith('urn:li:'):
|
|
3414
|
+
try:
|
|
3415
|
+
id = DataHubConnectionUrn.from_string(id)
|
|
3416
|
+
except InvalidUrnError:
|
|
3417
|
+
raise InvalidUrnError(f'Expecting a DataHubConnectionUrn but got {id}')
|
|
3418
|
+
else:
|
|
3419
|
+
id = UrnEncoder.encode_string(id)
|
|
2851
3420
|
|
|
2852
3421
|
# Validation logic.
|
|
2853
3422
|
if not id:
|
|
2854
3423
|
raise InvalidUrnError("DataHubConnectionUrn id cannot be empty")
|
|
3424
|
+
if isinstance(id, DataHubConnectionUrn):
|
|
3425
|
+
id = id.id
|
|
3426
|
+
elif isinstance(id, Urn):
|
|
3427
|
+
raise InvalidUrnError(f'Expecting a DataHubConnectionUrn but got {id}')
|
|
2855
3428
|
if UrnEncoder.contains_reserved_char(id):
|
|
2856
3429
|
raise InvalidUrnError(f'DataHubConnectionUrn id contains reserved characters')
|
|
2857
3430
|
|
|
@@ -2859,8 +3432,8 @@ class DataHubConnectionUrn(_SpecificUrn):
|
|
|
2859
3432
|
|
|
2860
3433
|
@classmethod
|
|
2861
3434
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubConnectionUrn":
|
|
2862
|
-
if len(entity_ids) != cls.
|
|
2863
|
-
raise InvalidUrnError(f"DataHubConnectionUrn should have {cls.
|
|
3435
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3436
|
+
raise InvalidUrnError(f"DataHubConnectionUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2864
3437
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
2865
3438
|
|
|
2866
3439
|
@classmethod
|
|
@@ -2880,23 +3453,34 @@ class DataHubConnectionUrn(_SpecificUrn):
|
|
|
2880
3453
|
|
|
2881
3454
|
@property
|
|
2882
3455
|
def id(self) -> str:
|
|
2883
|
-
return self.
|
|
3456
|
+
return self._entity_ids[0]
|
|
2884
3457
|
|
|
2885
3458
|
if TYPE_CHECKING:
|
|
2886
3459
|
from datahub.metadata.schema_classes import RemoteExecutorKeyClass
|
|
2887
3460
|
|
|
2888
3461
|
class DataHubRemoteExecutorUrn(_SpecificUrn):
|
|
2889
|
-
ENTITY_TYPE: ClassVar[
|
|
2890
|
-
|
|
3462
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubRemoteExecutor"]] = "dataHubRemoteExecutor"
|
|
3463
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
2891
3464
|
|
|
2892
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
3465
|
+
def __init__(self, id: Union["DataHubRemoteExecutorUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
2893
3466
|
if _allow_coercion:
|
|
2894
3467
|
# Field coercion logic (if any is required).
|
|
2895
|
-
|
|
3468
|
+
if isinstance(id, str):
|
|
3469
|
+
if id.startswith('urn:li:'):
|
|
3470
|
+
try:
|
|
3471
|
+
id = DataHubRemoteExecutorUrn.from_string(id)
|
|
3472
|
+
except InvalidUrnError:
|
|
3473
|
+
raise InvalidUrnError(f'Expecting a DataHubRemoteExecutorUrn but got {id}')
|
|
3474
|
+
else:
|
|
3475
|
+
id = UrnEncoder.encode_string(id)
|
|
2896
3476
|
|
|
2897
3477
|
# Validation logic.
|
|
2898
3478
|
if not id:
|
|
2899
3479
|
raise InvalidUrnError("DataHubRemoteExecutorUrn id cannot be empty")
|
|
3480
|
+
if isinstance(id, DataHubRemoteExecutorUrn):
|
|
3481
|
+
id = id.id
|
|
3482
|
+
elif isinstance(id, Urn):
|
|
3483
|
+
raise InvalidUrnError(f'Expecting a DataHubRemoteExecutorUrn but got {id}')
|
|
2900
3484
|
if UrnEncoder.contains_reserved_char(id):
|
|
2901
3485
|
raise InvalidUrnError(f'DataHubRemoteExecutorUrn id contains reserved characters')
|
|
2902
3486
|
|
|
@@ -2904,8 +3488,8 @@ class DataHubRemoteExecutorUrn(_SpecificUrn):
|
|
|
2904
3488
|
|
|
2905
3489
|
@classmethod
|
|
2906
3490
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubRemoteExecutorUrn":
|
|
2907
|
-
if len(entity_ids) != cls.
|
|
2908
|
-
raise InvalidUrnError(f"DataHubRemoteExecutorUrn should have {cls.
|
|
3491
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3492
|
+
raise InvalidUrnError(f"DataHubRemoteExecutorUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2909
3493
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
2910
3494
|
|
|
2911
3495
|
@classmethod
|
|
@@ -2925,24 +3509,32 @@ class DataHubRemoteExecutorUrn(_SpecificUrn):
|
|
|
2925
3509
|
|
|
2926
3510
|
@property
|
|
2927
3511
|
def id(self) -> str:
|
|
2928
|
-
return self.
|
|
3512
|
+
return self._entity_ids[0]
|
|
2929
3513
|
|
|
2930
3514
|
if TYPE_CHECKING:
|
|
2931
3515
|
from datahub.metadata.schema_classes import MonitorKeyClass
|
|
2932
3516
|
|
|
2933
3517
|
class MonitorUrn(_SpecificUrn):
|
|
2934
|
-
ENTITY_TYPE: ClassVar[
|
|
2935
|
-
|
|
3518
|
+
ENTITY_TYPE: ClassVar[Literal["monitor"]] = "monitor"
|
|
3519
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
2936
3520
|
|
|
2937
|
-
def __init__(self, entity: str, id: str, *, _allow_coercion: bool = True) -> None:
|
|
3521
|
+
def __init__(self, entity: Union["DatasetUrn", str], id: str, *, _allow_coercion: bool = True) -> None:
|
|
2938
3522
|
if _allow_coercion:
|
|
2939
3523
|
# Field coercion logic (if any is required).
|
|
3524
|
+
if isinstance(entity, str):
|
|
3525
|
+
if entity.startswith('urn:li:'):
|
|
3526
|
+
try:
|
|
3527
|
+
entity = DatasetUrn.from_string(entity)
|
|
3528
|
+
except InvalidUrnError:
|
|
3529
|
+
raise InvalidUrnError(f'Expecting a DatasetUrn but got {entity}')
|
|
3530
|
+
else:
|
|
3531
|
+
entity = UrnEncoder.encode_string(entity)
|
|
2940
3532
|
id = UrnEncoder.encode_string(id)
|
|
2941
3533
|
|
|
2942
3534
|
# Validation logic.
|
|
2943
3535
|
if not entity:
|
|
2944
3536
|
raise InvalidUrnError("MonitorUrn entity cannot be empty")
|
|
2945
|
-
entity = str(entity)
|
|
3537
|
+
entity = str(entity) # convert urn type to str
|
|
2946
3538
|
assert DatasetUrn.from_string(entity)
|
|
2947
3539
|
if not id:
|
|
2948
3540
|
raise InvalidUrnError("MonitorUrn id cannot be empty")
|
|
@@ -2953,8 +3545,8 @@ class MonitorUrn(_SpecificUrn):
|
|
|
2953
3545
|
|
|
2954
3546
|
@classmethod
|
|
2955
3547
|
def _parse_ids(cls, entity_ids: List[str]) -> "MonitorUrn":
|
|
2956
|
-
if len(entity_ids) != cls.
|
|
2957
|
-
raise InvalidUrnError(f"MonitorUrn should have {cls.
|
|
3548
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3549
|
+
raise InvalidUrnError(f"MonitorUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
2958
3550
|
return cls(entity=entity_ids[0], id=entity_ids[1], _allow_coercion=False)
|
|
2959
3551
|
|
|
2960
3552
|
@classmethod
|
|
@@ -2974,27 +3566,38 @@ class MonitorUrn(_SpecificUrn):
|
|
|
2974
3566
|
|
|
2975
3567
|
@property
|
|
2976
3568
|
def entity(self) -> str:
|
|
2977
|
-
return self.
|
|
3569
|
+
return self._entity_ids[0]
|
|
2978
3570
|
|
|
2979
3571
|
@property
|
|
2980
3572
|
def id(self) -> str:
|
|
2981
|
-
return self.
|
|
3573
|
+
return self._entity_ids[1]
|
|
2982
3574
|
|
|
2983
3575
|
if TYPE_CHECKING:
|
|
2984
3576
|
from datahub.metadata.schema_classes import CorpUserKeyClass
|
|
2985
3577
|
|
|
2986
3578
|
class CorpUserUrn(_SpecificUrn):
|
|
2987
|
-
ENTITY_TYPE: ClassVar[
|
|
2988
|
-
|
|
3579
|
+
ENTITY_TYPE: ClassVar[Literal["corpuser"]] = "corpuser"
|
|
3580
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
2989
3581
|
|
|
2990
|
-
def __init__(self, username: str, *, _allow_coercion: bool = True) -> None:
|
|
3582
|
+
def __init__(self, username: Union["CorpUserUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
2991
3583
|
if _allow_coercion:
|
|
2992
3584
|
# Field coercion logic (if any is required).
|
|
2993
|
-
|
|
3585
|
+
if isinstance(username, str):
|
|
3586
|
+
if username.startswith('urn:li:'):
|
|
3587
|
+
try:
|
|
3588
|
+
username = CorpUserUrn.from_string(username)
|
|
3589
|
+
except InvalidUrnError:
|
|
3590
|
+
raise InvalidUrnError(f'Expecting a CorpUserUrn but got {username}')
|
|
3591
|
+
else:
|
|
3592
|
+
username = UrnEncoder.encode_string(username)
|
|
2994
3593
|
|
|
2995
3594
|
# Validation logic.
|
|
2996
3595
|
if not username:
|
|
2997
3596
|
raise InvalidUrnError("CorpUserUrn username cannot be empty")
|
|
3597
|
+
if isinstance(username, CorpUserUrn):
|
|
3598
|
+
username = username.username
|
|
3599
|
+
elif isinstance(username, Urn):
|
|
3600
|
+
raise InvalidUrnError(f'Expecting a CorpUserUrn but got {username}')
|
|
2998
3601
|
if UrnEncoder.contains_reserved_char(username):
|
|
2999
3602
|
raise InvalidUrnError(f'CorpUserUrn username contains reserved characters')
|
|
3000
3603
|
|
|
@@ -3002,8 +3605,8 @@ class CorpUserUrn(_SpecificUrn):
|
|
|
3002
3605
|
|
|
3003
3606
|
@classmethod
|
|
3004
3607
|
def _parse_ids(cls, entity_ids: List[str]) -> "CorpUserUrn":
|
|
3005
|
-
if len(entity_ids) != cls.
|
|
3006
|
-
raise InvalidUrnError(f"CorpUserUrn should have {cls.
|
|
3608
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3609
|
+
raise InvalidUrnError(f"CorpUserUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
3007
3610
|
return cls(username=entity_ids[0], _allow_coercion=False)
|
|
3008
3611
|
|
|
3009
3612
|
@classmethod
|
|
@@ -3028,14 +3631,14 @@ class CorpUserUrn(_SpecificUrn):
|
|
|
3028
3631
|
|
|
3029
3632
|
@property
|
|
3030
3633
|
def username(self) -> str:
|
|
3031
|
-
return self.
|
|
3634
|
+
return self._entity_ids[0]
|
|
3032
3635
|
|
|
3033
3636
|
if TYPE_CHECKING:
|
|
3034
3637
|
from datahub.metadata.schema_classes import VersionSetKeyClass
|
|
3035
3638
|
|
|
3036
3639
|
class VersionSetUrn(_SpecificUrn):
|
|
3037
|
-
ENTITY_TYPE: ClassVar[
|
|
3038
|
-
|
|
3640
|
+
ENTITY_TYPE: ClassVar[Literal["versionSet"]] = "versionSet"
|
|
3641
|
+
_URN_PARTS: ClassVar[int] = 2
|
|
3039
3642
|
|
|
3040
3643
|
def __init__(self, id: str, entity_type: str, *, _allow_coercion: bool = True) -> None:
|
|
3041
3644
|
if _allow_coercion:
|
|
@@ -3057,8 +3660,8 @@ class VersionSetUrn(_SpecificUrn):
|
|
|
3057
3660
|
|
|
3058
3661
|
@classmethod
|
|
3059
3662
|
def _parse_ids(cls, entity_ids: List[str]) -> "VersionSetUrn":
|
|
3060
|
-
if len(entity_ids) != cls.
|
|
3061
|
-
raise InvalidUrnError(f"VersionSetUrn should have {cls.
|
|
3663
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3664
|
+
raise InvalidUrnError(f"VersionSetUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
3062
3665
|
return cls(id=entity_ids[0], entity_type=entity_ids[1], _allow_coercion=False)
|
|
3063
3666
|
|
|
3064
3667
|
@classmethod
|
|
@@ -3078,27 +3681,38 @@ class VersionSetUrn(_SpecificUrn):
|
|
|
3078
3681
|
|
|
3079
3682
|
@property
|
|
3080
3683
|
def id(self) -> str:
|
|
3081
|
-
return self.
|
|
3684
|
+
return self._entity_ids[0]
|
|
3082
3685
|
|
|
3083
3686
|
@property
|
|
3084
3687
|
def entity_type(self) -> str:
|
|
3085
|
-
return self.
|
|
3688
|
+
return self._entity_ids[1]
|
|
3086
3689
|
|
|
3087
3690
|
if TYPE_CHECKING:
|
|
3088
3691
|
from datahub.metadata.schema_classes import TestKeyClass
|
|
3089
3692
|
|
|
3090
3693
|
class TestUrn(_SpecificUrn):
|
|
3091
|
-
ENTITY_TYPE: ClassVar[
|
|
3092
|
-
|
|
3694
|
+
ENTITY_TYPE: ClassVar[Literal["test"]] = "test"
|
|
3695
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
3093
3696
|
|
|
3094
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
3697
|
+
def __init__(self, id: Union["TestUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
3095
3698
|
if _allow_coercion:
|
|
3096
3699
|
# Field coercion logic (if any is required).
|
|
3097
|
-
|
|
3700
|
+
if isinstance(id, str):
|
|
3701
|
+
if id.startswith('urn:li:'):
|
|
3702
|
+
try:
|
|
3703
|
+
id = TestUrn.from_string(id)
|
|
3704
|
+
except InvalidUrnError:
|
|
3705
|
+
raise InvalidUrnError(f'Expecting a TestUrn but got {id}')
|
|
3706
|
+
else:
|
|
3707
|
+
id = UrnEncoder.encode_string(id)
|
|
3098
3708
|
|
|
3099
3709
|
# Validation logic.
|
|
3100
3710
|
if not id:
|
|
3101
3711
|
raise InvalidUrnError("TestUrn id cannot be empty")
|
|
3712
|
+
if isinstance(id, TestUrn):
|
|
3713
|
+
id = id.id
|
|
3714
|
+
elif isinstance(id, Urn):
|
|
3715
|
+
raise InvalidUrnError(f'Expecting a TestUrn but got {id}')
|
|
3102
3716
|
if UrnEncoder.contains_reserved_char(id):
|
|
3103
3717
|
raise InvalidUrnError(f'TestUrn id contains reserved characters')
|
|
3104
3718
|
|
|
@@ -3106,8 +3720,8 @@ class TestUrn(_SpecificUrn):
|
|
|
3106
3720
|
|
|
3107
3721
|
@classmethod
|
|
3108
3722
|
def _parse_ids(cls, entity_ids: List[str]) -> "TestUrn":
|
|
3109
|
-
if len(entity_ids) != cls.
|
|
3110
|
-
raise InvalidUrnError(f"TestUrn should have {cls.
|
|
3723
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3724
|
+
raise InvalidUrnError(f"TestUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
3111
3725
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
3112
3726
|
|
|
3113
3727
|
@classmethod
|
|
@@ -3127,23 +3741,34 @@ class TestUrn(_SpecificUrn):
|
|
|
3127
3741
|
|
|
3128
3742
|
@property
|
|
3129
3743
|
def id(self) -> str:
|
|
3130
|
-
return self.
|
|
3744
|
+
return self._entity_ids[0]
|
|
3131
3745
|
|
|
3132
3746
|
if TYPE_CHECKING:
|
|
3133
3747
|
from datahub.metadata.schema_classes import DataHubIngestionSourceKeyClass
|
|
3134
3748
|
|
|
3135
3749
|
class DataHubIngestionSourceUrn(_SpecificUrn):
|
|
3136
|
-
ENTITY_TYPE: ClassVar[
|
|
3137
|
-
|
|
3750
|
+
ENTITY_TYPE: ClassVar[Literal["dataHubIngestionSource"]] = "dataHubIngestionSource"
|
|
3751
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
3138
3752
|
|
|
3139
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
3753
|
+
def __init__(self, id: Union["DataHubIngestionSourceUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
3140
3754
|
if _allow_coercion:
|
|
3141
3755
|
# Field coercion logic (if any is required).
|
|
3142
|
-
|
|
3756
|
+
if isinstance(id, str):
|
|
3757
|
+
if id.startswith('urn:li:'):
|
|
3758
|
+
try:
|
|
3759
|
+
id = DataHubIngestionSourceUrn.from_string(id)
|
|
3760
|
+
except InvalidUrnError:
|
|
3761
|
+
raise InvalidUrnError(f'Expecting a DataHubIngestionSourceUrn but got {id}')
|
|
3762
|
+
else:
|
|
3763
|
+
id = UrnEncoder.encode_string(id)
|
|
3143
3764
|
|
|
3144
3765
|
# Validation logic.
|
|
3145
3766
|
if not id:
|
|
3146
3767
|
raise InvalidUrnError("DataHubIngestionSourceUrn id cannot be empty")
|
|
3768
|
+
if isinstance(id, DataHubIngestionSourceUrn):
|
|
3769
|
+
id = id.id
|
|
3770
|
+
elif isinstance(id, Urn):
|
|
3771
|
+
raise InvalidUrnError(f'Expecting a DataHubIngestionSourceUrn but got {id}')
|
|
3147
3772
|
if UrnEncoder.contains_reserved_char(id):
|
|
3148
3773
|
raise InvalidUrnError(f'DataHubIngestionSourceUrn id contains reserved characters')
|
|
3149
3774
|
|
|
@@ -3151,8 +3776,8 @@ class DataHubIngestionSourceUrn(_SpecificUrn):
|
|
|
3151
3776
|
|
|
3152
3777
|
@classmethod
|
|
3153
3778
|
def _parse_ids(cls, entity_ids: List[str]) -> "DataHubIngestionSourceUrn":
|
|
3154
|
-
if len(entity_ids) != cls.
|
|
3155
|
-
raise InvalidUrnError(f"DataHubIngestionSourceUrn should have {cls.
|
|
3779
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3780
|
+
raise InvalidUrnError(f"DataHubIngestionSourceUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
3156
3781
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
3157
3782
|
|
|
3158
3783
|
@classmethod
|
|
@@ -3172,27 +3797,26 @@ class DataHubIngestionSourceUrn(_SpecificUrn):
|
|
|
3172
3797
|
|
|
3173
3798
|
@property
|
|
3174
3799
|
def id(self) -> str:
|
|
3175
|
-
return self.
|
|
3800
|
+
return self._entity_ids[0]
|
|
3176
3801
|
|
|
3177
3802
|
if TYPE_CHECKING:
|
|
3178
3803
|
from datahub.metadata.schema_classes import MLModelDeploymentKeyClass
|
|
3179
3804
|
|
|
3180
3805
|
class MlModelDeploymentUrn(_SpecificUrn):
|
|
3181
|
-
ENTITY_TYPE: ClassVar[
|
|
3182
|
-
|
|
3806
|
+
ENTITY_TYPE: ClassVar[Literal["mlModelDeployment"]] = "mlModelDeployment"
|
|
3807
|
+
_URN_PARTS: ClassVar[int] = 3
|
|
3183
3808
|
|
|
3184
|
-
def __init__(self, platform: str, name: str, env: str = "PROD", *, _allow_coercion: bool = True) -> None:
|
|
3809
|
+
def __init__(self, platform: Union["DataPlatformUrn", str], name: str, env: str = "PROD", *, _allow_coercion: bool = True) -> None:
|
|
3185
3810
|
if _allow_coercion:
|
|
3186
3811
|
# Field coercion logic (if any is required).
|
|
3187
3812
|
platform = DataPlatformUrn(platform).urn()
|
|
3188
3813
|
name = UrnEncoder.encode_string(name)
|
|
3189
3814
|
env = env.upper()
|
|
3190
|
-
env = UrnEncoder.encode_string(env)
|
|
3191
3815
|
|
|
3192
3816
|
# Validation logic.
|
|
3193
3817
|
if not platform:
|
|
3194
3818
|
raise InvalidUrnError("MlModelDeploymentUrn platform cannot be empty")
|
|
3195
|
-
platform = str(platform)
|
|
3819
|
+
platform = str(platform) # convert urn type to str
|
|
3196
3820
|
assert DataPlatformUrn.from_string(platform)
|
|
3197
3821
|
if not name:
|
|
3198
3822
|
raise InvalidUrnError("MlModelDeploymentUrn name cannot be empty")
|
|
@@ -3207,8 +3831,8 @@ class MlModelDeploymentUrn(_SpecificUrn):
|
|
|
3207
3831
|
|
|
3208
3832
|
@classmethod
|
|
3209
3833
|
def _parse_ids(cls, entity_ids: List[str]) -> "MlModelDeploymentUrn":
|
|
3210
|
-
if len(entity_ids) != cls.
|
|
3211
|
-
raise InvalidUrnError(f"MlModelDeploymentUrn should have {cls.
|
|
3834
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3835
|
+
raise InvalidUrnError(f"MlModelDeploymentUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
3212
3836
|
return cls(platform=entity_ids[0], name=entity_ids[1], env=entity_ids[2], _allow_coercion=False)
|
|
3213
3837
|
|
|
3214
3838
|
@classmethod
|
|
@@ -3228,31 +3852,42 @@ class MlModelDeploymentUrn(_SpecificUrn):
|
|
|
3228
3852
|
|
|
3229
3853
|
@property
|
|
3230
3854
|
def platform(self) -> str:
|
|
3231
|
-
return self.
|
|
3855
|
+
return self._entity_ids[0]
|
|
3232
3856
|
|
|
3233
3857
|
@property
|
|
3234
3858
|
def name(self) -> str:
|
|
3235
|
-
return self.
|
|
3859
|
+
return self._entity_ids[1]
|
|
3236
3860
|
|
|
3237
3861
|
@property
|
|
3238
3862
|
def env(self) -> str:
|
|
3239
|
-
return self.
|
|
3863
|
+
return self._entity_ids[2]
|
|
3240
3864
|
|
|
3241
3865
|
if TYPE_CHECKING:
|
|
3242
3866
|
from datahub.metadata.schema_classes import LinkPreviewKeyClass
|
|
3243
3867
|
|
|
3244
3868
|
class LinkPreviewUrn(_SpecificUrn):
|
|
3245
|
-
ENTITY_TYPE: ClassVar[
|
|
3246
|
-
|
|
3869
|
+
ENTITY_TYPE: ClassVar[Literal["linkPreview"]] = "linkPreview"
|
|
3870
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
3247
3871
|
|
|
3248
|
-
def __init__(self, id: str, *, _allow_coercion: bool = True) -> None:
|
|
3872
|
+
def __init__(self, id: Union["LinkPreviewUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
3249
3873
|
if _allow_coercion:
|
|
3250
3874
|
# Field coercion logic (if any is required).
|
|
3251
|
-
|
|
3875
|
+
if isinstance(id, str):
|
|
3876
|
+
if id.startswith('urn:li:'):
|
|
3877
|
+
try:
|
|
3878
|
+
id = LinkPreviewUrn.from_string(id)
|
|
3879
|
+
except InvalidUrnError:
|
|
3880
|
+
raise InvalidUrnError(f'Expecting a LinkPreviewUrn but got {id}')
|
|
3881
|
+
else:
|
|
3882
|
+
id = UrnEncoder.encode_string(id)
|
|
3252
3883
|
|
|
3253
3884
|
# Validation logic.
|
|
3254
3885
|
if not id:
|
|
3255
3886
|
raise InvalidUrnError("LinkPreviewUrn id cannot be empty")
|
|
3887
|
+
if isinstance(id, LinkPreviewUrn):
|
|
3888
|
+
id = id.id
|
|
3889
|
+
elif isinstance(id, Urn):
|
|
3890
|
+
raise InvalidUrnError(f'Expecting a LinkPreviewUrn but got {id}')
|
|
3256
3891
|
if UrnEncoder.contains_reserved_char(id):
|
|
3257
3892
|
raise InvalidUrnError(f'LinkPreviewUrn id contains reserved characters')
|
|
3258
3893
|
|
|
@@ -3260,8 +3895,8 @@ class LinkPreviewUrn(_SpecificUrn):
|
|
|
3260
3895
|
|
|
3261
3896
|
@classmethod
|
|
3262
3897
|
def _parse_ids(cls, entity_ids: List[str]) -> "LinkPreviewUrn":
|
|
3263
|
-
if len(entity_ids) != cls.
|
|
3264
|
-
raise InvalidUrnError(f"LinkPreviewUrn should have {cls.
|
|
3898
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3899
|
+
raise InvalidUrnError(f"LinkPreviewUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
3265
3900
|
return cls(id=entity_ids[0], _allow_coercion=False)
|
|
3266
3901
|
|
|
3267
3902
|
@classmethod
|
|
@@ -3281,23 +3916,34 @@ class LinkPreviewUrn(_SpecificUrn):
|
|
|
3281
3916
|
|
|
3282
3917
|
@property
|
|
3283
3918
|
def id(self) -> str:
|
|
3284
|
-
return self.
|
|
3919
|
+
return self._entity_ids[0]
|
|
3285
3920
|
|
|
3286
3921
|
if TYPE_CHECKING:
|
|
3287
3922
|
from datahub.metadata.schema_classes import TelemetryKeyClass
|
|
3288
3923
|
|
|
3289
3924
|
class TelemetryUrn(_SpecificUrn):
|
|
3290
|
-
ENTITY_TYPE: ClassVar[
|
|
3291
|
-
|
|
3925
|
+
ENTITY_TYPE: ClassVar[Literal["telemetry"]] = "telemetry"
|
|
3926
|
+
_URN_PARTS: ClassVar[int] = 1
|
|
3292
3927
|
|
|
3293
|
-
def __init__(self, name: str, *, _allow_coercion: bool = True) -> None:
|
|
3928
|
+
def __init__(self, name: Union["TelemetryUrn", str], *, _allow_coercion: bool = True) -> None:
|
|
3294
3929
|
if _allow_coercion:
|
|
3295
3930
|
# Field coercion logic (if any is required).
|
|
3296
|
-
|
|
3931
|
+
if isinstance(name, str):
|
|
3932
|
+
if name.startswith('urn:li:'):
|
|
3933
|
+
try:
|
|
3934
|
+
name = TelemetryUrn.from_string(name)
|
|
3935
|
+
except InvalidUrnError:
|
|
3936
|
+
raise InvalidUrnError(f'Expecting a TelemetryUrn but got {name}')
|
|
3937
|
+
else:
|
|
3938
|
+
name = UrnEncoder.encode_string(name)
|
|
3297
3939
|
|
|
3298
3940
|
# Validation logic.
|
|
3299
3941
|
if not name:
|
|
3300
3942
|
raise InvalidUrnError("TelemetryUrn name cannot be empty")
|
|
3943
|
+
if isinstance(name, TelemetryUrn):
|
|
3944
|
+
name = name.name
|
|
3945
|
+
elif isinstance(name, Urn):
|
|
3946
|
+
raise InvalidUrnError(f'Expecting a TelemetryUrn but got {name}')
|
|
3301
3947
|
if UrnEncoder.contains_reserved_char(name):
|
|
3302
3948
|
raise InvalidUrnError(f'TelemetryUrn name contains reserved characters')
|
|
3303
3949
|
|
|
@@ -3305,8 +3951,8 @@ class TelemetryUrn(_SpecificUrn):
|
|
|
3305
3951
|
|
|
3306
3952
|
@classmethod
|
|
3307
3953
|
def _parse_ids(cls, entity_ids: List[str]) -> "TelemetryUrn":
|
|
3308
|
-
if len(entity_ids) != cls.
|
|
3309
|
-
raise InvalidUrnError(f"TelemetryUrn should have {cls.
|
|
3954
|
+
if len(entity_ids) != cls._URN_PARTS:
|
|
3955
|
+
raise InvalidUrnError(f"TelemetryUrn should have {cls._URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
|
|
3310
3956
|
return cls(name=entity_ids[0], _allow_coercion=False)
|
|
3311
3957
|
|
|
3312
3958
|
@classmethod
|
|
@@ -3326,6 +3972,6 @@ class TelemetryUrn(_SpecificUrn):
|
|
|
3326
3972
|
|
|
3327
3973
|
@property
|
|
3328
3974
|
def name(self) -> str:
|
|
3329
|
-
return self.
|
|
3975
|
+
return self._entity_ids[0]
|
|
3330
3976
|
|
|
3331
3977
|
# fmt: on
|