-
Notifications
You must be signed in to change notification settings - Fork 31
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
(DOCSP-46656) Adds handwritten command for atlas api. #838
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,176 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.. _atlas-api: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
========= | ||||||||||||||||||||||||||||||||||||||||||||||||||||
atlas api | ||||||||||||||||||||||||||||||||||||||||||||||||||||
========= | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
.. default-domain:: mongodb | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
.. contents:: On this page | ||||||||||||||||||||||||||||||||||||||||||||||||||||
:local: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
:backlinks: none | ||||||||||||||||||||||||||||||||||||||||||||||||||||
:depth: 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
:class: singlecol | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
Access all features of the `{+atlas-admin-api+} <https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/>`__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
by using the {+atlas-cli+} with the syntax: ``atlas api <tag> <operationId>``. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
This experimental feature streamlines script development by letting you interact | ||||||||||||||||||||||||||||||||||||||||||||||||||||
directly with any {+atlas-admin-api+} endpoint by using the {+atlas-cli+}. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
To learn more about working with the {+atlas-admin-api+}, see :ref:`atlas-admin-api-access`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
Syntax | ||||||||||||||||||||||||||||||||||||||||||||||||||||
------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
.. code-block:: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
:caption: Command Syntax | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
atlas api <tag> <operationId> [options] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
.. important:: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
Both ``<tag>`` and ``<operationId>`` must be in :wikipedia:`camelCase <Camel_case>`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
Arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should use a table for the arguments here, similar to other pages in the Atlas CLI docs |
||||||||||||||||||||||||||||||||||||||||||||||||||||
--------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
.. list-table:: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
:header-rows: 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
:widths: 20 20 10 50 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
* - Name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Type | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Required | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* - <tag> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- string | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- true | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- The category of {+atlas-admin-api+} operations in :wikipedia:`camelCase <Camel_case>`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
To find and format the tag, check | ||||||||||||||||||||||||||||||||||||||||||||||||||||
the `API documentation <https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/>`__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|url| for the endpoint. It appears after ``#tag/``, but you need to change to camelCase. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
For example, in | ||||||||||||||||||||||||||||||||||||||||||||||||||||
``https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Monitoring-and-Logs``, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
the tag is ``Monitoring-and-Logs``. In camelCase, it's ``monitoringAndLogs``. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* - <operationId> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- string | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- true | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- The identifier of the {+atlas-admin-api+} endpoint in :wikipedia:`camelCase <Camel_case>`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
To find the operationId, check the | ||||||||||||||||||||||||||||||||||||||||||||||||||||
`API documentation <https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/>`__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|url| for the endpoint. It appears after ``operation/``. For example, in | ||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these descriptions could benefit from a space between the overview and the example to improve legibility.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
``https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Clusters/operation/listClusters``, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
the operationId is ``listClusters``. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
Options | ||||||||||||||||||||||||||||||||||||||||||||||||||||
------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
Pass in the path and query parameters for the {+atlas-admin-api+} endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||
as flags. For example, if the endpoint is ``/api/atlas/v2/orgs/{orgId}/invoices/{invoiceId}``, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
the {+atlas-cli+} command is: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
.. code-block:: shell | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
atlas api <tag> <operationId> --orgId <ORG_ID> --invoiceId <INVOICE_ID> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be helpful to mention that |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
.. note:: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
You usually don't need to specify ``--orgId`` and ``--projectId`` as they are sourced | ||||||||||||||||||||||||||||||||||||||||||||||||||||
from your profile. Specify them only if they are not set in your profile. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
If applicable to the endpoint, pass in the request body using the ``--file`` option | ||||||||||||||||||||||||||||||||||||||||||||||||||||
or standard input (``stdin``). | ||||||||||||||||||||||||||||||||||||||||||||||||||||
For example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
.. code-block:: shell | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
atlas api clusters create --file cluster-config.json | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
In addition, the following options are available for all {+atlas-admin-api+} endpoints. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
.. list-table:: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
:header-rows: 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
:widths: 20 10 10 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
* - Name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Type | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Required | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* - ``--api-version`` | ||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||||||||||||||||||||||||||||||||||||||||||||||||||||
- string | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- false | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Specify the :ref:`version <api-versioning-overview>` of the {+atlas-admin-api+} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
for the command. Defaults to the latest API version or the value you've configured for ``api_version`` in your profile. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* - ``--format`` | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- string | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- false | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Output format. The default is ``json``, but the supported formats can vary by endpoint: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
- Most endpoints output ``json``. When ``json`` is supported, you can also use a Go template. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Some endpoints support ``json`` and ``csv``, allowing you to use ``json``, ``csv``, or a Go template. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Certain endpoints output binary data (for example, logs in gzip format), requiring the ``--out`` option. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
To determine the supported formats for an endpoint: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
- Check the content response type examples in the `API documentation <https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/>`__. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Run ``atlas api <tag> <operationId> --help`` for details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* - ``--file`` | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- string | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- false | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- File path to the request body content, if required by the operation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Alternatively, provide input through standard input (``stdin``). | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* - ``-o, --out`` | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- string | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- false | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- File path to save the output. By default, the result is displayed in the terminal. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* - ``-h, --help`` | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- false | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Help for the current command. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
Inherited Options | ||||||||||||||||||||||||||||||||||||||||||||||||||||
----------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
.. list-table:: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
:header-rows: 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
:widths: 20 10 10 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
* - Name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Type | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Required | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* - ``-P, --profile`` | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- string | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- false | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- Name of the profile to use from your configuration file. For more information about profiles, see `Atlas CLI Configuration <https://dochub.mongodb.org/core/atlas-cli-save-connection-settings>`__. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
Output | ||||||||||||||||||||||||||||||||||||||||||||||||||||
------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
If the command succeeds, the {+atlas-cli+} outputs the result of the {+atlas-admin-api+} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
operation, formatted as specified by the ``--format`` option. If no format is provided, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
the output defaults to JSON. For example responses, see the `{+atlas-admin-api+} Specification <https://mongodb.com/docs/atlas/reference/api-resources-spec>`__. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
Examples | ||||||||||||||||||||||||||||||||||||||||||||||||||||
-------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
.. code-block:: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
:copyable: false | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
# Create a new cluster using the latest API version: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
atlas api clusters createCluster --file createCluster.json | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
# List all clusters for a specific organization: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
atlas api clusters listClusters --orgId <ORG_ID> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
# Get details of a specific invoice by organization ID and invoice ID: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
atlas api orgs getInvoice --orgId <ORG_ID> --invoiceId <INVOICE_ID> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
# Output in CSV format and save the result to a file: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
atlas api clusters listClusters --format csv --out clusters.csv | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
# Specify a particular API version for an operation: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
atlas api clusters getCluster --name <CLUSTER_NAME> --api-version 2023-10-01 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,7 @@ Related Commands | |
accessLists </command/atlas-accessLists> | ||
accessLogs </command/atlas-accessLogs> | ||
alerts </command/atlas-alerts> | ||
api </command/atlas-api> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This page is autogenerated, so this change will be overwritten at the next release. I don't think we can have this on this page due to our automation system unless they add it upstream. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jeroenvervaeke are you able to add this upstream? This is so the new page shows up in the left-hand table of contents. |
||
auditing </command/atlas-auditing> | ||
auth </command/atlas-auth> | ||
backups </command/atlas-backups> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it's correct that we use
<tag>
and<operationId>
, we use acamelCase
version of these values.This will mainly influence
<tag>
, afaik the current operationIds are already in camelCase.Some examples:
Flex Clusters
->flexClusters
Monitoring and Logs
->monitoringAndLogs
I don't see this captured anywhere in this page yet.