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.
Obtaining AK/SK-based Authentication Information
- 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
- On the API Credentials page, locate the project to which the graph belongs in the project list.
Figure 3 Project
- 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
- 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
- Query the IAM endpoint by referring to Regions and Endpoints.
Figure 6 Querying a VPC endpoint
- 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
- 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
- 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.
- 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
- 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
- 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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot