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