Creating or updating resource data

Ops Center Analyzer Detail View REST API Reference Guide

Version
11.0.x
Audience
anonymous
Part Number
MK-99ANA004-10

You can create resource data or update the existing resource data in a single request.

Request line

POST baseURL/dbapi.do?action=createOrUpdateResourceData&dataset =<Datasetname>

Request body

{
  "meta":{
    "ts":"",
    "dataSubsetId":"",
    "fullSubsetData":,
    "fullSubsetFor": [
      ""
    ]
  },
  "resources":[
    {
      "signature":"",
      "name":"",
      "memory":"",
      "cpuUsage":[
        {
          "from":"",
          "interval":,
          "data":[
            , , , 
          ]
        }
      ],
      "relationsCompleteList":[
        ""
      ]
    },
    {
      "signature":"",
      "name":"",
      "memory":"",
      "relationsAdded":[
        ""
      ]
    }
  ]
}

Request example

POST /dbapi.do?action=createOrUpdateResourceData&dataset=defaultDs HTTP /1.1 Authorization:Basic ZnJlZDpmcmVk
{
  "meta":{
    "ts":"20140714_000000",
    "dataSubsetId":"Cumulus_Lab",
    "fullSubsetData":true,
    "fullSubsetFor": [
      "vm"
    ]
  },
  "resources":[
    {
      "signature":"vm#cumulus-labvm1",
      "name":"cumulus-lab-vm1",
      "memory":"204800",
      "cpuUsage":[
        {
          "from":"20140714_003403",
          "interval":1,
          "data":[
            23.5, 33, 67.5, 4
          ]
        }
      ],
      "relationsCompleteList":[
        "h#cumulus-lab-host1"
      ]
    },
    {
      "signature":"vm#cumulus-labvm2",
      "name":"cumulus-lab-vm2",
      "memory":"204800",
      "relationsAdded":[
        "h#cumulus-lab-host2"
      ]
    }
  ]
}

Request parameters

Parameter Type Description
action String createOrUpdateResourceData.

Specify the API function to be invoked.

dataset String Dataset name. From 2 to 32 alphanumeric, underscore (_), and hyphen (-) characters are allowed.
meta String Contains meta information of the resource data.
meta.ts String Time in yyyyMMdd_HHmmss format, at which resources specified in the body must be created or updated.

Default time zone is UTC.

meta.dataSubsetId String The resource data subset ID logically categorizes the resource data.
meta.fullSubsetData Boolean

This flag indicates if the request body is a snapshot. A snapshot contains all resources belonging to a data subset at a particular point in time. If the request body is a snapshot, the resources that are not in the snapshot request and are in the database are marked as deleted in the database.

Default: False

meta.fullSubsetFor String[ ] List of valid resource data types for the full snapshot request.

If this parameter is specified, then fullSubsetData must be set to true.

resources Object[ ] Array of the resource data.

Resource object includes a composite resource definition where both scalar and timeseries data can be specified.

resources.signature String
  • Allowed characters for <resource-type> are: alphanumeric, _, and -
  • Allowed characters for <unique-part> are: alphanumeric, _, -, ^, (, ), /, \, #, :, . and space.
  • Resource signature should be unique within a dataset.

Signature works as a unique key and is composed as <resource-type>#<unique-part>.

For example:

<resource-type> = vm <unique-part> = abc

The signature is formed as vm#abc.

resources<scalar attribute Id> String

Request body can have one or more scalar attribute data. From 1 to 4000 alphanumeric characters are allowed for scalar attribute data. Scalar attribute data is stored as a string value in the Analyzer detail view database.

For example:

"name":"cumulus-lab-vm1",

"memory":"204600",

resources data <timeseries attribute Id> String

The request body can have one or more timeseries attribute data. The timeseries data point is stored as a double value in the Analyzer detail view database.

For example:

"cpuUsage":[ { "from":"20140714_003403", "interval":60, "data":[ 23.5, 33, 67.5, 4 ] } ],

resources.from String

(Optional) Property that represents the start time in the UTC time zone of the time series sequence. If the from parameter is not specified, then ts is considered as the start time.

Supported range of value is: 9223372036854775808 to 9223372036854775807

Values outside the range 4503599627370496 to 4503599627370496 might have precision loss.

resources.interval Integer Data interval, in seconds. A positive integer from 1 to 86400 is allowed.

Data at a frequency of up to 1 day can be inserted.

resources.data <timeseries attribute Id> -> data Double[ ] Array of doubles.
resources.<relations> String[ ]
Relation to a resource can be specified in three ways:
  • relationsCompleteList: List of resource signatures that are related to this resource. If this list is present, it overwrites all existing relations.
  • relationsAdded: List of newly added relations.
  • relationsRemoved: List of removed relations.

If relationsCompleteList is present then relationsAdded and relationsRemoved are not considered.

utcOffset String (Optional) Offset from the Coordinated Universal Time (UTC), is applicable for the API request and response.

