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 Python 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 the SDK

  1. Extract huaweicloud-ges-sdk-xxx.zip and find a Python project called graph-python-sdk-example. This project contains Python 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 Python SDK sample code file for an API, refer to Python 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 Python SDK sample code file in Python SDK Sample Reference. The file is named ExecuteCypherQuerySample.py, the file is located in com.huawei.ges.graph.sdk.v1.examples.querylanguage. The path also includes a Main file named QueryLanguageMain.py for debugging.
    Figure 9 Python SDK sample code file
  3. In the package path com.huawei.ges.graph.sdk.v1.examples.base, you can find the Base.py file that provides client initialization examples for different authentication modes. Choose the one that suits your needs.
    Figure 10 Varying authentication modes
  4. The following is an example of the result of executing a Cypher query:
    Figure 11 Cypher query result

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