Skip to content

Commit c1c5951

Browse files
committed
Added additional integration tests for purging and creating glossaries
1 parent a16c21b commit c1c5951

File tree

8 files changed

+232
-97
lines changed

8 files changed

+232
-97
lines changed

pyatlan/client/atlan.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def call_api(self, api, query_params=None, request_obj=None):
5757

5858
if request_obj is not None:
5959
if isinstance(request_obj, AtlanObject):
60-
params["data"] = request_obj.json(by_alias=True, exclude_unset=True)
60+
params["data"] = request_obj.json(by_alias=True)
6161
else:
6262
params["data"] = json.dumps(request_obj)
6363

pyatlan/client/entity.py

+25
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
AssetMutationResponse,
2626
BulkRequest,
2727
)
28+
29+
from pyatlan.model.enums import AtlanDeleteType
2830
from pyatlan.utils import (
2931
API,
3032
APPLICATION_JSON,
@@ -168,6 +170,10 @@ class EntityClient:
168170
MULTIPART_FORM_DATA,
169171
APPLICATION_JSON,
170172
)
173+
# Glossary APIS
174+
GLOSSARY_URI = BASE_URI + "glossary"
175+
176+
GET_ALL_GLOSSARIES = API(GLOSSARY_URI, HTTPMethod.GET, HTTPStatus.OK)
171177

172178
# Labels APIs
173179
ADD_LABELS = API(
@@ -196,6 +202,11 @@ class EntityClient:
196202
HTTPMethod.DELETE,
197203
HTTPStatus.NO_CONTENT,
198204
)
205+
DEFAULT_LIMIT = -1
206+
DEFAULT_OFFSET = 0
207+
DEFAULT_SORT = "ASC"
208+
LIMIT = "limit"
209+
OFFSET = "offset"
199210

200211
def __init__(self, client: AtlanClient):
201212
self.client = client
@@ -228,3 +239,17 @@ def update_entity(self, entity: T) -> AssetMutationResponse[T]:
228239
raw_json = self.client.call_api(EntityClient.BULK_UPDATE, None, request)
229240
response: AssetMutationResponse[T] = AssetMutationResponse(**raw_json)
230241
return response
242+
243+
def create_entity(self, entity: T) -> AssetMutationResponse[T]:
244+
request = BulkRequest[T](entities=[entity])
245+
raw_json = self.client.call_api(EntityClient.BULK_UPDATE, None, request)
246+
response: AssetMutationResponse[T] = AssetMutationResponse(**raw_json)
247+
return response
248+
249+
def purge_entity_by_guid(self, guid) -> AssetMutationResponse[T]:
250+
raw_json = self.client.call_api(
251+
EntityClient.DELETE_ENTITY_BY_GUID.format_path_with_params(guid),
252+
{"deleteType": AtlanDeleteType.HARD.value},
253+
)
254+
response: AssetMutationResponse[T] = AssetMutationResponse(**raw_json)
255+
return response

pyatlan/generator/templates/entity.jinja2

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ from datetime import datetime
55
from pyatlan.model.core import AtlanObject, Classification, Announcement
66
from pyatlan.model.enums import CertificateStatus, EntityStatus, google_datastudio_asset_type, powerbi_endorsement, \
77
IconType, AnnouncementType, SourceCostUnitType
8+
from pyatlan.utils import next_id
89

910
class Internal(AtlanObject):
1011
"""For internal usage"""
@@ -29,7 +30,8 @@ class {{ entity_def.name }}({{super_classes[0]}}):
2930
class Attributes(AtlanObject):
3031
{%- for attribute_def in entity_def.attribute_defs %}
3132
{%- set type = attribute_def.typeName | get_type %}
32-
{{attribute_def.name | to_snake_case }}: {% if attribute_def.isOptional %}Optional[{% endif %}{{type}}{% if attribute_def.isOptional %}]{% endif %} = Field(None, description='' , alias='{{attribute_def.name}}')
33+
{%- set default_value = "''" if attribute_def.name == "qualifiedName" else "None" %}
34+
{{attribute_def.name | to_snake_case }}: {% if attribute_def.isOptional %}Optional[{% endif %}{{type}}{% if attribute_def.isOptional %}]{% endif %} = Field({{ default_value }}, description='' , alias='{{attribute_def.name}}')
3335
{%- endfor %}
3436
{%- for attribute_def in entity_def.relationship_attribute_defs %}
3537
{%- set type = attribute_def.typeName | get_type %}
@@ -56,9 +58,9 @@ class {{ entity_def.name }}({{super_classes[0]}}):
5658
example=1648852296555,
5759
)
5860
guid: Optional[str] = Field(
59-
None,
6061
description='Unique identifier of the entity instance.\n',
6162
example='917ffec9-fa84-4c59-8e6c-c7b114d04be3',
63+
default_factory=next_id,
6264
)
6365
is_incomplete: Optional[bool] = Field(False, description='', example=False)
6466
labels: Optional[List[str]] = Field(None, description='Internal use only.')
@@ -124,7 +126,7 @@ class {{ entity_def.name }}({{super_classes[0]}}):
124126
{%- if entity_def.attribute_defs %}
125127
{%- if not entity_def.sub_types %}
126128

127-
type_name: Literal['{{ entity_def.name }}']
129+
type_name: Literal['{{ entity_def.name }}'] = Field("{{ entity_def.name }}")
128130

129131
{%- endif %}
130132
class Attributes({{super_classes[0]}}.Attributes):

0 commit comments

Comments
 (0)