Updated on 2024-01-04 GMT+08:00

Adding Metadata

Function

This API is used to add metadata.

URI

POST /v2/{project_id}/graphs/metadatas

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request Parameters

Table 2 Request header parameter

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. The token can be obtained by calling the IAM API. (The token is the value of X-Subject-Token in the response header.)

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

metadata_path

Yes

String

Path for storing the metadata

name

Yes

String

Metadata name, which contains 1 to 64 characters consisting of only letters, digits, and underscores (_)

description

Yes

String

Metadata description

is_overwrite

Yes

Boolean

Whether to overwrite the file.

ges_metadata

Yes

ges_metadata object

Object for storing metadata message information.

Table 4 ges_metadata

Parameter

Mandatory

Type

Description

labels

Yes

Array of labels objects

Label list

Table 5 labels

Parameter

Mandatory

Type

Description

name

No

String

Name of a label

properties

No

Array of Map<String,String> objects

Label property map

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

id

String

Metadata ID

name

String

Metadata name

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

System prompt code.

  • If execution succeeds, this parameter may be left blank.
  • If execution fails, this parameter is used to display the error code.

error_msg

String

System prompt code.

  • If execution succeeds, this parameter may be left blank.
  • If execution fails, this parameter is used to display the error message.

Example Request

Add metadata. The metadata is stored in devdata/unionsdk/unionsdk_test.xml. The metadata does not overwrite existing data, the metadata name is unionsdk_test, and the metadata description is test.

POST https://Endpoint/v2/{project_id}/graphs/metadatas

{
  "metadata_path" : "devdata/unionsdk/unionsdk_test.xml",
  "is_overwrite" : false,
  "name" : "unionsdk_test",
  "description": " test",
  "ges_metadata" : {
    "labels" : [ {
      "name" : "friends"
    }, {
      "name" : "movie",
      "properties" : [ {
        "dataType" : "string",
        "name" : "ChineseTitle",
        "cardinality" : "single"
      }, {
        "dataType" : "int",
        "name" : "Year",
        "cardinality" : "single"
      }, {
        "dataType" : "string",
        "name" : "Genres",
        "cardinality" : "set"
      } ]
    }, {
      "name" : "user",
      "properties" : [ {
        "dataType" : "string",
        "name" : "ChineseName",
        "cardinality" : "single"
      }, {
        "typeName1" : "F",
        "typeName2" : "M",
        "typeNameCount" : "2",
        "dataType" : "enum",
        "name" : "Gender",
        "cardinality" : "single"
      }, {
        "typeName1" : "Under 18",
        "typeName2" : "18-24",
        "typeName3" : "25-34",
        "typeName4" : "35-44",
        "typeNameCount" : "7",
        "dataType" : "enum",
        "name" : "Age",
        "typeName5" : "45-49",
        "typeName6" : "50-55",
        "cardinality" : "single",
        "typeName7" : "56+"
      }, {
        "dataType" : "string",
        "name" : "Occupation",
        "cardinality" : "single"
      }, {
        "dataType" : "char array",
        "name" : "Zip-code",
        "maxDataSize" : "12",
        "cardinality" : "single"
      } ]
    }, {
      "name" : "rate",
      "properties" : [ {
        "dataType" : "int",
        "name" : "Score",
        "cardinality" : "single"
      }, {
        "dataType" : "date",
        "name" : "Datetime",
        "cardinality" : "single"
      } ]
    } ]
  }
}

Example Response

Status code: 200

Example response for a successful request

{
  "id" : "ff8080815f9a3c84015f9a438ff70001",
  "name" : "movie_schema"
}

Status code: 400

Example response for a failed request

{
  "error_msg" : "The metadata file already exists.",
  "error_code" : "GES.2067"
}

Status Code

Return Value

Description

400 Bad Request

Request error

401 Unauthorized

Authorization failed

403 Forbidden

No operation permissions

404 Not Found

No resources found

500 Internal Server Error

Internal server error

503 Service Unavailable

Service unavailable

Error Code

See Error Code.