Skip to content

Commit af47092

Browse files
CLOUDP-288870: Add a ⭐️ to the most recent version of the Admin API Postman collection (#444)
1 parent a63b98e commit af47092

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

tools/postman/scripts/transform-for-api.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ sed 's/\\"value\\": \\"<Circular reference to #[^>"]* detected>\\"//g' intermedi
5050

5151
echo "Updating name with version $current_api_revision"
5252
jq --arg api_version "$current_api_revision" \
53-
'.collection.info.name = ("MongoDB Atlas Administration API " + $api_version)' \
53+
'.collection.info.name = ("MongoDB Atlas Administration API " + $api_version)' \
5454
intermediateCollectionNoCircular.json > intermediateCollectionWithName.json
5555

5656
echo "Adding Collection description to $DESCRIPTION_FILE"

tools/postman/scripts/upload-collection.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ collection_transformed_path="${PWD}/${TMP_FOLDER}/${COLLECTION_TRANSFORMED_FILE_
2525

2626
pushd "${OPENAPI_FOLDER}"
2727

28-
current_collection_name="MongoDB Atlas Administration API ${current_api_revision}"
28+
current_collection_name="MongoDB Atlas Administration API ${current_api_revision}"
2929

3030
echo "Fetching list of current collections"
3131
echo "curl -o ${COLLECTIONS_LIST_FILE}
@@ -38,6 +38,24 @@ curl --show-error --fail --silent -o "${COLLECTIONS_LIST_FILE}" \
3838
collection_exists=$(jq '.collections | any(.name=="'"${current_collection_name}"'")' "${COLLECTIONS_LIST_FILE}")
3939

4040
if [ "$collection_exists" = "false" ]; then
41+
# Check if a collection with a star icon already exists
42+
previous_star_collection_id=$(jq -r '.collections | map(select(.name | startswith("⭐")).id)[0] // empty' "${COLLECTIONS_LIST_FILE}")
43+
if [[ -n "${previous_star_collection_id}" ]]; then
44+
previous_collection_name=$(jq -r '.collections | map(select(.id=="'"${previous_star_collection_id}"'").name)[0]' "${COLLECTIONS_LIST_FILE}")
45+
new_collection_name="${previous_collection_name///}"
46+
47+
echo "Removing star icon from the previous collection name"
48+
echo "curl -o ${COLLECTIONS_LIST_FILE}
49+
--location 'https://api.getpostman.com/collections/${previous_star_collection_id}'
50+
--header 'X-API-Key: **********'
51+
--data \"{\"collection\": {\"info\": {\"name\": \"${new_collection_name}\"}}}\""
52+
curl --show-error --fail --silent --request PATCH \
53+
--location "https://api.getpostman.com/collections/${previous_star_collection_id}" \
54+
--header "Content-Type: application/json" \
55+
--header "X-API-Key: ${POSTMAN_API_KEY}" \
56+
--data "{\"collection\": {\"info\": {\"name\": \"${new_collection_name}\"}}}"
57+
fi
58+
4159
# Create new collection
4260
echo "Creating new remote collection ${current_collection_name}"
4361
echo "curl -o ${COLLECTIONS_LIST_FILE}

0 commit comments

Comments
 (0)