Skip to content

Commit 956071d

Browse files
authored
Merge pull request #37 from atlanhq/update_crud
Make minor changes found when updating documentation
2 parents 7463d13 + ef8bc19 commit 956071d

File tree

11 files changed

+505
-97
lines changed

11 files changed

+505
-97
lines changed

pyatlan/HISTORY.md HISTORY.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
## 0.0.21 (Apr 11, 2023)
2+
3+
* Added relation_attributes parameter to IndexSearchRequest to specify the attributes to be included in each relationship that is included in the results of the search
4+
* Set assets to empty list when no entities are returned by search
5+
* Add classmethod ref_by_guid to Referencable
6+
* Add classmethod ref_by_qualified_name to Referencable
7+
18
## 0.0.20 (Apr 5, 2023)
29

310
* Corrected issue with from, size and track_total_hits in DSL object not being sent to server if the defaults weren't changed
11+
* Added relation_attributes parameter to IndexSearchRequest to specify the attributes to be included in each relationship that is included in the results of the search
412

513
## 0.0.19 (Mar 30, 2023)
614

pyatlan/client/atlan.py

+30-12
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def _get_next_page(self):
156156
request_obj=self._criteria,
157157
)
158158
if "entities" not in raw_json:
159+
self._assets = []
159160
return False
160161
self._assets = parse_obj_as(list[Asset], raw_json["entities"])
161162
return True
@@ -320,7 +321,7 @@ def get_asset_by_qualified_name(
320321
return asset
321322
except AtlanError as ae:
322323
if ae.status_code == HTTPStatus.NOT_FOUND:
323-
raise NotFoundError(message=ae.user_message, code=ae.code)
324+
raise NotFoundError(message=ae.user_message, code=ae.code) from ae
324325
raise ae
325326

326327
@validate_arguments()
@@ -341,9 +342,13 @@ def get_asset_by_guid(
341342
GET_ENTITY_BY_GUID.format_path_with_params(guid),
342343
query_params,
343344
)
344-
raw_json["entity"]["attributes"].update(
345-
raw_json["entity"]["relationshipAttributes"]
346-
)
345+
if (
346+
"relationshipAttributes" in raw_json["entity"]
347+
and raw_json["entity"]["relationshipAttributes"]
348+
):
349+
raw_json["entity"]["attributes"].update(
350+
raw_json["entity"]["relationshipAttributes"]
351+
)
347352
raw_json["entity"]["relationshipAttributes"] = {}
348353
asset = AssetResponse[A](**raw_json).entity
349354
asset.is_incomplete = False
@@ -355,9 +360,18 @@ def get_asset_by_guid(
355360
return asset
356361
except AtlanError as ae:
357362
if ae.status_code == HTTPStatus.NOT_FOUND:
358-
raise NotFoundError(message=ae.user_message, code=ae.code)
363+
raise NotFoundError(message=ae.user_message, code=ae.code) from ae
359364
raise ae
360365

366+
@validate_arguments()
367+
def retrieve_minimal(self, guid: str, asset_type: Type[A]) -> A:
368+
return self.get_asset_by_guid(
369+
guid=guid,
370+
asset_type=asset_type,
371+
min_ext_info=True,
372+
ignore_relationships=True,
373+
)
374+
361375
def upsert(
362376
self,
363377
entity: Union[Asset, list[Asset]],
@@ -387,6 +401,13 @@ def purge_entity_by_guid(self, guid) -> AssetMutationResponse:
387401
)
388402
return AssetMutationResponse(**raw_json)
389403

404+
def delete_entity_by_guid(self, guid) -> AssetMutationResponse:
405+
raw_json = self._call_api(
406+
DELETE_ENTITY_BY_GUID.format_path_with_params(guid),
407+
{"deleteType": AtlanDeleteType.SOFT.value},
408+
)
409+
return AssetMutationResponse(**raw_json)
410+
390411
def search(self, criteria: IndexSearchRequest) -> SearchResults:
391412
raw_json = self._call_api(
392413
INDEX_SEARCH,
@@ -419,7 +440,6 @@ def get_typedefs(self, type_category: AtlanTypeCategory) -> TypeDefResponse:
419440
return TypeDefResponse(**raw_json)
420441

421442
def create_typedef(self, typedef: TypeDef) -> TypeDefResponse:
422-
payload = None
423443
if isinstance(typedef, ClassificationDef):
424444
# Set up the request payload...
425445
payload = TypeDefResponse(
@@ -463,15 +483,15 @@ def add_classifications(
463483
classification_names: list[str],
464484
propagate: bool = True,
465485
remove_propagation_on_delete: bool = True,
466-
restrict_lineage_propogation: bool = True,
486+
restrict_lineage_propagation: bool = True,
467487
) -> None:
468488
classifications = Classifications(
469489
__root__=[
470490
Classification(
471491
type_name=ClassificationName(display_text=name),
472492
propagate=propagate,
473493
remove_propagations_on_entity_delete=remove_propagation_on_delete,
474-
restrict_propagation_through_lineage=restrict_lineage_propogation,
494+
restrict_propagation_through_lineage=restrict_lineage_propagation,
475495
)
476496
for name in classification_names
477497
]
@@ -528,11 +548,9 @@ def _update_asset_by_attribute(self, asset, asset_type, qualified_name: str):
528548
AssetRequest[Asset](entity=asset),
529549
)
530550
response = AssetMutationResponse(**raw_json)
531-
assets = response.assets_partially_updated(asset_type=asset_type)
532-
if assets:
551+
if assets := response.assets_partially_updated(asset_type=asset_type):
533552
return assets[0]
534-
assets = response.assets_updated(asset_type=asset_type)
535-
if assets:
553+
if assets := response.assets_updated(asset_type=asset_type):
536554
return assets[0]
537555
return None
538556

0 commit comments

Comments
 (0)