Skip to content

basic upsert #520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: dev-ckb-sdk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
from pinecone.core.openapi.ckb_knowledge_data.model.delete_document_response import (
DeleteDocumentResponse,
)
from pinecone.core.openapi.ckb_knowledge_data.model.document_for_upsert import DocumentForUpsert
from pinecone.core.openapi.ckb_knowledge_data.model.get_document_response import GetDocumentResponse
from pinecone.core.openapi.ckb_knowledge_data.model.list_document_response import (
ListDocumentResponse,
from pinecone.core.openapi.ckb_knowledge_data.model.list_documents_response import (
ListDocumentsResponse,
)
from pinecone.core.openapi.ckb_knowledge_data.model.upsert_document_response import (
UpsertDocumentResponse,
Expand Down Expand Up @@ -93,7 +92,7 @@ def __delete_document(self, namespace, document_id, **kwargs: ExtraOpenApiKwargs
settings={
"response_type": (DeleteDocumentResponse,),
"auth": ["ApiKeyAuth"],
"endpoint_path": "/namespaces/{namespace}/documents/{document_id}",
"endpoint_path": "/ckb-stub-namespaces/{namespace}/documents/{document_id}",
"operation_id": "delete_document",
"http_method": "DELETE",
"servers": None,
Expand Down Expand Up @@ -164,7 +163,7 @@ def __get_document(self, namespace, document_id, **kwargs: ExtraOpenApiKwargsTyp
settings={
"response_type": (GetDocumentResponse,),
"auth": ["ApiKeyAuth"],
"endpoint_path": "/namespaces/{namespace}/documents/{document_id}",
"endpoint_path": "/ckb-stub-namespaces/{namespace}/documents/{document_id}",
"operation_id": "get_document",
"http_method": "GET",
"servers": None,
Expand Down Expand Up @@ -221,7 +220,7 @@ def __list_documents(self, namespace, **kwargs: ExtraOpenApiKwargsTypedDict):
async_req (bool): execute request asynchronously

Returns:
ListDocumentResponse
ListDocumentsResponse
If the method is called asynchronously, returns the request
thread.
"""
Expand All @@ -231,9 +230,9 @@ def __list_documents(self, namespace, **kwargs: ExtraOpenApiKwargsTypedDict):

self.list_documents = _Endpoint(
settings={
"response_type": (ListDocumentResponse,),
"response_type": (ListDocumentsResponse,),
"auth": ["ApiKeyAuth"],
"endpoint_path": "/namespaces/{namespace}/documents",
"endpoint_path": "/ckb-stub-namespaces/{namespace}/documents",
"operation_id": "list_documents",
"http_method": "GET",
"servers": None,
Expand All @@ -258,21 +257,19 @@ def __list_documents(self, namespace, **kwargs: ExtraOpenApiKwargsTypedDict):
callable=__list_documents,
)

def __upsert_document(
self, namespace, document_for_upsert, **kwargs: ExtraOpenApiKwargsTypedDict
):
def __upsert_document(self, namespace, request_body, **kwargs: ExtraOpenApiKwargsTypedDict):
"""Create or update a document in the given namespace # noqa: E501

Upserts a document into the specified namespace. The request body may contain any valid JSON document that conforms to the schema. Optionally, an `_id` field can be provided to use as the document's identifier; if omitted, the system will assign one. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True

>>> thread = api.upsert_document(namespace, document_for_upsert, async_req=True)
>>> thread = api.upsert_document(namespace, request_body, async_req=True)
>>> result = thread.get()

Args:
namespace (str): Namespace where the document will be stored.
document_for_upsert (DocumentForUpsert):
request_body ({str: (bool, dict, float, int, list, str, none_type)}):

Keyword Args:
_return_http_data_only (bool): response data without head status
Expand All @@ -299,31 +296,34 @@ def __upsert_document(
"""
kwargs = self._process_openapi_kwargs(kwargs)
kwargs["namespace"] = namespace
kwargs["document_for_upsert"] = document_for_upsert
kwargs["request_body"] = request_body
return self.call_with_http_info(**kwargs)

self.upsert_document = _Endpoint(
settings={
"response_type": (UpsertDocumentResponse,),
"auth": ["ApiKeyAuth"],
"endpoint_path": "/namespaces/{namespace}/documents/upsert",
"endpoint_path": "/ckb-stub-namespaces/{namespace}/documents/upsert",
"operation_id": "upsert_document",
"http_method": "POST",
"servers": None,
},
params_map={
"all": ["namespace", "document_for_upsert"],
"required": ["namespace", "document_for_upsert"],
"all": ["namespace", "request_body"],
"required": ["namespace", "request_body"],
"nullable": [],
"enum": [],
"validation": [],
},
root_map={
"validations": {},
"allowed_values": {},
"openapi_types": {"namespace": (str,), "document_for_upsert": (DocumentForUpsert,)},
"openapi_types": {
"namespace": (str,),
"request_body": ({str: (bool, dict, float, int, list, str, none_type)},),
},
"attribute_map": {"namespace": "namespace"},
"location_map": {"namespace": "path", "document_for_upsert": "body"},
"location_map": {"namespace": "path", "request_body": "body"},
"collection_format_map": {},
},
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
Expand Down Expand Up @@ -382,7 +382,7 @@ async def __delete_document(self, namespace, document_id, **kwargs):
settings={
"response_type": (DeleteDocumentResponse,),
"auth": ["ApiKeyAuth"],
"endpoint_path": "/namespaces/{namespace}/documents/{document_id}",
"endpoint_path": "/ckb-stub-namespaces/{namespace}/documents/{document_id}",
"operation_id": "delete_document",
"http_method": "DELETE",
"servers": None,
Expand Down Expand Up @@ -446,7 +446,7 @@ async def __get_document(self, namespace, document_id, **kwargs):
settings={
"response_type": (GetDocumentResponse,),
"auth": ["ApiKeyAuth"],
"endpoint_path": "/namespaces/{namespace}/documents/{document_id}",
"endpoint_path": "/ckb-stub-namespaces/{namespace}/documents/{document_id}",
"operation_id": "get_document",
"http_method": "GET",
"servers": None,
Expand Down Expand Up @@ -498,17 +498,17 @@ async def __list_documents(self, namespace, **kwargs):
Default is True.

Returns:
ListDocumentResponse
ListDocumentsResponse
"""
self._process_openapi_kwargs(kwargs)
kwargs["namespace"] = namespace
return await self.call_with_http_info(**kwargs)

self.list_documents = _AsyncioEndpoint(
settings={
"response_type": (ListDocumentResponse,),
"response_type": (ListDocumentsResponse,),
"auth": ["ApiKeyAuth"],
"endpoint_path": "/namespaces/{namespace}/documents",
"endpoint_path": "/ckb-stub-namespaces/{namespace}/documents",
"operation_id": "list_documents",
"http_method": "GET",
"servers": None,
Expand All @@ -533,15 +533,15 @@ async def __list_documents(self, namespace, **kwargs):
callable=__list_documents,
)

async def __upsert_document(self, namespace, document_for_upsert, **kwargs):
async def __upsert_document(self, namespace, request_body, **kwargs):
"""Create or update a document in the given namespace # noqa: E501

Upserts a document into the specified namespace. The request body may contain any valid JSON document that conforms to the schema. Optionally, an `_id` field can be provided to use as the document's identifier; if omitted, the system will assign one. # noqa: E501


Args:
namespace (str): Namespace where the document will be stored.
document_for_upsert (DocumentForUpsert):
request_body ({str: (bool, dict, float, int, list, str, none_type)}):

Keyword Args:
_return_http_data_only (bool): response data without head status
Expand All @@ -565,31 +565,34 @@ async def __upsert_document(self, namespace, document_for_upsert, **kwargs):
"""
self._process_openapi_kwargs(kwargs)
kwargs["namespace"] = namespace
kwargs["document_for_upsert"] = document_for_upsert
kwargs["request_body"] = request_body
return await self.call_with_http_info(**kwargs)

self.upsert_document = _AsyncioEndpoint(
settings={
"response_type": (UpsertDocumentResponse,),
"auth": ["ApiKeyAuth"],
"endpoint_path": "/namespaces/{namespace}/documents/upsert",
"endpoint_path": "/ckb-stub-namespaces/{namespace}/documents/upsert",
"operation_id": "upsert_document",
"http_method": "POST",
"servers": None,
},
params_map={
"all": ["namespace", "document_for_upsert"],
"required": ["namespace", "document_for_upsert"],
"all": ["namespace", "request_body"],
"required": ["namespace", "request_body"],
"nullable": [],
"enum": [],
"validation": [],
},
root_map={
"validations": {},
"allowed_values": {},
"openapi_types": {"namespace": (str,), "document_for_upsert": (DocumentForUpsert,)},
"openapi_types": {
"namespace": (str,),
"request_body": ({str: (bool, dict, float, int, list, str, none_type)},),
},
"attribute_map": {"namespace": "namespace"},
"location_map": {"namespace": "path", "document_for_upsert": "body"},
"location_map": {"namespace": "path", "request_body": "body"},
"collection_format_map": {},
},
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def openapi_types(cls):
"""
lazy_import()
return {
"id": (str,), # noqa: E501
"_id": (str,), # noqa: E501
"namespace": (str,), # noqa: E501
"usage": (Usage,), # noqa: E501
"lsn_status": (LSNStatus,), # noqa: E501
Expand All @@ -105,7 +105,7 @@ def discriminator(cls):
return None

attribute_map: Dict[str, str] = {
"id": "_id", # noqa: E501
"_id": "_id", # noqa: E501
"namespace": "namespace", # noqa: E501
"usage": "usage", # noqa: E501
"lsn_status": "_lsn_status", # noqa: E501
Expand All @@ -117,11 +117,11 @@ def discriminator(cls):

@classmethod
@convert_js_args_to_python_args
def _from_openapi_data(cls: Type[T], id, namespace, usage, lsn_status, *args, **kwargs) -> T: # noqa: E501
def _from_openapi_data(cls: Type[T], _id, namespace, usage, lsn_status, *args, **kwargs) -> T: # noqa: E501
"""DeleteDocumentResponse - a model defined in OpenAPI

Args:
id (str): Identifier of the document to be deleted.
_id (str): Identifier of the document to be deleted.
namespace (str): Namespace of the document to be deleted.
usage (Usage):
lsn_status (LSNStatus):
Expand Down Expand Up @@ -186,7 +186,7 @@ def _from_openapi_data(cls: Type[T], id, namespace, usage, lsn_status, *args, **
self._configuration = _configuration
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)

self.id = id
self._id = _id
self.namespace = namespace
self.usage = usage
self.lsn_status = lsn_status
Expand Down Expand Up @@ -216,11 +216,11 @@ def _from_openapi_data(cls: Type[T], id, namespace, usage, lsn_status, *args, **
)

@convert_js_args_to_python_args
def __init__(self, id, namespace, usage, lsn_status, *args, **kwargs) -> None: # noqa: E501
def __init__(self, _id, namespace, usage, lsn_status, *args, **kwargs) -> None: # noqa: E501
"""DeleteDocumentResponse - a model defined in OpenAPI

Args:
id (str): Identifier of the document to be deleted.
_id (str): Identifier of the document to be deleted.
namespace (str): Namespace of the document to be deleted.
usage (Usage):
lsn_status (LSNStatus):
Expand Down Expand Up @@ -283,7 +283,7 @@ def __init__(self, id, namespace, usage, lsn_status, *args, **kwargs) -> None:
self._configuration = _configuration
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)

self.id = id
self._id = _id
self.namespace = namespace
self.usage = usage
self.lsn_status = lsn_status
Expand Down
16 changes: 8 additions & 8 deletions pinecone/core/openapi/ckb_knowledge_data/model/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ def openapi_types(cls):
and the value is attribute type.
"""
return {
"id": (str,) # noqa: E501
"_id": (str,) # noqa: E501
}

@cached_class_property
def discriminator(cls):
return None

attribute_map: Dict[str, str] = {
"id": "_id" # noqa: E501
"_id": "_id" # noqa: E501
}

read_only_vars: Set[str] = set([])
Expand All @@ -101,11 +101,11 @@ def discriminator(cls):

@classmethod
@convert_js_args_to_python_args
def _from_openapi_data(cls: Type[T], id, *args, **kwargs) -> T: # noqa: E501
def _from_openapi_data(cls: Type[T], _id, *args, **kwargs) -> T: # noqa: E501
"""Document - a model defined in OpenAPI

Args:
id (str): Unique identifier for the document.
_id (str): Unique identifier for the document.

Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
Expand Down Expand Up @@ -167,7 +167,7 @@ def _from_openapi_data(cls: Type[T], id, *args, **kwargs) -> T: # noqa: E501
self._configuration = _configuration
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)

self.id = id
self._id = _id
for var_name, var_value in kwargs.items():
if (
var_name not in self.attribute_map
Expand All @@ -194,11 +194,11 @@ def _from_openapi_data(cls: Type[T], id, *args, **kwargs) -> T: # noqa: E501
)

@convert_js_args_to_python_args
def __init__(self, id, *args, **kwargs) -> None: # noqa: E501
def __init__(self, _id, *args, **kwargs) -> None: # noqa: E501
"""Document - a model defined in OpenAPI

Args:
id (str): Unique identifier for the document.
_id (str): Unique identifier for the document.

Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
Expand Down Expand Up @@ -258,7 +258,7 @@ def __init__(self, id, *args, **kwargs) -> None: # noqa: E501
self._configuration = _configuration
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)

self.id = id
self._id = _id
for var_name, var_value in kwargs.items():
if (
var_name not in self.attribute_map
Expand Down
Loading
Loading