Skip to content

Commit 81ea57e

Browse files
committed
[change] Moved AtlanResponse directly to _call_api method
1 parent 6d56e42 commit 81ea57e

2 files changed

Lines changed: 9 additions & 22 deletions

File tree

pyatlan/client/asset.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
AssetRequest,
7171
AssetResponse,
7272
AtlanObject,
73-
AtlanResponse,
7473
AtlanTag,
7574
AtlanTagName,
7675
BulkRequest,
@@ -247,10 +246,7 @@ def search(self, criteria: IndexSearchRequest, bulk=False) -> IndexSearchResults
247246
unflatten_custom_metadata_for_entity(
248247
entity=entity, attributes=criteria.attributes
249248
)
250-
translated_entities = AtlanResponse(
251-
raw_json=raw_json["entities"], client=self._client
252-
).to_dict()
253-
assets = parse_obj_as(List[Asset], translated_entities)
249+
assets = parse_obj_as(List[Asset], raw_json["entities"])
254250
except ValidationError as err:
255251
raise ErrorCode.JSON_ERROR.exception_with_parameters(
256252
raw_json, 200, str(err)
@@ -322,10 +318,7 @@ def get_lineage_list(
322318
unflatten_custom_metadata_for_entity(
323319
entity=entity, attributes=lineage_request.attributes
324320
)
325-
translated_entities = AtlanResponse(
326-
raw_json=raw_json["entities"], client=self._client
327-
).to_dict()
328-
assets = parse_obj_as(List[Asset], translated_entities)
321+
assets = parse_obj_as(List[Asset], raw_json["entities"])
329322
has_more = parse_obj_as(bool, raw_json["hasMore"])
330323
except ValidationError as err:
331324
raise ErrorCode.JSON_ERROR.exception_with_parameters(
@@ -553,10 +546,7 @@ def _handle_relationships(self, raw_json):
553546
raw_json["entity"]["relationshipAttributes"]
554547
)
555548
raw_json["entity"]["relationshipAttributes"] = {}
556-
translated_raw_json = AtlanResponse(
557-
raw_json=raw_json, client=self._client
558-
).to_dict()
559-
asset = AssetResponse[A](**translated_raw_json).entity
549+
asset = AssetResponse[A](**raw_json).entity
560550
asset.is_incomplete = False
561551
return asset
562552

@@ -640,10 +630,7 @@ def save(
640630
asset.validate_required()
641631
request = BulkRequest[Asset](entities=entities)
642632
raw_json = self._client._call_api(BULK_UPDATE, query_params, request)
643-
translated_raw_json = AtlanResponse(
644-
raw_json=raw_json, client=self._client
645-
).to_dict()
646-
response = AssetMutationResponse(**translated_raw_json)
633+
response = AssetMutationResponse(**raw_json)
647634
if connections_created := response.assets_created(Connection):
648635
self._wait_for_connections_to_be_created(connections_created)
649636
return response
@@ -2095,10 +2082,7 @@ def _process_entities(self, entities):
20952082
unflatten_custom_metadata_for_entity(
20962083
entity=entity, attributes=self._criteria.attributes
20972084
)
2098-
translated_entities = AtlanResponse(
2099-
raw_json=entities, client=self._client
2100-
).to_dict()
2101-
self._assets = parse_obj_as(List[Asset], translated_entities)
2085+
self._assets = parse_obj_as(List[Asset], entities)
21022086

21032087
def _update_first_last_record_creation_times(self):
21042088
self._first_record_creation_time = self._last_record_creation_time = -2

pyatlan/client/atlan.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
Purpose,
8282
)
8383
from pyatlan.model.atlan_image import AtlanImage
84-
from pyatlan.model.core import Announcement, AtlanObject
84+
from pyatlan.model.core import Announcement, AtlanObject, AtlanResponse
8585
from pyatlan.model.custom_metadata import CustomMetadataDict
8686
from pyatlan.model.enums import AtlanConnectorType, AtlanTypeCategory, CertificateStatus
8787
from pyatlan.model.group import AtlanGroup, CreateGroupResponse, GroupResponse
@@ -511,6 +511,9 @@ def _call_api_internal(
511511
response_ = response.text
512512
else:
513513
response_ = events if events else response.json()
514+
response_ = AtlanResponse(
515+
raw_json=response.json(), client=self
516+
).to_dict()
514517
LOGGER.debug("response: %s", response_)
515518
return response_
516519
except (

0 commit comments

Comments
 (0)