Listing Scopes and Collections

  • reference
    +
    Scopes and collections can be listed, by means of the REST API.

    Description

    Scopes and collections are listed by means of the GET /pools/default/buckets/<bucket_name>/scopes/ HTTP method and URI.

    HTTP Method and URI

    GET /pools/default/buckets/<bucket_name>/scopes/

    Syntax

    The curl syntax is as follows:

    curl -X GET -v
      http://<hostname-or-ip>:8091/pools/default/buckets/<bucket_name>/scopes
      -u <username>:<password>

    The <bucket-name> path-parameter specifies the name of the bucket whose defined collections are to be listed.

    Responses

    Success returns 200 OK. Failure to authenticate gives 401 Unauthorized. A malformed URI fails with 404 Object Not Found.

    Examples

    The following example lists the collections in a bucket named testBucket, making use of the tool jq, to format output:

    curl -X GET -v -u Administrator:password \
    http://10.145.250.101:8091/pools/default/buckets/testBucket/scopes | jq '.'

    If successful, the call returns 200 OK, and an object listing scopes and collections. For example:

    {
      "uid": "3",
      "scopes": [
        {
          "name": "_default",
          "uid": "0",
          "collections": [
            {
              "name": "MySecondCollection",
              "uid": "b",
              "maxTTL": 0,
              "history": false
            },
            {
              "name": "MyFirstCollection",
              "uid": "a",
              "maxTTL": 0,
              "history": false
            },
            {
              "name": "_default",
              "uid": "0",
              "history": false
            }
          ]
        },
        {
          "name": "_system",
          "uid": "8",
          "collections": [
            {
              "name": "_query",
              "uid": "9",
              "maxTTL": 0,
              "history": false
            },
            {
              "name": "_mobile",
              "uid": "8",
              "maxTTL": 0,
              "history": false
            }
          ]
        }
      ]
    }

    See Also

    An overview of scopes and collections is provided in Scopes and Collections. Step-by-step procedures for management are provided in Manage Scopes and Collections. See also the CLI reference page for the collection-manage command.