diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 1681899..48d091f 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -41,6 +41,8 @@ docs/CreateSecretResponse.md docs/CreateWorkspaceRequest.md docs/CreateWorkspaceResponse.md docs/DatabaseAttachmentInfo.md +docs/DatabaseContextApi.md +docs/DatabaseContextEntry.md docs/DatabaseDefaultSchemaDecl.md docs/DatabaseDefaultTableDecl.md docs/DatabaseDetailResponse.md @@ -62,10 +64,10 @@ docs/EmbeddingProvidersApi.md docs/Error.md docs/ExecuteSavedQueryRequest.md docs/GetConnectionResponse.md +docs/GetDatabaseContextResponse.md docs/GetDatasetResponse.md docs/GetResultResponse.md docs/GetSecretResponse.md -docs/GetWorkspaceContextResponse.md docs/IndexInfoResponse.md docs/IndexStatus.md docs/IndexesApi.md @@ -80,6 +82,7 @@ docs/JobType.md docs/JobsApi.md docs/ListConnectionTypesResponse.md docs/ListConnectionsResponse.md +docs/ListDatabaseContextsResponse.md docs/ListDatabasesResponse.md docs/ListDatasetVersionsResponse.md docs/ListDatasetsResponse.md @@ -93,7 +96,6 @@ docs/ListSavedQueriesResponse.md docs/ListSavedQueryVersionsResponse.md docs/ListSecretsResponse.md docs/ListUploadsResponse.md -docs/ListWorkspaceContextsResponse.md docs/ListWorkspacesResponse.md docs/LoadManagedTableRequest.md docs/LoadManagedTableResponse.md @@ -142,11 +144,9 @@ docs/UploadDatasetSource.md docs/UploadInfo.md docs/UploadResponse.md docs/UploadsApi.md -docs/UpsertWorkspaceContextRequest.md -docs/UpsertWorkspaceContextResponse.md +docs/UpsertDatabaseContextRequest.md +docs/UpsertDatabaseContextResponse.md docs/UrlDatasetSource.md -docs/WorkspaceContextApi.md -docs/WorkspaceContextEntry.md docs/WorkspaceDetail.md docs/WorkspaceListItem.md docs/WorkspacesApi.md @@ -154,6 +154,7 @@ hotdata/__init__.py hotdata/api/__init__.py hotdata/api/connection_types_api.py hotdata/api/connections_api.py +hotdata/api/database_context_api.py hotdata/api/databases_api.py hotdata/api/datasets_api.py hotdata/api/embedding_providers_api.py @@ -168,7 +169,6 @@ hotdata/api/sandboxes_api.py hotdata/api/saved_queries_api.py hotdata/api/secrets_api.py hotdata/api/uploads_api.py -hotdata/api/workspace_context_api.py hotdata/api/workspaces_api.py hotdata/api_client.py hotdata/api_response.py @@ -213,6 +213,7 @@ hotdata/models/create_secret_response.py hotdata/models/create_workspace_request.py hotdata/models/create_workspace_response.py hotdata/models/database_attachment_info.py +hotdata/models/database_context_entry.py hotdata/models/database_default_schema_decl.py hotdata/models/database_default_table_decl.py hotdata/models/database_detail_response.py @@ -231,10 +232,10 @@ hotdata/models/embedding_provider_response.py hotdata/models/error.py hotdata/models/execute_saved_query_request.py hotdata/models/get_connection_response.py +hotdata/models/get_database_context_response.py hotdata/models/get_dataset_response.py hotdata/models/get_result_response.py hotdata/models/get_secret_response.py -hotdata/models/get_workspace_context_response.py hotdata/models/index_info_response.py hotdata/models/index_status.py hotdata/models/information_schema_response.py @@ -246,6 +247,7 @@ hotdata/models/job_status_response.py hotdata/models/job_type.py hotdata/models/list_connection_types_response.py hotdata/models/list_connections_response.py +hotdata/models/list_database_contexts_response.py hotdata/models/list_databases_response.py hotdata/models/list_dataset_versions_response.py hotdata/models/list_datasets_response.py @@ -259,7 +261,6 @@ hotdata/models/list_saved_queries_response.py hotdata/models/list_saved_query_versions_response.py hotdata/models/list_secrets_response.py hotdata/models/list_uploads_response.py -hotdata/models/list_workspace_contexts_response.py hotdata/models/list_workspaces_response.py hotdata/models/load_managed_table_request.py hotdata/models/load_managed_table_response.py @@ -300,10 +301,9 @@ hotdata/models/update_secret_response.py hotdata/models/upload_dataset_source.py hotdata/models/upload_info.py hotdata/models/upload_response.py -hotdata/models/upsert_workspace_context_request.py -hotdata/models/upsert_workspace_context_response.py +hotdata/models/upsert_database_context_request.py +hotdata/models/upsert_database_context_response.py hotdata/models/url_dataset_source.py -hotdata/models/workspace_context_entry.py hotdata/models/workspace_detail.py hotdata/models/workspace_list_item.py hotdata/py.typed @@ -313,4 +313,10 @@ requirements.txt setup.cfg test-requirements.txt test/__init__.py +test/test_database_context_api.py +test/test_database_context_entry.py +test/test_get_database_context_response.py +test/test_list_database_contexts_response.py +test/test_upsert_database_context_request.py +test/test_upsert_database_context_response.py tox.ini diff --git a/docs/DatabaseContextApi.md b/docs/DatabaseContextApi.md new file mode 100644 index 0000000..6547496 --- /dev/null +++ b/docs/DatabaseContextApi.md @@ -0,0 +1,359 @@ +# hotdata.DatabaseContextApi + +All URIs are relative to *https://api.hotdata.dev* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_database_context**](DatabaseContextApi.md#delete_database_context) | **DELETE** /v1/databases/{database_id}/context/{name} | Delete database context +[**get_database_context**](DatabaseContextApi.md#get_database_context) | **GET** /v1/databases/{database_id}/context/{name} | Get one database context +[**list_database_contexts**](DatabaseContextApi.md#list_database_contexts) | **GET** /v1/databases/{database_id}/context | List database contexts +[**upsert_database_context**](DatabaseContextApi.md#upsert_database_context) | **POST** /v1/databases/{database_id}/context | Create or update database context + + +# **delete_database_context** +> delete_database_context(database_id, name) + +Delete database context + +Removes a named context document from a database. + +### Example + +* Api Key Authentication (WorkspaceId): +* Bearer Authentication (BearerAuth): + +```python +import hotdata +from hotdata.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://api.hotdata.dev +# See configuration.py for a list of all supported configuration parameters. +configuration = hotdata.Configuration( + host = "https://api.hotdata.dev" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: WorkspaceId +configuration.api_key['WorkspaceId'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['WorkspaceId'] = 'Bearer' + +# Configure Bearer authorization: BearerAuth +configuration = hotdata.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with hotdata.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = hotdata.DatabaseContextApi(api_client) + database_id = 'database_id_example' # str | Database ID + name = 'name_example' # str | Context key: same character rules as a dataset table name + + try: + # Delete database context + api_instance.delete_database_context(database_id, name) + except Exception as e: + print("Exception when calling DatabaseContextApi->delete_database_context: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **database_id** | **str**| Database ID | + **name** | **str**| Context key: same character rules as a dataset table name | + +### Return type + +void (empty response body) + +### Authorization + +[WorkspaceId](../README.md#WorkspaceId), [BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Context deleted | - | +**400** | Invalid request | - | +**404** | Database or context not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_database_context** +> GetDatabaseContextResponse get_database_context(database_id, name) + +Get one database context + +### Example + +* Api Key Authentication (WorkspaceId): +* Bearer Authentication (BearerAuth): + +```python +import hotdata +from hotdata.models.get_database_context_response import GetDatabaseContextResponse +from hotdata.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://api.hotdata.dev +# See configuration.py for a list of all supported configuration parameters. +configuration = hotdata.Configuration( + host = "https://api.hotdata.dev" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: WorkspaceId +configuration.api_key['WorkspaceId'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['WorkspaceId'] = 'Bearer' + +# Configure Bearer authorization: BearerAuth +configuration = hotdata.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with hotdata.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = hotdata.DatabaseContextApi(api_client) + database_id = 'database_id_example' # str | Database ID + name = 'name_example' # str | Context key: same character rules as a dataset table name + + try: + # Get one database context + api_response = api_instance.get_database_context(database_id, name) + print("The response of DatabaseContextApi->get_database_context:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling DatabaseContextApi->get_database_context: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **database_id** | **str**| Database ID | + **name** | **str**| Context key: same character rules as a dataset table name | + +### Return type + +[**GetDatabaseContextResponse**](GetDatabaseContextResponse.md) + +### Authorization + +[WorkspaceId](../README.md#WorkspaceId), [BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Context found | - | +**400** | Invalid request | - | +**404** | Database or context not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **list_database_contexts** +> ListDatabaseContextsResponse list_database_contexts(database_id) + +List database contexts + +### Example + +* Api Key Authentication (WorkspaceId): +* Bearer Authentication (BearerAuth): + +```python +import hotdata +from hotdata.models.list_database_contexts_response import ListDatabaseContextsResponse +from hotdata.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://api.hotdata.dev +# See configuration.py for a list of all supported configuration parameters. +configuration = hotdata.Configuration( + host = "https://api.hotdata.dev" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: WorkspaceId +configuration.api_key['WorkspaceId'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['WorkspaceId'] = 'Bearer' + +# Configure Bearer authorization: BearerAuth +configuration = hotdata.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with hotdata.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = hotdata.DatabaseContextApi(api_client) + database_id = 'database_id_example' # str | Database ID + + try: + # List database contexts + api_response = api_instance.list_database_contexts(database_id) + print("The response of DatabaseContextApi->list_database_contexts:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling DatabaseContextApi->list_database_contexts: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **database_id** | **str**| Database ID | + +### Return type + +[**ListDatabaseContextsResponse**](ListDatabaseContextsResponse.md) + +### Authorization + +[WorkspaceId](../README.md#WorkspaceId), [BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Contexts | - | +**404** | Database not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **upsert_database_context** +> UpsertDatabaseContextResponse upsert_database_context(database_id, upsert_database_context_request) + +Create or update database context + +Stores a named document (for example Markdown) scoped to a database. Reuses the same name to replace content. + +### Example + +* Api Key Authentication (WorkspaceId): +* Bearer Authentication (BearerAuth): + +```python +import hotdata +from hotdata.models.upsert_database_context_request import UpsertDatabaseContextRequest +from hotdata.models.upsert_database_context_response import UpsertDatabaseContextResponse +from hotdata.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://api.hotdata.dev +# See configuration.py for a list of all supported configuration parameters. +configuration = hotdata.Configuration( + host = "https://api.hotdata.dev" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: WorkspaceId +configuration.api_key['WorkspaceId'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['WorkspaceId'] = 'Bearer' + +# Configure Bearer authorization: BearerAuth +configuration = hotdata.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with hotdata.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = hotdata.DatabaseContextApi(api_client) + database_id = 'database_id_example' # str | Database ID + upsert_database_context_request = hotdata.UpsertDatabaseContextRequest() # UpsertDatabaseContextRequest | + + try: + # Create or update database context + api_response = api_instance.upsert_database_context(database_id, upsert_database_context_request) + print("The response of DatabaseContextApi->upsert_database_context:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling DatabaseContextApi->upsert_database_context: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **database_id** | **str**| Database ID | + **upsert_database_context_request** | [**UpsertDatabaseContextRequest**](UpsertDatabaseContextRequest.md)| | + +### Return type + +[**UpsertDatabaseContextResponse**](UpsertDatabaseContextResponse.md) + +### Authorization + +[WorkspaceId](../README.md#WorkspaceId), [BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Context saved | - | +**400** | Invalid request | - | +**404** | Database not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/docs/DatabaseContextEntry.md b/docs/DatabaseContextEntry.md new file mode 100644 index 0000000..4b37bd0 --- /dev/null +++ b/docs/DatabaseContextEntry.md @@ -0,0 +1,32 @@ +# DatabaseContextEntry + +One context entry returned by the API. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**content** | **str** | | +**name** | **str** | | +**updated_at** | **datetime** | | + +## Example + +```python +from hotdata.models.database_context_entry import DatabaseContextEntry + +# TODO update the JSON string below +json = "{}" +# create an instance of DatabaseContextEntry from a JSON string +database_context_entry_instance = DatabaseContextEntry.from_json(json) +# print the JSON string representation of the object +print(DatabaseContextEntry.to_json()) + +# convert the object into a dict +database_context_entry_dict = database_context_entry_instance.to_dict() +# create an instance of DatabaseContextEntry from a dict +database_context_entry_from_dict = DatabaseContextEntry.from_dict(database_context_entry_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/GetDatabaseContextResponse.md b/docs/GetDatabaseContextResponse.md new file mode 100644 index 0000000..054ff48 --- /dev/null +++ b/docs/GetDatabaseContextResponse.md @@ -0,0 +1,30 @@ +# GetDatabaseContextResponse + +Response body for GET `/v1/databases/{database_id}/context/{name}`. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**context** | [**DatabaseContextEntry**](DatabaseContextEntry.md) | | + +## Example + +```python +from hotdata.models.get_database_context_response import GetDatabaseContextResponse + +# TODO update the JSON string below +json = "{}" +# create an instance of GetDatabaseContextResponse from a JSON string +get_database_context_response_instance = GetDatabaseContextResponse.from_json(json) +# print the JSON string representation of the object +print(GetDatabaseContextResponse.to_json()) + +# convert the object into a dict +get_database_context_response_dict = get_database_context_response_instance.to_dict() +# create an instance of GetDatabaseContextResponse from a dict +get_database_context_response_from_dict = GetDatabaseContextResponse.from_dict(get_database_context_response_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/ListDatabaseContextsResponse.md b/docs/ListDatabaseContextsResponse.md new file mode 100644 index 0000000..917c5c5 --- /dev/null +++ b/docs/ListDatabaseContextsResponse.md @@ -0,0 +1,30 @@ +# ListDatabaseContextsResponse + +Response body for GET `/v1/databases/{database_id}/context`. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**contexts** | [**List[DatabaseContextEntry]**](DatabaseContextEntry.md) | | + +## Example + +```python +from hotdata.models.list_database_contexts_response import ListDatabaseContextsResponse + +# TODO update the JSON string below +json = "{}" +# create an instance of ListDatabaseContextsResponse from a JSON string +list_database_contexts_response_instance = ListDatabaseContextsResponse.from_json(json) +# print the JSON string representation of the object +print(ListDatabaseContextsResponse.to_json()) + +# convert the object into a dict +list_database_contexts_response_dict = list_database_contexts_response_instance.to_dict() +# create an instance of ListDatabaseContextsResponse from a dict +list_database_contexts_response_from_dict = ListDatabaseContextsResponse.from_dict(list_database_contexts_response_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/UpsertDatabaseContextRequest.md b/docs/UpsertDatabaseContextRequest.md new file mode 100644 index 0000000..e891781 --- /dev/null +++ b/docs/UpsertDatabaseContextRequest.md @@ -0,0 +1,31 @@ +# UpsertDatabaseContextRequest + +Request body for POST `/v1/databases/{database_id}/context`. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**content** | **str** | | +**name** | **str** | Upsert key in the catalog. Validated with dataset table-name rules (preserves case): ASCII letter or `_` first; then alphanumeric or `_` only; 1–128 chars; not a SQL reserved word. | + +## Example + +```python +from hotdata.models.upsert_database_context_request import UpsertDatabaseContextRequest + +# TODO update the JSON string below +json = "{}" +# create an instance of UpsertDatabaseContextRequest from a JSON string +upsert_database_context_request_instance = UpsertDatabaseContextRequest.from_json(json) +# print the JSON string representation of the object +print(UpsertDatabaseContextRequest.to_json()) + +# convert the object into a dict +upsert_database_context_request_dict = upsert_database_context_request_instance.to_dict() +# create an instance of UpsertDatabaseContextRequest from a dict +upsert_database_context_request_from_dict = UpsertDatabaseContextRequest.from_dict(upsert_database_context_request_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/UpsertDatabaseContextResponse.md b/docs/UpsertDatabaseContextResponse.md new file mode 100644 index 0000000..c1a8ad3 --- /dev/null +++ b/docs/UpsertDatabaseContextResponse.md @@ -0,0 +1,30 @@ +# UpsertDatabaseContextResponse + +Response body for POST `/v1/databases/{database_id}/context`. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**context** | [**DatabaseContextEntry**](DatabaseContextEntry.md) | | + +## Example + +```python +from hotdata.models.upsert_database_context_response import UpsertDatabaseContextResponse + +# TODO update the JSON string below +json = "{}" +# create an instance of UpsertDatabaseContextResponse from a JSON string +upsert_database_context_response_instance = UpsertDatabaseContextResponse.from_json(json) +# print the JSON string representation of the object +print(UpsertDatabaseContextResponse.to_json()) + +# convert the object into a dict +upsert_database_context_response_dict = upsert_database_context_response_instance.to_dict() +# create an instance of UpsertDatabaseContextResponse from a dict +upsert_database_context_response_from_dict = UpsertDatabaseContextResponse.from_dict(upsert_database_context_response_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/hotdata/__init__.py b/hotdata/__init__.py index 620edb2..e53be7a 100644 --- a/hotdata/__init__.py +++ b/hotdata/__init__.py @@ -26,6 +26,7 @@ __all__ = [ "ConnectionTypesApi", "ConnectionsApi", + "DatabaseContextApi", "DatabasesApi", "DatasetsApi", "EmbeddingProvidersApi", @@ -40,7 +41,6 @@ "SavedQueriesApi", "SecretsApi", "UploadsApi", - "WorkspaceContextApi", "WorkspacesApi", "ApiResponse", "ApiClient", @@ -89,6 +89,7 @@ "CreateWorkspaceRequest", "CreateWorkspaceResponse", "DatabaseAttachmentInfo", + "DatabaseContextEntry", "DatabaseDefaultSchemaDecl", "DatabaseDefaultTableDecl", "DatabaseDetailResponse", @@ -107,10 +108,10 @@ "Error", "ExecuteSavedQueryRequest", "GetConnectionResponse", + "GetDatabaseContextResponse", "GetDatasetResponse", "GetResultResponse", "GetSecretResponse", - "GetWorkspaceContextResponse", "IndexInfoResponse", "IndexStatus", "InformationSchemaResponse", @@ -122,6 +123,7 @@ "JobType", "ListConnectionTypesResponse", "ListConnectionsResponse", + "ListDatabaseContextsResponse", "ListDatabasesResponse", "ListDatasetVersionsResponse", "ListDatasetsResponse", @@ -135,7 +137,6 @@ "ListSavedQueryVersionsResponse", "ListSecretsResponse", "ListUploadsResponse", - "ListWorkspaceContextsResponse", "ListWorkspacesResponse", "LoadManagedTableRequest", "LoadManagedTableResponse", @@ -176,10 +177,9 @@ "UploadDatasetSource", "UploadInfo", "UploadResponse", - "UpsertWorkspaceContextRequest", - "UpsertWorkspaceContextResponse", + "UpsertDatabaseContextRequest", + "UpsertDatabaseContextResponse", "UrlDatasetSource", - "WorkspaceContextEntry", "WorkspaceDetail", "WorkspaceListItem", ] @@ -187,6 +187,7 @@ # import apis into sdk package from hotdata.api.connection_types_api import ConnectionTypesApi as ConnectionTypesApi from hotdata.api.connections_api import ConnectionsApi as ConnectionsApi +from hotdata.api.database_context_api import DatabaseContextApi as DatabaseContextApi from hotdata.api.databases_api import DatabasesApi as DatabasesApi from hotdata.api.datasets_api import DatasetsApi as DatasetsApi from hotdata.api.embedding_providers_api import EmbeddingProvidersApi as EmbeddingProvidersApi @@ -201,7 +202,6 @@ from hotdata.api.saved_queries_api import SavedQueriesApi as SavedQueriesApi from hotdata.api.secrets_api import SecretsApi as SecretsApi from hotdata.api.uploads_api import UploadsApi as UploadsApi -from hotdata.api.workspace_context_api import WorkspaceContextApi as WorkspaceContextApi from hotdata.api.workspaces_api import WorkspacesApi as WorkspacesApi # import ApiClient @@ -254,6 +254,7 @@ from hotdata.models.create_workspace_request import CreateWorkspaceRequest as CreateWorkspaceRequest from hotdata.models.create_workspace_response import CreateWorkspaceResponse as CreateWorkspaceResponse from hotdata.models.database_attachment_info import DatabaseAttachmentInfo as DatabaseAttachmentInfo +from hotdata.models.database_context_entry import DatabaseContextEntry as DatabaseContextEntry from hotdata.models.database_default_schema_decl import DatabaseDefaultSchemaDecl as DatabaseDefaultSchemaDecl from hotdata.models.database_default_table_decl import DatabaseDefaultTableDecl as DatabaseDefaultTableDecl from hotdata.models.database_detail_response import DatabaseDetailResponse as DatabaseDetailResponse @@ -272,10 +273,10 @@ from hotdata.models.error import Error as Error from hotdata.models.execute_saved_query_request import ExecuteSavedQueryRequest as ExecuteSavedQueryRequest from hotdata.models.get_connection_response import GetConnectionResponse as GetConnectionResponse +from hotdata.models.get_database_context_response import GetDatabaseContextResponse as GetDatabaseContextResponse from hotdata.models.get_dataset_response import GetDatasetResponse as GetDatasetResponse from hotdata.models.get_result_response import GetResultResponse as GetResultResponse from hotdata.models.get_secret_response import GetSecretResponse as GetSecretResponse -from hotdata.models.get_workspace_context_response import GetWorkspaceContextResponse as GetWorkspaceContextResponse from hotdata.models.index_info_response import IndexInfoResponse as IndexInfoResponse from hotdata.models.index_status import IndexStatus as IndexStatus from hotdata.models.information_schema_response import InformationSchemaResponse as InformationSchemaResponse @@ -287,6 +288,7 @@ from hotdata.models.job_type import JobType as JobType from hotdata.models.list_connection_types_response import ListConnectionTypesResponse as ListConnectionTypesResponse from hotdata.models.list_connections_response import ListConnectionsResponse as ListConnectionsResponse +from hotdata.models.list_database_contexts_response import ListDatabaseContextsResponse as ListDatabaseContextsResponse from hotdata.models.list_databases_response import ListDatabasesResponse as ListDatabasesResponse from hotdata.models.list_dataset_versions_response import ListDatasetVersionsResponse as ListDatasetVersionsResponse from hotdata.models.list_datasets_response import ListDatasetsResponse as ListDatasetsResponse @@ -300,7 +302,6 @@ from hotdata.models.list_saved_query_versions_response import ListSavedQueryVersionsResponse as ListSavedQueryVersionsResponse from hotdata.models.list_secrets_response import ListSecretsResponse as ListSecretsResponse from hotdata.models.list_uploads_response import ListUploadsResponse as ListUploadsResponse -from hotdata.models.list_workspace_contexts_response import ListWorkspaceContextsResponse as ListWorkspaceContextsResponse from hotdata.models.list_workspaces_response import ListWorkspacesResponse as ListWorkspacesResponse from hotdata.models.load_managed_table_request import LoadManagedTableRequest as LoadManagedTableRequest from hotdata.models.load_managed_table_response import LoadManagedTableResponse as LoadManagedTableResponse @@ -341,10 +342,9 @@ from hotdata.models.upload_dataset_source import UploadDatasetSource as UploadDatasetSource from hotdata.models.upload_info import UploadInfo as UploadInfo from hotdata.models.upload_response import UploadResponse as UploadResponse -from hotdata.models.upsert_workspace_context_request import UpsertWorkspaceContextRequest as UpsertWorkspaceContextRequest -from hotdata.models.upsert_workspace_context_response import UpsertWorkspaceContextResponse as UpsertWorkspaceContextResponse +from hotdata.models.upsert_database_context_request import UpsertDatabaseContextRequest as UpsertDatabaseContextRequest +from hotdata.models.upsert_database_context_response import UpsertDatabaseContextResponse as UpsertDatabaseContextResponse from hotdata.models.url_dataset_source import UrlDatasetSource as UrlDatasetSource -from hotdata.models.workspace_context_entry import WorkspaceContextEntry as WorkspaceContextEntry from hotdata.models.workspace_detail import WorkspaceDetail as WorkspaceDetail from hotdata.models.workspace_list_item import WorkspaceListItem as WorkspaceListItem diff --git a/hotdata/api/__init__.py b/hotdata/api/__init__.py index 0cac8b2..30250d0 100644 --- a/hotdata/api/__init__.py +++ b/hotdata/api/__init__.py @@ -3,6 +3,7 @@ # import apis into api package from hotdata.api.connection_types_api import ConnectionTypesApi from hotdata.api.connections_api import ConnectionsApi +from hotdata.api.database_context_api import DatabaseContextApi from hotdata.api.databases_api import DatabasesApi from hotdata.api.datasets_api import DatasetsApi from hotdata.api.embedding_providers_api import EmbeddingProvidersApi @@ -17,6 +18,5 @@ from hotdata.api.saved_queries_api import SavedQueriesApi from hotdata.api.secrets_api import SecretsApi from hotdata.api.uploads_api import UploadsApi -from hotdata.api.workspace_context_api import WorkspaceContextApi from hotdata.api.workspaces_api import WorkspacesApi diff --git a/hotdata/api/database_context_api.py b/hotdata/api/database_context_api.py new file mode 100644 index 0000000..230c7dd --- /dev/null +++ b/hotdata/api/database_context_api.py @@ -0,0 +1,1162 @@ +""" + Hotdata API + + Powerful data platform API for datasets, queries, and analytics. + + The version of the OpenAPI document: 1.0.0 + Contact: developers@hotdata.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictStr +from typing_extensions import Annotated +from hotdata.models.get_database_context_response import GetDatabaseContextResponse +from hotdata.models.list_database_contexts_response import ListDatabaseContextsResponse +from hotdata.models.upsert_database_context_request import UpsertDatabaseContextRequest +from hotdata.models.upsert_database_context_response import UpsertDatabaseContextResponse + +from hotdata.api_client import ApiClient, RequestSerialized +from hotdata.api_response import ApiResponse +from hotdata.rest import RESTResponseType + + +class DatabaseContextApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def delete_database_context( + self, + database_id: Annotated[StrictStr, Field(description="Database ID")], + name: Annotated[StrictStr, Field(description="Context key: same character rules as a dataset table name")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Delete database context + + Removes a named context document from a database. + + :param database_id: Database ID (required) + :type database_id: str + :param name: Context key: same character rules as a dataset table name (required) + :type name: str + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_database_context_serialize( + database_id=database_id, + name=name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '400': "ApiErrorResponse", + '404': "ApiErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def delete_database_context_with_http_info( + self, + database_id: Annotated[StrictStr, Field(description="Database ID")], + name: Annotated[StrictStr, Field(description="Context key: same character rules as a dataset table name")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Delete database context + + Removes a named context document from a database. + + :param database_id: Database ID (required) + :type database_id: str + :param name: Context key: same character rules as a dataset table name (required) + :type name: str + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_database_context_serialize( + database_id=database_id, + name=name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '400': "ApiErrorResponse", + '404': "ApiErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def delete_database_context_without_preload_content( + self, + database_id: Annotated[StrictStr, Field(description="Database ID")], + name: Annotated[StrictStr, Field(description="Context key: same character rules as a dataset table name")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete database context + + Removes a named context document from a database. + + :param database_id: Database ID (required) + :type database_id: str + :param name: Context key: same character rules as a dataset table name (required) + :type name: str + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_database_context_serialize( + database_id=database_id, + name=name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '400': "ApiErrorResponse", + '404': "ApiErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _delete_database_context_serialize( + self, + database_id, + name, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if database_id is not None: + _path_params['database_id'] = database_id + if name is not None: + _path_params['name'] = name + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'WorkspaceId', + 'BearerAuth' + ] + + return self.api_client.param_serialize( + method='DELETE', + resource_path='/v1/databases/{database_id}/context/{name}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_database_context( + self, + database_id: Annotated[StrictStr, Field(description="Database ID")], + name: Annotated[StrictStr, Field(description="Context key: same character rules as a dataset table name")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetDatabaseContextResponse: + """Get one database context + + + :param database_id: Database ID (required) + :type database_id: str + :param name: Context key: same character rules as a dataset table name (required) + :type name: str + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_database_context_serialize( + database_id=database_id, + name=name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "GetDatabaseContextResponse", + '400': "ApiErrorResponse", + '404': "ApiErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_database_context_with_http_info( + self, + database_id: Annotated[StrictStr, Field(description="Database ID")], + name: Annotated[StrictStr, Field(description="Context key: same character rules as a dataset table name")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetDatabaseContextResponse]: + """Get one database context + + + :param database_id: Database ID (required) + :type database_id: str + :param name: Context key: same character rules as a dataset table name (required) + :type name: str + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_database_context_serialize( + database_id=database_id, + name=name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "GetDatabaseContextResponse", + '400': "ApiErrorResponse", + '404': "ApiErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_database_context_without_preload_content( + self, + database_id: Annotated[StrictStr, Field(description="Database ID")], + name: Annotated[StrictStr, Field(description="Context key: same character rules as a dataset table name")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get one database context + + + :param database_id: Database ID (required) + :type database_id: str + :param name: Context key: same character rules as a dataset table name (required) + :type name: str + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_database_context_serialize( + database_id=database_id, + name=name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "GetDatabaseContextResponse", + '400': "ApiErrorResponse", + '404': "ApiErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_database_context_serialize( + self, + database_id, + name, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if database_id is not None: + _path_params['database_id'] = database_id + if name is not None: + _path_params['name'] = name + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'WorkspaceId', + 'BearerAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/databases/{database_id}/context/{name}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def list_database_contexts( + self, + database_id: Annotated[StrictStr, Field(description="Database ID")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ListDatabaseContextsResponse: + """List database contexts + + + :param database_id: Database ID (required) + :type database_id: str + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._list_database_contexts_serialize( + database_id=database_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListDatabaseContextsResponse", + '404': "ApiErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def list_database_contexts_with_http_info( + self, + database_id: Annotated[StrictStr, Field(description="Database ID")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ListDatabaseContextsResponse]: + """List database contexts + + + :param database_id: Database ID (required) + :type database_id: str + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._list_database_contexts_serialize( + database_id=database_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListDatabaseContextsResponse", + '404': "ApiErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def list_database_contexts_without_preload_content( + self, + database_id: Annotated[StrictStr, Field(description="Database ID")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List database contexts + + + :param database_id: Database ID (required) + :type database_id: str + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._list_database_contexts_serialize( + database_id=database_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListDatabaseContextsResponse", + '404': "ApiErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _list_database_contexts_serialize( + self, + database_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if database_id is not None: + _path_params['database_id'] = database_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'WorkspaceId', + 'BearerAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/databases/{database_id}/context', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def upsert_database_context( + self, + database_id: Annotated[StrictStr, Field(description="Database ID")], + upsert_database_context_request: UpsertDatabaseContextRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> UpsertDatabaseContextResponse: + """Create or update database context + + Stores a named document (for example Markdown) scoped to a database. Reuses the same name to replace content. + + :param database_id: Database ID (required) + :type database_id: str + :param upsert_database_context_request: (required) + :type upsert_database_context_request: UpsertDatabaseContextRequest + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._upsert_database_context_serialize( + database_id=database_id, + upsert_database_context_request=upsert_database_context_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UpsertDatabaseContextResponse", + '400': "ApiErrorResponse", + '404': "ApiErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def upsert_database_context_with_http_info( + self, + database_id: Annotated[StrictStr, Field(description="Database ID")], + upsert_database_context_request: UpsertDatabaseContextRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[UpsertDatabaseContextResponse]: + """Create or update database context + + Stores a named document (for example Markdown) scoped to a database. Reuses the same name to replace content. + + :param database_id: Database ID (required) + :type database_id: str + :param upsert_database_context_request: (required) + :type upsert_database_context_request: UpsertDatabaseContextRequest + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._upsert_database_context_serialize( + database_id=database_id, + upsert_database_context_request=upsert_database_context_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UpsertDatabaseContextResponse", + '400': "ApiErrorResponse", + '404': "ApiErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def upsert_database_context_without_preload_content( + self, + database_id: Annotated[StrictStr, Field(description="Database ID")], + upsert_database_context_request: UpsertDatabaseContextRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create or update database context + + Stores a named document (for example Markdown) scoped to a database. Reuses the same name to replace content. + + :param database_id: Database ID (required) + :type database_id: str + :param upsert_database_context_request: (required) + :type upsert_database_context_request: UpsertDatabaseContextRequest + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._upsert_database_context_serialize( + database_id=database_id, + upsert_database_context_request=upsert_database_context_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UpsertDatabaseContextResponse", + '400': "ApiErrorResponse", + '404': "ApiErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _upsert_database_context_serialize( + self, + database_id, + upsert_database_context_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if database_id is not None: + _path_params['database_id'] = database_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if upsert_database_context_request is not None: + _body_params = upsert_database_context_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'WorkspaceId', + 'BearerAuth' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/v1/databases/{database_id}/context', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/hotdata/api_client.py b/hotdata/api_client.py index 33f8db9..07e72e8 100644 --- a/hotdata/api_client.py +++ b/hotdata/api_client.py @@ -91,7 +91,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/0.2.2/python' + self.user_agent = 'OpenAPI-Generator/0.2.3/python' self.client_side_validation = configuration.client_side_validation def __enter__(self): diff --git a/hotdata/models/__init__.py b/hotdata/models/__init__.py index 7bbb976..58f1201 100644 --- a/hotdata/models/__init__.py +++ b/hotdata/models/__init__.py @@ -52,6 +52,7 @@ from hotdata.models.create_workspace_request import CreateWorkspaceRequest from hotdata.models.create_workspace_response import CreateWorkspaceResponse from hotdata.models.database_attachment_info import DatabaseAttachmentInfo +from hotdata.models.database_context_entry import DatabaseContextEntry from hotdata.models.database_default_schema_decl import DatabaseDefaultSchemaDecl from hotdata.models.database_default_table_decl import DatabaseDefaultTableDecl from hotdata.models.database_detail_response import DatabaseDetailResponse @@ -70,10 +71,10 @@ from hotdata.models.error import Error from hotdata.models.execute_saved_query_request import ExecuteSavedQueryRequest from hotdata.models.get_connection_response import GetConnectionResponse +from hotdata.models.get_database_context_response import GetDatabaseContextResponse from hotdata.models.get_dataset_response import GetDatasetResponse from hotdata.models.get_result_response import GetResultResponse from hotdata.models.get_secret_response import GetSecretResponse -from hotdata.models.get_workspace_context_response import GetWorkspaceContextResponse from hotdata.models.index_info_response import IndexInfoResponse from hotdata.models.index_status import IndexStatus from hotdata.models.information_schema_response import InformationSchemaResponse @@ -85,6 +86,7 @@ from hotdata.models.job_type import JobType from hotdata.models.list_connection_types_response import ListConnectionTypesResponse from hotdata.models.list_connections_response import ListConnectionsResponse +from hotdata.models.list_database_contexts_response import ListDatabaseContextsResponse from hotdata.models.list_databases_response import ListDatabasesResponse from hotdata.models.list_dataset_versions_response import ListDatasetVersionsResponse from hotdata.models.list_datasets_response import ListDatasetsResponse @@ -98,7 +100,6 @@ from hotdata.models.list_saved_query_versions_response import ListSavedQueryVersionsResponse from hotdata.models.list_secrets_response import ListSecretsResponse from hotdata.models.list_uploads_response import ListUploadsResponse -from hotdata.models.list_workspace_contexts_response import ListWorkspaceContextsResponse from hotdata.models.list_workspaces_response import ListWorkspacesResponse from hotdata.models.load_managed_table_request import LoadManagedTableRequest from hotdata.models.load_managed_table_response import LoadManagedTableResponse @@ -139,10 +140,9 @@ from hotdata.models.upload_dataset_source import UploadDatasetSource from hotdata.models.upload_info import UploadInfo from hotdata.models.upload_response import UploadResponse -from hotdata.models.upsert_workspace_context_request import UpsertWorkspaceContextRequest -from hotdata.models.upsert_workspace_context_response import UpsertWorkspaceContextResponse +from hotdata.models.upsert_database_context_request import UpsertDatabaseContextRequest +from hotdata.models.upsert_database_context_response import UpsertDatabaseContextResponse from hotdata.models.url_dataset_source import UrlDatasetSource -from hotdata.models.workspace_context_entry import WorkspaceContextEntry from hotdata.models.workspace_detail import WorkspaceDetail from hotdata.models.workspace_list_item import WorkspaceListItem diff --git a/hotdata/models/database_context_entry.py b/hotdata/models/database_context_entry.py new file mode 100644 index 0000000..b930fe3 --- /dev/null +++ b/hotdata/models/database_context_entry.py @@ -0,0 +1,93 @@ +# coding: utf-8 + +""" + Hotdata API + + Powerful data platform API for datasets, queries, and analytics. + + The version of the OpenAPI document: 1.0.0 + Contact: developers@hotdata.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class DatabaseContextEntry(BaseModel): + """ + One context entry returned by the API. + """ # noqa: E501 + content: StrictStr + name: StrictStr + updated_at: datetime + __properties: ClassVar[List[str]] = ["content", "name", "updated_at"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DatabaseContextEntry from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DatabaseContextEntry from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "content": obj.get("content"), + "name": obj.get("name"), + "updated_at": obj.get("updated_at") + }) + return _obj + + diff --git a/hotdata/models/get_database_context_response.py b/hotdata/models/get_database_context_response.py new file mode 100644 index 0000000..9ed42a9 --- /dev/null +++ b/hotdata/models/get_database_context_response.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + Hotdata API + + Powerful data platform API for datasets, queries, and analytics. + + The version of the OpenAPI document: 1.0.0 + Contact: developers@hotdata.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from hotdata.models.database_context_entry import DatabaseContextEntry +from typing import Optional, Set +from typing_extensions import Self + +class GetDatabaseContextResponse(BaseModel): + """ + Response body for GET `/v1/databases/{database_id}/context/{name}`. + """ # noqa: E501 + context: DatabaseContextEntry + __properties: ClassVar[List[str]] = ["context"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetDatabaseContextResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of context + if self.context: + _dict['context'] = self.context.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetDatabaseContextResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "context": DatabaseContextEntry.from_dict(obj["context"]) if obj.get("context") is not None else None + }) + return _obj + + diff --git a/hotdata/models/list_database_contexts_response.py b/hotdata/models/list_database_contexts_response.py new file mode 100644 index 0000000..8464222 --- /dev/null +++ b/hotdata/models/list_database_contexts_response.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + Hotdata API + + Powerful data platform API for datasets, queries, and analytics. + + The version of the OpenAPI document: 1.0.0 + Contact: developers@hotdata.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from hotdata.models.database_context_entry import DatabaseContextEntry +from typing import Optional, Set +from typing_extensions import Self + +class ListDatabaseContextsResponse(BaseModel): + """ + Response body for GET `/v1/databases/{database_id}/context`. + """ # noqa: E501 + contexts: List[DatabaseContextEntry] + __properties: ClassVar[List[str]] = ["contexts"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ListDatabaseContextsResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in contexts (list) + _items = [] + if self.contexts: + for _item_contexts in self.contexts: + if _item_contexts: + _items.append(_item_contexts.to_dict()) + _dict['contexts'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ListDatabaseContextsResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "contexts": [DatabaseContextEntry.from_dict(_item) for _item in obj["contexts"]] if obj.get("contexts") is not None else None + }) + return _obj + + diff --git a/hotdata/models/upsert_database_context_request.py b/hotdata/models/upsert_database_context_request.py new file mode 100644 index 0000000..e54b1eb --- /dev/null +++ b/hotdata/models/upsert_database_context_request.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + Hotdata API + + Powerful data platform API for datasets, queries, and analytics. + + The version of the OpenAPI document: 1.0.0 + Contact: developers@hotdata.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class UpsertDatabaseContextRequest(BaseModel): + """ + Request body for POST `/v1/databases/{database_id}/context`. + """ # noqa: E501 + content: StrictStr + name: StrictStr = Field(description="Upsert key in the catalog. Validated with dataset table-name rules (preserves case): ASCII letter or `_` first; then alphanumeric or `_` only; 1–128 chars; not a SQL reserved word.") + __properties: ClassVar[List[str]] = ["content", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of UpsertDatabaseContextRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UpsertDatabaseContextRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "content": obj.get("content"), + "name": obj.get("name") + }) + return _obj + + diff --git a/hotdata/models/upsert_database_context_response.py b/hotdata/models/upsert_database_context_response.py new file mode 100644 index 0000000..9870a68 --- /dev/null +++ b/hotdata/models/upsert_database_context_response.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + Hotdata API + + Powerful data platform API for datasets, queries, and analytics. + + The version of the OpenAPI document: 1.0.0 + Contact: developers@hotdata.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from hotdata.models.database_context_entry import DatabaseContextEntry +from typing import Optional, Set +from typing_extensions import Self + +class UpsertDatabaseContextResponse(BaseModel): + """ + Response body for POST `/v1/databases/{database_id}/context`. + """ # noqa: E501 + context: DatabaseContextEntry + __properties: ClassVar[List[str]] = ["context"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of UpsertDatabaseContextResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of context + if self.context: + _dict['context'] = self.context.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UpsertDatabaseContextResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "context": DatabaseContextEntry.from_dict(obj["context"]) if obj.get("context") is not None else None + }) + return _obj + + diff --git a/test/test_database_context_api.py b/test/test_database_context_api.py new file mode 100644 index 0000000..df3c2a0 --- /dev/null +++ b/test/test_database_context_api.py @@ -0,0 +1,60 @@ +# coding: utf-8 + +""" + Hotdata API + + Powerful data platform API for datasets, queries, and analytics. + + The version of the OpenAPI document: 1.0.0 + Contact: developers@hotdata.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from hotdata.api.database_context_api import DatabaseContextApi + + +class TestDatabaseContextApi(unittest.TestCase): + """DatabaseContextApi unit test stubs""" + + def setUp(self) -> None: + self.api = DatabaseContextApi() + + def tearDown(self) -> None: + pass + + def test_delete_database_context(self) -> None: + """Test case for delete_database_context + + Delete database context + """ + pass + + def test_get_database_context(self) -> None: + """Test case for get_database_context + + Get one database context + """ + pass + + def test_list_database_contexts(self) -> None: + """Test case for list_database_contexts + + List database contexts + """ + pass + + def test_upsert_database_context(self) -> None: + """Test case for upsert_database_context + + Create or update database context + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_database_context_entry.py b/test/test_database_context_entry.py new file mode 100644 index 0000000..bfd7950 --- /dev/null +++ b/test/test_database_context_entry.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + Hotdata API + + Powerful data platform API for datasets, queries, and analytics. + + The version of the OpenAPI document: 1.0.0 + Contact: developers@hotdata.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from hotdata.models.database_context_entry import DatabaseContextEntry + +class TestDatabaseContextEntry(unittest.TestCase): + """DatabaseContextEntry unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> DatabaseContextEntry: + """Test DatabaseContextEntry + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `DatabaseContextEntry` + """ + model = DatabaseContextEntry() + if include_optional: + return DatabaseContextEntry( + content = '', + name = '', + updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f') + ) + else: + return DatabaseContextEntry( + content = '', + name = '', + updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + ) + """ + + def testDatabaseContextEntry(self): + """Test DatabaseContextEntry""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_get_database_context_response.py b/test/test_get_database_context_response.py new file mode 100644 index 0000000..d3a75b1 --- /dev/null +++ b/test/test_get_database_context_response.py @@ -0,0 +1,59 @@ +# coding: utf-8 + +""" + Hotdata API + + Powerful data platform API for datasets, queries, and analytics. + + The version of the OpenAPI document: 1.0.0 + Contact: developers@hotdata.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from hotdata.models.get_database_context_response import GetDatabaseContextResponse + +class TestGetDatabaseContextResponse(unittest.TestCase): + """GetDatabaseContextResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> GetDatabaseContextResponse: + """Test GetDatabaseContextResponse + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `GetDatabaseContextResponse` + """ + model = GetDatabaseContextResponse() + if include_optional: + return GetDatabaseContextResponse( + context = hotdata.models.database_context_entry.DatabaseContextEntry( + content = '', + name = '', + updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), ) + ) + else: + return GetDatabaseContextResponse( + context = hotdata.models.database_context_entry.DatabaseContextEntry( + content = '', + name = '', + updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), ), + ) + """ + + def testGetDatabaseContextResponse(self): + """Test GetDatabaseContextResponse""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_list_database_contexts_response.py b/test/test_list_database_contexts_response.py new file mode 100644 index 0000000..ca0fdad --- /dev/null +++ b/test/test_list_database_contexts_response.py @@ -0,0 +1,63 @@ +# coding: utf-8 + +""" + Hotdata API + + Powerful data platform API for datasets, queries, and analytics. + + The version of the OpenAPI document: 1.0.0 + Contact: developers@hotdata.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from hotdata.models.list_database_contexts_response import ListDatabaseContextsResponse + +class TestListDatabaseContextsResponse(unittest.TestCase): + """ListDatabaseContextsResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ListDatabaseContextsResponse: + """Test ListDatabaseContextsResponse + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ListDatabaseContextsResponse` + """ + model = ListDatabaseContextsResponse() + if include_optional: + return ListDatabaseContextsResponse( + contexts = [ + hotdata.models.database_context_entry.DatabaseContextEntry( + content = '', + name = '', + updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), ) + ] + ) + else: + return ListDatabaseContextsResponse( + contexts = [ + hotdata.models.database_context_entry.DatabaseContextEntry( + content = '', + name = '', + updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), ) + ], + ) + """ + + def testListDatabaseContextsResponse(self): + """Test ListDatabaseContextsResponse""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_upsert_database_context_request.py b/test/test_upsert_database_context_request.py new file mode 100644 index 0000000..02e64ef --- /dev/null +++ b/test/test_upsert_database_context_request.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + Hotdata API + + Powerful data platform API for datasets, queries, and analytics. + + The version of the OpenAPI document: 1.0.0 + Contact: developers@hotdata.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from hotdata.models.upsert_database_context_request import UpsertDatabaseContextRequest + +class TestUpsertDatabaseContextRequest(unittest.TestCase): + """UpsertDatabaseContextRequest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> UpsertDatabaseContextRequest: + """Test UpsertDatabaseContextRequest + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `UpsertDatabaseContextRequest` + """ + model = UpsertDatabaseContextRequest() + if include_optional: + return UpsertDatabaseContextRequest( + content = '', + name = '' + ) + else: + return UpsertDatabaseContextRequest( + content = '', + name = '', + ) + """ + + def testUpsertDatabaseContextRequest(self): + """Test UpsertDatabaseContextRequest""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_upsert_database_context_response.py b/test/test_upsert_database_context_response.py new file mode 100644 index 0000000..695f478 --- /dev/null +++ b/test/test_upsert_database_context_response.py @@ -0,0 +1,59 @@ +# coding: utf-8 + +""" + Hotdata API + + Powerful data platform API for datasets, queries, and analytics. + + The version of the OpenAPI document: 1.0.0 + Contact: developers@hotdata.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from hotdata.models.upsert_database_context_response import UpsertDatabaseContextResponse + +class TestUpsertDatabaseContextResponse(unittest.TestCase): + """UpsertDatabaseContextResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> UpsertDatabaseContextResponse: + """Test UpsertDatabaseContextResponse + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `UpsertDatabaseContextResponse` + """ + model = UpsertDatabaseContextResponse() + if include_optional: + return UpsertDatabaseContextResponse( + context = hotdata.models.database_context_entry.DatabaseContextEntry( + content = '', + name = '', + updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), ) + ) + else: + return UpsertDatabaseContextResponse( + context = hotdata.models.database_context_entry.DatabaseContextEntry( + content = '', + name = '', + updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), ), + ) + """ + + def testUpsertDatabaseContextResponse(self): + """Test UpsertDatabaseContextResponse""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main()