@@ -154,7 +154,16 @@ def from_yaml(cls, yaml_str: str):
154154
155155
156156class 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
188203class 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
0 commit comments