Skip to content

Commit 325242b

Browse files
committed
Added replace_custom_metadata method to AtlanClient
1 parent fc6f221 commit 325242b

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

pyatlan/client/atlan.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from urllib3.util.retry import Retry
2121

2222
from pyatlan.client.constants import (
23+
ADD_BUSINESS_ATTRIBUTE_BY_ID,
2324
BULK_UPDATE,
2425
CREATE_TYPE_DEFS,
2526
DELETE_ENTITY_BY_ATTRIBUTE,
@@ -57,6 +58,8 @@
5758
Classification,
5859
ClassificationName,
5960
Classifications,
61+
CustomMetadata,
62+
CustomMetadataReqest,
6063
)
6164
from pyatlan.model.enums import AtlanDeleteType, AtlanTypeCategory, CertificateStatus
6265
from pyatlan.model.response import AssetMutationResponse
@@ -588,3 +591,14 @@ def remove_announcement(
588591
asset.name = name
589592
asset.remove_announcement()
590593
return self._update_asset_by_attribute(asset, asset_type, qualified_name)
594+
595+
def replace_custom_metadata(self, guid: str, custom_metadata: CustomMetadata):
596+
# TODO: This endpoint is not currently functioning correctly on the server
597+
custom_metadata_request = CustomMetadataReqest(__root__=custom_metadata)
598+
self._call_api(
599+
ADD_BUSINESS_ATTRIBUTE_BY_ID.format_path(
600+
{"entity_guid": guid, "bm_id": custom_metadata._meta_data_type_id}
601+
),
602+
None,
603+
custom_metadata_request,
604+
)

pyatlan/client/constants.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@
122122

123123
# Business Attributes APIs
124124
ADD_BUSINESS_ATTRIBUTE = API(
125-
ENTITY_API + "guid/{entity_guid}/businessmetadata",
125+
ENTITY_API + "guid/{entity_guid}/businessmetadata/",
126+
HTTPMethod.POST,
127+
HTTPStatus.NO_CONTENT,
128+
)
129+
ADD_BUSINESS_ATTRIBUTE_BY_ID = API(
130+
ENTITY_API + "guid/{entity_guid}/businessmetadata/{bm_id}",
126131
HTTPMethod.POST,
127132
HTTPStatus.NO_CONTENT,
128133
)

pyatlan/model/core.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,7 @@ def __setattr__(self, key, value):
197197
if not hasattr(self, key):
198198
raise AttributeError(f"Attribute {key} does not exist")
199199
super().__setattr__(key, value)
200+
201+
202+
class CustomMetadataReqest(AtlanObject):
203+
__root__: CustomMetadata

0 commit comments

Comments
 (0)