When we moved from a single-server CARA master to an HA setup, we started using a retrieval agent group instead of a specific retrieval agent. This was all fine, except that the original agent, which no longer existed, could not be removed from the system, as many artifacts were still associated with it as their retrieval agent. This meant that I always saw a missing agent, even though technically all "real" agents were fine.
It's been nearly a year since doing this, so I determined that we could simply delete any older artifacts that were still associated with the old retrieval agent. But how to do this? When trying to delete the old agent, CARA responded with a list of over 1600 artifacts that prevented the agent removal. I certainly was NOT going to manually adjust or remove 1600+ artifacts!
Enter Postman - a REST client from Google that allows me to run REST requests in a very flexible and powerful way: by driving the calls with a csv file. Here's what I did:
- Attempt to delete the old agent - it responds with a large text field listing all the artifacts that are associated with it.
- Since the list of artifacts was not formatted for data processing, I needed to massage it. Using Notepad++ I was able to do some simple manipulation to quickly get an artifact list with comma-separation:
- I opened this up in Excel just to ensure that I everything lined up correctly.
- Now I opened Postman. I'm gong to use a feature called the "Collection Runner" to drive the calls with the csv file, so I first created a new collection, then added an API call to the delete-artifact-version method:
- I edited the collection to specify the authentication along with the Base URL of my CARA server. (I did not need to do this, but I find it good practice to specify anything used across multiple calls in the collection itself).
- Next I set up the delete-artifact-version call. The key here being the setup of the message body. I used the names of the csv file headers as placeholders for real data at run time:
- At this point the request is basically ready - now we need to automate calling it for each row in the csv file I created earlier. This is what the Postman Collection Runner is for.
- After starting the Collection runner from postman, I selected the new collection I created for this:
- Now I can select the csv file, and even preview the data to ensure it looks like what I want:
- Then I run it, go grab some coffee, and wait for all 1600+ artifact versions to be deleted.
Once all this was completed, I was able to remove the old agent, and it no longer showed up as a missing agent.