Navigation

mongocli iam organization list

On this page

The mongocli iam organization list command lists organizations in your Ops Manager instance.

To list all organizations in your Ops Manager, your profile must use a Global API key pair or a Personal API key.

When you use a Programmatic API Key, the command retrieves only the organization of the project whose API key has the Project Owner role.

You can also list organizations through the API.

Syntax

mongocli iam organization|organizations|org|orgs list|ls
     [ --limit <number-of-orgs> ]
     [ --page <number-of-pages> ]
     [ --profile|-P <profile-name> ]

Note

Use -h or --help to view the command-line help for this command.

Options

Option Type Description Required?
--limit integer

Number of organizations to return per page.

  • If this value exceeds the number of organizations, mongocli returns all organizations. Maximum value is 500.
  • If omitted, defaults to 100.

For example usage, see List the Sixth through Tenth Organizations.

no
--page integer

Page number (1-based) to return from the result set.

  • The --limit flag sets the number of organizations per page.
  • If omitted, returns the first page.

For example usage, see List the Sixth through Tenth Organizations.

no
--profile, -P string

Name of the profile where your credentials are saved.

If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI.

no

Output

The command prints following fields in JSON format to the terminal if the command succeeds. If the command returns errors, see Troubleshooting for recommended solutions.

The JSON document includes an array of result objects, an array of link objects and a count of the total number of result objects retrieved.

Field Description
links Array includes one or more links to sub-resources and/or related resources. The relations between URLs are explained in the Web Linking Specification.
results Array includes one object for each item detailed in the results Embedded Document section.
totalCount Integer count of the total number of items in the result set. It may be greater than the number of objects in the results array if the entire result set is paginated.

results Embedded Document

Each result is one organization.

Name Description
id Unique identifier for the organization.
links One or more links to sub-resources and/or related resources. The relations between URLs are explained in the Web Linking Specification.
name Name of the organization.

Examples

List All Organizations using Default Profile

The following mongocli iam org list command lists the Ops Manager organizations using the default profile. The profile contains a Programmatic API Key.

mongocli iam org list

The command returns the following JSON document:

{
 "links": [
  {
   "rel": "self",
   "href": "http://example.com:8080/api/public/v1.0/orgs?pageNum=1\u0026itemsPerPage=100"
  }
 ],
 "results": [
  {
   "id": "abcdef3e1234de007b387a9f",
   "links": [
    {
     "rel": "self",
     "href": "http://example.com:8080/api/public/v1.0/orgs/abcdef3e1234de007b387a9f"
    }
   ],
   "name": "Org1"
  }
 ],
 "totalCount": 1
}

List All Organizations using Defined Profile

The following mongocli iam org list command lists all the organizations in an Ops Manager deployment. The command uses the om-personalkey profile, which contains a Personal API Key.

mongocli iam org list -P om-personalkey

The command returns the following JSON document:

{
 "links": [
  {
   "rel": "self",
   "href": "http://www.example.com:8080/api/public/v1.0/orgs?pageNum=1\u0026itemsPerPage=100"
  }
 ],
 "results": [
  {
   "id": "5e332f3e1234de007b387a9f",
   "links": [
    {
     "rel": "self",
     "href": "http://www.example.com:8080/api/public/v1.0/orgs/5e332f3e1234de007b387a9f"
    }
   ],
   "name": "Org1"
  },
  {
   "id": "5e38efd83b60f567896baf4d",
   "links": [
    {
     "rel": "self",
     "href": "http://www.example.com:8080/api/public/v1.0/orgs/5e38efd83b60f567896baf4d"
    }
   ],
   "name": "Org2"
  }
 ],
 "totalCount": 2
}

List the Sixth through Tenth Organizations

The following mongocli iam org list command lists the sixth through tenth organizations in an Ops Manager deployment that has 20 organizations. The command uses the om-personalkey profile, which contains a Personal API Key.

mongocli iam org list -P om-personalkey --limit 5 --page 2

This command returns the following list in JSON format to the terminal. To learn more about these fields, see Output.

{
 "links": [
  {
   "rel": "self",
   "href": "http://www.example.com:8080/api/public/v1.0/orgs?pageNum=1\u0026itemsPerPage=5"
  }
 ],
 "results": [
  {
   "id": "5e332f3e1234de007b387a9f",
   "links": [
    {
     "rel": "self",
     "href": "http://www.example.com:8080/api/public/v1.0/orgs/5e332f3e1234de007b387a9f"
    }
   ],
   "name": "Org6"
  },
  {
   "id": "5e38efd83b60f567896baf4d",
   "links": [
    {
     "rel": "self",
     "href": "http://www.example.com:8080/api/public/v1.0/orgs/5e38efd83b60f567896baf4d"
    }
   ],
   "name": "Org7"
  },
  {
   "id": "27a91237ba9cb28a15ed3f51",
   "links": [
    {
     "rel": "self",
     "href": "http://www.example.com:8080/api/public/v1.0/orgs/27a91237ba9cb28a15ed3f51"
    }
   ],
   "name": "Org8"
  },
  {
   "id": "959bd41f6c65d5a31077f78a",
   "links": [
    {
     "rel": "self",
     "href": "http://www.example.com:8080/api/public/v1.0/orgs/959bd41f6c65d5a31077f78a"
    }
   ],
   "name": "Org9"
  },
  {
   "id": "f459b51a9a6e4eba907b47ad",
   "links": [
    {
     "rel": "self",
     "href": "http://www.example.com:8080/api/public/v1.0/orgs/f459b51a9a6e4eba907b47ad"
    }
   ],
   "name": "Org10"
  }
 ],
 "totalCount": 20
}