in src/package/dataplexutils/metadata/wizard.py [0:0]
def _check_if_exists_aspect_type(self, aspect_type_id: str):
"""Checks if a specified aspect type exists in Dataplex catalog.
Args:
aspect_type_id (str): The ID of the aspect type to check
Returns:
bool: True if the aspect type exists, False otherwise
Raises:
Exception: If there is an error checking the aspect type existence
beyond a NotFound error
"""
# Create a client
client = self._cloud_clients[constants["CLIENTS"]["DATAPLEX_CATALOG"]]
# Initialize request argument(s)
request = dataplex_v1.GetAspectTypeRequest(
name=f"projects/{self._project_id}/locations/global/aspectTypes/{aspect_type_id}"
)
# Make the request
try:
client.get_aspect_type(request=request)
return True
except google.api_core.exceptions.NotFound:
return False