Updated on 2024-11-25 GMT+08:00

Usage Process

Obtain parameters and initialize the client by referring to Obtaining Initialization Parameters. The following uses the memory edition's Executing a Cypher Query API as an example to demonstrate how to use the Java SDK.

Obtaining the Graph Name and Access Address

Log in to the GES console and choose Graph Management in the navigation pane on the left. On the displayed page, obtain the graph name (Name/ID) and access address (Internal Access Address/External Access Address) as needed.

Figure 1 Obtaining the graph name and access address

Obtaining AK/SK-based Authentication Information

  1. Log in to the Huawei Cloud management console, hover over the username in the upper right corner, and choose My Credentials from the drop-down list.
    Figure 2 My Credentials
  2. On the API Credentials page, locate the project to which the graph belongs in the project list.
    Figure 3 Project
  3. In the navigation pane on the left, choose Access Keys. On the page that appears, click Create Access Key.
    Figure 4 Creating an access key
  4. Once the access key is created, click Download to obtain the AK, SK, and region code.
    Figure 5 Clicking Download

Obtaining Token-based Authentication Information

  1. Query the IAM endpoint by referring to Regions and Endpoints.
    Figure 6 Querying a VPC endpoint
  2. Log in to the Huawei Cloud management console, hover over the username in the upper right corner, and choose My Credentials from the drop-down list.
    Figure 7 My Credentials
  3. On the API Credentials page, find IAM User Name and Account Name, as well as Project ID in the project list.
    Figure 8 Obtaining information

How to Use Java SDK

  1. Extract huaweicloud-ges-sdk-xxx.zip and find a Maven project called graph-java-sdk-example. This project contains Java SDK sample code for GES APIs, which can be imported into an IDE for debugging by modifying API parameters.

    For detailed information and parameter description of GES APIs, refer to Service Plane APIs. For how to find the corresponding Java SDK sample code file for an API, refer to Java SDK Sample Reference. The sample code file is located in a path that includes a Main file for debugging purposes.

  2. Take the "Executing a Cypher Query" API of the memory edition as an example. Find the corresponding Java SDK sample code file in Java SDK Sample Reference. The file is named ExecuteCypherQuerySample.java, the file is located in com.huawei.ges.graph.sdk.v1.examples.querylanguage. The path also includes a Main file named QueryLanguageMain.java for debugging.
    Figure 9 Java SDK sample code file
  3. The parameters for client initialization are defined in the GraphClientUtils class. Select an appropriate authentication method and set the parameters.
    Figure 10 GraphClientUtils class
    Figure 11 Authentication mode parameters
  4. The following is an example of the result of executing a Cypher query:
    Figure 12 Cypher query result

For SDK sample code for more APIs, see Java SDK Sample Reference.