Skip to content

feat: add cleanup process for sunsetted collections#1284

Open
yelizhenden-mdb wants to merge 3 commits into
mainfrom
CLOUDP-260980
Open

feat: add cleanup process for sunsetted collections#1284
yelizhenden-mdb wants to merge 3 commits into
mainfrom
CLOUDP-260980

Conversation

@yelizhenden-mdb
Copy link
Copy Markdown
Collaborator

@yelizhenden-mdb yelizhenden-mdb commented May 22, 2026

Proposed changes

Jira ticket: CLOUDP-260980

Problem

Every time a new Atlas Admin API version is released, a new Postman collection is published but the old one is only renamed (⭐ removed) and left in the workspace. Over time, this accumulates redundant collections that create noise for customers browsing the workspace.

The Postman collection is generated from the latest FOAS, which contains all endpoints across all API versions. Customers select the API version they want via the Accept header, not by choosing a different collection. Old collections don't provide any additional endpoint coverage.

What changed

tools/postman/scripts/upload-collection.sh

  • Removed the PATCH call that renamed the previous starred collection (removing ⭐ from its name) before creating a new one
  • Added a cleanup loop at the end of the script that deletes all MongoDB Atlas Administration API collections from the workspace except the current one

The cleanup runs after every upload. Because the initial collection list is fetched before the new collection is posted, the current collection is safely excluded by name regardless of whether it was just created or updated in place.

Testing

Created new test collections with old versions on Postman:
Screenshot 2026-05-25 at 11 43 36
After running the script, successfully confirmed the old collections are removed:
Screenshot 2026-05-25 at 11 46 27

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works

Changes to Spectral

  • I have read the README file for Spectral Updates

Further comments

@yelizhenden-mdb yelizhenden-mdb changed the title feat(postman): add cleanup process for sunsetted collections (CLOUDP-260980) feat(postman): add cleanup process for sunsetted collections May 22, 2026
@yelizhenden-mdb yelizhenden-mdb changed the title feat(postman): add cleanup process for sunsetted collections feat: add cleanup process for sunsetted collections May 25, 2026
@yelizhenden-mdb yelizhenden-mdb marked this pull request as ready for review May 25, 2026 11:01
@yelizhenden-mdb yelizhenden-mdb requested a review from a team as a code owner May 25, 2026 11:01
Comment on lines +94 to +117
# Delete all previous Atlas Admin API collections from the workspace.
# The current collection is excluded by name — it was either just created (not in the
# initial list) or matched by name in the update case.
deleted=0
while IFS= read -r row; do
id=$(echo "${row}" | jq -r '.id')
name=$(echo "${row}" | jq -r '.name')
echo "Deleting old collection: ${name} (id: ${id})"
echo "curl --request DELETE --location 'https://api.getpostman.com/collections/${id}' --header 'X-API-Key: **********'"
http_code=$(execute_curl --silent --show-error \
--write-out "%{http_code}" \
-o /dev/null \
--request DELETE \
--location "https://api.getpostman.com/collections/${id}" \
--header "X-API-Key: ${POSTMAN_API_KEY}")
if [[ "${http_code}" != "200" ]]; then
echo "[ERROR] Failed to delete old collection: ${name} (id: ${id}), HTTP status: ${http_code}"
else
deleted=$((deleted + 1))
fi
done < <(jq -c --arg current "${current_collection_name}" \
'.collections[] | select(.name | contains("MongoDB Atlas Administration API")) | select(.name != $current)' \
"${COLLECTIONS_LIST_FILE}")
echo "[SUMMARY] Deleted ${deleted} old collection(s)"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a breaking changes for customers using that collection? Do you remember the reasons why we decided to rename the collection?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The customers always must use the latest collection. Can you think of any use case a customer might need to use a previous collection?
This PR does not introduce any renaming, it is just cleaning up the previous collections

Copy link
Copy Markdown
Collaborator

@andreaangiolillo andreaangiolillo May 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you think of any use case a customer might need to use a previous collection?

I don't have enough context on how we generate the collection. In particular, it would be helpful to understand how we handle deprecated versions. Are we removing them from the collection and requiring customers to move to the new API version? If so, one use case for keeping the old collection available would be to let customers continue using the deprecated endpoints until they've fully migrated.

This PR does not introduce any renaming, it is just cleaning up the previous collections

Got it. My question is more along the lines of: if a customer is currently using any of the collections you're planning to delete, will they encounter an error? If so, that wouldn't be a great experience, and I'm wondering if that was the reason we chose to rename the old collection when we worked on Postman instead of deleting them.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid concerns. Here is my understanding of how this works:

  • The collection is generated from the latest FOAS (openapi-YYYY-MM-DD.json file). Deprecated endpoints will still be included as long as they haven't been sunset
  • If a customer forks the collection, it persists locally and independently, so deleting the source will have no impact. If a customer references the collection directly by URL or ID, deletion could cause an issue
  • I implemented the star feature as well. The original requirement was just to make the latest collection more prominent. I haven't been asked to remove the older ones, or that option wasn't considered at the time

Also, to ensure I didn't misinterpret the ticket, I'm going to sync with Stephen to confirm this PR aligns with what he wanted. Thanks for calling this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants