From 491bb4dffd1a6cc6c986d37fa42c9dbd2b7a420d Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 21 Feb 2025 17:29:01 +0000 Subject: [PATCH 1/3] =?UTF-8?q?CLOUDP-288870:=20Add=20a=20=E2=AD=90?= =?UTF-8?q?=EF=B8=8F=20to=20the=20most=20recent=20version=20of=20the=20Adm?= =?UTF-8?q?in=20API=20Postman=20collection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/postman/scripts/transform-for-api.sh | 2 +- tools/postman/scripts/upload-collection.sh | 23 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tools/postman/scripts/transform-for-api.sh b/tools/postman/scripts/transform-for-api.sh index 9e922e0eda..7e08a60f7b 100755 --- a/tools/postman/scripts/transform-for-api.sh +++ b/tools/postman/scripts/transform-for-api.sh @@ -50,7 +50,7 @@ sed 's/\\"value\\": \\""]* detected>\\"//g' intermedi echo "Updating name with version $current_api_revision" jq --arg api_version "$current_api_revision" \ - '.collection.info.name = ("MongoDB Atlas Administration API " + $api_version)' \ + '.collection.info.name = ("⭐MongoDB Atlas Administration API " + $api_version)' \ intermediateCollectionNoCircular.json > intermediateCollectionWithName.json echo "Adding Collection description to $DESCRIPTION_FILE" diff --git a/tools/postman/scripts/upload-collection.sh b/tools/postman/scripts/upload-collection.sh index cb8b9c0420..93024280f7 100755 --- a/tools/postman/scripts/upload-collection.sh +++ b/tools/postman/scripts/upload-collection.sh @@ -25,8 +25,9 @@ collection_transformed_path="${PWD}/${TMP_FOLDER}/${COLLECTION_TRANSFORMED_FILE_ pushd "${OPENAPI_FOLDER}" -current_collection_name="MongoDB Atlas Administration API ${current_api_revision}" +current_collection_name="⭐MongoDB Atlas Administration API ${current_api_revision}" +echo "${WORKSPACE_ID}" echo "Fetching list of current collections" echo "curl -o ${COLLECTIONS_LIST_FILE} --location 'https://api.getpostman.com/collections?workspace=${WORKSPACE_ID}' @@ -38,6 +39,26 @@ 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}") + echo "Previous star collection id: ${previous_star_collection_id}" + 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 "New collection name: ${new_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}\"}}}\"" + 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} From 77e0f88666925a7f1b3869cbfa5982bd03d09eed Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 21 Feb 2025 17:38:14 +0000 Subject: [PATCH 2/3] remove some debug logs --- tools/postman/scripts/upload-collection.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/postman/scripts/upload-collection.sh b/tools/postman/scripts/upload-collection.sh index 93024280f7..79b81a9c62 100755 --- a/tools/postman/scripts/upload-collection.sh +++ b/tools/postman/scripts/upload-collection.sh @@ -41,11 +41,9 @@ collection_exists=$(jq '.collections | any(.name=="'"${current_collection_name}" 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}") - echo "Previous star collection id: ${previous_star_collection_id}" 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 "New collection name: ${new_collection_name}" echo "Removing star icon from the previous collection name" echo "curl -o ${COLLECTIONS_LIST_FILE} From bc5e86377c74008cd6b3fe6b9df62be2331851c2 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 21 Feb 2025 17:48:02 +0000 Subject: [PATCH 3/3] remove some debug logs --- tools/postman/scripts/upload-collection.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/postman/scripts/upload-collection.sh b/tools/postman/scripts/upload-collection.sh index 79b81a9c62..f913e7596e 100755 --- a/tools/postman/scripts/upload-collection.sh +++ b/tools/postman/scripts/upload-collection.sh @@ -27,7 +27,6 @@ pushd "${OPENAPI_FOLDER}" current_collection_name="⭐MongoDB Atlas Administration API ${current_api_revision}" -echo "${WORKSPACE_ID}" echo "Fetching list of current collections" echo "curl -o ${COLLECTIONS_LIST_FILE} --location 'https://api.getpostman.com/collections?workspace=${WORKSPACE_ID}'