List Resources

Overview

  • Lists all metering resources.

  • Narrow down the result by specifying the following parameters in a query.

    • resource id
    • resource name
    • namespace
    • project id
  • This API performs the same function as "OpenStack Telemetry API: GET /v2/resources".

Classification

  • List

API Operation Object

  • resource

Synchronous / Asynchronous

  • Synchronous

Request

HTTP Request Method

  • GET

HTTP Request Path

{api_endpoint}/v2/resources

HTTP Request Header

Content-Type: application/json
Accept: application/json
X-Auth-Token: <token_id>

HTTP Request Body

  • none

Request Parameter

Input Parameters
name style format description required/optional default value action for invalid parameter response code for invalid parameter
q Query list queries of the resource retrieval condition (Key-Value) optional - Terminate 400
meter_links Query integer all meter links are returned if "meter_links=1" was set as the query optional - Ignore 200
page Query integer target page number optional 1 Terminate 400
per_page Query integer number of resources contained in a page optional 100 Terminate 400
token_id Header authentication token string authentication token required - Terminate 401

A query key can be designated by describing after a dot(.) . (ex. q.field, q.op)

Valied query keys
key name format description required/optional default value
field string a meter column of retrieving target required -
op string a comparison operator optional eq
value string a field value for retrieving resources required -
type string format used to convert the value for comparison optional -

A query field can be designated by describing after "q.field=". (ex. q.field=meter_id)

Valied query fields
key name format description default value
project_id string project(tenant) id -
resource_id string resource id -
resource_name string resource name -
namespace string namespace of the services -

A query operator can be designated by describing after "q.op=". (ex. q.op=eq)

Valied operators in a query
operator description
eq equal to

A query type can be designated by describing after "q.type=". (ex. q.type=integer)

Valied types in a query
type ex. (q.value)
integer 1234
float 1234.1234
boolean 0 or 1
string abcd
datetime 2015-12-01T12:34:00+09:00

Response

Response Header

Format

HTTP/1.1 <response_code> <status>       (ex. 200 OK)
Per-Page: <per_page>
Link: <link>; rel="<rel>", <link>; rel="<rel>", <link>; rel="<rel>", <link>; rel="<rel>"
Total: <total>
Content-Type: application/json; charset=utf-8
  • <response_code>: see "Response Code" section
  • <status>: message based on the response code
  • <per_page>: number of resources contained in a page

The following are the information about pagination.

  • <link>: url of a specific page (ex. http://monitoring-jp1-ecl.api.ntt.com/v2/resources?page=3)

  • <rel>: property of the url
    • "next": url of the next page
    • "last": url of the last page
    • "prev": url of the previous page
    • "first": url of the first page
  • <total>: total number of corresponding resources

注釈

Not including auto-insert fields such as "Transfer-Encoding", "Date" and others.

Response Code

Response Codes
response code status condition message
200 ok normal end  
400 bad request specified non query field Field can't be blank.
    invalid query field Unrecognized field in query. valid keys:["project_id", "namespace", "resource_id", "resource_name"]
    invalid query op Unimplemented operator 'xxxx' for specified field.
    specified non query value Value can't be blank.
    invalid meter type Invalid meter type. valid meter types: ['cumulative', 'delta', 'gauge']
    invalid query data type The data type 'xxxx' is not supported. The supported data type list is: ['integer', 'float', 'boolean', 'string', 'datetime']
    invalid value (1) Unable to convert the value 'xxxx' to the expected data type 'integer'.
    invalid value (2) Unexpected exception converting 'xxxx' to the expected data type "datetime".
401 unauthorized authentication failure The request you have made requires authentication.
    invalid project id Not authorized to access project.
500 internal server error internal server error The request processing has failed due to some unknown error, exception or failure

Response Body

Format

[
    {
        "links": [
                {
                    "href": "<href>",
                    "rel": "<rel>"
                }
                <<repeat (if "meter_links=1" query was set)>>
        ],
        "metadata": "",
        "project_id": "<project_id>",
        "resource_id": "<resource_id>",
        "source": "",
        "user_id": "",
        "namespace": "<namespace>",
        "display_name": "<display_name>",
        "deleted": <deleted>
    },
    <<repeat>>
]

Response Parameter

Response Parameters
item format   description
links list   the links of the resource and meters
href String   link url to access the resource or its meters
rel String   link type ("self" or meter name)
name String   the meter name
display_name String   display name of the resource
project_id String   ID of the project which the resource is belonging to
resource_id String   the unique id of the metering resource
namespace String   namespace of the metering SDP
deleted String   if this parameter is "false", the resource has been monitored
metadata -   metadata (non-use)
source -   source (non-use)
user_id -   user id (non-use)

Sample Request and Response

Sample API Request

Request URL

GET /v2/resources/?q.field=resource_id&q.op=eq&q.type=string&q.value=nova_bd9431c1-8d69-4ad3-803a-8d4a6b89fd36?page=2&per_page=100

Request Header

Content-Type: application/json
Accept: application/json
X-Auth-Token: 61389973e52b49c394ba3b89179b290b

Request Body

  • none

Sample API Response

Response Header

HTTP/1.1 200 OK

Response Body

[
    {
        "links": [
              {
                "href": "https://example.com/v2/resources/nova_bd9431c1-8d69-4ad3-803a-8d4a6b89fd36",
                "rel": "self"
              }
        ],
        "metadata": "",
        "project_id": "35b17138-b364-4e6a-a131-8f3099c5be68",
        "resource_id": "nova_bd9431c1-8d69-4ad3-803a-8d4a6b89fd36",
        "source": "",
        "user_id": "",
        "namespace": "nova",
        "display_name": "vm1",
        "deleted": false
    }
]

Sample Error Response

HTTP Request

GET /v2/resources?q.field=resource_id&q.op=eq&q.type=string&q.value=
User-Agent: curl/7.19.7
Content-Type: application/json
Accept: application/json
X-Auth-Token: 61389973e52b49c394ba3b89179b290b

HTTP Response

HTTP/1.1 400 Bad Request
Date: Tue, 19 Jul 2016 06:19:25 GMT
Server: Apache
Cache-Control: no-cache
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Status: 400 Bad Request
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8

{"error":{"code":400,"message":"Value can't be blank.","title":"Bad Request"}}