Creating a custom resource definition

Ops Center Analyzer Detail View REST API Reference Guide

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

You can create a new resource definition. If the resource definition already exists, then an error message is received in the response message. You can create multiple resource definitions in a single request.

Request line

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

Request body

[
  {
    "type":"",
    "name":"",
    "attributes":[
      ""
    ],
    "relations":[
      "",
      ""
    ]
  },
  {
    "type":"",
    "name":"",
    "attributes":[
      "",
      "",
      ""
    ],
    "relations":[
      "",
      ""
    ]
  }
]

Request example

POST /dbapi.do?action=createResourceDef&dataset=defaultDs HTTP /1.1 Authorization: Basic ZnJlZDpmcmVk
[
  {
    "type":"vm",
    "name":"VM",
    "attributes":[
      "name"
    ],
    "relations":[
      "host",
      "vDisk"
    ]
  },
  {
    "type":"host",
    "name":"VM",
    "attributes":[
      "name",
      "cpuUsage",
      "memUsage"
    ],
    "relations":[
      "vCpu",
      "vDisk"
    ]
  }
]

Request parameters

Parameter Type Description
action String createResourceDef

Specify the API function to be invoked.

dataset String Dataset name. From 2 to 32 alphanumeric, underscore (_), and hyphen (-) characters are allowed.
type String A unique resource type.

From 2 to 32 alphanumeric, underscore (_), and hyphen (-) characters are allowed.

name String (Optional) Resource definition name.

From 1 to 32 alphanumeric characters are allowed.

Default: type

attributes String[ ] (Optional) List of scalar and timeseries attribute IDs.

Default: Blank

relations String[ ] (Optional) List of valid related resource types .

Default: Blank

additionalProperties Object (Optional) Additional key value pairs to be stored with the resource definition.

Note: Properties type, name, relations, and attributes cannot be specified in additionalProperties as they constitute a resource definition.

JSON object having valid key value pairs. Maximum of 128 key value pairs can be specified.

Key: From 2 to 32 alphanumeric, underscore (_), and hyphen (-) characters are allowed.

Value: \, ", & ,> , <, and ' are not allowed.

From 1 to 1024 alphanumeric characters are allowed.

Response body

{
  "created":[
    ],
  "failed":[
    {
      "code":"",
      "type":"",
      "error":""
    }
  ]
}

Response example

{
  "created":[
    ],
  "failed":[
    {
      "code":"31020012",
      "type":"vm",
      "error":"createResourceDef failed for {type}:[vm]. Create attribute definition for [name]."
    },
    {
      "code":"31020012",
      "type":"host",
      "error":"createResourceDef failed for {type}:[host]. Create attribute definition for [name,cpuUsage,memUsage]."
    }
  ]
}

Response parameters

Parameter

Type

Description

created String[ ] List of created resource types.
failed Object[ ] List of failed entities.
failed:code String Eight-digit hexadecimal error code.
failed:type String Failed resource type.
failed:error String Error message.

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 definitions fail, then the 500 SERVER ERROR message is received in the response message.

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
31050004 Resource definition with {type}:[vm] already exists. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The requested resource definition already exists.
31010008 Mandatory parameter {type} is not specified. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The resource type is not specified.
3101000F Invalid value is specified for parameter {type}. It must be of type string. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The specified resource type is not of type string.
3101000F Invalid value is specified for parameter {type}. Resource {type}:[] length must be between 1 to 32 characters. Minimum of one resource definition is created and the creation of one or more resource definitions failed The specified resource type is less than 1 character or more than 32 character.
3101000F Invalid value is specified for parameter {type}. The {<?<} contains an invalid characters. The valid characters are alphanumeric, -, and _ . Minimum of one resource definition is created and the creation of one or more resource definitions failed. The specified resource type contains an invalid characters.
3101000F Invalid value is specified for parameter {name}. It must be of type string. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The specified resource name is not of the type string.
3101000F Invalid value is specified for parameter {name}. The {name} length must be between 1 to 32 characters. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The resource name is not the allowed length.
3101000F Invalid value is specified for parameter {attributes}. It must be of type JSON list of string. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The specified attribute is not of type JSON.
3101000F createResourceDef failed for {type}:[host]. Create attribute definition for [cpuUsage]. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The specified attribute IDs are not defined.
3101000F Invalid value specified for parameter {relations}. It must be of type JSON list of string. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The specified relation is not of type JSON.
3101000F Invalid value is specified for parameter {relations}. The {<>?} contains an invalid characters. The valid characters are alphanumeric, -, and _. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The relation contains an invalid character.
3101000F Invalid value is specified for parameter {relations}. Resource {type}:[] length must be between 1 to 32 characters. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The specified relations are not in the allowed length
3101000F Invalid value is specified for parameter {additionalProperties}. It must be of type JSON object. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The specified addtionalProperties are not of type JSON object.
3101000F Invalid value is specified for parameter {additionalProperties}. The maximum 128 additional properties can be provided in the resource definition. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The properties specified in the addtionalProperties are more than 128.
3101000F Invalid value is specified for parameter {additionalProperties}. Additional properties key cannot be one of the following: type, configAttributes, displayName, and directRelations. Minimum of one resource definition is created and the creation of one or more resource definitions failed. Invalid properties are specified in the addtionalProperties.
3101000F Invalid value is specified for parameter {additionalProperties}. The {@@} contains invalid characters. The valid characters are alphanumeric, -,and _. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The key specified in addtionalProperties contains an invalid character.
3101000F Invalid value is specified for parameter {additionalProperties}. The {} length must be between 1 to 32 characters. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The key specified in addtionalProperties is not in allowed length.
3101000F Invalid value is specified for parameter {additionalProperties values}. It must be of type string. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The specified value for a key in addtionalProperties is not of type string.
3101000F Invalid value is specified for parameter {additionalProperties}. {key} length must be between 1 to 32 characters. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The specified value for a key in addtionalProperties is not the allowed length.
3101000F Invalid value specified for parameter {additionalProperties}. The {>>} contains invalid characters. The valid characters are alphanumeric, -, and _. Minimum of one resource definition is created and one or more resource definitions failed. The value specified for a key in addtionalProperties contains invalid character.
31020012 createResourceDef failed for {type}:[host]. Remove self association from resource definition [host]. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The resource definition is associated to itself.
31020012 createResourceDef failed for {type}:[host]. Resource type [host] is already associated with [vm]. Minimum of one resource definition is created and the creation of one or more resource definitions failed. The resource definition contains relations that is already defined through related resource type.
31010002 Invalid JSON Request. Specified input JSON is invalid.
310000E9 License is not valid. License is not uploaded, or the uploaded license is invalid or expired.
310000E9 Authorization needed. Request is sent with an invalid authentication token.
310000E4 Dataset with {name}:[ds1] does not exist. Request sent for a dataset does not exist.
310000E0 HTTP method [PUT] is not supported for action [createResourceDef]. Request is sent with any HTTP method other than POST.
310000E2 Application encountered an internal error. API server encountered an unknown error.