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

Adding Edges in Batches

Function

This API is used to add edges in batches.

URI

POST /ges/v1.0/{project_id}/graphs/{graph_name}/edges/action?action_id=batch-add
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

Parameter

Mandatory

Type

Description

edges

Yes

Object

Edge array to be added

parallelEdge

No

Object

How to process repetitive edges

action

No

String

Processing mode. The value can be override or ignore.

  • If the value is override, the previous repetitive edges are overwritten.
  • If the value is ignore and an edge already exists, the previous edge will not be overwritten. If no edge exists, the system adds an edge.

ignoreLabel

No

Boolean

Whether to ignore labels on repetitive edges. The value can only be false.

false: Edges with the same source vertex, target vertex, and label are duplicate edges.

createNotExists

No

Boolean

Whether to add source or target vertices that do not exist in the edges parameter before adding edges. The value can only be false.

false: Edges can be added regardless of whether the source or target vertex exists.

Table 2 edges parameter description

Parameter

Mandatory

Type

Description

source

Yes

String

Source vertex of an edge

target

Yes

String

Target vertex of an edge

label

Yes

String

Edge label

properties

No

Object

Value of each property

Response Parameters

Table 3 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.

  • 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.

Example Request

Add edges in batches. The source vertex is 46, the target vertices are 39 and 38, and the edge label is rate.

POST http://{SERVER_URL}/ges/v1.0/{project_id}/graphs/{graph_name}/edges/action?action_id=batch-add
{
    "edges": [
        {
            "source": "46",
            "target": "39",
            "label": "rate",
            "properties": {
                "Rating": [
                    5
                ],
                "Datetime": [
                    "2018-01-0120:30:05"
                ]
            }
        },
        {
            "source": "46",
            "target": "38",
            "label": "rate",
            "properties": {
                "Rating": [
                    4
                ],
                "Datetime": [
                    "2018-01-0120:30:05"
                ]
            }
        }
    ],
    "parallelEdge": {
        "action": "override",
        "ignoreLabel": false
    },
    "createNotExists": false
}
  • SERVER_URL: Address for accessing a graph. For details about its value, see Using Service Plane APIs.
  • In the example, if vertices 666 and 777 are not in the original graph, create vertices 666 and 777, retain the default value of each label, and add an edge.

Example Response

Status code: 200

Example response for a successful request

Http Status Code: 200
{
 "result":"success",
 "data": {
     "edges": [
         {
             "index": "7",
             "source": "46",
             "target": "39"
         },
         {
             "index": "0",
             "source": "46",
             "target": "38"
         }
     ]
 }
}

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 Codes

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 Codes

See Error Codes.