Skip to content

Commit 3c05b20

Browse files
Sergey Polyarusicreated
authored andcommitted
twingraph endpoints
1 parent cc941ea commit 3c05b20

File tree

6 files changed

+26
-22
lines changed

6 files changed

+26
-22
lines changed

doc/Apis/TwingraphApi.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ All URIs are relative to *https://dev.api.cosmotech.com*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**delete**](TwingraphApi.md#delete) | **DELETE** /organizations/{organization_id}/{graph_id} |
8-
[**importGraph**](TwingraphApi.md#importGraph) | **POST** /organizations/{organization_id}/import |
9-
[**query**](TwingraphApi.md#query) | **POST** /organizations/{organization_id}/query |
7+
[**delete**](TwingraphApi.md#delete) | **DELETE** /organizations/{organization_id}/twingraph/{graph_id} |
8+
[**importGraph**](TwingraphApi.md#importGraph) | **POST** /organizations/{organization_id}/twingraph/import |
9+
[**query**](TwingraphApi.md#query) | **POST** /organizations/{organization_id}/twingraph/{graph_id}/query |
1010

1111

1212
<a name="delete"></a>
@@ -67,7 +67,7 @@ Name | Type | Description | Notes
6767

6868
<a name="query"></a>
6969
# **query**
70-
> String query(organization\_id, TwinGraphQuery)
70+
> String query(organization\_id, graph\_id, TwinGraphQuery)
7171
7272

7373

@@ -78,6 +78,7 @@ Name | Type | Description | Notes
7878
Name | Type | Description | Notes
7979
------------- | ------------- | ------------- | -------------
8080
**organization\_id** | **String**| the Organization identifier | [default to null]
81+
**graph\_id** | **String**| the Graph Identifier | [default to null]
8182
**TwinGraphQuery** | [**TwinGraphQuery**](../Models/TwinGraphQuery.md)| the query to run |
8283

8384
### Return type

doc/Models/TwinGraphQuery.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
6-
**graphId** | **String** | Twin graph name | [optional] [default to null]
76
**version** | **String** | Twin graph version | [optional] [default to null]
87
**query** | **String** | the query in cypher language | [optional] [default to null]
98

doc/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ Class | Method | HTTP request | Description
8888
*SolutionApi* | [**updateSolution**](Apis/SolutionApi.md#updatesolution) | **PATCH** /organizations/{organization_id}/solutions/{solution_id} | Update a solution
8989
*SolutionApi* | [**updateSolutionRunTemplate**](Apis/SolutionApi.md#updatesolutionruntemplate) | **PATCH** /organizations/{organization_id}/solutions/{solution_id}/runTemplates/{run_template_id} | Update the specified Solution Run Template
9090
*SolutionApi* | [**uploadRunTemplateHandler**](Apis/SolutionApi.md#uploadruntemplatehandler) | **POST** /organizations/{organization_id}/solutions/{solution_id}/runtemplates/{run_template_id}/handlers/{handler_id}/upload | Upload a Run Template step handler zip file
91-
*TwingraphApi* | [**delete**](Apis/TwingraphApi.md#delete) | **DELETE** /organizations/{organization_id}/{graph_id} | Launch a mass delete job
92-
*TwingraphApi* | [**importGraph**](Apis/TwingraphApi.md#importgraph) | **POST** /organizations/{organization_id}/import | Import a new version of a twin graph
93-
*TwingraphApi* | [**query**](Apis/TwingraphApi.md#query) | **POST** /organizations/{organization_id}/query | Run a query on a graph instance
91+
*TwingraphApi* | [**delete**](Apis/TwingraphApi.md#delete) | **DELETE** /organizations/{organization_id}/twingraph/{graph_id} | Launch a mass delete job
92+
*TwingraphApi* | [**importGraph**](Apis/TwingraphApi.md#importgraph) | **POST** /organizations/{organization_id}/twingraph/import | Import a new version of a twin graph
93+
*TwingraphApi* | [**query**](Apis/TwingraphApi.md#query) | **POST** /organizations/{organization_id}/twingraph/{graph_id}/query | Run a query on a graph instance
9494
*UserApi* | [**authorizeUser**](Apis/UserApi.md#authorizeuser) | **GET** /oauth2/authorize | Authorize an User with OAuth2. Delegated to configured OAuth2 service
9595
*UserApi* | [**findAllUsers**](Apis/UserApi.md#findallusers) | **GET** /users | List all Users
9696
*UserApi* | [**findUserById**](Apis/UserApi.md#finduserbyid) | **GET** /users/{user_id} | Get the details of an user

openapi/plantuml/schemas.plantuml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ entity TwinGraphImportInfo {
426426
}
427427

428428
entity TwinGraphQuery {
429-
graphId: String
430429
version: String
431430
query: String
432431
}

twingraph/src/main/kotlin/com/cosmotech/twingraph/api/TwingraphServiceImpl.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,27 @@ class TwingraphServiceImpl(
6464
logger.debug("$count keys are removed from Twingraph with prefix $graphId")
6565
}
6666

67-
override fun query(organizationId: String, twinGraphQuery: TwinGraphQuery): String {
67+
override fun query(
68+
organizationId: String,
69+
twingraphId: String,
70+
twinGraphQuery: TwinGraphQuery
71+
): String {
6872
val organization = organizationService.findOrganizationById(organizationId)
6973
csmRbac.verify(organization.getRbac(), PERMISSION_READ)
7074
if (twinGraphQuery.version.isNullOrEmpty()) {
71-
twinGraphQuery.version = jedis.hget("${twinGraphQuery.graphId}MetaData", "lastVersion")
75+
twinGraphQuery.version = jedis.hget("${twingraphId}MetaData", "lastVersion")
7276
if (twinGraphQuery.version.isNullOrEmpty()) {
73-
throw CsmResourceNotFoundException(
74-
"Cannot find lastVersion in ${twinGraphQuery.graphId}MetaData")
77+
throw CsmResourceNotFoundException("Cannot find lastVersion in ${twingraphId}MetaData")
7578
}
7679
}
7780

78-
val redisGraphId = "${twinGraphQuery.graphId}:${twinGraphQuery.version}"
81+
val redisGraphId = "${twingraphId}:${twinGraphQuery.version}"
7982
val resultSet: ResultSet = jedis.graphQuery(redisGraphId, twinGraphQuery.query)
8083

8184
val iterator = resultSet.iterator()
8285
if (!iterator.hasNext()) {
8386
throw CsmResourceNotFoundException(
84-
"TwinGraph empty with given ${twinGraphQuery.graphId} " +
85-
"and version ${twinGraphQuery.version}")
87+
"TwinGraph empty with given ${twingraphId} " + "and version ${twinGraphQuery.version}")
8688
}
8789

8890
val result = mutableMapOf<Int, MutableSet<String>>()

twingraph/src/main/openapi/twingraph.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tags:
1717
description: Twin Graph Management
1818

1919
paths:
20-
/organizations/{organization_id}/import:
20+
/organizations/{organization_id}/twingraph/import:
2121
parameters:
2222
- name: organization_id
2323
in: path
@@ -47,14 +47,20 @@ paths:
4747
application/json:
4848
schema:
4949
$ref: '#/components/schemas/TwinGraphImportInfo'
50-
/organizations/{organization_id}/query:
50+
/organizations/{organization_id}/twingraph/{graph_id}/query:
5151
parameters:
5252
- name: organization_id
5353
in: path
5454
description: the Organization identifier
5555
required: true
5656
schema:
5757
type: string
58+
- name: graph_id
59+
in: path
60+
description: the Graph Identifier
61+
required: true
62+
schema:
63+
type: string
5864
post:
5965
operationId: query
6066
tags:
@@ -77,7 +83,7 @@ paths:
7783
application/json:
7884
schema:
7985
type: string
80-
/organizations/{organization_id}/{graph_id}:
86+
/organizations/{organization_id}/twingraph/{graph_id}:
8187
parameters:
8288
- name: organization_id
8389
in: path
@@ -116,9 +122,6 @@ components:
116122
type: object
117123
description: a twin graph query in cypher language
118124
properties:
119-
graphId:
120-
type: string
121-
description: Twin graph name
122125
version:
123126
type: string
124127
description: Twin graph version

0 commit comments

Comments
 (0)