Import data files using the curl command

Updated at:

This topic describes how to use the curl command to import data files from an Object Storage Service (OSS) bucket to a Graph Database (GDB) instance, view an import task, and cancel an import task.

Prerequisites

Procedure

  1. On a client, run the following command to import data files from an OSS bucket to a GDB instance.
    curl -i -u <username>:<password> -X POST \
      -H 'Content-Type: application/json' \
      http://<mygdb-endpoint>:<port>/loader -d '
      {
        "source" : "oss://<bucket>/air-routes/<filename>",
        "ramRoleArn" : "<arninfo>",
      }'
    Note
    • <username>: Replace with the username of the GDB instance.
    • <password>: Replace with the password for the GDB instance.
    • <mygdb-endpoint>: Replace with the endpoint of the GDB instance (internal or public endpoint).
    • <port>: Replace with the port number of the GDB instance endpoint (internal or public port).
    • <bucket>: Replace with the name of the bucket that stores the data files.
    • <filename>: Replace with the name of the data file to import.
    • <arninfo>: Replace with the ARN of the AliyunServiceRoleForGDB role in your Alibaba Cloud account. For more information, see Obtain an ARN.
    • When you copy the command, do not add a space after the backslash (\).
    Example:
    • Import a point file
      curl -i -u gdb_account:******** -X POST \
        -H 'Content-Type: application/json' \
        http://gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com:****/loader -d '
        {
          "source" : "oss://examplebucket/air-routes/air-routes-latest-nodes.csv",
          "ramRoleArn" : "acs:ram::140692647406****:role/aliyunserviceroleforgdb",
        }'
    • Import an edge file
      curl -i -u gdb_account:******** -X POST \
        -H 'Content-Type: application/json' \
        http://gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com:****/loader -d '
        {
          "source" : "oss://examplebucket/air-routes/air-routes-latest-edges.csv",
          "ramRoleArn" : "acs:ram::140692647406****:role/aliyunserviceroleforgdb",
        }'
    A response similar to the following is returned. This indicates that the GDB import program has verified the parameters and returned the import task ID (loadId).
    {
      "status" : "200 OK",
      "payload" : {
          "loadId" : "552617AF-4F1E-4CD8-9533-A2EC154688DC"
      }
    }
  2. Use the import task ID to run the corresponding command to view the status of the import task or cancel the import task.
    • View the status of the import task
      curl -u <username>:<password> -X GET 'http://<mygdb-endpoint>:<port>/loader/<loadId>'
      Note
      • <username>: Replace with the username of the GDB instance.
      • <password>: Replace with the password for the GDB instance.
      • <mygdb-endpoint>: Replace with the endpoint of the GDB instance (internal or public endpoint).
      • <port>: Replace with the port number of the GDB instance endpoint (internal or public port).
      • <loadId>: Replace with the import task ID returned in Step 1.
      Example:
      curl -u gdb_account:******** -X GET 'http://gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com:****/loader/552617AF-4F1E-4CD8-9533-A2EC154688DC'

      If the response contains an error message, see List of error messages for more information.

    • Cancel the import task
      Important
      • If you cancel a task that is running in the background, the process is blocked until the task stops.
      • Point and edge data that has already been imported to the GDB instance is not rolled back and remains in the instance.
      curl -u <username>:<password> -X DELETE 'http://<mygdb-endpoint>:<port>/loader/<loadId>'
      Note
      • <username>: Replace with the username of the GDB instance.
      • <password>: Replace with the password for the GDB instance.
      • <mygdb-endpoint>: Replace with the endpoint of the GDB instance (internal or public endpoint).
      • <port>: Replace with the port number of the GDB instance endpoint (internal or public port).
      • <loadId>: Replace with the import task ID returned in Step 1.
      Example:
      curl -u gdb_account:******** -X DELETE 'http://gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com:****/loader/552617AF-4F1E-4CD8-9533-A2EC154688DC'