diff --git a/builder/model/pom.xml b/builder/model/pom.xml index 3ac4c9523..d901d3a4e 100644 --- a/builder/model/pom.xml +++ b/builder/model/pom.xml @@ -43,9 +43,5 @@ commons-codec commons-codec - - com.antgroup.openspg - common-util - diff --git a/cloudext/impl/graph-store/tugraph/src/main/java/com/antgroup/openspg/cloudext/impl/graphstore/tugraph/TuGraphStoreClient.java b/cloudext/impl/graph-store/tugraph/src/main/java/com/antgroup/openspg/cloudext/impl/graphstore/tugraph/TuGraphStoreClient.java index 27528bd0c..ddcfb9bce 100644 --- a/cloudext/impl/graph-store/tugraph/src/main/java/com/antgroup/openspg/cloudext/impl/graphstore/tugraph/TuGraphStoreClient.java +++ b/cloudext/impl/graph-store/tugraph/src/main/java/com/antgroup/openspg/cloudext/impl/graphstore/tugraph/TuGraphStoreClient.java @@ -48,7 +48,6 @@ import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.schema.operation.SchemaAtomicOperationEnum; import com.antgroup.openspg.cloudext.interfaces.graphstore.util.TypeNameUtils; import com.antgroup.openspg.core.schema.model.type.BasicTypeEnum; -import com.antgroup.openspg.server.api.facade.ApiConstants; import com.antgroup.tugraph.TuGraphDbRpcClient; import com.google.common.collect.Lists; import java.io.InputStream; @@ -78,13 +77,16 @@ public class TuGraphStoreClient extends BaseLPGGraphStoreClient { @Getter private final LPGTypeNameConvertor typeNameConvertor; @Getter private final String connUrl; + private static final String ACCESS_ID = "accessId"; + private static final String ACCESS_KEY = "accessKey"; + private static final String TIMEOUT = "timeout"; + public TuGraphStoreClient(String connUrl, LPGTypeNameConvertor typeNameConvertor) { UriComponents uriComponents = UriComponentsBuilder.fromUriString(connUrl).build(); this.connUrl = connUrl; this.graphName = uriComponents.getQueryParams().getFirst(TuGraphConstants.GRAPH_NAME); this.timeout = - Double.parseDouble( - String.valueOf(uriComponents.getQueryParams().getFirst(ApiConstants.TIMEOUT))); + Double.parseDouble(String.valueOf(uriComponents.getQueryParams().getFirst(TIMEOUT))); this.client = initTuGraphClient(uriComponents); this.internalIdGenerator = new NoChangedIdGenerator(); this.typeNameConvertor = typeNameConvertor; @@ -149,8 +151,8 @@ public void close() throws Exception { private TuGraphDbRpcClient initTuGraphClient(UriComponents uriComponents) { String host = String.format("%s:%s", uriComponents.getHost(), uriComponents.getPort()); - String accessId = uriComponents.getQueryParams().getFirst(ApiConstants.ACCESS_ID); - String accessKey = uriComponents.getQueryParams().getFirst(ApiConstants.ACCESS_KEY); + String accessId = uriComponents.getQueryParams().getFirst(ACCESS_ID); + String accessKey = uriComponents.getQueryParams().getFirst(ACCESS_KEY); TuGraphDbRpcClient client = null; try { client = new TuGraphDbRpcClient(host, accessId, accessKey); diff --git a/cloudext/impl/search-engine/elasticsearch/src/main/java/com/antgroup/openspg/cloudext/impl/searchengine/elasticsearch/util/ElasticSearchRecordUtils.java b/cloudext/impl/search-engine/elasticsearch/src/main/java/com/antgroup/openspg/cloudext/impl/searchengine/elasticsearch/util/ElasticSearchRecordUtils.java index 9f82f121a..f3ac53284 100644 --- a/cloudext/impl/search-engine/elasticsearch/src/main/java/com/antgroup/openspg/cloudext/impl/searchengine/elasticsearch/util/ElasticSearchRecordUtils.java +++ b/cloudext/impl/search-engine/elasticsearch/src/main/java/com/antgroup/openspg/cloudext/impl/searchengine/elasticsearch/util/ElasticSearchRecordUtils.java @@ -31,8 +31,8 @@ import com.antgroup.openspg.cloudext.interfaces.searchengine.model.request.query.MatchQuery; import com.antgroup.openspg.cloudext.interfaces.searchengine.model.request.query.QueryGroup; import com.antgroup.openspg.cloudext.interfaces.searchengine.model.request.query.TermQuery; +import com.antgroup.openspg.common.util.SchemaJsonUtils; import com.antgroup.openspg.common.util.StringUtils; -import com.antgroup.openspg.server.api.facade.SchemaJsonUtils; import com.dtflys.forest.http.ForestResponse; import com.google.gson.reflect.TypeToken; import java.net.URLEncoder; diff --git a/cloudext/interface/graph-store/src/main/java/com/antgroup/openspg/cloudext/interfaces/graphstore/model/lpg/record/VertexRecord.java b/cloudext/interface/graph-store/src/main/java/com/antgroup/openspg/cloudext/interfaces/graphstore/model/lpg/record/VertexRecord.java index 43fe5cc0a..f351f7a5d 100644 --- a/cloudext/interface/graph-store/src/main/java/com/antgroup/openspg/cloudext/interfaces/graphstore/model/lpg/record/VertexRecord.java +++ b/cloudext/interface/graph-store/src/main/java/com/antgroup/openspg/cloudext/interfaces/graphstore/model/lpg/record/VertexRecord.java @@ -14,7 +14,7 @@ package com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record; import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.schema.VertexType; -import com.antgroup.openspg.server.api.facade.ApiConstants; +import com.google.common.collect.Lists; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -35,12 +35,18 @@ public class VertexRecord extends BaseLPGRecord { private final String id; + private static final long DEFAULT_VERSION = 0L; + public VertexRecord(String id, String vertexType, List properties) { super(LPGRecordTypeEnum.VERTEX, properties); this.id = id; this.vertexType = vertexType; } + public VertexRecord(String id, String vertexType) { + this(id, vertexType, Lists.newArrayList()); + } + @Override public Map toPropertyMapWithId() { Map otherProperties = toPropertyMap(); @@ -55,7 +61,7 @@ public Map> toPropertyMapWithIdAndVersion() { otherProperties.forEach( (key, value) -> { TreeMap propertyVersion = new TreeMap<>(); - propertyVersion.put(ApiConstants.DEFAULT_VERSION, value); + propertyVersion.put(DEFAULT_VERSION, value); results.put(key, propertyVersion); }); return results; diff --git a/cloudext/interface/graph-store/src/main/java/com/antgroup/openspg/cloudext/interfaces/graphstore/model/lpg/schema/EdgeTypeName.java b/cloudext/interface/graph-store/src/main/java/com/antgroup/openspg/cloudext/interfaces/graphstore/model/lpg/schema/EdgeTypeName.java index 8457e3e11..819647561 100644 --- a/cloudext/interface/graph-store/src/main/java/com/antgroup/openspg/cloudext/interfaces/graphstore/model/lpg/schema/EdgeTypeName.java +++ b/cloudext/interface/graph-store/src/main/java/com/antgroup/openspg/cloudext/interfaces/graphstore/model/lpg/schema/EdgeTypeName.java @@ -17,6 +17,7 @@ import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; +import lombok.NoArgsConstructor; /** * {@link EdgeTypeName EdgeTypeName} is the unique identifier of {@link EdgeType EdgeType}, and it @@ -25,15 +26,16 @@ */ @Getter @AllArgsConstructor +@NoArgsConstructor @EqualsAndHashCode(callSuper = false) public class EdgeTypeName extends BaseValObj { - private final String startVertexType; + private String startVertexType; /** The label of edge type */ - private final String edgeLabel; + private String edgeLabel; - private final String endVertexType; + private String endVertexType; public static EdgeTypeName parse(String edgeTypeName) { String[] splits = edgeTypeName.split("_"); diff --git a/cloudext/interface/search-engine/src/main/java/com/antgroup/openspg/cloudext/interfaces/searchengine/model/request/query/FullTextSearchQuery.java b/cloudext/interface/search-engine/src/main/java/com/antgroup/openspg/cloudext/interfaces/searchengine/model/request/query/FullTextSearchQuery.java index 01ba1f34f..e4c629576 100644 --- a/cloudext/interface/search-engine/src/main/java/com/antgroup/openspg/cloudext/interfaces/searchengine/model/request/query/FullTextSearchQuery.java +++ b/cloudext/interface/search-engine/src/main/java/com/antgroup/openspg/cloudext/interfaces/searchengine/model/request/query/FullTextSearchQuery.java @@ -14,14 +14,17 @@ package com.antgroup.openspg.cloudext.interfaces.searchengine.model.request.query; import java.util.List; +import java.util.Map; import javax.annotation.Nullable; import lombok.Getter; import lombok.NonNull; +import lombok.Setter; public class FullTextSearchQuery extends BaseQuery { @Getter private final String queryString; @Getter private final List labelConstraints; + @Getter @Setter private Map params; public FullTextSearchQuery(@NonNull String queryString) { this(queryString, null); diff --git a/cloudext/interface/search-engine/src/main/java/com/antgroup/openspg/cloudext/interfaces/searchengine/model/request/query/VectorSearchQuery.java b/cloudext/interface/search-engine/src/main/java/com/antgroup/openspg/cloudext/interfaces/searchengine/model/request/query/VectorSearchQuery.java index a6a5212b2..3cc6c1a19 100644 --- a/cloudext/interface/search-engine/src/main/java/com/antgroup/openspg/cloudext/interfaces/searchengine/model/request/query/VectorSearchQuery.java +++ b/cloudext/interface/search-engine/src/main/java/com/antgroup/openspg/cloudext/interfaces/searchengine/model/request/query/VectorSearchQuery.java @@ -13,8 +13,10 @@ package com.antgroup.openspg.cloudext.interfaces.searchengine.model.request.query; +import java.util.Map; import lombok.Getter; import lombok.NonNull; +import lombok.Setter; public class VectorSearchQuery extends BaseQuery { @@ -22,17 +24,15 @@ public class VectorSearchQuery extends BaseQuery { @Getter private final String propertyKey; @Getter private final float[] queryVector; @Getter private final int efSearch; + @Getter @Setter private Map params; public VectorSearchQuery( - @NonNull String label, @NonNull String propertyKey, float @NonNull [] queryVector) { + String label, @NonNull String propertyKey, float @NonNull [] queryVector) { this(label, propertyKey, queryVector, -1); } public VectorSearchQuery( - @NonNull String label, - @NonNull String propertyKey, - float @NonNull [] queryVector, - int efSearch) { + String label, @NonNull String propertyKey, float @NonNull [] queryVector, int efSearch) { this.label = label; this.propertyKey = propertyKey; this.queryVector = queryVector; diff --git a/common/util/pom.xml b/common/util/pom.xml index 1e0e20d17..15e7b96c7 100644 --- a/common/util/pom.xml +++ b/common/util/pom.xml @@ -25,7 +25,7 @@ com.antgroup.openspg.server - api-facade + core-schema-model commons-codec @@ -59,5 +59,13 @@ org.neo4j.driver neo4j-java-driver + + com.google.code.gson + gson + + + org.danilopianini + gson-extras + diff --git a/common/util/src/main/java/com/antgroup/openspg/common/util/JsonUtils.java b/common/util/src/main/java/com/antgroup/openspg/common/util/JsonUtils.java index ee83328bd..02f41a47a 100644 --- a/common/util/src/main/java/com/antgroup/openspg/common/util/JsonUtils.java +++ b/common/util/src/main/java/com/antgroup/openspg/common/util/JsonUtils.java @@ -13,7 +13,6 @@ package com.antgroup.openspg.common.util; -import com.antgroup.openspg.server.api.facade.SchemaJsonUtils; import lombok.extern.slf4j.Slf4j; @Slf4j diff --git a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/SchemaJsonUtils.java b/common/util/src/main/java/com/antgroup/openspg/common/util/SchemaJsonUtils.java similarity index 99% rename from server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/SchemaJsonUtils.java rename to common/util/src/main/java/com/antgroup/openspg/common/util/SchemaJsonUtils.java index 7f796fb20..f6a64fae4 100644 --- a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/SchemaJsonUtils.java +++ b/common/util/src/main/java/com/antgroup/openspg/common/util/SchemaJsonUtils.java @@ -11,7 +11,7 @@ * or implied. */ -package com.antgroup.openspg.server.api.facade; +package com.antgroup.openspg.common.util; import com.antgroup.openspg.core.schema.model.constraint.BaseConstraintItem; import com.antgroup.openspg.core.schema.model.constraint.ConstraintTypeEnum; diff --git a/python/knext/KNEXT_VERSION b/python/knext/KNEXT_VERSION index f44d044dc..d1363a983 100644 --- a/python/knext/KNEXT_VERSION +++ b/python/knext/KNEXT_VERSION @@ -1 +1 @@ -0.0.3.20241022.2 +0.6.0.20241127.1 diff --git a/python/knext/knext/__init__.py b/python/knext/knext/__init__.py index 368d87015..74976673b 100644 --- a/python/knext/knext/__init__.py +++ b/python/knext/knext/__init__.py @@ -11,7 +11,7 @@ __package_name__ = "openspg-knext" -__version__ = "0.0.3.20241022.2" +__version__ = "0.6.0.20241127.1" from knext.common.env import init_env diff --git a/python/knext/knext/common/rest/models/__init__.py b/python/knext/knext/common/rest/models/__init__.py index 616e15f03..ca17c13e8 100644 --- a/python/knext/knext/common/rest/models/__init__.py +++ b/python/knext/knext/common/rest/models/__init__.py @@ -14,5 +14,5 @@ from knext.reasoner.rest.models import * from knext.project.rest.models import * from knext.search.rest.models import * -from knext.graph_algo.rest.models import * +from knext.graph.rest.models import * from knext.thinker.rest.models import * diff --git a/python/knext/knext/graph/__init__.py b/python/knext/knext/graph/__init__.py new file mode 100644 index 000000000..09c5daee3 --- /dev/null +++ b/python/knext/knext/graph/__init__.py @@ -0,0 +1,58 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +# flake8: noqa + +""" + knext + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +__version__ = "1.0.0" + +# import apis into sdk package +from knext.graph.rest.graph_api import GraphApi + + +# import models into model package +from knext.graph.rest.models.get_page_rank_scores_request import ( + GetPageRankScoresRequest, +) +from knext.graph.rest.models.get_page_rank_scores_request_start_nodes import ( + GetPageRankScoresRequestStartNodes, +) +from knext.graph.rest.models.page_rank_score_instance import PageRankScoreInstance +from knext.graph.rest.models.delete_vertex_request import DeleteVertexRequest +from knext.graph.rest.models.delete_edge_request import DeleteEdgeRequest +from knext.graph.rest.models.edge_record_instance import EdgeRecordInstance +from knext.graph.rest.models.upsert_vertex_request import UpsertVertexRequest +from knext.graph.rest.models.upsert_edge_request import UpsertEdgeRequest +from knext.graph.rest.models.vertex_record_instance import VertexRecordInstance +from knext.graph.rest.models.writer_graph_request import WriterGraphRequest +from knext.graph.rest.models.edge_record import EdgeRecord +from knext.graph.rest.models.edge_type_name import EdgeTypeName +from knext.graph.rest.models.expend_one_hop_request import ExpendOneHopRequest +from knext.graph.rest.models.lpg_property_record import LpgPropertyRecord +from knext.graph.rest.models.query_vertex_request import QueryVertexRequest +from knext.graph.rest.models.query_vertex_response import QueryVertexResponse +from knext.graph.rest.models.batch_query_vertex_request import BatchQueryVertexRequest +from knext.graph.rest.models.batch_query_vertex_response import BatchQueryVertexResponse +from knext.graph.rest.models.vertex_record import VertexRecord +from knext.graph.rest.models.expend_one_hop_response import ExpendOneHopResponse diff --git a/python/knext/knext/graph_algo/client.py b/python/knext/knext/graph/client.py similarity index 70% rename from python/knext/knext/graph_algo/client.py rename to python/knext/knext/graph/client.py index 07fb5e7f9..baa13517e 100644 --- a/python/knext/knext/graph_algo/client.py +++ b/python/knext/knext/graph/client.py @@ -13,15 +13,19 @@ from knext.common.base.client import Client from knext.common.rest import ApiClient, Configuration -from knext.graph_algo import ( +from knext.graph import ( + rest, GetPageRankScoresRequest, GetPageRankScoresRequestStartNodes, WriterGraphRequest, + QueryVertexRequest, + BatchQueryVertexRequest, + ExpendOneHopRequest, + EdgeTypeName, ) -from knext.graph_algo import rest -class GraphAlgoClient(Client): +class GraphClient(Client): """ """ def __init__(self, host_addr: str = None, project_id: int = None): @@ -67,9 +71,39 @@ def write_graph(self, sub_graph: dict, operation: str, lead_to_builder: bool): ) self._rest_client.graph_writer_graph_post(writer_graph_request=request) + def query_vertex(self, type_name: str, biz_id: str): + request = QueryVertexRequest( + project_id=self._project_id, type_name=type_name, biz_id=biz_id + ) + return self._rest_client.graph_query_vertex_post(query_vertex_request=request) + + def batch_query_vertex(self, type_name: str, biz_ids: List[str]): + request = BatchQueryVertexRequest( + project_id=self._project_id, type_name=type_name, biz_ids=biz_ids + ) + return self._rest_client.graph_batch_query_vertex_post( + batch_query_vertex_request=request + ) + + def expend_one_hop( + self, + type_name: str, + biz_id: str, + edge_type_name_constraint: List[EdgeTypeName] = None, + ): + request = ExpendOneHopRequest( + project_id=self._project_id, + type_name=type_name, + biz_id=biz_id, + edge_type_name_constraint=edge_type_name_constraint, + ) + return self._rest_client.graph_expend_one_hop_post( + expend_one_hop_request=request + ) + if __name__ == "__main__": - sc = GraphAlgoClient("http://127.0.0.1:8887", 4) + sc = GraphClient("http://127.0.0.1:8887", 4) out = sc.calculate_pagerank_scores( "Entity", [{"name": "Anxiety_and_nervousness", "type": "Entity"}] ) diff --git a/python/knext/knext/graph/rest/__init__.py b/python/knext/knext/graph/rest/__init__.py new file mode 100644 index 000000000..09c5daee3 --- /dev/null +++ b/python/knext/knext/graph/rest/__init__.py @@ -0,0 +1,58 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +# flake8: noqa + +""" + knext + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +__version__ = "1.0.0" + +# import apis into sdk package +from knext.graph.rest.graph_api import GraphApi + + +# import models into model package +from knext.graph.rest.models.get_page_rank_scores_request import ( + GetPageRankScoresRequest, +) +from knext.graph.rest.models.get_page_rank_scores_request_start_nodes import ( + GetPageRankScoresRequestStartNodes, +) +from knext.graph.rest.models.page_rank_score_instance import PageRankScoreInstance +from knext.graph.rest.models.delete_vertex_request import DeleteVertexRequest +from knext.graph.rest.models.delete_edge_request import DeleteEdgeRequest +from knext.graph.rest.models.edge_record_instance import EdgeRecordInstance +from knext.graph.rest.models.upsert_vertex_request import UpsertVertexRequest +from knext.graph.rest.models.upsert_edge_request import UpsertEdgeRequest +from knext.graph.rest.models.vertex_record_instance import VertexRecordInstance +from knext.graph.rest.models.writer_graph_request import WriterGraphRequest +from knext.graph.rest.models.edge_record import EdgeRecord +from knext.graph.rest.models.edge_type_name import EdgeTypeName +from knext.graph.rest.models.expend_one_hop_request import ExpendOneHopRequest +from knext.graph.rest.models.lpg_property_record import LpgPropertyRecord +from knext.graph.rest.models.query_vertex_request import QueryVertexRequest +from knext.graph.rest.models.query_vertex_response import QueryVertexResponse +from knext.graph.rest.models.batch_query_vertex_request import BatchQueryVertexRequest +from knext.graph.rest.models.batch_query_vertex_response import BatchQueryVertexResponse +from knext.graph.rest.models.vertex_record import VertexRecord +from knext.graph.rest.models.expend_one_hop_response import ExpendOneHopResponse diff --git a/python/knext/knext/graph_algo/rest/graph_api.py b/python/knext/knext/graph/rest/graph_api.py similarity index 67% rename from python/knext/knext/graph_algo/rest/graph_api.py rename to python/knext/knext/graph/rest/graph_api.py index 1256b12ea..887a7926a 100644 --- a/python/knext/knext/graph_algo/rest/graph_api.py +++ b/python/knext/knext/graph/rest/graph_api.py @@ -753,3 +753,357 @@ def graph_writer_graph_post_with_http_info(self, **kwargs): # noqa: E501 _request_timeout=local_var_params.get("_request_timeout"), collection_formats=collection_formats, ) + + def graph_expend_one_hop_post(self, **kwargs): # noqa: E501 + """expend_one_hop # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.graph_expend_one_hop_post(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param ExpendOneHopRequest expend_one_hop_request: + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: ExpendOneHopResponse + If the method is called asynchronously, + returns the request thread. + """ + kwargs["_return_http_data_only"] = True + return self.graph_expend_one_hop_post_with_http_info(**kwargs) # noqa: E501 + + def graph_expend_one_hop_post_with_http_info(self, **kwargs): # noqa: E501 + """expend_one_hop # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.graph_expend_one_hop_post_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param ExpendOneHopRequest expend_one_hop_request: + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: tuple(ExpendOneHopResponse, status_code(int), headers(HTTPHeaderDict)) + If the method is called asynchronously, + returns the request thread. + """ + + local_var_params = locals() + + all_params = ["expend_one_hop_request"] + all_params.extend( + [ + "async_req", + "_return_http_data_only", + "_preload_content", + "_request_timeout", + ] + ) + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method graph_expend_one_hop_post" % key + ) + local_var_params[key] = val + del local_var_params["kwargs"] + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if "expend_one_hop_request" in local_var_params: + body_params = local_var_params["expend_one_hop_request"] + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 + + # HTTP header `Content-Type` + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 + + # Authentication setting + auth_settings = [] # noqa: E501 + + return self.api_client.call_api( + "/graph/expendOneHop", + "POST", + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type="ExpendOneHopResponse", # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) + + def graph_query_vertex_post(self, **kwargs): # noqa: E501 + """query_vertex # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.graph_query_vertex_post(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param QueryVertexRequest query_vertex_request: + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: QueryVertexResponse + If the method is called asynchronously, + returns the request thread. + """ + kwargs["_return_http_data_only"] = True + return self.graph_query_vertex_post_with_http_info(**kwargs) # noqa: E501 + + def graph_query_vertex_post_with_http_info(self, **kwargs): # noqa: E501 + """query_vertex # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.graph_query_vertex_post_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param QueryVertexRequest query_vertex_request: + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: tuple(QueryVertexResponse, status_code(int), headers(HTTPHeaderDict)) + If the method is called asynchronously, + returns the request thread. + """ + + local_var_params = locals() + + all_params = ["query_vertex_request"] + all_params.extend( + [ + "async_req", + "_return_http_data_only", + "_preload_content", + "_request_timeout", + ] + ) + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method graph_query_vertex_post" % key + ) + local_var_params[key] = val + del local_var_params["kwargs"] + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if "query_vertex_request" in local_var_params: + body_params = local_var_params["query_vertex_request"] + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 + + # HTTP header `Content-Type` + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 + + # Authentication setting + auth_settings = [] # noqa: E501 + + return self.api_client.call_api( + "/graph/queryVertex", + "POST", + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type="QueryVertexResponse", # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) + + def graph_batch_query_vertex_post(self, **kwargs): # noqa: E501 + """batch_query_vertex # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.graph_batch_query_vertex_post(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param BatchQueryVertexRequest batch_query_vertex_request: + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: BatchQueryVertexResponse + If the method is called asynchronously, + returns the request thread. + """ + kwargs["_return_http_data_only"] = True + return self.graph_batch_query_vertex_post_with_http_info(**kwargs) # noqa: E501 + + def graph_batch_query_vertex_post_with_http_info(self, **kwargs): # noqa: E501 + """batch_query_vertex # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.graph_batch_query_vertex_post_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param BatchQueryVertexRequest batch_query_vertex_request: + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: tuple(BatchQueryVertexResponse, status_code(int), headers(HTTPHeaderDict)) + If the method is called asynchronously, + returns the request thread. + """ + + local_var_params = locals() + + all_params = ["batch_query_vertex_request"] + all_params.extend( + [ + "async_req", + "_return_http_data_only", + "_preload_content", + "_request_timeout", + ] + ) + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method graph_batch_query_vertex_post" % key + ) + local_var_params[key] = val + del local_var_params["kwargs"] + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if "batch_query_vertex_request" in local_var_params: + body_params = local_var_params["batch_query_vertex_request"] + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 + + # HTTP header `Content-Type` + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 + + # Authentication setting + auth_settings = [] # noqa: E501 + + return self.api_client.call_api( + "/graph/batchQueryVertex", + "POST", + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type="BatchQueryVertexResponse", # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) diff --git a/python/knext/knext/graph/rest/models/__init__.py b/python/knext/knext/graph/rest/models/__init__.py new file mode 100644 index 000000000..3a808f782 --- /dev/null +++ b/python/knext/knext/graph/rest/models/__init__.py @@ -0,0 +1,42 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +# flake8: noqa + +from __future__ import absolute_import + +# import models into model package +from knext.graph.rest.models.get_page_rank_scores_request import ( + GetPageRankScoresRequest, +) +from knext.graph.rest.models.get_page_rank_scores_request_start_nodes import ( + GetPageRankScoresRequestStartNodes, +) +from knext.graph.rest.models.page_rank_score_instance import PageRankScoreInstance +from knext.graph.rest.models.delete_vertex_request import DeleteVertexRequest +from knext.graph.rest.models.delete_edge_request import DeleteEdgeRequest +from knext.graph.rest.models.edge_record_instance import EdgeRecordInstance +from knext.graph.rest.models.upsert_vertex_request import UpsertVertexRequest +from knext.graph.rest.models.upsert_edge_request import UpsertEdgeRequest +from knext.graph.rest.models.vertex_record_instance import VertexRecordInstance +from knext.graph.rest.models.writer_graph_request import WriterGraphRequest +from knext.graph.rest.models.edge_record import EdgeRecord +from knext.graph.rest.models.edge_type_name import EdgeTypeName +from knext.graph.rest.models.expend_one_hop_request import ExpendOneHopRequest +from knext.graph.rest.models.lpg_property_record import LpgPropertyRecord +from knext.graph.rest.models.query_vertex_request import QueryVertexRequest +from knext.graph.rest.models.query_vertex_response import QueryVertexResponse +from knext.graph.rest.models.batch_query_vertex_request import BatchQueryVertexRequest +from knext.graph.rest.models.batch_query_vertex_response import BatchQueryVertexResponse +from knext.graph.rest.models.vertex_record import VertexRecord +from knext.graph.rest.models.expend_one_hop_response import ExpendOneHopResponse diff --git a/python/knext/knext/graph/rest/models/batch_query_vertex_request.py b/python/knext/knext/graph/rest/models/batch_query_vertex_request.py new file mode 100644 index 000000000..e120eabae --- /dev/null +++ b/python/knext/knext/graph/rest/models/batch_query_vertex_request.py @@ -0,0 +1,202 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +""" + knext + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from knext.common.rest.configuration import Configuration + + +class BatchQueryVertexRequest(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = {"project_id": "int", "type_name": "str", "biz_ids": "list[str]"} + + attribute_map = { + "project_id": "projectId", + "type_name": "typeName", + "biz_ids": "bizIds", + } + + def __init__( + self, + project_id=None, + type_name=None, + biz_ids=None, + local_vars_configuration=None, + ): # noqa: E501 + """BatchQueryVertexRequest - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._project_id = None + self._type_name = None + self._biz_ids = None + self.discriminator = None + + self.project_id = project_id + self.type_name = type_name + self.biz_ids = biz_ids + + @property + def project_id(self): + """Gets the project_id of this BatchQueryVertexRequest. # noqa: E501 + + + :return: The project_id of this BatchQueryVertexRequest. # noqa: E501 + :rtype: int + """ + return self._project_id + + @project_id.setter + def project_id(self, project_id): + """Sets the project_id of this BatchQueryVertexRequest. + + + :param project_id: The project_id of this BatchQueryVertexRequest. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation and project_id is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `project_id`, must not be `None`" + ) # noqa: E501 + + self._project_id = project_id + + @property + def type_name(self): + """Gets the type_name of this BatchQueryVertexRequest. # noqa: E501 + + + :return: The type_name of this BatchQueryVertexRequest. # noqa: E501 + :rtype: str + """ + return self._type_name + + @type_name.setter + def type_name(self, type_name): + """Sets the type_name of this BatchQueryVertexRequest. + + + :param type_name: The type_name of this BatchQueryVertexRequest. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and type_name is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `type_name`, must not be `None`" + ) # noqa: E501 + + self._type_name = type_name + + @property + def biz_ids(self): + """Gets the biz_ids of this BatchQueryVertexRequest. # noqa: E501 + + + :return: The biz_ids of this BatchQueryVertexRequest. # noqa: E501 + :rtype: list[str] + """ + return self._biz_ids + + @biz_ids.setter + def biz_ids(self, biz_ids): + """Sets the biz_ids of this BatchQueryVertexRequest. + + + :param biz_ids: The biz_ids of this BatchQueryVertexRequest. # noqa: E501 + :type: list[str] + """ + if ( + self.local_vars_configuration.client_side_validation and biz_ids is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `biz_ids`, must not be `None`" + ) # noqa: E501 + + self._biz_ids = biz_ids + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, BatchQueryVertexRequest): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, BatchQueryVertexRequest): + return True + + return self.to_dict() != other.to_dict() diff --git a/python/knext/knext/graph/rest/models/batch_query_vertex_response.py b/python/knext/knext/graph/rest/models/batch_query_vertex_response.py new file mode 100644 index 000000000..28466d9f5 --- /dev/null +++ b/python/knext/knext/graph/rest/models/batch_query_vertex_response.py @@ -0,0 +1,134 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +""" + knext + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from knext.common.rest.configuration import Configuration + + +class BatchQueryVertexResponse(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = {"vertices": "list[VertexRecord]"} + + attribute_map = {"vertices": "vertices"} + + def __init__(self, vertices=None, local_vars_configuration=None): # noqa: E501 + """BatchQueryVertexResponse - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._vertices = None + self.discriminator = None + + self.vertices = vertices + + @property + def vertices(self): + """Gets the vertices of this BatchQueryVertexResponse. # noqa: E501 + + + :return: The vertices of this BatchQueryVertexResponse. # noqa: E501 + :rtype: list[VertexRecord] + """ + return self._vertices + + @vertices.setter + def vertices(self, vertices): + """Sets the vertices of this BatchQueryVertexResponse. + + + :param vertices: The vertices of this BatchQueryVertexResponse. # noqa: E501 + :type: list[VertexRecord] + """ + if ( + self.local_vars_configuration.client_side_validation and vertices is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `vertices`, must not be `None`" + ) # noqa: E501 + + self._vertices = vertices + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, BatchQueryVertexResponse): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, BatchQueryVertexResponse): + return True + + return self.to_dict() != other.to_dict() diff --git a/python/knext/knext/graph_algo/rest/models/delete_edge_request.py b/python/knext/knext/graph/rest/models/delete_edge_request.py similarity index 100% rename from python/knext/knext/graph_algo/rest/models/delete_edge_request.py rename to python/knext/knext/graph/rest/models/delete_edge_request.py diff --git a/python/knext/knext/graph_algo/rest/models/delete_vertex_request.py b/python/knext/knext/graph/rest/models/delete_vertex_request.py similarity index 100% rename from python/knext/knext/graph_algo/rest/models/delete_vertex_request.py rename to python/knext/knext/graph/rest/models/delete_vertex_request.py diff --git a/python/knext/knext/graph/rest/models/edge_record.py b/python/knext/knext/graph/rest/models/edge_record.py new file mode 100644 index 000000000..12414040f --- /dev/null +++ b/python/knext/knext/graph/rest/models/edge_record.py @@ -0,0 +1,245 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +""" + knext + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from knext.common.rest.configuration import Configuration + + +class EdgeRecord(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + "record_type": "str", + "edge_type": "EdgeTypeName", + "src_id": "str", + "dst_id": "str", + "properties": "list[LpgPropertyRecord]", + } + + attribute_map = { + "record_type": "recordType", + "edge_type": "edgeType", + "src_id": "srcId", + "dst_id": "dstId", + "properties": "properties", + } + + def __init__( + self, + record_type=None, + edge_type=None, + src_id=None, + dst_id=None, + properties=None, + local_vars_configuration=None, + ): # noqa: E501 + """EdgeRecord - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._record_type = None + self._edge_type = None + self._src_id = None + self._dst_id = None + self._properties = None + self.discriminator = None + + if record_type is not None: + self.record_type = record_type + if edge_type is not None: + self.edge_type = edge_type + if src_id is not None: + self.src_id = src_id + if dst_id is not None: + self.dst_id = dst_id + if properties is not None: + self.properties = properties + + @property + def record_type(self): + """Gets the record_type of this EdgeRecord. # noqa: E501 + + + :return: The record_type of this EdgeRecord. # noqa: E501 + :rtype: str + """ + return self._record_type + + @record_type.setter + def record_type(self, record_type): + """Sets the record_type of this EdgeRecord. + + + :param record_type: The record_type of this EdgeRecord. # noqa: E501 + :type: str + """ + + self._record_type = record_type + + @property + def edge_type(self): + """Gets the edge_type of this EdgeRecord. # noqa: E501 + + + :return: The edge_type of this EdgeRecord. # noqa: E501 + :rtype: EdgeTypeName + """ + return self._edge_type + + @edge_type.setter + def edge_type(self, edge_type): + """Sets the edge_type of this EdgeRecord. + + + :param edge_type: The edge_type of this EdgeRecord. # noqa: E501 + :type: EdgeTypeName + """ + + self._edge_type = edge_type + + @property + def src_id(self): + """Gets the src_id of this EdgeRecord. # noqa: E501 + + + :return: The src_id of this EdgeRecord. # noqa: E501 + :rtype: str + """ + return self._src_id + + @src_id.setter + def src_id(self, src_id): + """Sets the src_id of this EdgeRecord. + + + :param src_id: The src_id of this EdgeRecord. # noqa: E501 + :type: str + """ + + self._src_id = src_id + + @property + def dst_id(self): + """Gets the dst_id of this EdgeRecord. # noqa: E501 + + + :return: The dst_id of this EdgeRecord. # noqa: E501 + :rtype: str + """ + return self._dst_id + + @dst_id.setter + def dst_id(self, dst_id): + """Sets the dst_id of this EdgeRecord. + + + :param dst_id: The dst_id of this EdgeRecord. # noqa: E501 + :type: str + """ + + self._dst_id = dst_id + + @property + def properties(self): + """Gets the properties of this EdgeRecord. # noqa: E501 + + + :return: The properties of this EdgeRecord. # noqa: E501 + :rtype: list[LpgPropertyRecord] + """ + return self._properties + + @properties.setter + def properties(self, properties): + """Sets the properties of this EdgeRecord. + + + :param properties: The properties of this EdgeRecord. # noqa: E501 + :type: list[LpgPropertyRecord] + """ + + self._properties = properties + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, EdgeRecord): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, EdgeRecord): + return True + + return self.to_dict() != other.to_dict() diff --git a/python/knext/knext/graph_algo/rest/models/edge_record_instance.py b/python/knext/knext/graph/rest/models/edge_record_instance.py similarity index 100% rename from python/knext/knext/graph_algo/rest/models/edge_record_instance.py rename to python/knext/knext/graph/rest/models/edge_record_instance.py diff --git a/python/knext/knext/graph/rest/models/edge_type_name.py b/python/knext/knext/graph/rest/models/edge_type_name.py new file mode 100644 index 000000000..fcdeafa0c --- /dev/null +++ b/python/knext/knext/graph/rest/models/edge_type_name.py @@ -0,0 +1,208 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +""" + knext + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from knext.common.rest.configuration import Configuration + + +class EdgeTypeName(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + "start_vertex_type": "str", + "edge_label": "str", + "end_vertex_type": "str", + } + + attribute_map = { + "start_vertex_type": "startVertexType", + "edge_label": "edgeLabel", + "end_vertex_type": "endVertexType", + } + + def __init__( + self, + start_vertex_type=None, + edge_label=None, + end_vertex_type=None, + local_vars_configuration=None, + ): # noqa: E501 + """EdgeTypeName - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._start_vertex_type = None + self._edge_label = None + self._end_vertex_type = None + self.discriminator = None + + self.start_vertex_type = start_vertex_type + self.edge_label = edge_label + self.end_vertex_type = end_vertex_type + + @property + def start_vertex_type(self): + """Gets the start_vertex_type of this EdgeTypeName. # noqa: E501 + + + :return: The start_vertex_type of this EdgeTypeName. # noqa: E501 + :rtype: str + """ + return self._start_vertex_type + + @start_vertex_type.setter + def start_vertex_type(self, start_vertex_type): + """Sets the start_vertex_type of this EdgeTypeName. + + + :param start_vertex_type: The start_vertex_type of this EdgeTypeName. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation + and start_vertex_type is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `start_vertex_type`, must not be `None`" + ) # noqa: E501 + + self._start_vertex_type = start_vertex_type + + @property + def edge_label(self): + """Gets the edge_label of this EdgeTypeName. # noqa: E501 + + + :return: The edge_label of this EdgeTypeName. # noqa: E501 + :rtype: str + """ + return self._edge_label + + @edge_label.setter + def edge_label(self, edge_label): + """Sets the edge_label of this EdgeTypeName. + + + :param edge_label: The edge_label of this EdgeTypeName. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and edge_label is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `edge_label`, must not be `None`" + ) # noqa: E501 + + self._edge_label = edge_label + + @property + def end_vertex_type(self): + """Gets the end_vertex_type of this EdgeTypeName. # noqa: E501 + + + :return: The end_vertex_type of this EdgeTypeName. # noqa: E501 + :rtype: str + """ + return self._end_vertex_type + + @end_vertex_type.setter + def end_vertex_type(self, end_vertex_type): + """Sets the end_vertex_type of this EdgeTypeName. + + + :param end_vertex_type: The end_vertex_type of this EdgeTypeName. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation + and end_vertex_type is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `end_vertex_type`, must not be `None`" + ) # noqa: E501 + + self._end_vertex_type = end_vertex_type + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, EdgeTypeName): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, EdgeTypeName): + return True + + return self.to_dict() != other.to_dict() diff --git a/python/knext/knext/graph/rest/models/expend_one_hop_request.py b/python/knext/knext/graph/rest/models/expend_one_hop_request.py new file mode 100644 index 000000000..94c339c54 --- /dev/null +++ b/python/knext/knext/graph/rest/models/expend_one_hop_request.py @@ -0,0 +1,232 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +""" + knext + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from knext.common.rest.configuration import Configuration + + +class ExpendOneHopRequest(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + "project_id": "int", + "type_name": "str", + "biz_id": "str", + "edge_type_name_constraint": "list[EdgeTypeName]", + } + + attribute_map = { + "project_id": "projectId", + "type_name": "typeName", + "biz_id": "bizId", + "edge_type_name_constraint": "edgeTypeNameConstraint", + } + + def __init__( + self, + project_id=None, + type_name=None, + biz_id=None, + edge_type_name_constraint=None, + local_vars_configuration=None, + ): # noqa: E501 + """ExpendOneHopRequest - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._project_id = None + self._type_name = None + self._biz_id = None + self._edge_type_name_constraint = None + self.discriminator = None + + self.project_id = project_id + self.type_name = type_name + self.biz_id = biz_id + self.edge_type_name_constraint = edge_type_name_constraint + + @property + def project_id(self): + """Gets the project_id of this ExpendOneHopRequest. # noqa: E501 + + + :return: The project_id of this ExpendOneHopRequest. # noqa: E501 + :rtype: int + """ + return self._project_id + + @project_id.setter + def project_id(self, project_id): + """Sets the project_id of this ExpendOneHopRequest. + + + :param project_id: The project_id of this ExpendOneHopRequest. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation and project_id is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `project_id`, must not be `None`" + ) # noqa: E501 + + self._project_id = project_id + + @property + def type_name(self): + """Gets the type_name of this ExpendOneHopRequest. # noqa: E501 + + + :return: The type_name of this ExpendOneHopRequest. # noqa: E501 + :rtype: str + """ + return self._type_name + + @type_name.setter + def type_name(self, type_name): + """Sets the type_name of this ExpendOneHopRequest. + + + :param type_name: The type_name of this ExpendOneHopRequest. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and type_name is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `type_name`, must not be `None`" + ) # noqa: E501 + + self._type_name = type_name + + @property + def biz_id(self): + """Gets the biz_id of this ExpendOneHopRequest. # noqa: E501 + + + :return: The biz_id of this ExpendOneHopRequest. # noqa: E501 + :rtype: str + """ + return self._biz_id + + @biz_id.setter + def biz_id(self, biz_id): + """Sets the biz_id of this ExpendOneHopRequest. + + + :param biz_id: The biz_id of this ExpendOneHopRequest. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and biz_id is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `biz_id`, must not be `None`" + ) # noqa: E501 + + self._biz_id = biz_id + + @property + def edge_type_name_constraint(self): + """Gets the edge_type_name_constraint of this ExpendOneHopRequest. # noqa: E501 + + + :return: The edge_type_name_constraint of this ExpendOneHopRequest. # noqa: E501 + :rtype: list[EdgeTypeName] + """ + return self._edge_type_name_constraint + + @edge_type_name_constraint.setter + def edge_type_name_constraint(self, edge_type_name_constraint): + """Sets the edge_type_name_constraint of this ExpendOneHopRequest. + + + :param edge_type_name_constraint: The edge_type_name_constraint of this ExpendOneHopRequest. # noqa: E501 + :type: list[EdgeTypeName] + """ + + self._edge_type_name_constraint = edge_type_name_constraint + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, ExpendOneHopRequest): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, ExpendOneHopRequest): + return True + + return self.to_dict() != other.to_dict() diff --git a/python/knext/knext/graph/rest/models/expend_one_hop_response.py b/python/knext/knext/graph/rest/models/expend_one_hop_response.py new file mode 100644 index 000000000..fdc036655 --- /dev/null +++ b/python/knext/knext/graph/rest/models/expend_one_hop_response.py @@ -0,0 +1,191 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +""" + knext + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from knext.common.rest.configuration import Configuration + + +class ExpendOneHopResponse(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + "vertex": "VertexRecord", + "edges": "list[EdgeRecord]", + "adjacent_vertices": "list[VertexRecord]", + } + + attribute_map = { + "vertex": "vertex", + "edges": "edges", + "adjacent_vertices": "adjacentVertices", + } + + def __init__( + self, + vertex=None, + edges=None, + adjacent_vertices=None, + local_vars_configuration=None, + ): # noqa: E501 + """ExpendOneHopResponse - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._vertex = None + self._edges = None + self._adjacent_vertices = None + self.discriminator = None + + if vertex is not None: + self.vertex = vertex + if edges is not None: + self.edges = edges + if adjacent_vertices is not None: + self.adjacent_vertices = adjacent_vertices + + @property + def vertex(self): + """Gets the vertex of this ExpendOneHopResponse. # noqa: E501 + + + :return: The vertex of this ExpendOneHopResponse. # noqa: E501 + :rtype: VertexRecord + """ + return self._vertex + + @vertex.setter + def vertex(self, vertex): + """Sets the vertex of this ExpendOneHopResponse. + + + :param vertex: The vertex of this ExpendOneHopResponse. # noqa: E501 + :type: VertexRecord + """ + + self._vertex = vertex + + @property + def edges(self): + """Gets the edges of this ExpendOneHopResponse. # noqa: E501 + + + :return: The edges of this ExpendOneHopResponse. # noqa: E501 + :rtype: list[EdgeRecord] + """ + return self._edges + + @edges.setter + def edges(self, edges): + """Sets the edges of this ExpendOneHopResponse. + + + :param edges: The edges of this ExpendOneHopResponse. # noqa: E501 + :type: list[EdgeRecord] + """ + + self._edges = edges + + @property + def adjacent_vertices(self): + """Gets the adjacent_vertices of this ExpendOneHopResponse. # noqa: E501 + + + :return: The adjacent_vertices of this ExpendOneHopResponse. # noqa: E501 + :rtype: list[VertexRecord] + """ + return self._adjacent_vertices + + @adjacent_vertices.setter + def adjacent_vertices(self, adjacent_vertices): + """Sets the adjacent_vertices of this ExpendOneHopResponse. + + + :param adjacent_vertices: The adjacent_vertices of this ExpendOneHopResponse. # noqa: E501 + :type: list[VertexRecord] + """ + + self._adjacent_vertices = adjacent_vertices + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, ExpendOneHopResponse): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, ExpendOneHopResponse): + return True + + return self.to_dict() != other.to_dict() diff --git a/python/knext/knext/graph_algo/rest/models/get_page_rank_scores_request.py b/python/knext/knext/graph/rest/models/get_page_rank_scores_request.py similarity index 100% rename from python/knext/knext/graph_algo/rest/models/get_page_rank_scores_request.py rename to python/knext/knext/graph/rest/models/get_page_rank_scores_request.py diff --git a/python/knext/knext/graph_algo/rest/models/get_page_rank_scores_request_start_nodes.py b/python/knext/knext/graph/rest/models/get_page_rank_scores_request_start_nodes.py similarity index 100% rename from python/knext/knext/graph_algo/rest/models/get_page_rank_scores_request_start_nodes.py rename to python/knext/knext/graph/rest/models/get_page_rank_scores_request_start_nodes.py diff --git a/python/knext/knext/graph/rest/models/lpg_property_record.py b/python/knext/knext/graph/rest/models/lpg_property_record.py new file mode 100644 index 000000000..33668e0a5 --- /dev/null +++ b/python/knext/knext/graph/rest/models/lpg_property_record.py @@ -0,0 +1,160 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +""" + knext + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from knext.common.rest.configuration import Configuration + + +class LpgPropertyRecord(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = {"name": "str", "value": "str"} + + attribute_map = {"name": "name", "value": "value"} + + def __init__( + self, name=None, value=None, local_vars_configuration=None + ): # noqa: E501 + """LpgPropertyRecord - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._name = None + self._value = None + self.discriminator = None + + self.name = name + if value is not None: + self.value = value + + @property + def name(self): + """Gets the name of this LpgPropertyRecord. # noqa: E501 + + + :return: The name of this LpgPropertyRecord. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this LpgPropertyRecord. + + + :param name: The name of this LpgPropertyRecord. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and name is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `name`, must not be `None`" + ) # noqa: E501 + + self._name = name + + @property + def value(self): + """Gets the value of this LpgPropertyRecord. # noqa: E501 + + + :return: The value of this LpgPropertyRecord. # noqa: E501 + :rtype: str + """ + return self._value + + @value.setter + def value(self, value): + """Sets the value of this LpgPropertyRecord. + + + :param value: The value of this LpgPropertyRecord. # noqa: E501 + :type: str + """ + + self._value = value + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, LpgPropertyRecord): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, LpgPropertyRecord): + return True + + return self.to_dict() != other.to_dict() diff --git a/python/knext/knext/graph_algo/rest/models/page_rank_score_instance.py b/python/knext/knext/graph/rest/models/page_rank_score_instance.py similarity index 100% rename from python/knext/knext/graph_algo/rest/models/page_rank_score_instance.py rename to python/knext/knext/graph/rest/models/page_rank_score_instance.py diff --git a/python/knext/knext/graph/rest/models/query_vertex_request.py b/python/knext/knext/graph/rest/models/query_vertex_request.py new file mode 100644 index 000000000..81ea26a6f --- /dev/null +++ b/python/knext/knext/graph/rest/models/query_vertex_request.py @@ -0,0 +1,202 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +""" + knext + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from knext.common.rest.configuration import Configuration + + +class QueryVertexRequest(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = {"project_id": "int", "type_name": "str", "biz_id": "str"} + + attribute_map = { + "project_id": "projectId", + "type_name": "typeName", + "biz_id": "bizId", + } + + def __init__( + self, + project_id=None, + type_name=None, + biz_id=None, + local_vars_configuration=None, + ): # noqa: E501 + """QueryVertexRequest - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._project_id = None + self._type_name = None + self._biz_id = None + self.discriminator = None + + self.project_id = project_id + self.type_name = type_name + self.biz_id = biz_id + + @property + def project_id(self): + """Gets the project_id of this QueryVertexRequest. # noqa: E501 + + + :return: The project_id of this QueryVertexRequest. # noqa: E501 + :rtype: int + """ + return self._project_id + + @project_id.setter + def project_id(self, project_id): + """Sets the project_id of this QueryVertexRequest. + + + :param project_id: The project_id of this QueryVertexRequest. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation and project_id is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `project_id`, must not be `None`" + ) # noqa: E501 + + self._project_id = project_id + + @property + def type_name(self): + """Gets the type_name of this QueryVertexRequest. # noqa: E501 + + + :return: The type_name of this QueryVertexRequest. # noqa: E501 + :rtype: str + """ + return self._type_name + + @type_name.setter + def type_name(self, type_name): + """Sets the type_name of this QueryVertexRequest. + + + :param type_name: The type_name of this QueryVertexRequest. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and type_name is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `type_name`, must not be `None`" + ) # noqa: E501 + + self._type_name = type_name + + @property + def biz_id(self): + """Gets the biz_id of this QueryVertexRequest. # noqa: E501 + + + :return: The biz_id of this QueryVertexRequest. # noqa: E501 + :rtype: str + """ + return self._biz_id + + @biz_id.setter + def biz_id(self, biz_id): + """Sets the biz_id of this QueryVertexRequest. + + + :param biz_id: The biz_id of this QueryVertexRequest. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and biz_id is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `biz_id`, must not be `None`" + ) # noqa: E501 + + self._biz_id = biz_id + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, QueryVertexRequest): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, QueryVertexRequest): + return True + + return self.to_dict() != other.to_dict() diff --git a/python/knext/knext/graph/rest/models/query_vertex_response.py b/python/knext/knext/graph/rest/models/query_vertex_response.py new file mode 100644 index 000000000..eb48a99d6 --- /dev/null +++ b/python/knext/knext/graph/rest/models/query_vertex_response.py @@ -0,0 +1,129 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +""" + knext + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from knext.common.rest.configuration import Configuration + + +class QueryVertexResponse(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = {"vertex": "VertexRecord"} + + attribute_map = {"vertex": "vertex"} + + def __init__(self, vertex=None, local_vars_configuration=None): # noqa: E501 + """QueryVertexResponse - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._vertex = None + self.discriminator = None + + if vertex is not None: + self.vertex = vertex + + @property + def vertex(self): + """Gets the vertex of this QueryVertexResponse. # noqa: E501 + + + :return: The vertex of this QueryVertexResponse. # noqa: E501 + :rtype: VertexRecord + """ + return self._vertex + + @vertex.setter + def vertex(self, vertex): + """Sets the vertex of this QueryVertexResponse. + + + :param vertex: The vertex of this QueryVertexResponse. # noqa: E501 + :type: VertexRecord + """ + + self._vertex = vertex + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, QueryVertexResponse): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, QueryVertexResponse): + return True + + return self.to_dict() != other.to_dict() diff --git a/python/knext/knext/graph_algo/rest/models/upsert_edge_request.py b/python/knext/knext/graph/rest/models/upsert_edge_request.py similarity index 100% rename from python/knext/knext/graph_algo/rest/models/upsert_edge_request.py rename to python/knext/knext/graph/rest/models/upsert_edge_request.py diff --git a/python/knext/knext/graph_algo/rest/models/upsert_vertex_request.py b/python/knext/knext/graph/rest/models/upsert_vertex_request.py similarity index 100% rename from python/knext/knext/graph_algo/rest/models/upsert_vertex_request.py rename to python/knext/knext/graph/rest/models/upsert_vertex_request.py diff --git a/python/knext/knext/graph/rest/models/vertex_record.py b/python/knext/knext/graph/rest/models/vertex_record.py new file mode 100644 index 000000000..9ed57e280 --- /dev/null +++ b/python/knext/knext/graph/rest/models/vertex_record.py @@ -0,0 +1,218 @@ +# coding: utf-8 +# Copyright 2023 OpenSPG Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. + + +""" + knext + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from knext.common.rest.configuration import Configuration + + +class VertexRecord(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + "record_type": "str", + "vertex_type": "str", + "id": "str", + "properties": "list[LpgPropertyRecord]", + } + + attribute_map = { + "record_type": "recordType", + "vertex_type": "vertexType", + "id": "id", + "properties": "properties", + } + + def __init__( + self, + record_type=None, + vertex_type=None, + id=None, + properties=None, + local_vars_configuration=None, + ): # noqa: E501 + """VertexRecord - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._record_type = None + self._vertex_type = None + self._id = None + self._properties = None + self.discriminator = None + + if record_type is not None: + self.record_type = record_type + if vertex_type is not None: + self.vertex_type = vertex_type + if id is not None: + self.id = id + if properties is not None: + self.properties = properties + + @property + def record_type(self): + """Gets the record_type of this VertexRecord. # noqa: E501 + + + :return: The record_type of this VertexRecord. # noqa: E501 + :rtype: str + """ + return self._record_type + + @record_type.setter + def record_type(self, record_type): + """Sets the record_type of this VertexRecord. + + + :param record_type: The record_type of this VertexRecord. # noqa: E501 + :type: str + """ + + self._record_type = record_type + + @property + def vertex_type(self): + """Gets the vertex_type of this VertexRecord. # noqa: E501 + + + :return: The vertex_type of this VertexRecord. # noqa: E501 + :rtype: str + """ + return self._vertex_type + + @vertex_type.setter + def vertex_type(self, vertex_type): + """Sets the vertex_type of this VertexRecord. + + + :param vertex_type: The vertex_type of this VertexRecord. # noqa: E501 + :type: str + """ + + self._vertex_type = vertex_type + + @property + def id(self): + """Gets the id of this VertexRecord. # noqa: E501 + + + :return: The id of this VertexRecord. # noqa: E501 + :rtype: str + """ + return self._id + + @id.setter + def id(self, id): + """Sets the id of this VertexRecord. + + + :param id: The id of this VertexRecord. # noqa: E501 + :type: str + """ + + self._id = id + + @property + def properties(self): + """Gets the properties of this VertexRecord. # noqa: E501 + + + :return: The properties of this VertexRecord. # noqa: E501 + :rtype: list[LpgPropertyRecord] + """ + return self._properties + + @properties.setter + def properties(self, properties): + """Sets the properties of this VertexRecord. + + + :param properties: The properties of this VertexRecord. # noqa: E501 + :type: list[LpgPropertyRecord] + """ + + self._properties = properties + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, VertexRecord): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, VertexRecord): + return True + + return self.to_dict() != other.to_dict() diff --git a/python/knext/knext/graph_algo/rest/models/vertex_record_instance.py b/python/knext/knext/graph/rest/models/vertex_record_instance.py similarity index 100% rename from python/knext/knext/graph_algo/rest/models/vertex_record_instance.py rename to python/knext/knext/graph/rest/models/vertex_record_instance.py diff --git a/python/knext/knext/graph_algo/rest/models/writer_graph_request.py b/python/knext/knext/graph/rest/models/writer_graph_request.py similarity index 100% rename from python/knext/knext/graph_algo/rest/models/writer_graph_request.py rename to python/knext/knext/graph/rest/models/writer_graph_request.py diff --git a/python/knext/knext/graph_algo/__init__.py b/python/knext/knext/graph_algo/__init__.py deleted file mode 100644 index b4afad6a7..000000000 --- a/python/knext/knext/graph_algo/__init__.py +++ /dev/null @@ -1,48 +0,0 @@ -# coding: utf-8 -# Copyright 2023 OpenSPG Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. - - -# flake8: noqa - -""" - knext - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 - - The version of the OpenAPI document: 1.0.0 - Generated by: https://openapi-generator.tech -""" - - -from __future__ import absolute_import - -__version__ = "1.0.0" - -# import apis into sdk package -from knext.graph_algo.rest.graph_api import GraphApi - - -# import models into model package -from knext.graph_algo.rest.models.get_page_rank_scores_request import ( - GetPageRankScoresRequest, -) -from knext.graph_algo.rest.models.get_page_rank_scores_request_start_nodes import ( - GetPageRankScoresRequestStartNodes, -) -from knext.graph_algo.rest.models.page_rank_score_instance import PageRankScoreInstance -from knext.graph_algo.rest.models.delete_vertex_request import DeleteVertexRequest -from knext.graph_algo.rest.models.delete_edge_request import DeleteEdgeRequest -from knext.graph_algo.rest.models.edge_record_instance import EdgeRecordInstance -from knext.graph_algo.rest.models.upsert_vertex_request import UpsertVertexRequest -from knext.graph_algo.rest.models.upsert_edge_request import UpsertEdgeRequest -from knext.graph_algo.rest.models.vertex_record_instance import VertexRecordInstance -from knext.graph_algo.rest.models.writer_graph_request import WriterGraphRequest diff --git a/python/knext/knext/graph_algo/rest/__init__.py b/python/knext/knext/graph_algo/rest/__init__.py deleted file mode 100644 index b4afad6a7..000000000 --- a/python/knext/knext/graph_algo/rest/__init__.py +++ /dev/null @@ -1,48 +0,0 @@ -# coding: utf-8 -# Copyright 2023 OpenSPG Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. - - -# flake8: noqa - -""" - knext - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 - - The version of the OpenAPI document: 1.0.0 - Generated by: https://openapi-generator.tech -""" - - -from __future__ import absolute_import - -__version__ = "1.0.0" - -# import apis into sdk package -from knext.graph_algo.rest.graph_api import GraphApi - - -# import models into model package -from knext.graph_algo.rest.models.get_page_rank_scores_request import ( - GetPageRankScoresRequest, -) -from knext.graph_algo.rest.models.get_page_rank_scores_request_start_nodes import ( - GetPageRankScoresRequestStartNodes, -) -from knext.graph_algo.rest.models.page_rank_score_instance import PageRankScoreInstance -from knext.graph_algo.rest.models.delete_vertex_request import DeleteVertexRequest -from knext.graph_algo.rest.models.delete_edge_request import DeleteEdgeRequest -from knext.graph_algo.rest.models.edge_record_instance import EdgeRecordInstance -from knext.graph_algo.rest.models.upsert_vertex_request import UpsertVertexRequest -from knext.graph_algo.rest.models.upsert_edge_request import UpsertEdgeRequest -from knext.graph_algo.rest.models.vertex_record_instance import VertexRecordInstance -from knext.graph_algo.rest.models.writer_graph_request import WriterGraphRequest diff --git a/python/knext/knext/graph_algo/rest/models/__init__.py b/python/knext/knext/graph_algo/rest/models/__init__.py deleted file mode 100644 index 2c1ef91e5..000000000 --- a/python/knext/knext/graph_algo/rest/models/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding: utf-8 -# Copyright 2023 OpenSPG Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. - - -# flake8: noqa - -from __future__ import absolute_import - -# import models into model package -from knext.graph_algo.rest.models.get_page_rank_scores_request import ( - GetPageRankScoresRequest, -) -from knext.graph_algo.rest.models.get_page_rank_scores_request_start_nodes import ( - GetPageRankScoresRequestStartNodes, -) -from knext.graph_algo.rest.models.page_rank_score_instance import PageRankScoreInstance -from knext.graph_algo.rest.models.delete_vertex_request import DeleteVertexRequest -from knext.graph_algo.rest.models.delete_edge_request import DeleteEdgeRequest -from knext.graph_algo.rest.models.edge_record_instance import EdgeRecordInstance -from knext.graph_algo.rest.models.upsert_vertex_request import UpsertVertexRequest -from knext.graph_algo.rest.models.upsert_edge_request import UpsertEdgeRequest -from knext.graph_algo.rest.models.vertex_record_instance import VertexRecordInstance -from knext.graph_algo.rest.models.writer_graph_request import WriterGraphRequest diff --git a/python/knext/knext/search/client.py b/python/knext/knext/search/client.py index 6c5c08f03..4b28fe134 100644 --- a/python/knext/knext/search/client.py +++ b/python/knext/knext/search/client.py @@ -28,14 +28,18 @@ def __init__(self, host_addr: str = None, project_id: int = None): api_client=ApiClient(configuration=Configuration(host=host_addr)) ) - def search_text(self, query_string, label_constraints=None, topk=10): - req = TextSearchRequest(self._project_id, query_string, label_constraints, topk) + def search_text(self, query_string, label_constraints=None, topk=10, params=None): + req = TextSearchRequest( + self._project_id, query_string, label_constraints, topk, params + ) records = self._rest_client.search_text_post(text_search_request=req) return [idx_record_to_dict(record) for record in records] - def search_vector(self, label, property_key, query_vector, topk=10, ef_search=None): + def search_vector( + self, label, property_key, query_vector, topk=10, ef_search=None, params=None + ): req = VectorSearchRequest( - self._project_id, label, property_key, query_vector, ef_search, topk + self._project_id, label, property_key, query_vector, ef_search, topk, params ) records = self._rest_client.search_vector_post(vector_search_request=req) return [idx_record_to_dict(record) for record in records] diff --git a/python/knext/knext/search/rest/models/text_search_request.py b/python/knext/knext/search/rest/models/text_search_request.py index 360ba9a93..046301ee0 100644 --- a/python/knext/knext/search/rest/models/text_search_request.py +++ b/python/knext/knext/search/rest/models/text_search_request.py @@ -10,7 +10,6 @@ # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express # or implied. - """ knext @@ -48,6 +47,7 @@ class TextSearchRequest(object): "query_string": "str", "label_constraints": "list[str]", "topk": "int", + "params": "object", } attribute_map = { @@ -55,6 +55,7 @@ class TextSearchRequest(object): "query_string": "queryString", "label_constraints": "labelConstraints", "topk": "topk", + "params": "params", } def __init__( @@ -63,6 +64,7 @@ def __init__( query_string=None, label_constraints=None, topk=None, + params=None, local_vars_configuration=None, ): # noqa: E501 """TextSearchRequest - a model defined in OpenAPI""" # noqa: E501 @@ -74,12 +76,16 @@ def __init__( self._query_string = None self._label_constraints = None self._topk = None + self._params = None self.discriminator = None self.project_id = project_id self.query_string = query_string - self.label_constraints = label_constraints + if label_constraints is not None: + self.label_constraints = label_constraints self.topk = topk + if params is not None: + self.params = params @property def project_id(self): @@ -154,6 +160,7 @@ def label_constraints(self, label_constraints): :param label_constraints: The label_constraints of this TextSearchRequest. # noqa: E501 :type: list[str] """ + self._label_constraints = label_constraints @property @@ -183,6 +190,27 @@ def topk(self, topk): self._topk = topk + @property + def params(self): + """Gets the params of this TextSearchRequest. # noqa: E501 + + + :return: The params of this TextSearchRequest. # noqa: E501 + :rtype: object + """ + return self._params + + @params.setter + def params(self, params): + """Sets the params of this TextSearchRequest. + + + :param params: The params of this TextSearchRequest. # noqa: E501 + :type: object + """ + + self._params = params + def to_dict(self): """Returns the model properties as a dict""" result = {} diff --git a/python/knext/knext/search/rest/models/vector_search_request.py b/python/knext/knext/search/rest/models/vector_search_request.py index 641f8c2b7..9475adbaf 100644 --- a/python/knext/knext/search/rest/models/vector_search_request.py +++ b/python/knext/knext/search/rest/models/vector_search_request.py @@ -10,7 +10,6 @@ # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express # or implied. - """ knext @@ -50,6 +49,7 @@ class VectorSearchRequest(object): "query_vector": "list[float]", "ef_search": "int", "topk": "int", + "params": "object", } attribute_map = { @@ -59,6 +59,7 @@ class VectorSearchRequest(object): "query_vector": "queryVector", "ef_search": "efSearch", "topk": "topk", + "params": "params", } def __init__( @@ -69,6 +70,7 @@ def __init__( query_vector=None, ef_search=None, topk=None, + params=None, local_vars_configuration=None, ): # noqa: E501 """VectorSearchRequest - a model defined in OpenAPI""" # noqa: E501 @@ -82,6 +84,7 @@ def __init__( self._query_vector = None self._ef_search = None self._topk = None + self._params = None self.discriminator = None self.project_id = project_id @@ -91,6 +94,8 @@ def __init__( if ef_search is not None: self.ef_search = ef_search self.topk = topk + if params is not None: + self.params = params @property def project_id(self): @@ -250,6 +255,27 @@ def topk(self, topk): self._topk = topk + @property + def params(self): + """Gets the params of this VectorSearchRequest. # noqa: E501 + + + :return: The params of this VectorSearchRequest. # noqa: E501 + :rtype: object + """ + return self._params + + @params.setter + def params(self, params): + """Sets the params of this VectorSearchRequest. + + + :param params: The params of this VectorSearchRequest. # noqa: E501 + :type: object + """ + + self._params = params + def to_dict(self): """Returns the model properties as a dict""" result = {} diff --git a/server/api/facade/pom.xml b/server/api/facade/pom.xml index 633d159dd..3b884f5bb 100644 --- a/server/api/facade/pom.xml +++ b/server/api/facade/pom.xml @@ -29,12 +29,8 @@ core-schema-model - com.google.code.gson - gson - - - org.danilopianini - gson-extras + com.antgroup.openspg.cloudext + cloudext-interface-graph-store diff --git a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/ApiConstants.java b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/ApiConstants.java index 42db1bd76..7ebcc73e1 100644 --- a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/ApiConstants.java +++ b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/ApiConstants.java @@ -21,10 +21,7 @@ public class ApiConstants { public static final String TOKEN = "token"; public static final String ENV = "env"; - public static final String ACCESS_ID = "accessId"; - public static final String ACCESS_KEY = "accessKey"; public static final String HOST = "host"; - public static final String TIMEOUT = "timeout"; public static final String PORT = "port"; public static final String SCHEME = "scheme"; diff --git a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/BatchQueryVertexRequest.java b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/BatchQueryVertexRequest.java new file mode 100644 index 000000000..23a88763a --- /dev/null +++ b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/BatchQueryVertexRequest.java @@ -0,0 +1,29 @@ +/* + * Copyright 2023 OpenSPG Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. + */ + +package com.antgroup.openspg.server.api.facade.dto.service.request; + +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class BatchQueryVertexRequest { + + private Long projectId; + private String typeName; + private List bizIds; +} diff --git a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/ExpendOneHopRequest.java b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/ExpendOneHopRequest.java new file mode 100644 index 000000000..2b8885364 --- /dev/null +++ b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/ExpendOneHopRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2023 OpenSPG Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. + */ + +package com.antgroup.openspg.server.api.facade.dto.service.request; + +import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.schema.EdgeTypeName; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ExpendOneHopRequest { + + private Long projectId; + private String typeName; + private String bizId; + private List edgeTypeNameConstraint; +} diff --git a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/QueryVertexRequest.java b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/QueryVertexRequest.java new file mode 100644 index 000000000..987eb554b --- /dev/null +++ b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/QueryVertexRequest.java @@ -0,0 +1,28 @@ +/* + * Copyright 2023 OpenSPG Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. + */ + +package com.antgroup.openspg.server.api.facade.dto.service.request; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class QueryVertexRequest { + + private Long projectId; + private String typeName; + private String bizId; +} diff --git a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/TextSearchRequest.java b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/TextSearchRequest.java index 8b686214e..2686e1e37 100644 --- a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/TextSearchRequest.java +++ b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/TextSearchRequest.java @@ -13,13 +13,19 @@ package com.antgroup.openspg.server.api.facade.dto.service.request; +import java.util.Map; import java.util.Set; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; @Data +@AllArgsConstructor +@NoArgsConstructor public class TextSearchRequest { private Long projectId; private String queryString; private Set labelConstraints; private Integer topk; + private Map params; } diff --git a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/VectorSearchRequest.java b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/VectorSearchRequest.java index 75fc9649c..b3e22802e 100644 --- a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/VectorSearchRequest.java +++ b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/request/VectorSearchRequest.java @@ -13,14 +13,20 @@ package com.antgroup.openspg.server.api.facade.dto.service.request; +import java.util.Map; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; @Data +@NoArgsConstructor +@AllArgsConstructor public class VectorSearchRequest { private Long projectId; - private final String label; - private final String propertyKey; - private final float[] queryVector; - private final Integer efSearch; - private final Integer topk; + private String label; + private String propertyKey; + private float[] queryVector; + private Integer efSearch; + private Integer topk; + private Map params; } diff --git a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/response/BatchQueryVertexResponse.java b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/response/BatchQueryVertexResponse.java new file mode 100644 index 000000000..efd8020b3 --- /dev/null +++ b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/response/BatchQueryVertexResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright 2023 OpenSPG Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. + */ + +package com.antgroup.openspg.server.api.facade.dto.service.response; + +import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.VertexRecord; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class BatchQueryVertexResponse { + + private List vertices; +} diff --git a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/response/ExpendOneHopResponse.java b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/response/ExpendOneHopResponse.java new file mode 100644 index 000000000..dd0063be7 --- /dev/null +++ b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/response/ExpendOneHopResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright 2023 OpenSPG Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. + */ + +package com.antgroup.openspg.server.api.facade.dto.service.response; + +import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.EdgeRecord; +import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.VertexRecord; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ExpendOneHopResponse { + + private VertexRecord vertex; + private List edges; + private List adjacentVertices; +} diff --git a/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/response/QueryVertexResponse.java b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/response/QueryVertexResponse.java new file mode 100644 index 000000000..fc857bdc0 --- /dev/null +++ b/server/api/facade/src/main/java/com/antgroup/openspg/server/api/facade/dto/service/response/QueryVertexResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 OpenSPG Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. + */ + +package com.antgroup.openspg.server.api.facade.dto.service.response; + +import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.VertexRecord; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class QueryVertexResponse { + + private VertexRecord vertex; +} diff --git a/server/api/http-client/src/main/java/com/antgroup/openspg/server/api/http/client/forest/GsonConvertor.java b/server/api/http-client/src/main/java/com/antgroup/openspg/server/api/http/client/forest/GsonConvertor.java index f6d3ceb7f..aa0d57096 100644 --- a/server/api/http-client/src/main/java/com/antgroup/openspg/server/api/http/client/forest/GsonConvertor.java +++ b/server/api/http-client/src/main/java/com/antgroup/openspg/server/api/http/client/forest/GsonConvertor.java @@ -13,7 +13,7 @@ package com.antgroup.openspg.server.api.http.client.forest; -import com.antgroup.openspg.server.api.facade.SchemaJsonUtils; +import com.antgroup.openspg.common.util.SchemaJsonUtils; import com.dtflys.forest.converter.ConvertOptions; import com.dtflys.forest.converter.json.ForestJsonConverter; import com.dtflys.forest.http.ForestRequest; diff --git a/server/api/http-server/src/main/java/com/antgroup/openspg/server/api/http/server/WebMvcConfig.java b/server/api/http-server/src/main/java/com/antgroup/openspg/server/api/http/server/WebMvcConfig.java index 8c4eb11b2..e8584840b 100644 --- a/server/api/http-server/src/main/java/com/antgroup/openspg/server/api/http/server/WebMvcConfig.java +++ b/server/api/http-server/src/main/java/com/antgroup/openspg/server/api/http/server/WebMvcConfig.java @@ -13,7 +13,7 @@ package com.antgroup.openspg.server.api.http.server; -import com.antgroup.openspg.server.api.facade.SchemaJsonUtils; +import com.antgroup.openspg.common.util.SchemaJsonUtils; import java.util.Collections; import java.util.List; import org.springframework.context.annotation.Configuration; diff --git a/server/api/http-server/src/main/java/com/antgroup/openspg/server/api/http/server/openapi/GraphController.java b/server/api/http-server/src/main/java/com/antgroup/openspg/server/api/http/server/openapi/GraphController.java index ffe5681dc..62c2122c2 100644 --- a/server/api/http-server/src/main/java/com/antgroup/openspg/server/api/http/server/openapi/GraphController.java +++ b/server/api/http-server/src/main/java/com/antgroup/openspg/server/api/http/server/openapi/GraphController.java @@ -29,8 +29,7 @@ import com.antgroup.openspg.core.schema.model.type.ConceptList; import com.antgroup.openspg.core.schema.model.type.ProjectSchema; import com.antgroup.openspg.server.api.facade.dto.service.request.*; -import com.antgroup.openspg.server.api.facade.dto.service.response.ManipulateDataResponse; -import com.antgroup.openspg.server.api.facade.dto.service.response.PageRankScoreInstance; +import com.antgroup.openspg.server.api.facade.dto.service.response.*; import com.antgroup.openspg.server.api.http.server.HttpBizCallback; import com.antgroup.openspg.server.api.http.server.HttpBizTemplate; import com.antgroup.openspg.server.api.http.server.HttpResult; @@ -234,4 +233,65 @@ private Map getConceptLists( } return results; } + + @RequestMapping(value = "/expendOneHop", method = RequestMethod.POST) + @ResponseBody + public HttpResult expendOneHop(@RequestBody ExpendOneHopRequest request) { + return HttpBizTemplate.execute2( + new HttpBizCallback() { + @Override + public void check() { + AssertUtils.assertParamObjectIsNotNull("request", request); + AssertUtils.assertParamObjectIsNotNull("projectId", request.getProjectId()); + AssertUtils.assertParamObjectIsNotNull("typeName", request.getTypeName()); + AssertUtils.assertParamObjectIsNotNull("bizId", request.getBizId()); + } + + @Override + public ExpendOneHopResponse action() { + return graphManager.expendOneHop(request); + } + }); + } + + @RequestMapping(value = "/queryVertex", method = RequestMethod.POST) + @ResponseBody + public HttpResult queryVertex(@RequestBody QueryVertexRequest request) { + return HttpBizTemplate.execute2( + new HttpBizCallback() { + @Override + public void check() { + AssertUtils.assertParamObjectIsNotNull("request", request); + AssertUtils.assertParamObjectIsNotNull("projectId", request.getProjectId()); + AssertUtils.assertParamObjectIsNotNull("typeName", request.getTypeName()); + AssertUtils.assertParamObjectIsNotNull("bizId", request.getBizId()); + } + + @Override + public QueryVertexResponse action() { + return graphManager.queryVertex(request); + } + }); + } + + @RequestMapping(value = "/batchQueryVertex", method = RequestMethod.POST) + @ResponseBody + public HttpResult batchQueryVertex( + @RequestBody BatchQueryVertexRequest request) { + return HttpBizTemplate.execute2( + new HttpBizCallback() { + @Override + public void check() { + AssertUtils.assertParamObjectIsNotNull("request", request); + AssertUtils.assertParamObjectIsNotNull("projectId", request.getProjectId()); + AssertUtils.assertParamObjectIsNotNull("typeName", request.getTypeName()); + AssertUtils.assertParamObjectIsNotNull("bizIds", request.getBizIds()); + } + + @Override + public BatchQueryVertexResponse action() { + return graphManager.batchQueryVertex(request); + } + }); + } } diff --git a/server/biz/service/src/main/java/com/antgroup/openspg/server/biz/service/GraphManager.java b/server/biz/service/src/main/java/com/antgroup/openspg/server/biz/service/GraphManager.java index 3d32b24b2..882cfb82e 100644 --- a/server/biz/service/src/main/java/com/antgroup/openspg/server/biz/service/GraphManager.java +++ b/server/biz/service/src/main/java/com/antgroup/openspg/server/biz/service/GraphManager.java @@ -14,8 +14,7 @@ package com.antgroup.openspg.server.biz.service; import com.antgroup.openspg.server.api.facade.dto.service.request.*; -import com.antgroup.openspg.server.api.facade.dto.service.response.ManipulateDataResponse; -import com.antgroup.openspg.server.api.facade.dto.service.response.PageRankScoreInstance; +import com.antgroup.openspg.server.api.facade.dto.service.response.*; import java.util.List; public interface GraphManager { @@ -31,4 +30,10 @@ public interface GraphManager { ManipulateDataResponse deleteEdgeRequest(DeleteEdgeRequest request); List getPageRankScores(GetPageRankScoresRequest request); + + QueryVertexResponse queryVertex(QueryVertexRequest request); + + BatchQueryVertexResponse batchQueryVertex(BatchQueryVertexRequest request); + + ExpendOneHopResponse expendOneHop(ExpendOneHopRequest request); } diff --git a/server/biz/service/src/main/java/com/antgroup/openspg/server/biz/service/impl/GraphManagerImpl.java b/server/biz/service/src/main/java/com/antgroup/openspg/server/biz/service/impl/GraphManagerImpl.java index 2777d2476..c43f0e6f0 100644 --- a/server/biz/service/src/main/java/com/antgroup/openspg/server/biz/service/impl/GraphManagerImpl.java +++ b/server/biz/service/src/main/java/com/antgroup/openspg/server/biz/service/impl/GraphManagerImpl.java @@ -15,17 +15,23 @@ import com.antgroup.openspg.cloudext.interfaces.graphstore.BaseLPGGraphStoreClient; import com.antgroup.openspg.cloudext.interfaces.graphstore.GraphStoreClientDriverManager; +import com.antgroup.openspg.cloudext.interfaces.graphstore.cmd.BatchVertexLPGRecordQuery; +import com.antgroup.openspg.cloudext.interfaces.graphstore.cmd.OneHopLPGRecordQuery; import com.antgroup.openspg.cloudext.interfaces.graphstore.cmd.PageRankCompete; +import com.antgroup.openspg.cloudext.interfaces.graphstore.cmd.VertexLPGRecordQuery; import com.antgroup.openspg.cloudext.interfaces.graphstore.model.ComputeResultRow; +import com.antgroup.openspg.cloudext.interfaces.graphstore.model.Direction; import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.EdgeRecord; import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.VertexRecord; +import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.struct.GraphLPGRecordStruct; +import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.schema.EdgeTypeName; import com.antgroup.openspg.server.api.facade.dto.service.request.*; -import com.antgroup.openspg.server.api.facade.dto.service.response.ManipulateDataResponse; -import com.antgroup.openspg.server.api.facade.dto.service.response.PageRankScoreInstance; +import com.antgroup.openspg.server.api.facade.dto.service.response.*; import com.antgroup.openspg.server.biz.common.ProjectManager; import com.antgroup.openspg.server.biz.service.GraphManager; import com.antgroup.openspg.server.biz.service.convertor.InstanceConvertor; -import java.util.List; +import com.google.common.collect.Lists; +import java.util.*; import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -164,4 +170,103 @@ public List getPageRankScores(GetPageRankScoresRequest re row.getNode().getVertexType(), row.getNode().getId(), row.getScore())) .collect(Collectors.toList()); } + + @Override + public ExpendOneHopResponse expendOneHop(ExpendOneHopRequest request) { + String graphStoreUrl = projectManager.getGraphStoreUrl(request.getProjectId()); + BaseLPGGraphStoreClient lpgGraphStoreClient = + (BaseLPGGraphStoreClient) GraphStoreClientDriverManager.getClient(graphStoreUrl); + + Set edgeTypeNameSet = + request.getEdgeTypeNameConstraint() == null + ? null + : new HashSet<>(request.getEdgeTypeNameConstraint()); + OneHopLPGRecordQuery query = + new OneHopLPGRecordQuery( + request.getBizId(), request.getTypeName(), edgeTypeNameSet, Direction.BOTH); + GraphLPGRecordStruct struct = (GraphLPGRecordStruct) lpgGraphStoreClient.queryRecord(query); + return convert2ExpendOneHopResponse(request.getTypeName(), request.getBizId(), struct); + } + + private ExpendOneHopResponse convert2ExpendOneHopResponse( + String type, String id, GraphLPGRecordStruct graphLPGRecordStruct) { + if (graphLPGRecordStruct == null) { + return null; + } + ExpendOneHopResponse response = new ExpendOneHopResponse(); + if (CollectionUtils.isEmpty(graphLPGRecordStruct.getVertices()) + && CollectionUtils.isEmpty(graphLPGRecordStruct.getEdges())) { + return response; + } + + Map vertexRecordMap = new HashMap<>(); + for (VertexRecord vertexRecord : graphLPGRecordStruct.getVertices()) { + vertexRecordMap.put(vertexRecord.generateUniqueString(), vertexRecord); + } + + String sourceVertexUniqueString = new VertexRecord(id, type, null).generateUniqueString(); + response.setVertex(vertexRecordMap.get(sourceVertexUniqueString)); + + response.setEdges(graphLPGRecordStruct.getEdges()); + + List adjacentVertices = Lists.newArrayList(); + for (EdgeRecord edgeRecord : graphLPGRecordStruct.getEdges()) { + String startVertexUniqueString = + new VertexRecord(edgeRecord.getSrcId(), edgeRecord.getEdgeType().getStartVertexType()) + .generateUniqueString(); + if (sourceVertexUniqueString.equals(startVertexUniqueString)) { + String endVertexUniqueString = + new VertexRecord(edgeRecord.getDstId(), edgeRecord.getEdgeType().getEndVertexType()) + .generateUniqueString(); + adjacentVertices.add(vertexRecordMap.get(endVertexUniqueString)); + } else { + adjacentVertices.add(vertexRecordMap.get(startVertexUniqueString)); + } + } + response.setAdjacentVertices(adjacentVertices); + + return response; + } + + @Override + public QueryVertexResponse queryVertex(QueryVertexRequest request) { + String graphStoreUrl = projectManager.getGraphStoreUrl(request.getProjectId()); + BaseLPGGraphStoreClient lpgGraphStoreClient = + (BaseLPGGraphStoreClient) GraphStoreClientDriverManager.getClient(graphStoreUrl); + + VertexLPGRecordQuery query = + new VertexLPGRecordQuery(request.getBizId(), request.getTypeName()); + GraphLPGRecordStruct struct = (GraphLPGRecordStruct) lpgGraphStoreClient.queryRecord(query); + + QueryVertexResponse response = new QueryVertexResponse(); + if (struct == null || struct.getVertices().isEmpty()) { + return response; + } + response.setVertex(struct.getVertices().get(0)); + return response; + } + + @Override + public BatchQueryVertexResponse batchQueryVertex(BatchQueryVertexRequest request) { + String graphStoreUrl = projectManager.getGraphStoreUrl(request.getProjectId()); + BaseLPGGraphStoreClient lpgGraphStoreClient = + (BaseLPGGraphStoreClient) GraphStoreClientDriverManager.getClient(graphStoreUrl); + + BatchQueryVertexResponse response = new BatchQueryVertexResponse(); + response.setVertices(Lists.newArrayList()); + + if (CollectionUtils.isEmpty(request.getBizIds())) { + return response; + } + + Set idSet = new HashSet<>(request.getBizIds()); + + BatchVertexLPGRecordQuery query = new BatchVertexLPGRecordQuery(idSet, request.getTypeName()); + GraphLPGRecordStruct struct = (GraphLPGRecordStruct) lpgGraphStoreClient.queryRecord(query); + + if (struct != null && !struct.getVertices().isEmpty()) { + response.setVertices(struct.getVertices()); + } + return response; + } } diff --git a/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/ExtConfigConvertor.java b/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/ExtConfigConvertor.java index d4a5c0c89..901dfb56f 100644 --- a/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/ExtConfigConvertor.java +++ b/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/ExtConfigConvertor.java @@ -13,9 +13,9 @@ package com.antgroup.openspg.server.infra.dao.repository.schema.convertor; +import com.antgroup.openspg.common.util.SchemaJsonUtils; import com.antgroup.openspg.core.schema.model.SchemaConstants; import com.antgroup.openspg.core.schema.model.SchemaExtInfo; -import com.antgroup.openspg.server.api.facade.SchemaJsonUtils; import com.antgroup.openspg.server.core.schema.service.predicate.model.SimpleProperty; import com.antgroup.openspg.server.core.schema.service.type.model.SimpleSPGType; import java.util.stream.Collectors; diff --git a/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/OntologyConvertor.java b/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/OntologyConvertor.java index ba99eb185..7b7dfefa9 100644 --- a/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/OntologyConvertor.java +++ b/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/OntologyConvertor.java @@ -13,6 +13,7 @@ package com.antgroup.openspg.server.infra.dao.repository.schema.convertor; +import com.antgroup.openspg.common.util.SchemaJsonUtils; import com.antgroup.openspg.common.util.StringUtils; import com.antgroup.openspg.core.schema.model.BasicInfo; import com.antgroup.openspg.core.schema.model.OntologyId; @@ -27,7 +28,6 @@ import com.antgroup.openspg.core.schema.model.type.ParentTypeInfo; import com.antgroup.openspg.core.schema.model.type.SPGTypeEnum; import com.antgroup.openspg.core.schema.model.type.VisibleScopeEnum; -import com.antgroup.openspg.server.api.facade.SchemaJsonUtils; import com.antgroup.openspg.server.core.schema.service.type.model.OperatorConfig; import com.antgroup.openspg.server.core.schema.service.type.model.ProjectOntologyRel; import com.antgroup.openspg.server.core.schema.service.type.model.SimpleSPGType; diff --git a/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/SimplePropertyConvertor.java b/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/SimplePropertyConvertor.java index 3f23b282f..4dca4e807 100644 --- a/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/SimplePropertyConvertor.java +++ b/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/SimplePropertyConvertor.java @@ -13,6 +13,7 @@ package com.antgroup.openspg.server.infra.dao.repository.schema.convertor; +import com.antgroup.openspg.common.util.SchemaJsonUtils; import com.antgroup.openspg.common.util.StringUtils; import com.antgroup.openspg.core.schema.model.BasicInfo; import com.antgroup.openspg.core.schema.model.OntologyId; @@ -28,7 +29,6 @@ import com.antgroup.openspg.core.schema.model.semantic.SPGOntologyEnum; import com.antgroup.openspg.core.schema.model.type.MultiVersionConfig; import com.antgroup.openspg.core.schema.model.type.SPGTypeEnum; -import com.antgroup.openspg.server.api.facade.SchemaJsonUtils; import com.antgroup.openspg.server.core.schema.service.predicate.model.SimpleProperty; import com.antgroup.openspg.server.infra.dao.dataobject.OntologyPropertyDO; import com.antgroup.openspg.server.infra.dao.repository.schema.enums.MapTypeEnum; diff --git a/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/SimpleSubPropertyConvertor.java b/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/SimpleSubPropertyConvertor.java index 3335ee745..9f514978a 100644 --- a/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/SimpleSubPropertyConvertor.java +++ b/server/infra/dao/src/main/java/com/antgroup/openspg/server/infra/dao/repository/schema/convertor/SimpleSubPropertyConvertor.java @@ -14,6 +14,7 @@ package com.antgroup.openspg.server.infra.dao.repository.schema.convertor; import com.alibaba.fastjson.JSON; +import com.antgroup.openspg.common.util.SchemaJsonUtils; import com.antgroup.openspg.common.util.StringUtils; import com.antgroup.openspg.core.schema.model.BasicInfo; import com.antgroup.openspg.core.schema.model.OntologyId; @@ -23,7 +24,6 @@ import com.antgroup.openspg.core.schema.model.identifier.PredicateIdentifier; import com.antgroup.openspg.core.schema.model.predicate.EncryptTypeEnum; import com.antgroup.openspg.core.schema.model.type.MultiVersionConfig; -import com.antgroup.openspg.server.api.facade.SchemaJsonUtils; import com.antgroup.openspg.server.core.schema.service.predicate.model.SimpleSubProperty; import com.antgroup.openspg.server.infra.dao.dataobject.OntologyPropertyDO; import com.antgroup.openspg.server.infra.dao.repository.schema.enums.MapTypeEnum;