From 4d2749f97798e87b184d5fb2026377bd689e205c Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Wed, 14 Aug 2024 11:49:24 +0100 Subject: [PATCH 1/2] CLOUDP-267379: Add collection description to generated collections --- tools/postman/collection-description.md | 15 +++++++++++++++ tools/postman/scripts/transform-for-api.sh | 12 +++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tools/postman/collection-description.md diff --git a/tools/postman/collection-description.md b/tools/postman/collection-description.md new file mode 100644 index 000000000..80b0c4075 --- /dev/null +++ b/tools/postman/collection-description.md @@ -0,0 +1,15 @@ +## MongoDB Atlas Administration API 2024-05-30 + +This collection is an introduction to the [MongoDB Atlas Administration API](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/). The MongoDB Atlas Administration API offers a method to manage your [MongoDB Atlas clusters](https://www.mongodb.com/resources/products/fundamentals/clusters) following the principles of the REST architectural style. To learn more, visit the [MongoDB Atlas Administration API documentation](https://www.mongodb.com/docs/atlas/api/atlas-admin-api-ref/). + +## Getting Started + +To test out the MongoDB Atlas Admin API collection, start by [creating a free MongoDB Atlas cluster](https://www.mongodb.com/docs/atlas/tutorial/deploy-free-tier-cluster/). +Once you have a cluster, you can [fork this collection](https://learning.postman.com/docs/collaborating-in-postman/using-version-control/forking-elements/\#create-a-fork) into your own workspace in order to manage your MongoDB Atlas resources. Make sure to also fork the MongoDB Atlas Administration API Environment at the same time. + +Once you have your cluster up and running, follow [this guide](https://www.mongodb.com/docs/atlas/configure-api-access/) to find your public and private API keys. Set each of these values as secrets in the Postman Vault: + +- public API key as the value for a key named \`mongodb-public-api-key\` +- private API key as the value for a key named \`mongodb-private-api-key\` + +You can now explore the various endpoints. For each endpoint, edit the query and path variables such as group ID and organization ID. For some requests, like POST requests, editing the body of the request is also required. \ No newline at end of file diff --git a/tools/postman/scripts/transform-for-api.sh b/tools/postman/scripts/transform-for-api.sh index 04ba295c9..16f099ed7 100755 --- a/tools/postman/scripts/transform-for-api.sh +++ b/tools/postman/scripts/transform-for-api.sh @@ -12,6 +12,7 @@ set -euo pipefail # TOGGLE_USE_ENVIRONMENT_AUTH - bool for if auth variables are stored at the environment or collection level # TOGGLE_INCLUDE_BODY - bool for if generated bodies should be removed or kept # VERSIONS_FILE - name for the openapi versions file +# DESCRIPTION_FILE - name for the markdown description file # BASE_URL - the default base url the Postman Collection will use ######################################################### @@ -20,7 +21,9 @@ COLLECTION_TRANSFORMED_FILE_NAME=${COLLECTION_TRANSFORMED_FILE_NAME:-"collection OPENAPI_FILE_NAME=${OPENAPI_FILE_NAME:-"atlas-api.json"} OPENAPI_FOLDER=${OPENAPI_FOLDER:-"../openapi"} TMP_FOLDER=${TMP_FOLDER:-"../tmp"} + VERSIONS_FILE=${VERSIONS_FILE:-"versions.json"} +DESCRIPTION_FILE=${DESCRIPTION_FILE:-"../collection-description.md"} TOGGLE_USE_ENVIRONMENT_AUTH=${TOGGLE_USE_ENVIRONMENT_AUTH:-true} TOGGLE_INCLUDE_BODY=${TOGGLE_INCLUDE_BODY:-true} @@ -49,10 +52,16 @@ jq --arg api_version "$current_api_revision" \ '.collection.info.name = ("MongoDB Atlas Administration API " + $api_version)' \ intermediateCollectionNoCircular.json > intermediateCollectionWithName.json +echo "Adding Collection description" +description=$(<"$DESCRIPTION_FILE") +jq --arg desc "$description" \ + '.collection.info.description.content = $desc' \ + intermediateCollectionWithName.json > intermediateCollectionWithDescription.json + echo "Updating baseUrl" jq --arg base_url "$BASE_URL" \ '.collection.variable[0].value = $base_url' \ - intermediateCollectionWithName.json > intermediateCollectionWithBaseURL.json + intermediateCollectionWithDescription.json > intermediateCollectionWithBaseURL.json echo "Adding links to docs" cp intermediateCollectionWithBaseURL.json intermediateCollectionWithLinks.json @@ -114,6 +123,7 @@ rm intermediateCollectionWrapped.json \ intermediateCollectionNoPostmanID.json \ intermediateCollectionNoCircular.json \ intermediateCollectionWithName.json \ + intermediateCollectionWithDescription.json \ intermediateCollectionWithBaseURL.json \ intermediateCollectionWithLinks.json \ intermediateCollectionPostBody.json From e10fa300461fd623552340c49257fe0ff01175e4 Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Wed, 14 Aug 2024 12:10:10 +0100 Subject: [PATCH 2/2] CLOUDP-267379: Adding link to docs for Postman Vault --- tools/postman/collection-description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/postman/collection-description.md b/tools/postman/collection-description.md index 80b0c4075..67a56807f 100644 --- a/tools/postman/collection-description.md +++ b/tools/postman/collection-description.md @@ -7,7 +7,7 @@ This collection is an introduction to the [MongoDB Atlas Administration API](htt To test out the MongoDB Atlas Admin API collection, start by [creating a free MongoDB Atlas cluster](https://www.mongodb.com/docs/atlas/tutorial/deploy-free-tier-cluster/). Once you have a cluster, you can [fork this collection](https://learning.postman.com/docs/collaborating-in-postman/using-version-control/forking-elements/\#create-a-fork) into your own workspace in order to manage your MongoDB Atlas resources. Make sure to also fork the MongoDB Atlas Administration API Environment at the same time. -Once you have your cluster up and running, follow [this guide](https://www.mongodb.com/docs/atlas/configure-api-access/) to find your public and private API keys. Set each of these values as secrets in the Postman Vault: +Once you have your cluster up and running, follow [this guide](https://www.mongodb.com/docs/atlas/configure-api-access/) to find your public and private API keys. Set each of these values as secrets in the [Postman Vault](https://learning.postman.com/docs/sending-requests/postman-vault/postman-vault-secrets/): - public API key as the value for a key named \`mongodb-public-api-key\` - private API key as the value for a key named \`mongodb-private-api-key\`