UTC+/-HH:MM

For example: UTC+09:00

Default: UTC

Note: If you specify an invalid value type for any optional parameter, then that parameter is not considered.

The resource definition must have only scalar or time series data.

Response body

{
  "updated":,
  "failed":[
    ""
  ]
}

Response example

Resources data successfully created:

{  
   "updated":2
}

One or more resources data successfully created:

{
  "updated":1,
  "failed":[
    "vm#cumulus-labvm2"
  ]
}

Failed to create all resources data:

{
  "updated":0,
  "failed":[
    "vm#cumulus-labvm2"
  ]
}

Response parameters

Parameter

Type

Description

updated Integer Number of created or updated resources
failed Object[ ] List of failed entities.

Status codes

Status code

Message

Description

200 OK Request was successful, and the response body contains the requested log details.
206 PARTIAL CONTENT Request is in progress, and the incremental content is available in the response body.
277 PARTIAL OK Request completed successfully with some failures. Check the response body for details.
400 BAD REQUEST Request URL or request body validation failed. Check the response body for details.
401 UNAUTHORIZED Supplied authentication token is invalid or does not have the appropriate credentials to access the resource.
404 NOT FOUND API server could not find a resource matching the request.
405 METHOD NOT ALLOWED Request HTTP method is not allowed for the operation.
500 SERVER ERROR API operation request failed. Check the response body for details.
Note: If all of the specified resource data fail, then the 500 SERVER ERROR message is received in the response message.

For the 277 PARTIAL SUCCESS message (where a minimum of one resource data is created and the creation of one or more resource data failed), one of the following error messages is shown in the response body.

Message Condition
{ "updated" : 1 , "failed" : [ "null" ] } The resource signature is not specified for a resource.
{ "updated" : 1 , "failed" : [ "" ] } The resource data contains an empty resource signature.
{ "updated" : 1 , "failed" : [ "vm#cumulus-lab-vm!!" ] } The resource signature contains invalid characters.
{ "updated" : 1 , "failed" : [ "cumulus-lab-vm" ] } The resource signature is not prefixed with the resource type.
{ "updated" : 1 , "failed" : [ "disk#cumulus-lab-vm" ] } The resource definition is not present for the specified resource type.
{ "updated" : 1 , "failed" : [ "vm#cumulus-lab-vm!!" ] } The related resource signature contains invalid characters.
{ "updated" : 1 , "failed" : [ "vm#cumulus-lab-vm" ] } The scalar data value is not valid in terms of allowed length.
{ "updated" : 1 , "failed" : [ "vm#cumulus-lab-vm" ] } The interval for any timeseries data is not in valid range.

Response codes

The following table lists the common API response codes that might be generated through the standard API. If an error response is not listed, examine the HTTP status codes to determine the best method for addressing the issue.

Response code Message Condition
51010002 Invalid JSON Request. Specified JSON input is invalid.
51010008 Mandatory parameter {meta} not specified. Parameter meta is not specified in the request body.
5101000F Invalid value specified for parameter {meta}. Specified meta is not of type JSON object.
5101000F Invalid value specified for parameter {ts}. Parameter ts is not specified or is invalid.
5101000F Invalid value specified for parameter {ts}. Specified date in ts is not in valid range.
5101000F Invalid value specified for parameter {dataSubsetId}. Parameter dataSubsetId is not specified or is not of type JSON string.
51010005 DataSubset with {id}:[ds11] does not exist. Parameter dataSubsetId with the specified dataSubsetId does not exist.
5101000F Invalid value specified for parameter {fullSubsetData}. Specified fullSubsetData parameter is not of type boolean.
5101000F Invalid value specified for parameter {fullSubsetFor}. Specified fullSubsetFor parameter is not of type string.
51010008 Mandatory parameter {resources} not specified. Parameter resources is not specified.
5101000F Invalid value specified for parameter {resources}. Specified resources are not of type JSON list.
5101000F Invalid value specified for parameter {fullSubsetData}. If {fullSubsetFor} is specified, then {fullSubsetData} must be true. ParameterfullSubsetFor is specified but the parameter fullSubsetData is false or not specified.
5101000F Invalid value specified for parameter {fullSubsetFor}. If {fullSubsetFor} is specified, then it must not be empty. Specified fullSubsetFor is an empty JSON list.
51010006 Resource definition [vm] does not exist. Specified resource type in fullSubsetFor is not defined.
5101000F Invalid value specified for parameter {signature}. Resource signature is not type string.
510000E9 License is not valid. License is not uploaded, or the uploaded license is invalid or expired.
510000E9 Authorization needed. Request is sent with an invalid authentication token.
510000E4 Dataset with {name}:[ds1] does not exist. Request is sent for a dataset that does not exist.
510000E0 HTTP method [GET] is not supported for action [createOrUpdateResourceData]. Request is sent with any HTTP method other than POST.
510000E2 Application encountered an internal error. API server encountered an unknown error.