Creating a Graph (1.0.0)

Function

This API is used to create a graph.

URI

  • URI format
    POST /v1.0/{project_id}/graphs
  • Parameter description
    Table 1 URI parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID, which is used for resource isolation. For details, see Obtaining a Project ID.

Request

  • Request example
    POST https://Endpoint/v1.0/{project_id}/graphs
    {
        "graph":{
            "name":"demo",
            "regionCode": "cn-north-1",
            "azCode": "cn-north-1a",
    	"dataSource": {
    			"type": "OBS",
    			"parameters": {
    				"schemaPath": "hkmovie/testcre/schema.xml",
    				"edgesetPath": "hkmovie/testcre/edges/edge.csv",
    				"edgesetFormat": "csv",
    				"edgesetDefaultLabel": "",
    				"vertexsetPath": "hkmovie/testcre/vetexs/vertex.csv",
    				"vertexsetFormat": "csv",
    				"vertexsetDefaultLabel": "",
    				"logDir": "hkmovie/logdir",
                                    "parallelEdge": "override"
    			}
            },
            "graphSizeTypeIndex": "1",
            "vpcId":"2d8af840-fd57-4e3b-a8f1-cda0f55ccd99",
            "subnetId":"dc018ec3-67d1-46c9-b2fc-19d83367f4e2",
            "securityGroupId":"11d27338-8649-4076-8579-5ebc1a60f79e",
            "publicIp":{
               "publicBindType":"bind_existing",
               "eipId":"30ef2d58-08a9-4481-b526-b2cbe67d020d"
            }
        }
    }

Table 2 Request body parameter description

Parameter

Mandatory

Type

Description

graph

Yes

For details, see the graph type data structure description.

Graph type

Table 3 Graph type data structure description

Parameter

Mandatory

Type

Description

name

Yes

String

Graph name

regionCode

Yes

String

Region code

azCode

Yes

String

AZ code

graphSizeTypeIndex

Yes

Integer

Graph size type index:

  • 0: indicates 10 thousand edges.
  • 1: indicates 1 million edges.
  • 2: indicates 10 million edges.
  • 3: indicates 100 million edges.
  • 4: indicates 1 billion edges.
  • 5: indicates 10 billion edges.

dataSource

No

DataSource data structure

Data source. This field is not set when you create an empty graph. For details, see Table 5.

vpcId

Yes

String

VPC ID

subnetId

Yes

String

Network ID in the specified VPC

securityGroupId

Yes

String

Security group ID

publicIp

No

Object

Public IP address. If the value is not specified, public connection is not used by default. For details, see Table 4.

Table 4 publicIp parameter description

Parameter

Mandatory

Type

Description

publicBindType

No

String

Binding type of an EIP. The value can be either of the following:

  • auto_assign
  • bind_existing

eipId

No

String

ID of an EIP. When publicBindType is set to bind_existing, its value is the ID of an EIP that has been created but has not been bound. When publicBindType is set to auto_assign, its value is set to null.

Table 5 DataSource data structure

Parameter

Mandatory

Type

Description

type

Yes

String

Data source type. The value is OBS. Currently, only OBS is supported.

parameters

Yes

Object

Data source parameters. For details, see Table 6.

Table 6 parameters parameter description

Parameter

Mandatory

Type

Description

schemaPath

Yes

String

OBS path for storing the metadata file. Only files are supported.

edgesetPath

Yes

String

OBS path for storing the edge file. Only files are supported.

edgesetFormat

No

String

Format of the edge data set. Currently, only the CSV format is supported.

The CSV format is used by default.

edgesetDefaultLabel

No

String

Default label of an edge data set. This parameter is left blank by default.

vertexsetPath

No

String

OBS path for storing the vertex file. Only files are supported.

vertexsetFormat

No

String

Format of the vertex data set. Currently, only the CSV format is supported.

The CSV format is used by default.

vertexsetDefaultLabel

No

String

Default label of a vertex data set. This parameter is left blank by default.

logDir

No

String

OBS log storage directory. This directory stores the data that fails to be imported during graph creation and detailed logs.

parallelEdge

No

Object

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.
  • For details about the value validity of the schemaPath, edgesetPath, vertexsetPath, and logDir character strings, see the OBS Object Name Restrictions.

Response

Table 7 Parameter description

Parameter

Mandatory

Type

Description

errorMessage

No

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

No

String

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

id

No

String

Graph ID

name

No

String

Graph name

  • Response example (successful request)
    Http Status Code: 200
    {
        "id": "f1529b88-c958-493e-8452-fccfe932cde1",
        "name": "demo"
    }
  • Response example (failed request)
    Http Status Code: 400
    {
        "errorCode": "GES.7022",
        "errorMessage": "The security group does not exist."
    }

Return Value

  • Normal

    200

  • Abnormal
    Table 8 Return code for failed requests

    Return Value

    Description

    400 Bad Request

    Request error.

    401 Unauthorized

    Authentication failed.

    403 Forbidden

    No operation permission.

    404 Not Found

    The requested resource was not found.

    500 Internal Server Error

    Internal service error.

    503 Service Unavailable

    Service unavailable.