Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 25 additions & 20 deletions tools/postman/scripts/upload-collection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,6 @@ execute_curl --show-error --fail --silent -o "${COLLECTIONS_LIST_FILE}" \
collection_exists=$(jq '.collections | any(.name=="'"${current_collection_name}"'")' "${COLLECTIONS_LIST_FILE}")

if [ "$collection_exists" = "false" ]; then
# Check if a collection with a star icon already exists
previous_star_collection_id=$(jq -r '.collections | map(select(.name | startswith("⭐")).id)[0] // empty' "${COLLECTIONS_LIST_FILE}")
if [[ -n "${previous_star_collection_id}" ]]; then
previous_collection_name=$(jq -r '.collections | map(select(.id=="'"${previous_star_collection_id}"'").name)[0]' "${COLLECTIONS_LIST_FILE}")
new_collection_name="${previous_collection_name//⭐/}"

echo "Removing star icon from the previous collection name"
echo "curl -o ${COLLECTIONS_LIST_FILE}
--location 'https://api.getpostman.com/collections/${previous_star_collection_id}'
--header 'X-API-Key: **********'
--data '{\"collection\": {\"info\": {\"name\": \"${new_collection_name}\"}}}'"

execute_curl --show-error --fail --silent --request PATCH \
--location "https://api.getpostman.com/collections/${previous_star_collection_id}" \
--header "Content-Type: application/json" \
--header "X-API-Key: ${POSTMAN_API_KEY}" \
--data "{\"collection\": {\"info\": {\"name\": \"${new_collection_name}\"}}}"

fi

# Create new collection
echo "Creating new remote collection ${current_collection_name}"
echo "curl -o ${COLLECTIONS_LIST_FILE}
Expand Down Expand Up @@ -111,4 +91,29 @@ else

fi

# 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)"
Comment on lines +94 to +117

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

@andreaangiolillo andreaangiolillo May 25, 2026

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.

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!

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.

@stephen-cassil0 confirmed that we only want to list the most recent collection. He also noted that deleting older collections and any potential side effects are not an issue


popd -0