Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLOUDP-267379: Add collection description to generated collections #166

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions tools/postman/collection-description.md
Original file line number Diff line number Diff line change
@@ -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](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\`

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.
12 changes: 11 additions & 1 deletion tools/postman/scripts/transform-for-api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
#########################################################

Expand All @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -114,6 +123,7 @@ rm intermediateCollectionWrapped.json \
intermediateCollectionNoPostmanID.json \
intermediateCollectionNoCircular.json \
intermediateCollectionWithName.json \
intermediateCollectionWithDescription.json \
intermediateCollectionWithBaseURL.json \
intermediateCollectionWithLinks.json \
intermediateCollectionPostBody.json
Expand Down
Loading