Skip to content

Commit

Permalink
docs(interactive): Refine the documentation of Interactive (#4209)
Browse files Browse the repository at this point in the history
- Add the documentation of CRU of Vertex/Edge.
- Update cpp_procedure.md
- Fix the documentation of python sdk.
  • Loading branch information
zhanglei1949 authored Sep 11, 2024
1 parent 4bc52fa commit 239b392
Show file tree
Hide file tree
Showing 18 changed files with 990 additions and 197 deletions.
230 changes: 230 additions & 0 deletions docs/flex/interactive/development/java/EdgeApi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
# EdgeAPi

All URIs are relative to *{INTERACTIVE_ADMIN_ENDPOINT}*

| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**addEdge**](EdgeApi.md#addEdge) | **POST** /v1/graph/{graph_id}/edge | Add edge to the graph |
| [**deleteEdge**](EdgeApi.md#deleteEdge) | **DELETE** /v1/graph/{graph_id}/edge | Remove edge from the graph |
| [**getEdge**](EdgeApi.md#getEdge) | **GET** /v1/graph/{graph_id}/edge | Get the edge's properties with src and dst vertex primary keys. |
| [**updateEdge**](EdgeApi.md#updateEdge) | **PUT** /v1/graph/{graph_id}/edge | Update edge's property |


<a id="addEdge"></a>
# **addEdge**
> Result&lt;String&gt; addEdge(graphId, edgeRequest)
Add edge to the graph.

See [Creating-Graph](GraphManagementApi.md#creategraph) about how to create a graph. Here we use the default graph(with id 1) for example.

### Example
```java
// Import classes:
import com.alibaba.graphscope.interactive.models.*;
import com.alibaba.graphscope.interactive.client.Driver;
import com.alibaba.graphscope.interactive.client.Session;
import com.alibaba.graphscope.interactive.client.common.Result;

public class Example {
public static void main(String[] args) {
Driver driver = Driver.connect();
Session session = driver.session();

String graphId = "1";
EdgeRequest edgeRequest3 =
new EdgeRequest()
.srcLabel("person")
.dstLabel("person")
.edgeLabel("knows")
.srcPrimaryKeyValue(2)
.dstPrimaryKeyValue(4)
.addPropertiesItem(new Property().name("weight").value(9.123));
EdgeRequest edgeRequest4 =
new EdgeRequest()
.srcLabel("person")
.dstLabel("person")
.edgeLabel("knows")
.srcPrimaryKeyValue(2)
.dstPrimaryKeyValue(6)
.addPropertiesItem(new Property().name("weight").value(3.233));
List<EdgeRequest> edgeRequests = new ArrayList<>();
edgeRequests.add(edgeRequest3);
edgeRequests.add(edgeRequest4);
Result<String> addEdgeResponse = session.addEdge(graphId, edgeRequests);
if (!addEdgeResponse.isOk()) {
System.out.println("Failed to create edge: " + addEdgeResponse.getStatusMessage());
}
else {
System.out.println("Create edge response: " + addEdgeResponse.getValue());
}
return;
}
}
```

### Parameters

| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **graphId** | **String**| | |
| **edgeRequest** | [**List&lt;EdgeRequest&gt;**](EdgeRequest.md)| | |

### Return type

**String**

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json

### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Successfully insert the edge | - |
| **400** | Invalid input edge | - |
| **409** | edge already exists | - |
| **500** | Server internal error | - |

<a id="getEdge"></a>
# **getEdge**
> Result&lt;EdgeData&gt; getEdge(graphId, edgeLabel, srcLabel, srcPrimaryKeyValue, dstLabel, dstPrimaryKeyValue)
Get the edge&#39;s properties with src and dst vertex primary keys.

### Example
```java
// Import classes:
import com.alibaba.graphscope.interactive.models.*;
import com.alibaba.graphscope.interactive.client.Driver;
import com.alibaba.graphscope.interactive.client.Session;
import com.alibaba.graphscope.interactive.client.common.Result;

public class Example {
public static void main(String[] args) {
Driver driver = Driver.connect();
Session session = driver.session();

String graphId = "1";
Result<EdgeData> getEdgeResponse =
session.getEdge(graphId, "knows", "person", 2, "person", 4);
if (getEdgeResponse.isOk()){
for (Property property : getEdgeResponse.getValue().getProperties()) {
if (property.getName().equals("weight")) {
Double weight = Double.parseDouble(property.getValue().toString());
assert weight.equals(9.123);
}
}
} else {
System.out.println("Get edge failed: " + getEdgeResponse.getValue());
}
return;
}
}
```

### Parameters

| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **graphId** | **String**| | |
| **edgeLabel** | **String**| The label name of querying edge. | |
| **srcLabel** | **String**| The label name of src vertex. | |
| **srcPrimaryKeyValue** | [**Object**](.md)| The primary key value of src vertex. | |
| **dstLabel** | **String**| The label name of dst vertex. | |
| **dstPrimaryKeyValue** | [**Object**](.md)| The value of dst vertex&#39;s primary key | |

### Return type

[**EdgeData**](EdgeData.md)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Found Edge | - |
| **400** | Bad input parameter | - |
| **404** | Edge not found or Graph not found | - |
| **500** | Server internal error | - |

<a id="updateEdge"></a>
# **updateEdge**
> Result&lt;String&gt; updateEdge(graphId, edgeRequest)
Update edge&#39;s property


### Example
```java
// Import classes:
import com.alibaba.graphscope.interactive.models.*;
import com.alibaba.graphscope.interactive.client.Driver;
import com.alibaba.graphscope.interactive.client.Session;
import com.alibaba.graphscope.interactive.client.common.Result;

public class Example {
public static void main(String[] args) {
Driver driver = Driver.connect();
Session session = driver.session();

String graphId = "1";
EdgeRequest updateEdgeRequest =
new EdgeRequest()
.srcLabel("person")
.dstLabel("person")
.edgeLabel("knows")
.srcPrimaryKeyValue(2)
.dstPrimaryKeyValue(4)
.addPropertiesItem(new Property().name("weight").value(3.0));
Result<String> updateEdgeResponse = session.updateEdge(graphId, updateEdgeRequest);
if (!updateEdgeResponse.isOk()) {
System.out.println("Failed to update edge: " + updateEdgeResponse.getStatusMessage());
}
else {
System.out.println("Update edge response: " + updateEdgeResponse.getValue());
}
}
}
```

### Parameters

| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **graphId** | **String**| | |
| **edgeRequest** | [**EdgeRequest**](EdgeRequest.md)| | [optional] |

### Return type

**String**

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json

### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Successfully update edge | - |
| **400** | Invalid input parameters | - |
| **404** | Edge not exists | - |
| **500** | Server internal error | - |

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ All URIs are relative to *{INTERACTIVE_ADMIN_ENDPOINT}*

Create a new procedure on a graph with give id.
Both `cypher` and `c++` stored procedures could be registered.
Please refer to [CppStoredProcedure](../stored_procedure/cpp_procedure.md) and [CypherStoredProcedure](../stored_procedure/cypher_procedure.md).
Please refer to [CppStoredProcedure](../stored_procedure/cpp_procedure.md) and [CypherStoredProcedure](../../stored_procedures.md).

### Example
```java
Expand Down
2 changes: 1 addition & 1 deletion docs/flex/interactive/development/java/QueryServiceApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If you attempt to submit a query to a graph that is not currently running, we wi
Submit procedure call queries to the specified graph.
The output format for the query is define by the [results.proto](https://github.com/alibaba/GraphScope/blob/main/interactive_engine/executor/ir/proto/results.proto).

For the creation of stored procedure please refer to [CypherStoredProcedure](../stored_procedure/cypher_procedure.md) and [CppStoredProcedure](../stored_procedure/cpp_procedure.md).
For the creation of stored procedure please refer to [CypherStoredProcedure](../../stored_procedures.md) and [CppStoredProcedure](../stored_procedure/cpp_procedure.md).

### Example
```java
Expand Down
Loading

0 comments on commit 239b392

Please sign in to comment.