Updated on 2024-05-23 GMT+08:00

Adding an Edge (2.1.2)

Function

This API is used to add an edge.

URI

POST /ges/v1.0/{project_id}/graphs/{graph_name}/edges
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.

graph_name

Yes

String

Graph name

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

source

Yes

String

Source vertex name

target

Yes

String

Target vertex name

label

No

String

Label of an edge. If no label exists, set it to __DEFAULT__.

properties

No

Object

Value of each property

parallelEdge

No

parallelEdge Object

How to process repetitive edges

Table 3 parallelEdge parameter description

Parameter

Mandatory

Type

Description

action

No

String

Processing mode of repetitive edges. The value can be allow, ignore, or override. The default value is allow.

  • allow indicates that repetitive edges are allowed.
  • ignore indicates that subsequent repetitive edges are ignored.
  • override indicates that the previous repetitive edges are overwritten.

ignoreLabel

No

Boolean

Whether to ignore labels on repetitive edges. The value can be true or false. The default value is true.

  • true: indicates that the repetitive edge definition does not contain the label. That is, <Source vertex, Target vertex> indicates an edge.
  • false: indicates that the repetitive edge definition contains the label. That is, <Source vertex, Target vertex, Label> indicates an edge.

targetProperties

No

targetProperties

Array

List of properties used to determine repetitive edges. If this parameter is specified, ignoreLabel is set to false to define repetitive edges that contain properties in the list specified by this parameter.

(This parameter is mandatory only when action is set to override.)

NOTE:
  • The current version supports only overwriting by property and does not support ignoring by property. In addition, only one property takes effect for each label.
  • Properties of the non-single type are considered unequal.
Table 4 targetProperties parameter description

Parameter

Mandatory

Type

Description

label

Yes

String

Labels whose repetitive edges need to be determined by property

properties

Yes

Array

List of properties whose repetitive edges need to be determined by property. Currently, only one property is supported. If multiple properties are entered, the first property is used.

Response Parameters

Table 5 Response body parameters

Parameter

Type

Description

errorMessage

String

System prompt.

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

errorCode

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.

result

String

Request result. If the request is successful, the value is success. If the request fails, the value is failed.

data

Object

Query results. If the query is successful, the query results are returned. If the query fails, this parameter is left blank.

Example Request

Add an edge. The source name is Lily, the target name is Rocky, and the label name of the edge is rate.

POST /ges/v1.0/{project_id}/graphs/{graph_name}/edges
{
    "source": "Lily",
    "target": "Rocky",
    "label": "rate",
    "properties": {
        "Score": [
            5
        ],
        "Datetime": [
            "2018-01-01 20:30:05"
        ]
    },
    "parallelEdge": {
        "action": "override",
        "ignoreLabel": true,
        "targetProperties": [
            {
                "label": "rate",
                "properties": [
                    "Datetime"
                ]
            },
            {
                "label": "superclassOf",
                "properties": [
                    "popularity"
                ]
            }
        ]
    }
}

SERVER_URL: Address for accessing a graph. For details about its value, see Using Service Plane APIs.

Example Response

Status code: 200

Example response for a successful request

Http Status Code: 200
{
 "result":"success",
 "data":{"index":"0"}
}

Status code: 400

Example response for a failed request
Http Status Code: 400
{
 "errorMessage":"edge source vertex [Lily] does not exist",
 "errorCode":"GES.8000"
}

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.