Skip to content

Commit 1172fdf

Browse files
committed
[docs] Updated docstrings and fixed source_tag_attachments field typo
1 parent b6ecf2e commit 1172fdf

26 files changed

+143
-113
lines changed

pyatlan/client/atlan.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,11 @@ def _call_api_internal(
446446
if text_response:
447447
response_ = response.text
448448
else:
449+
# The response may be either a JSON object or a list of events
450+
# If it's an event stream, return the list of events directly
451+
# Otherwise, parse the JSON response using AtlanResponse,
452+
# which handles translation tasks such as converting
453+
# Atlan tag hashed IDs into human-readable strings
449454
response_ = (
450455
events
451456
if events
@@ -631,6 +636,9 @@ def _create_params(
631636
params["params"] = query_params
632637
if request_obj is not None:
633638
if isinstance(request_obj, AtlanObject):
639+
# Always use AtlanRequest, which accepts a Pydantic model instance and the client
640+
# Behind the scenes, it handles retranslation tasks—such as converting
641+
# human-readable Atlan tag names back into hashed IDs as required by the backend
634642
params["data"] = AtlanRequest(instance=request_obj, client=self).json()
635643
elif api.consumes == APPLICATION_ENCODED_FORM:
636644
params["data"] = request_obj

pyatlan/model/core.py

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,16 @@ def from_yaml(cls, yaml_str: str):
154154

155155

156156
class AtlanResponse:
157+
"""
158+
A wrapper class to handle and translate raw JSON responses
159+
from the Atlan API into human-readable formats using registered translators.
160+
"""
161+
157162
def __init__(self, raw_json: Dict[str, Any], client: AtlanClient):
163+
"""
164+
Initialize the AtlanResponse with raw JSON and client.
165+
Automatically applies translations to the raw JSON.
166+
"""
158167
self.raw_json = raw_json
159168
self.client = client
160169
self.translators = [
@@ -166,6 +175,9 @@ def __init__(self, raw_json: Dict[str, Any], client: AtlanClient):
166175
def _deep_translate(
167176
self, data: Union[Dict[str, Any], List[Any], Any]
168177
) -> Union[Dict[str, Any], List[Any], Any]:
178+
"""
179+
Recursively translate fields in a JSON structure using registered translators.
180+
"""
169181
if isinstance(data, dict):
170182
# Apply translators to this dict if any apply
171183
for translator in self.translators:
@@ -182,11 +194,25 @@ def _deep_translate(
182194
return data
183195

184196
def to_dict(self) -> Union[Dict[str, Any], List[Any], Any]:
197+
"""
198+
Returns the translated version of the raw JSON response.
199+
"""
185200
return self.translated
186201

187202

188203
class AtlanRequest:
204+
"""
205+
A wrapper class to handle and retranslate an AtlanObject instance
206+
into a backend-compatible JSON format by applying retranslators.
207+
"""
208+
189209
def __init__(self, instance: AtlanObject, client: AtlanClient):
210+
"""
211+
Initialize an AtlanRequest for a given asset/model instance.
212+
213+
Serializes the instance to JSON, applies retranslation logic, and prepares
214+
a structure compatible with Atlan's API (e.g: converts tag names back to hashed IDs).
215+
"""
190216
self.client = client
191217
self.instance = instance
192218
self.retranslators = [
@@ -207,6 +233,9 @@ def __init__(self, instance: AtlanObject, client: AtlanClient):
207233
self.translated = self._deep_retranslate(parsed)
208234

209235
def _deep_retranslate(self, data: Any) -> Any:
236+
"""
237+
Recursively traverse and apply retranslators to JSON-like data.
238+
"""
210239
if isinstance(data, dict):
211240
for retranslator in self.retranslators:
212241
if retranslator.applies_to(data):
@@ -217,6 +246,9 @@ def _deep_retranslate(self, data: Any) -> Any:
217246
return data
218247

219248
def json(self, **kwargs) -> str:
249+
"""
250+
Returns the fully retranslated JSON string, suitable for API calls.
251+
"""
220252
return json.dumps(self.translated, **kwargs)
221253

222254

@@ -287,32 +319,13 @@ class Config:
287319
alias="restrictPropagationThroughHierarchy",
288320
)
289321
validity_periods: Optional[List[str]] = Field(default=None, alias="validityPeriods")
290-
source_tag_attachements: List[SourceTagAttachment] = Field(
322+
source_tag_attachments: List[SourceTagAttachment] = Field(
291323
default_factory=list, exclude=True
292324
)
293325

294326
attributes: Optional[Dict[str, Any]] = None
295327
tag_id: Optional[str] = Field(default=None, exclude=True)
296328

297-
# @property
298-
# def source_tag_attachements(self) -> List[SourceTagAttachment]:
299-
# return self._source_tag_attachements
300-
301-
# def __init__(self, *args, **kwargs):
302-
# from pyatlan.client.atlan import AtlanClient
303-
304-
# super().__init__(*args, **kwargs)
305-
# if self.type_name != AtlanTagName.get_deleted_sentinel():
306-
# attr_id = AtlanClient.get_current_client().atlan_tag_cache.get_source_tags_attr_id(
307-
# self.type_name.id
308-
# )
309-
# if self.attributes and attr_id in self.attributes:
310-
# self._source_tag_attachements = [
311-
# SourceTagAttachment(**source_tag["attributes"])
312-
# for source_tag in self.attributes[attr_id]
313-
# if isinstance(source_tag, dict) and source_tag.get("attributes")
314-
# ]
315-
316329
@classmethod
317330
def of(
318331
cls,
@@ -343,7 +356,7 @@ def of(
343356
tag_id or ""
344357
)
345358
tag.attributes = {source_tag_attr_id: [source_tag_attachment]} # type: ignore[dict-item]
346-
tag.source_tag_attachements.append(source_tag_attachment)
359+
tag.source_tag_attachments.append(source_tag_attachment)
347360
return tag
348361

349362

pyatlan/model/fields/atlan_fields.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from abc import ABC
44
from datetime import date
55
from enum import Enum
6-
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, overload
6+
from typing import Any, Dict, List, Optional, Union, overload
77

88
from pydantic.v1 import StrictBool, StrictFloat, StrictInt, StrictStr
99

@@ -28,9 +28,6 @@
2828
from pyatlan.model.typedef import AttributeDef
2929
from pyatlan.utils import ComparisonCategory, is_comparable_type
3030

31-
if TYPE_CHECKING:
32-
pass
33-
3431

3532
class AtlanField(ABC):
3633
"""

pyatlan/model/fluent_search.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def tagged(
106106
provided. This will match irrespective of the Atlan tag being directly applied to the
107107
asset, or if it was propagated to the asset.
108108
109+
:param client: connectivity to an Atlan tenant
109110
:param with_one_of: human-readable names of the Atlan tags
110111
:param directly: when True, the asset must have at least one Atlan tag directly assigned, otherwise
111112
even propagated tags will suffice
@@ -156,6 +157,7 @@ def tagged_with_value(
156157
Returns a query that will match assets that have a
157158
specific value for the specified tag (for source-synced tags).
158159
160+
:param client: connectivity to an Atlan tenant
159161
:param atlan_tag_name: human-readable name of the Atlan tag
160162
:param value: tag should have to match the query
161163
:param directly: when `True`, the asset must have the tag and

pyatlan/model/open_lineage/event.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def emit(self, client: AtlanClient) -> None:
7575
"""
7676
Send the OpenLineage event to Atlan to be processed.
7777
78+
:param client: connectivity to an Atlan tenant
7879
:raises AtlanError: on any API communication issues
7980
"""
8081
return client.open_lineage.send(

pyatlan/model/packages/base/crawler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class AbstractCrawler(AbstractPackage):
1212
"""
1313
Abstract class for crawlers
1414
15+
:param client: connectivity to an Atlan tenant
1516
:param connection_name: name for the connection
1617
:param connection_type: type of connector for the connection
1718
:param admin_roles: admin roles for the connection

pyatlan/model/packages/big_query_crawler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class BigQueryCrawler(AbstractCrawler):
1212
"""
1313
Base configuration for a new BigQuery crawler.
1414
15+
:param client: connectivity to an Atlan tenant
1516
:param connection_name: name for the connection
1617
:param admin_roles: admin roles for the connection
1718
:param admin_groups: admin groups for the connection

pyatlan/model/packages/confluent_kafka_crawler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class ConfluentKafkaCrawler(AbstractCrawler):
1212
"""
1313
Base configuration for a new Confluent Kafka crawler.
1414
15+
:param client: connectivity to an Atlan tenant
1516
:param connection_name: name for the connection
1617
:param admin_roles: admin roles for the connection
1718
:param admin_groups: admin groups for the connection

pyatlan/model/packages/databricks_crawler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class DatabricksCrawler(AbstractCrawler):
1313
"""
1414
Base configuration for a new Databricks crawler.
1515
16+
:param client: connectivity to an Atlan tenant
1617
:param connection_name: name for the connection
1718
:param admin_roles: admin roles for the connection
1819
:param admin_groups: admin groups for the connection

pyatlan/model/packages/dbt_crawler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class DbtCrawler(AbstractCrawler):
1212
"""
1313
Base configuration for a new Dbt crawler.
1414
15+
:param client: connectivity to an Atlan tenant
1516
:param connection_name: name for the connection
1617
:param admin_roles: admin roles for the connection
1718
:param admin_groups: admin groups for the connection

0 commit comments

Comments
 (0)