0

I am a collection admin of a purview account , and there is thousands of asset in a collection . and now I would like to delete the assets inside the collection .

how can I do that in bulk ( because there is no GUI method ) . How can I achieve that ?

I want to authen the API (purview API) using my AAD account which login to the purview .

Please help and advice . Better to use power shell or bash(Azure cloud) Thanks

mytabi
  • 639
  • 2
  • 12
  • 28

1 Answers1

2

Have you considered using PyApacheAtlas? A delete operation across many assets can be as simple as this delete sample.

client = PurviewClient(
        account_name = os.environ.get("PURVIEW_NAME", ""),
        authentication=oauth
)

# When you know the GUID that you want to delete
response = client.delete_entity(guid="123-abc-456-def")
print(json.dumps(response, indent=2))

# When you need to find multiple Guids to delete and they all
# are the same type
entities = client.get_entity(
qualifiedName=["qualifiedname1", "qualifiedname2", "qualifiedname3"],
    typeName="my_type"
)

# This is a naive approach and it would be better to batch
# the delete into groups of say 100
for entity in entities.get("entities"):
    guid = entity["guid"]
    delete_response = client.delete_entity(guid=guid)
    print(json.dumps(delete_response, indent=2))

Ultimately, if you don't know the guids, you'll need to fetch the entities based on searching for them or using the fully qualified name and type to get the entity and then retrieve their guid.

This can be accomplished via the Purview REST API as well using:

Will J
  • 347
  • 1
  • 10
  • Do you happen to know how we can use `PyApacheAtlas` to read from a list of assets from an `Excel` file and delete those assets.. If you have time to comment or suggest a solution, I have posted the question [here](https://stackoverflow.com/q/76285715/1232087) – nam May 19 '23 at 21:34