@@ -25,7 +25,7 @@ collection_transformed_path="${PWD}/${TMP_FOLDER}/${COLLECTION_TRANSFORMED_FILE_
2525
2626pushd " ${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
3030echo " Fetching list of current collections"
3131echo " curl -o ${COLLECTIONS_LIST_FILE}
@@ -38,6 +38,24 @@ curl --show-error --fail --silent -o "${COLLECTIONS_LIST_FILE}" \
3838collection_exists=$( jq ' .collections | any(.name=="' " ${current_collection_name} " ' ")' " ${COLLECTIONS_LIST_FILE} " )
3939
4040if [ " $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