From c7ea3aedd7c4ac098f20234adca541b2e967f991 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Wed, 14 Aug 2024 11:48:58 -0700 Subject: [PATCH] [FIX] Update generated rest clients to latest version, enabling pydantic2 interop GitOrigin-RevId: b74dde28f5a25bedaa02397961e3f2cbdc94ef30 --- src/gretel_client/_hybrid/connections_api.py | 20 +- src/gretel_client/_hybrid/workflows_api.py | 29 +- src/gretel_client/rest_v1/api/activity_api.py | 344 +- src/gretel_client/rest_v1/api/clusters_api.py | 621 ++- .../rest_v1/api/connections_api.py | 3181 +++++++---- src/gretel_client/rest_v1/api/logs_api.py | 646 ++- src/gretel_client/rest_v1/api/projects_api.py | 673 ++- .../rest_v1/api/workflows_api.py | 4751 +++++++++++------ src/gretel_client/rest_v1/api_client.py | 528 +- src/gretel_client/rest_v1/api_response.py | 28 +- src/gretel_client/rest_v1/configuration.py | 34 +- src/gretel_client/rest_v1/exceptions.py | 95 +- .../rest_v1/models/activity_event.py | 71 +- src/gretel_client/rest_v1/models/cluster.py | 62 +- .../models/cluster_cloud_provider_info.py | 50 +- .../rest_v1/models/cluster_config.py | 52 +- .../rest_v1/models/cluster_status.py | 64 +- .../models/config_asymmetric_key_metadata.py | 61 +- .../rest_v1/models/connection.py | 102 +- .../models/create_connection_request.py | 68 +- .../rest_v1/models/create_workflow_request.py | 86 +- .../models/create_workflow_run_request.py | 60 +- .../rest_v1/models/event_component.py | 58 +- .../rest_v1/models/get_cluster_response.py | 52 +- .../rest_v1/models/get_log_response.py | 54 +- .../models/get_log_upload_url_response.py | 50 +- .../rest_v1/models/get_project_response.py | 52 +- .../rest_v1/models/get_workflows_response.py | 56 +- .../rest_v1/models/google_protobuf_any.py | 57 +- .../rest_v1/models/list_clusters_response.py | 54 +- .../models/list_connections_response.py | 54 +- .../rest_v1/models/log_envelope.py | 54 +- src/gretel_client/rest_v1/models/project.py | 66 +- .../models/search_activity_response.py | 56 +- .../models/search_connections_response.py | 58 +- .../models/search_projects_response.py | 54 +- .../models/search_workflow_runs_response.py | 59 +- .../models/search_workflow_tasks_response.py | 59 +- .../models/search_workflows_response.py | 58 +- src/gretel_client/rest_v1/models/status.py | 60 +- .../rest_v1/models/status_details.py | 50 +- .../models/update_connection_request.py | 66 +- .../rest_v1/models/user_profile.py | 60 +- .../rest_v1/models/user_profile_image.py | 50 +- ...alidate_connection_credentials_response.py | 64 +- .../validate_workflow_action_response.py | 68 +- .../validate_workflow_config_request.py | 66 +- src/gretel_client/rest_v1/models/workflow.py | 117 +- .../rest_v1/models/workflow_run.py | 157 +- .../workflow_run_cancellation_request.py | 53 +- .../rest_v1/models/workflow_task.py | 130 +- src/gretel_client/rest_v1/rest.py | 320 +- 52 files changed, 8741 insertions(+), 5097 deletions(-) diff --git a/src/gretel_client/_hybrid/connections_api.py b/src/gretel_client/_hybrid/connections_api.py index 82ac593..f65d9e0 100644 --- a/src/gretel_client/_hybrid/connections_api.py +++ b/src/gretel_client/_hybrid/connections_api.py @@ -9,6 +9,7 @@ UpdateConnectionRequest, ) from gretel_client.rest_v1.api_response import ApiResponse +from gretel_client.rest_v1.models.connection import Connection class HybridConnectionsApi(ConnectionsApi): @@ -43,16 +44,29 @@ def __init__( super().__init__(api.api_client) self._creds_encryption = creds_encryption - def create_connection_with_http_info( - self, create_connection_request: CreateConnectionRequest, **kwargs - ) -> ApiResponse: + def _encrypt_creds( + self, create_connection_request: CreateConnectionRequest + ) -> CreateConnectionRequest: if creds := create_connection_request.credentials: create_connection_request.credentials = None encrypted_creds = self._creds_encryption.apply( creds, project_guid=create_connection_request.project_id ) create_connection_request.encrypted_credentials = encrypted_creds + return create_connection_request + def create_connection( + self, + create_connection_request: CreateConnectionRequest, + **kwargs, + ) -> Connection: + create_connection_request = self._encrypt_creds(create_connection_request) + return super().create_connection(create_connection_request, **kwargs) + + def create_connection_with_http_info( + self, create_connection_request: CreateConnectionRequest, **kwargs + ) -> ApiResponse: + create_connection_request = self._encrypt_creds(create_connection_request) return super().create_connection_with_http_info( create_connection_request, **kwargs ) diff --git a/src/gretel_client/_hybrid/workflows_api.py b/src/gretel_client/_hybrid/workflows_api.py index 90c385d..9874206 100644 --- a/src/gretel_client/_hybrid/workflows_api.py +++ b/src/gretel_client/_hybrid/workflows_api.py @@ -4,6 +4,7 @@ from gretel_client.rest_v1.api.workflows_api import CreateWorkflowRequest, WorkflowsApi from gretel_client.rest_v1.api_response import ApiResponse +from gretel_client.rest_v1.models.workflow import Workflow from gretel_client.workflows.runner_mode import RunnerMode @@ -25,18 +26,18 @@ class HybridWorkflowsApi(WorkflowsApi): def __init__(self, api: WorkflowsApi): super().__init__(api.api_client) - # We only override the ..._with_http_info methods, as these are - # the lower-level ones. + def create_workflow( + self, + create_workflow_request: CreateWorkflowRequest, + **kwargs, + ) -> Workflow: + create_workflow_request = _update_runner_mode(create_workflow_request) + return super().create_workflow(create_workflow_request, **kwargs) def create_workflow_with_http_info( self, create_workflow_request: CreateWorkflowRequest, **kwargs ) -> ApiResponse: - if create_workflow_request.runner_mode is None: - create_workflow_request.runner_mode = RunnerMode.RUNNER_MODE_HYBRID.value - elif create_workflow_request.runner_mode != RunnerMode.RUNNER_MODE_HYBRID.value: - raise ValueError( - "in hybrid mode, only workflows with runner mode RUNNER_MODE_HYBRID can be created" - ) + create_workflow_request = _update_runner_mode(create_workflow_request) return super().create_workflow_with_http_info(create_workflow_request, **kwargs) def validate_workflow_action_with_http_info( @@ -54,3 +55,15 @@ def validate_workflow_action_with_http_info( return super().validate_workflow_action_with_http_info( body, runner_mode, **kwargs ) + + +def _update_runner_mode( + create_workflow_request: CreateWorkflowRequest, +) -> CreateWorkflowRequest: + if create_workflow_request.runner_mode is None: + create_workflow_request.runner_mode = RunnerMode.RUNNER_MODE_HYBRID.value + elif create_workflow_request.runner_mode != RunnerMode.RUNNER_MODE_HYBRID.value: + raise ValueError( + "in hybrid mode, only workflows with runner mode RUNNER_MODE_HYBRID can be created" + ) + return create_workflow_request diff --git a/src/gretel_client/rest_v1/api/activity_api.py b/src/gretel_client/rest_v1/api/activity_api.py index 725814f..cfd6c16 100755 --- a/src/gretel_client/rest_v1/api/activity_api.py +++ b/src/gretel_client/rest_v1/api/activity_api.py @@ -11,50 +11,52 @@ Do not edit the class manually. """ # noqa: E501 - -import io -import re # noqa: F401 import warnings -from typing import Optional +from typing import Any, Dict, List, Optional, Tuple, Union -from pydantic import StrictInt, StrictStr, validate_arguments, ValidationError +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call from typing_extensions import Annotated -from gretel_client.rest_v1.api_client import ApiClient +from gretel_client.rest_v1.api_client import ApiClient, RequestSerialized from gretel_client.rest_v1.api_response import ApiResponse -from gretel_client.rest_v1.exceptions import ApiTypeError, ApiValueError # noqa: F401 from gretel_client.rest_v1.models.search_activity_response import SearchActivityResponse +from gretel_client.rest_v1.rest import RESTResponseType -class ActivityApi(object): +class ActivityApi: """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): + def __init__(self, api_client=None) -> None: if api_client is None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def search_activity( self, query: Optional[StrictStr] = None, sort: Optional[StrictStr] = None, limit: Optional[StrictInt] = None, skip: Optional[StrictInt] = None, - **kwargs, - ) -> SearchActivityResponse: # noqa: E501 - """search_activity # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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, + ) -> SearchActivityResponse: + """search_activity - >>> thread = api.search_activity(query, sort, limit, skip, async_req=True) - >>> result = thread.get() :param query: :type query: str @@ -64,42 +66,147 @@ def search_activity( :type limit: int :param skip: :type skip: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: SearchActivityResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the search_activity_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.search_activity_with_http_info( - query, sort, limit, skip, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._search_activity_serialize( + query=query, + sort=sort, + limit=limit, + skip=skip, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchActivityResponse", + } + 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_arguments + @validate_call def search_activity_with_http_info( self, query: Optional[StrictStr] = None, sort: Optional[StrictStr] = None, limit: Optional[StrictInt] = None, skip: Optional[StrictInt] = None, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """search_activity # noqa: E501 + _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[SearchActivityResponse]: + """search_activity + + + :param query: + :type query: str + :param sort: + :type sort: str + :param limit: + :type limit: int + :param skip: + :type skip: int + :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._search_activity_serialize( + query=query, + sort=sort, + limit=limit, + skip=skip, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchActivityResponse", + } + 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, + ) - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def search_activity_without_preload_content( + self, + query: Optional[StrictStr] = None, + sort: Optional[StrictStr] = None, + limit: Optional[StrictInt] = None, + skip: Optional[StrictInt] = None, + _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: + """search_activity - >>> thread = api.search_activity_with_http_info(query, sort, limit, skip, async_req=True) - >>> result = thread.get() :param query: :type query: str @@ -109,109 +216,112 @@ def search_activity_with_http_info( :type limit: int :param skip: :type skip: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(SearchActivityResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["query", "sort", "limit", "skip"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] + """ # noqa: E501 + + _param = self._search_activity_serialize( + query=query, + sort=sort, + limit=limit, + skip=skip, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, ) - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method search_activity" % _key - ) - _params[_key] = _val - del _params["kwargs"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchActivityResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response - _collection_formats = {} + def _search_activity_serialize( + self, + query, + sort, + limit, + skip, + _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]] = {} + _body_params: Optional[bytes] = None # process the path parameters - _path_params = {} - # process the query parameters - _query_params = [] - if _params.get("query") is not None: # noqa: E501 - _query_params.append(("query", _params["query"])) + if query is not None: + + _query_params.append(("query", query)) + + if sort is not None: + + _query_params.append(("sort", sort)) + + if limit is not None: - if _params.get("sort") is not None: # noqa: E501 - _query_params.append(("sort", _params["sort"])) + _query_params.append(("limit", limit)) - if _params.get("limit") is not None: # noqa: E501 - _query_params.append(("limit", _params["limit"])) + if skip is not None: - if _params.get("skip") is not None: # noqa: E501 - _query_params.append(("skip", _params["skip"])) + _query_params.append(("skip", skip)) # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "SearchActivityResponse", - } - - return self.api_client.call_api( - "/v1/activity", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/activity", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) diff --git a/src/gretel_client/rest_v1/api/clusters_api.py b/src/gretel_client/rest_v1/api/clusters_api.py index bd28bc9..2415324 100755 --- a/src/gretel_client/rest_v1/api/clusters_api.py +++ b/src/gretel_client/rest_v1/api/clusters_api.py @@ -11,334 +11,523 @@ Do not edit the class manually. """ # noqa: E501 - -import io -import re # noqa: F401 import warnings -from typing import Optional +from typing import Any, Dict, List, Optional, Tuple, Union -from pydantic import conlist, StrictBool, StrictStr, validate_arguments, ValidationError +from pydantic import Field, StrictBool, StrictFloat, StrictInt, StrictStr, validate_call from typing_extensions import Annotated -from gretel_client.rest_v1.api_client import ApiClient +from gretel_client.rest_v1.api_client import ApiClient, RequestSerialized from gretel_client.rest_v1.api_response import ApiResponse -from gretel_client.rest_v1.exceptions import ApiTypeError, ApiValueError # noqa: F401 from gretel_client.rest_v1.models.get_cluster_response import GetClusterResponse from gretel_client.rest_v1.models.list_clusters_response import ListClustersResponse +from gretel_client.rest_v1.rest import RESTResponseType -class ClustersApi(object): +class ClustersApi: """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): + def __init__(self, api_client=None) -> None: if api_client is None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def get_cluster( - self, cluster_id: StrictStr, **kwargs - ) -> GetClusterResponse: # noqa: E501 - """get_cluster # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + self, + cluster_id: StrictStr, + _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, + ) -> GetClusterResponse: + """get_cluster - >>> thread = api.get_cluster(cluster_id, async_req=True) - >>> result = thread.get() :param cluster_id: (required) :type cluster_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: GetClusterResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the get_cluster_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.get_cluster_with_http_info(cluster_id, **kwargs) # noqa: E501 + """ # noqa: E501 + + _param = self._get_cluster_serialize( + cluster_id=cluster_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetClusterResponse", + } + 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_arguments + @validate_call def get_cluster_with_http_info( - self, cluster_id: StrictStr, **kwargs - ) -> ApiResponse: # noqa: E501 - """get_cluster # noqa: E501 + self, + cluster_id: StrictStr, + _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[GetClusterResponse]: + """get_cluster + + + :param cluster_id: (required) + :type cluster_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._get_cluster_serialize( + cluster_id=cluster_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetClusterResponse", + } + 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, + ) - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def get_cluster_without_preload_content( + self, + cluster_id: StrictStr, + _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_cluster - >>> thread = api.get_cluster_with_http_info(cluster_id, async_req=True) - >>> result = thread.get() :param cluster_id: (required) :type cluster_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(GetClusterResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["cluster_id"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] + """ # noqa: E501 + + _param = self._get_cluster_serialize( + cluster_id=cluster_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetClusterResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout ) + return response_data.response - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_cluster" % _key - ) - _params[_key] = _val - del _params["kwargs"] + def _get_cluster_serialize( + self, + cluster_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: - _collection_formats = {} + _host = None - # process the path parameters - _path_params = {} - if _params["cluster_id"]: - _path_params["cluster_id"] = _params["cluster_id"] + _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]] = {} + _body_params: Optional[bytes] = None + # process the path parameters + if cluster_id is not None: + _path_params["cluster_id"] = cluster_id # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "GetClusterResponse", - } - - return self.api_client.call_api( - "/v1/clusters/{cluster_id}", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/clusters/{cluster_id}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def list_clusters( self, owned_only: Optional[StrictBool] = None, - expand: Optional[conlist(StrictStr)] = None, - **kwargs, - ) -> ListClustersResponse: # noqa: E501 - """list_clusters # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + expand: Optional[List[StrictStr]] = None, + _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, + ) -> ListClustersResponse: + """list_clusters - >>> thread = api.list_clusters(owned_only, expand, async_req=True) - >>> result = thread.get() :param owned_only: :type owned_only: bool :param expand: :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: ListClustersResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the list_clusters_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.list_clusters_with_http_info( - owned_only, expand, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._list_clusters_serialize( + owned_only=owned_only, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ListClustersResponse", + } + 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_arguments + @validate_call def list_clusters_with_http_info( self, owned_only: Optional[StrictBool] = None, - expand: Optional[conlist(StrictStr)] = None, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """list_clusters # noqa: E501 + expand: Optional[List[StrictStr]] = None, + _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[ListClustersResponse]: + """list_clusters - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_clusters_with_http_info(owned_only, expand, async_req=True) - >>> result = thread.get() + :param owned_only: + :type owned_only: bool + :param expand: + :type expand: List[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_clusters_serialize( + owned_only=owned_only, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ListClustersResponse", + } + 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_clusters_without_preload_content( + self, + owned_only: Optional[StrictBool] = None, + expand: Optional[List[StrictStr]] = None, + _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_clusters + :param owned_only: :type owned_only: bool :param expand: :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(ListClustersResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["owned_only", "expand"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] + """ # noqa: E501 + + _param = self._list_clusters_serialize( + owned_only=owned_only, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, ) - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method list_clusters" % _key - ) - _params[_key] = _val - del _params["kwargs"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "ListClustersResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response - _collection_formats = {} + def _list_clusters_serialize( + self, + owned_only, + expand, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + "expand": "multi", + } - # process the path parameters - _path_params = {} + _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]] = {} + _body_params: Optional[bytes] = None + # process the path parameters # process the query parameters - _query_params = [] - if _params.get("owned_only") is not None: # noqa: E501 - _query_params.append(("owned_only", _params["owned_only"])) + if owned_only is not None: + + _query_params.append(("owned_only", owned_only)) - if _params.get("expand") is not None: # noqa: E501 - _query_params.append(("expand", _params["expand"])) - _collection_formats["expand"] = "multi" + if expand is not None: + + _query_params.append(("expand", expand)) # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "ListClustersResponse", - } - - return self.api_client.call_api( - "/v1/clusters", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/clusters", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) diff --git a/src/gretel_client/rest_v1/api/connections_api.py b/src/gretel_client/rest_v1/api/connections_api.py index b6503da..da71897 100755 --- a/src/gretel_client/rest_v1/api/connections_api.py +++ b/src/gretel_client/rest_v1/api/connections_api.py @@ -11,19 +11,15 @@ Do not edit the class manually. """ # noqa: E501 - -import io -import re # noqa: F401 import warnings -from typing import Optional +from typing import Any, Dict, List, Optional, Tuple, Union -from pydantic import Field, StrictInt, StrictStr, validate_arguments, ValidationError +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call from typing_extensions import Annotated -from gretel_client.rest_v1.api_client import ApiClient +from gretel_client.rest_v1.api_client import ApiClient, RequestSerialized from gretel_client.rest_v1.api_response import ApiResponse -from gretel_client.rest_v1.exceptions import ApiTypeError, ApiValueError # noqa: F401 from gretel_client.rest_v1.models.connection import Connection from gretel_client.rest_v1.models.create_connection_request import ( CreateConnectionRequest, @@ -40,1042 +36,1687 @@ from gretel_client.rest_v1.models.validate_connection_credentials_response import ( ValidateConnectionCredentialsResponse, ) +from gretel_client.rest_v1.rest import RESTResponseType -class ConnectionsApi(object): +class ConnectionsApi: """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): + def __init__(self, api_client=None) -> None: if api_client is None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def create_connection( - self, create_connection_request: CreateConnectionRequest, **kwargs - ) -> Connection: # noqa: E501 - """create_connection # noqa: E501 - - Create a new connection. Credentials may be provided in plaintext or pre-encrypted. Plaintext credentials will be encrypted by Gretel. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + self, + create_connection_request: CreateConnectionRequest, + _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, + ) -> Connection: + """create_connection - >>> thread = api.create_connection(create_connection_request, async_req=True) - >>> result = thread.get() + Create a new connection. Credentials may be provided in plaintext or pre-encrypted. Plaintext credentials will be encrypted by Gretel. :param create_connection_request: (required) :type create_connection_request: CreateConnectionRequest - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: Connection - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the create_connection_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.create_connection_with_http_info( - create_connection_request, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._create_connection_serialize( + create_connection_request=create_connection_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - @validate_arguments + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + 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 create_connection_with_http_info( - self, create_connection_request: CreateConnectionRequest, **kwargs - ) -> ApiResponse: # noqa: E501 - """create_connection # noqa: E501 + self, + create_connection_request: CreateConnectionRequest, + _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[Connection]: + """create_connection + + Create a new connection. Credentials may be provided in plaintext or pre-encrypted. Plaintext credentials will be encrypted by Gretel. + + :param create_connection_request: (required) + :type create_connection_request: CreateConnectionRequest + :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._create_connection_serialize( + create_connection_request=create_connection_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - Create a new connection. Credentials may be provided in plaintext or pre-encrypted. Plaintext credentials will be encrypted by Gretel. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + 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, + ) - >>> thread = api.create_connection_with_http_info(create_connection_request, async_req=True) - >>> result = thread.get() + @validate_call + def create_connection_without_preload_content( + self, + create_connection_request: CreateConnectionRequest, + _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_connection + + Create a new connection. Credentials may be provided in plaintext or pre-encrypted. Plaintext credentials will be encrypted by Gretel. :param create_connection_request: (required) :type create_connection_request: CreateConnectionRequest - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(Connection, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["create_connection_request"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method create_connection" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._create_connection_serialize( + create_connection_request=create_connection_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _create_connection_serialize( + self, + create_connection_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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None - if _params["create_connection_request"] is not None: - _body_params = _params["create_connection_request"] + if create_connection_request is not None: + _body_params = create_connection_request # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` - _content_types_list = _params.get( - "_content_type", - self.api_client.select_header_content_type(["application/json"]), - ) - if _content_types_list: - _header_params["Content-Type"] = _content_types_list + 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 = [] # noqa: E501 - - _response_types_map = { - "200": "Connection", - } - - return self.api_client.call_api( - "/v1/connections", - "POST", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1/connections", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def delete_connection( self, connection_id: Annotated[ - StrictStr, Field(..., description="The connection ID to delete.") + StrictStr, Field(description="The connection ID to delete.") ], - **kwargs, - ) -> None: # noqa: E501 - """delete_connection # noqa: E501 - - Delete a connection by ID. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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_connection - >>> thread = api.delete_connection(connection_id, async_req=True) - >>> result = thread.get() + Delete a connection by ID. :param connection_id: The connection ID to delete. (required) :type connection_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: None - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the delete_connection_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.delete_connection_with_http_info( - connection_id, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._delete_connection_serialize( + connection_id=connection_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - @validate_arguments + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + } + 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_connection_with_http_info( self, connection_id: Annotated[ - StrictStr, Field(..., description="The connection ID to delete.") + StrictStr, Field(description="The connection ID to delete.") ], - **kwargs, - ) -> ApiResponse: # noqa: E501 - """delete_connection # noqa: E501 + _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_connection + + Delete a connection by ID. - Delete a connection by ID. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + :param connection_id: The connection ID to delete. (required) + :type connection_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._delete_connection_serialize( + connection_id=connection_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - >>> thread = api.delete_connection_with_http_info(connection_id, async_req=True) - >>> result = thread.get() + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + } + 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_connection_without_preload_content( + self, + connection_id: Annotated[ + StrictStr, Field(description="The connection ID to delete.") + ], + _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_connection + + Delete a connection by ID. :param connection_id: The connection ID to delete. (required) :type connection_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: None - """ - - _params = locals() - - _all_params = ["connection_id"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method delete_connection" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._delete_connection_serialize( + connection_id=connection_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} - if _params["connection_id"]: - _path_params["connection_id"] = _params["connection_id"] + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _delete_connection_serialize( + self, + connection_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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if connection_id is not None: + _path_params["connection_id"] = connection_id # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = {} - - return self.api_client.call_api( - "/v1/connections/{connection_id}", - "DELETE", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/v1/connections/{connection_id}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def get_connection( - self, connection_id: StrictStr, **kwargs - ) -> Connection: # noqa: E501 - """get_connection # noqa: E501 - - Get a single connection by ID. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + self, + connection_id: StrictStr, + _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, + ) -> Connection: + """get_connection - >>> thread = api.get_connection(connection_id, async_req=True) - >>> result = thread.get() + Get a single connection by ID. :param connection_id: (required) :type connection_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: Connection - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the get_connection_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.get_connection_with_http_info(connection_id, **kwargs) # noqa: E501 + """ # noqa: E501 + + _param = self._get_connection_serialize( + connection_id=connection_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + 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_arguments + @validate_call def get_connection_with_http_info( - self, connection_id: StrictStr, **kwargs - ) -> ApiResponse: # noqa: E501 - """get_connection # noqa: E501 + self, + connection_id: StrictStr, + _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[Connection]: + """get_connection + + Get a single connection by ID. + + :param connection_id: (required) + :type connection_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._get_connection_serialize( + connection_id=connection_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - Get a single connection by ID. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + 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_connection_without_preload_content( + self, + connection_id: StrictStr, + _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_connection - >>> thread = api.get_connection_with_http_info(connection_id, async_req=True) - >>> result = thread.get() + Get a single connection by ID. :param connection_id: (required) :type connection_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(Connection, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["connection_id"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_connection" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._get_connection_serialize( + connection_id=connection_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} - if _params["connection_id"]: - _path_params["connection_id"] = _params["connection_id"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _get_connection_serialize( + self, + connection_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]] = {} + _body_params: Optional[bytes] = None + # process the path parameters + if connection_id is not None: + _path_params["connection_id"] = connection_id # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "Connection", - } - - return self.api_client.call_api( - "/v1/connections/{connection_id}", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/connections/{connection_id}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def get_connection_with_credentials( - self, connection_id: StrictStr, **kwargs - ) -> Connection: # noqa: E501 - """get_connection_with_credentials # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + self, + connection_id: StrictStr, + _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, + ) -> Connection: + """get_connection_with_credentials - >>> thread = api.get_connection_with_credentials(connection_id, async_req=True) - >>> result = thread.get() :param connection_id: (required) :type connection_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: Connection - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the get_connection_with_credentials_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.get_connection_with_credentials_with_http_info( - connection_id, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._get_connection_with_credentials_serialize( + connection_id=connection_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + 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_arguments + @validate_call def get_connection_with_credentials_with_http_info( - self, connection_id: StrictStr, **kwargs - ) -> ApiResponse: # noqa: E501 - """get_connection_with_credentials # noqa: E501 + self, + connection_id: StrictStr, + _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[Connection]: + """get_connection_with_credentials + - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + :param connection_id: (required) + :type connection_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._get_connection_with_credentials_serialize( + connection_id=connection_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + 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_connection_with_credentials_without_preload_content( + self, + connection_id: StrictStr, + _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_connection_with_credentials - >>> thread = api.get_connection_with_credentials_with_http_info(connection_id, async_req=True) - >>> result = thread.get() :param connection_id: (required) :type connection_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(Connection, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["connection_id"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_connection_with_credentials" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._get_connection_with_credentials_serialize( + connection_id=connection_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} - if _params["connection_id"]: - _path_params["connection_id"] = _params["connection_id"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _get_connection_with_credentials_serialize( + self, + connection_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]] = {} + _body_params: Optional[bytes] = None + # process the path parameters + if connection_id is not None: + _path_params["connection_id"] = connection_id # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "Connection", - } - - return self.api_client.call_api( - "/v1/connections/{connection_id}/credentials", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/connections/{connection_id}/credentials", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def get_gretel_connection_with_credentials( - self, workflow_run_id: Optional[StrictStr] = None, **kwargs - ) -> Connection: # noqa: E501 - """get_gretel_connection_with_credentials # noqa: E501 - - Get connection details along with credentials. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + self, + workflow_run_id: Optional[StrictStr] = None, + _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, + ) -> Connection: + """get_gretel_connection_with_credentials - >>> thread = api.get_gretel_connection_with_credentials(workflow_run_id, async_req=True) - >>> result = thread.get() + Get connection details along with credentials. :param workflow_run_id: :type workflow_run_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: Connection - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the get_gretel_connection_with_credentials_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.get_gretel_connection_with_credentials_with_http_info( - workflow_run_id, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._get_gretel_connection_with_credentials_serialize( + workflow_run_id=workflow_run_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - @validate_arguments + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + 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_gretel_connection_with_credentials_with_http_info( - self, workflow_run_id: Optional[StrictStr] = None, **kwargs - ) -> ApiResponse: # noqa: E501 - """get_gretel_connection_with_credentials # noqa: E501 + self, + workflow_run_id: Optional[StrictStr] = None, + _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[Connection]: + """get_gretel_connection_with_credentials - Get connection details along with credentials. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + Get connection details along with credentials. - >>> thread = api.get_gretel_connection_with_credentials_with_http_info(workflow_run_id, async_req=True) - >>> result = thread.get() + :param workflow_run_id: + :type workflow_run_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._get_gretel_connection_with_credentials_serialize( + workflow_run_id=workflow_run_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + 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_gretel_connection_with_credentials_without_preload_content( + self, + workflow_run_id: Optional[StrictStr] = None, + _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_gretel_connection_with_credentials + + Get connection details along with credentials. :param workflow_run_id: :type workflow_run_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(Connection, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["workflow_run_id"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_gretel_connection_with_credentials" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._get_gretel_connection_with_credentials_serialize( + workflow_run_id=workflow_run_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _get_gretel_connection_with_credentials_serialize( + self, + workflow_run_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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters # process the query parameters - _query_params = [] - if _params.get("workflow_run_id") is not None: # noqa: E501 - _query_params.append(("workflow_run_id", _params["workflow_run_id"])) + if workflow_run_id is not None: + + _query_params.append(("workflow_run_id", workflow_run_id)) # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/connections/gretel", + 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, + ) - _response_types_map = { - "200": "Connection", + @validate_call + def list_connections( + self, + _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, + ) -> ListConnectionsResponse: + """list_connections + + List all connections available to the user. + + :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_connections_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ListConnectionsResponse", + } + 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_connections_with_http_info( + self, + _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[ListConnectionsResponse]: + """list_connections + + List all connections available to the user. + + :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_connections_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ListConnectionsResponse", } + 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_connections_without_preload_content( + self, + _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_connections - return self.api_client.call_api( - "/v1/connections/gretel", - "GET", - _path_params, - _query_params, - _header_params, + List all connections available to the user. + + :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_connections_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ListConnectionsResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _list_connections_serialize( + self, + _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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # 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] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/connections", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments - def list_connections(self, **kwargs) -> ListConnectionsResponse: # noqa: E501 - """list_connections # noqa: E501 - - List all connections available to the user. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def list_sample_connections( + self, + _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, + ) -> ListConnectionsResponse: + """list_sample_connections - >>> thread = api.list_connections(async_req=True) - >>> result = thread.get() + List all sample connections available to the user. - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: ListConnectionsResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the list_connections_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.list_connections_with_http_info(**kwargs) # noqa: E501 - - @validate_arguments - def list_connections_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 - """list_connections # noqa: E501 - - List all connections available to the user. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.list_connections_with_http_info(async_req=True) - >>> result = thread.get() - - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(ListConnectionsResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method list_connections" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get("_headers", {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + """ # noqa: E501 - # authentication setting - _auth_settings = [] # noqa: E501 + _param = self._list_sample_connections_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { "200": "ListConnectionsResponse", } - - return self.api_client.call_api( - "/v1/connections", - "GET", - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), - collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + 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_arguments - def list_sample_connections( - self, **kwargs - ) -> ListConnectionsResponse: # noqa: E501 - """list_sample_connections # noqa: E501 - - List all sample connections available to the user. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def list_sample_connections_with_http_info( + self, + _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[ListConnectionsResponse]: + """list_sample_connections - >>> thread = api.list_sample_connections(async_req=True) - >>> result = thread.get() + List all sample connections available to the user. - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: ListConnectionsResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the list_sample_connections_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.list_sample_connections_with_http_info(**kwargs) # noqa: E501 + """ # noqa: E501 + + _param = self._list_sample_connections_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ListConnectionsResponse", + } + 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_sample_connections_without_preload_content( + self, + _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_sample_connections + + List all sample connections available to the user. - @validate_arguments - def list_sample_connections_with_http_info( - self, **kwargs - ) -> ApiResponse: # noqa: E501 - """list_sample_connections # noqa: E501 - - List all sample connections available to the user. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.list_sample_connections_with_http_info(async_req=True) - >>> result = thread.get() - - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(ListConnectionsResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method list_sample_connections" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 - # process the path parameters - _path_params = {} + _param = self._list_sample_connections_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ListConnectionsResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + def _list_sample_connections_serialize( + self, + _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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "ListConnectionsResponse", - } - - return self.api_client.call_api( - "/v1/connections/sample_connections", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/connections/sample_connections", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def search_connections( self, query: Annotated[ @@ -1100,16 +1741,21 @@ def search_connections( Optional[StrictInt], Field(description="Number of connections to skip before applying limit."), ] = None, - **kwargs, - ) -> SearchConnectionsResponse: # noqa: E501 - """search_connections # noqa: E501 - - Search for connections available to the user. This endpoint supports pagination and querying. Valid query fields are: `project_id` Example query: `/v1/connections/search?query=project_id:proj_123abc&sort=-created_at # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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, + ) -> SearchConnectionsResponse: + """search_connections - >>> thread = api.search_connections(query, sort, limit, skip, async_req=True) - >>> result = thread.get() + Search for connections available to the user. This endpoint supports pagination and querying. Valid query fields are: `project_id` Example query: `/v1/connections/search?query=project_id:proj_123abc&sort=-created_at :param query: Query string to filter connections. Supported fields are: `project_id` :type query: str @@ -1119,27 +1765,52 @@ def search_connections( :type limit: int :param skip: Number of connections to skip before applying limit. :type skip: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: SearchConnectionsResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the search_connections_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.search_connections_with_http_info( - query, sort, limit, skip, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._search_connections_serialize( + query=query, + sort=sort, + limit=limit, + skip=skip, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchConnectionsResponse", + } + 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_arguments + @validate_call def search_connections_with_http_info( self, query: Annotated[ @@ -1164,16 +1835,115 @@ def search_connections_with_http_info( Optional[StrictInt], Field(description="Number of connections to skip before applying limit."), ] = None, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """search_connections # noqa: E501 + _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[SearchConnectionsResponse]: + """search_connections + + Search for connections available to the user. This endpoint supports pagination and querying. Valid query fields are: `project_id` Example query: `/v1/connections/search?query=project_id:proj_123abc&sort=-created_at + + :param query: Query string to filter connections. Supported fields are: `project_id` + :type query: str + :param sort: Sort order for connections. Supported sort fields are: `created_at`, `updated_at` + :type sort: str + :param limit: Maximum number of connections to return. Default is no limit. + :type limit: int + :param skip: Number of connections to skip before applying limit. + :type skip: int + :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._search_connections_serialize( + query=query, + sort=sort, + limit=limit, + skip=skip, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchConnectionsResponse", + } + 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, + ) - Search for connections available to the user. This endpoint supports pagination and querying. Valid query fields are: `project_id` Example query: `/v1/connections/search?query=project_id:proj_123abc&sort=-created_at # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def search_connections_without_preload_content( + self, + query: Annotated[ + Optional[StrictStr], + Field( + description="Query string to filter connections. Supported fields are: `project_id`" + ), + ] = None, + sort: Annotated[ + Optional[StrictStr], + Field( + description="Sort order for connections. Supported sort fields are: `created_at`, `updated_at`" + ), + ] = None, + limit: Annotated[ + Optional[StrictInt], + Field( + description="Maximum number of connections to return. Default is no limit." + ), + ] = None, + skip: Annotated[ + Optional[StrictInt], + Field(description="Number of connections to skip before applying limit."), + ] = None, + _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: + """search_connections - >>> thread = api.search_connections_with_http_info(query, sort, limit, skip, async_req=True) - >>> result = thread.get() + Search for connections available to the user. This endpoint supports pagination and querying. Valid query fields are: `project_id` Example query: `/v1/connections/search?query=project_id:proj_123abc&sort=-created_at :param query: Query string to filter connections. Supported fields are: `project_id` :type query: str @@ -1183,428 +1953,623 @@ def search_connections_with_http_info( :type limit: int :param skip: Number of connections to skip before applying limit. :type skip: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(SearchConnectionsResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["query", "sort", "limit", "skip"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method search_connections" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._search_connections_serialize( + query=query, + sort=sort, + limit=limit, + skip=skip, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchConnectionsResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _search_connections_serialize( + self, + query, + sort, + limit, + skip, + _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]] = {} + _body_params: Optional[bytes] = None + # process the path parameters # process the query parameters - _query_params = [] - if _params.get("query") is not None: # noqa: E501 - _query_params.append(("query", _params["query"])) + if query is not None: + + _query_params.append(("query", query)) + + if sort is not None: + + _query_params.append(("sort", sort)) - if _params.get("sort") is not None: # noqa: E501 - _query_params.append(("sort", _params["sort"])) + if limit is not None: - if _params.get("limit") is not None: # noqa: E501 - _query_params.append(("limit", _params["limit"])) + _query_params.append(("limit", limit)) - if _params.get("skip") is not None: # noqa: E501 - _query_params.append(("skip", _params["skip"])) + if skip is not None: + + _query_params.append(("skip", skip)) # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "SearchConnectionsResponse", - } - - return self.api_client.call_api( - "/v1/connections/search", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/connections/search", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def update_connection( self, connection_id: Annotated[ - StrictStr, Field(..., description="The connection ID to update.") + StrictStr, Field(description="The connection ID to update.") ], update_connection_request: UpdateConnectionRequest, - **kwargs, - ) -> Connection: # noqa: E501 - """update_connection # noqa: E501 - - Update a connection by ID. When updating connection credentials, the same encryption strategy must be used. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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, + ) -> Connection: + """update_connection - >>> thread = api.update_connection(connection_id, update_connection_request, async_req=True) - >>> result = thread.get() + Update a connection by ID. When updating connection credentials, the same encryption strategy must be used. :param connection_id: The connection ID to update. (required) :type connection_id: str :param update_connection_request: (required) :type update_connection_request: UpdateConnectionRequest - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: Connection - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the update_connection_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.update_connection_with_http_info( - connection_id, update_connection_request, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._update_connection_serialize( + connection_id=connection_id, + update_connection_request=update_connection_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + 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_arguments + @validate_call def update_connection_with_http_info( self, connection_id: Annotated[ - StrictStr, Field(..., description="The connection ID to update.") + StrictStr, Field(description="The connection ID to update.") ], update_connection_request: UpdateConnectionRequest, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """update_connection # noqa: E501 + _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[Connection]: + """update_connection - Update a connection by ID. When updating connection credentials, the same encryption strategy must be used. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + Update a connection by ID. When updating connection credentials, the same encryption strategy must be used. - >>> thread = api.update_connection_with_http_info(connection_id, update_connection_request, async_req=True) - >>> result = thread.get() + :param connection_id: The connection ID to update. (required) + :type connection_id: str + :param update_connection_request: (required) + :type update_connection_request: UpdateConnectionRequest + :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._update_connection_serialize( + connection_id=connection_id, + update_connection_request=update_connection_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + 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 update_connection_without_preload_content( + self, + connection_id: Annotated[ + StrictStr, Field(description="The connection ID to update.") + ], + update_connection_request: UpdateConnectionRequest, + _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: + """update_connection + + Update a connection by ID. When updating connection credentials, the same encryption strategy must be used. :param connection_id: The connection ID to update. (required) :type connection_id: str :param update_connection_request: (required) :type update_connection_request: UpdateConnectionRequest - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(Connection, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["connection_id", "update_connection_request"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method update_connection" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._update_connection_serialize( + connection_id=connection_id, + update_connection_request=update_connection_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} - if _params["connection_id"]: - _path_params["connection_id"] = _params["connection_id"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "Connection", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _update_connection_serialize( + self, + connection_id, + update_connection_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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if connection_id is not None: + _path_params["connection_id"] = connection_id # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None - if _params["update_connection_request"] is not None: - _body_params = _params["update_connection_request"] + if update_connection_request is not None: + _body_params = update_connection_request # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` - _content_types_list = _params.get( - "_content_type", - self.api_client.select_header_content_type(["application/json"]), - ) - if _content_types_list: - _header_params["Content-Type"] = _content_types_list + 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 = [] # noqa: E501 - - _response_types_map = { - "200": "Connection", - } - - return self.api_client.call_api( - "/v1/connections/{connection_id}", - "PATCH", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="PATCH", + resource_path="/v1/connections/{connection_id}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def validate_connection_credentials( - self, connection_id: StrictStr, **kwargs - ) -> ValidateConnectionCredentialsResponse: # noqa: E501 - """validate_connection_credentials # noqa: E501 - - Validate the credentials of a connection by ID. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + self, + connection_id: StrictStr, + _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, + ) -> ValidateConnectionCredentialsResponse: + """validate_connection_credentials - >>> thread = api.validate_connection_credentials(connection_id, async_req=True) - >>> result = thread.get() + Validate the credentials of a connection by ID. :param connection_id: (required) :type connection_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: ValidateConnectionCredentialsResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the validate_connection_credentials_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.validate_connection_credentials_with_http_info( - connection_id, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._validate_connection_credentials_serialize( + connection_id=connection_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ValidateConnectionCredentialsResponse", + } + 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_arguments + @validate_call def validate_connection_credentials_with_http_info( - self, connection_id: StrictStr, **kwargs - ) -> ApiResponse: # noqa: E501 - """validate_connection_credentials # noqa: E501 + self, + connection_id: StrictStr, + _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[ValidateConnectionCredentialsResponse]: + """validate_connection_credentials + + Validate the credentials of a connection by ID. + + :param connection_id: (required) + :type connection_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._validate_connection_credentials_serialize( + connection_id=connection_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ValidateConnectionCredentialsResponse", + } + 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 the credentials of a connection by ID. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def validate_connection_credentials_without_preload_content( + self, + connection_id: StrictStr, + _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: + """validate_connection_credentials - >>> thread = api.validate_connection_credentials_with_http_info(connection_id, async_req=True) - >>> result = thread.get() + Validate the credentials of a connection by ID. :param connection_id: (required) :type connection_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(ValidateConnectionCredentialsResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["connection_id"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method validate_connection_credentials" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._validate_connection_credentials_serialize( + connection_id=connection_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} - if _params["connection_id"]: - _path_params["connection_id"] = _params["connection_id"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "ValidateConnectionCredentialsResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _validate_connection_credentials_serialize( + self, + connection_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]] = {} + _body_params: Optional[bytes] = None + # process the path parameters + if connection_id is not None: + _path_params["connection_id"] = connection_id # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "ValidateConnectionCredentialsResponse", - } - - return self.api_client.call_api( - "/v1/connections/{connection_id}/validate-credentials", - "POST", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1/connections/{connection_id}/validate-credentials", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) diff --git a/src/gretel_client/rest_v1/api/logs_api.py b/src/gretel_client/rest_v1/api/logs_api.py index 7214b83..dde263f 100755 --- a/src/gretel_client/rest_v1/api/logs_api.py +++ b/src/gretel_client/rest_v1/api/logs_api.py @@ -11,52 +11,54 @@ Do not edit the class manually. """ # noqa: E501 - -import io -import re # noqa: F401 import warnings -from typing import Optional +from typing import Any, Dict, List, Optional, Tuple, Union -from pydantic import StrictInt, StrictStr, validate_arguments, ValidationError +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call from typing_extensions import Annotated -from gretel_client.rest_v1.api_client import ApiClient +from gretel_client.rest_v1.api_client import ApiClient, RequestSerialized from gretel_client.rest_v1.api_response import ApiResponse -from gretel_client.rest_v1.exceptions import ApiTypeError, ApiValueError # noqa: F401 from gretel_client.rest_v1.models.get_log_response import GetLogResponse from gretel_client.rest_v1.models.get_log_upload_url_response import ( GetLogUploadURLResponse, ) +from gretel_client.rest_v1.rest import RESTResponseType -class LogsApi(object): +class LogsApi: """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): + def __init__(self, api_client=None) -> None: if api_client is None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def get_log_upload_url( self, workflow_run_id: StrictStr, action_name: StrictStr, workflow_task_id: StrictStr, - **kwargs, - ) -> GetLogUploadURLResponse: # noqa: E501 - """get_log_upload_url # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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, + ) -> GetLogUploadURLResponse: + """get_log_upload_url - >>> thread = api.get_log_upload_url(workflow_run_id, action_name, workflow_task_id, async_req=True) - >>> result = thread.get() :param workflow_run_id: (required) :type workflow_run_id: str @@ -64,41 +66,70 @@ def get_log_upload_url( :type action_name: str :param workflow_task_id: (required) :type workflow_task_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: GetLogUploadURLResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the get_log_upload_url_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.get_log_upload_url_with_http_info( - workflow_run_id, action_name, workflow_task_id, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._get_log_upload_url_serialize( + workflow_run_id=workflow_run_id, + action_name=action_name, + workflow_task_id=workflow_task_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - @validate_arguments + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetLogUploadURLResponse", + } + 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_log_upload_url_with_http_info( self, workflow_run_id: StrictStr, action_name: StrictStr, workflow_task_id: StrictStr, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """get_log_upload_url # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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[GetLogUploadURLResponse]: + """get_log_upload_url - >>> thread = api.get_log_upload_url_with_http_info(workflow_run_id, action_name, workflow_task_id, async_req=True) - >>> result = thread.get() :param workflow_run_id: (required) :type workflow_run_id: str @@ -106,124 +137,195 @@ def get_log_upload_url_with_http_info( :type action_name: str :param workflow_task_id: (required) :type workflow_task_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(GetLogUploadURLResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["workflow_run_id", "action_name", "workflow_task_id"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] + """ # noqa: E501 + + _param = self._get_log_upload_url_serialize( + workflow_run_id=workflow_run_id, + action_name=action_name, + workflow_task_id=workflow_task_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, ) - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_log_upload_url" % _key - ) - _params[_key] = _val - del _params["kwargs"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetLogUploadURLResponse", + } + 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_log_upload_url_without_preload_content( + self, + workflow_run_id: StrictStr, + action_name: StrictStr, + workflow_task_id: StrictStr, + _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_log_upload_url - _collection_formats = {} - # process the path parameters - _path_params = {} - if _params["workflow_run_id"]: - _path_params["workflow_run_id"] = _params["workflow_run_id"] + :param workflow_run_id: (required) + :type workflow_run_id: str + :param action_name: (required) + :type action_name: str + :param workflow_task_id: (required) + :type workflow_task_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._get_log_upload_url_serialize( + workflow_run_id=workflow_run_id, + action_name=action_name, + workflow_task_id=workflow_task_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - if _params["action_name"]: - _path_params["action_name"] = _params["action_name"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetLogUploadURLResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response - if _params["workflow_task_id"]: - _path_params["workflow_task_id"] = _params["workflow_task_id"] + def _get_log_upload_url_serialize( + self, + workflow_run_id, + action_name, + workflow_task_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]] = {} + _body_params: Optional[bytes] = None + # process the path parameters + if workflow_run_id is not None: + _path_params["workflow_run_id"] = workflow_run_id + if action_name is not None: + _path_params["action_name"] = action_name + if workflow_task_id is not None: + _path_params["workflow_task_id"] = workflow_task_id # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "GetLogUploadURLResponse", - } - - return self.api_client.call_api( - "/v1/logs/workflowruns/{workflow_run_id}/actions/{action_name}/tasks/{workflow_task_id}", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/logs/workflowruns/{workflow_run_id}/actions/{action_name}/tasks/{workflow_task_id}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def get_logs( self, query: Optional[StrictStr] = None, limit: Optional[StrictInt] = None, page_token: Optional[StrictStr] = None, - **kwargs, - ) -> GetLogResponse: # noqa: E501 - """get_logs # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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, + ) -> GetLogResponse: + """get_logs - >>> thread = api.get_logs(query, limit, page_token, async_req=True) - >>> result = thread.get() :param query: :type query: str @@ -231,41 +333,141 @@ def get_logs( :type limit: int :param page_token: :type page_token: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: GetLogResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the get_logs_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.get_logs_with_http_info( - query, limit, page_token, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._get_logs_serialize( + query=query, + limit=limit, + page_token=page_token, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - @validate_arguments + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetLogResponse", + } + 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_logs_with_http_info( self, query: Optional[StrictStr] = None, limit: Optional[StrictInt] = None, page_token: Optional[StrictStr] = None, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """get_logs # noqa: E501 + _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[GetLogResponse]: + """get_logs + + + :param query: + :type query: str + :param limit: + :type limit: int + :param page_token: + :type page_token: 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_logs_serialize( + query=query, + limit=limit, + page_token=page_token, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetLogResponse", + } + 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_logs_without_preload_content( + self, + query: Optional[StrictStr] = None, + limit: Optional[StrictInt] = None, + page_token: Optional[StrictStr] = None, + _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_logs - >>> thread = api.get_logs_with_http_info(query, limit, page_token, async_req=True) - >>> result = thread.get() :param query: :type query: str @@ -273,106 +475,106 @@ def get_logs_with_http_info( :type limit: int :param page_token: :type page_token: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(GetLogResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["query", "limit", "page_token"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] + """ # noqa: E501 + + _param = self._get_logs_serialize( + query=query, + limit=limit, + page_token=page_token, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, ) - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_logs" % _key - ) - _params[_key] = _val - del _params["kwargs"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetLogResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response - _collection_formats = {} + def _get_logs_serialize( + self, + query, + limit, + page_token, + _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]] = {} + _body_params: Optional[bytes] = None # process the path parameters - _path_params = {} - # process the query parameters - _query_params = [] - if _params.get("query") is not None: # noqa: E501 - _query_params.append(("query", _params["query"])) + if query is not None: + + _query_params.append(("query", query)) - if _params.get("limit") is not None: # noqa: E501 - _query_params.append(("limit", _params["limit"])) + if limit is not None: - if _params.get("page_token") is not None: # noqa: E501 - _query_params.append(("page_token", _params["page_token"])) + _query_params.append(("limit", limit)) + + if page_token is not None: + + _query_params.append(("page_token", page_token)) # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "GetLogResponse", - } - - return self.api_client.call_api( - "/v1/logs", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/logs", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) diff --git a/src/gretel_client/rest_v1/api/projects_api.py b/src/gretel_client/rest_v1/api/projects_api.py index 5a70a8e..824ca46 100755 --- a/src/gretel_client/rest_v1/api/projects_api.py +++ b/src/gretel_client/rest_v1/api/projects_api.py @@ -11,218 +11,316 @@ Do not edit the class manually. """ # noqa: E501 - -import io -import re # noqa: F401 import warnings -from typing import Optional +from typing import Any, Dict, List, Optional, Tuple, Union from pydantic import ( - conlist, - constr, + Field, + field_validator, + StrictFloat, StrictInt, StrictStr, - validate_arguments, - ValidationError, - validator, + validate_call, ) from typing_extensions import Annotated -from gretel_client.rest_v1.api_client import ApiClient +from gretel_client.rest_v1.api_client import ApiClient, RequestSerialized from gretel_client.rest_v1.api_response import ApiResponse -from gretel_client.rest_v1.exceptions import ApiTypeError, ApiValueError # noqa: F401 from gretel_client.rest_v1.models.get_project_response import GetProjectResponse from gretel_client.rest_v1.models.search_projects_response import SearchProjectsResponse +from gretel_client.rest_v1.rest import RESTResponseType -class ProjectsApi(object): +class ProjectsApi: """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): + def __init__(self, api_client=None) -> None: if api_client is None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def get_project( self, - project_guid: constr(strict=True), - expand: Optional[conlist(StrictStr)] = None, - **kwargs, - ) -> GetProjectResponse: # noqa: E501 - """get_project # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + project_guid: Annotated[str, Field(strict=True)], + expand: Optional[List[StrictStr]] = None, + _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, + ) -> GetProjectResponse: + """get_project - >>> thread = api.get_project(project_guid, expand, async_req=True) - >>> result = thread.get() :param project_guid: (required) :type project_guid: str :param expand: :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: GetProjectResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the get_project_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.get_project_with_http_info( - project_guid, expand, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._get_project_serialize( + project_guid=project_guid, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - @validate_arguments + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetProjectResponse", + } + 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_project_with_http_info( self, - project_guid: constr(strict=True), - expand: Optional[conlist(StrictStr)] = None, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """get_project # noqa: E501 + project_guid: Annotated[str, Field(strict=True)], + expand: Optional[List[StrictStr]] = None, + _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[GetProjectResponse]: + """get_project + + + :param project_guid: (required) + :type project_guid: str + :param expand: + :type expand: List[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_project_serialize( + project_guid=project_guid, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetProjectResponse", + } + 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, + ) - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def get_project_without_preload_content( + self, + project_guid: Annotated[str, Field(strict=True)], + expand: Optional[List[StrictStr]] = None, + _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_project - >>> thread = api.get_project_with_http_info(project_guid, expand, async_req=True) - >>> result = thread.get() :param project_guid: (required) :type project_guid: str :param expand: :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(GetProjectResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["project_guid", "expand"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] + """ # noqa: E501 + + _param = self._get_project_serialize( + project_guid=project_guid, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, ) - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_project" % _key - ) - _params[_key] = _val - del _params["kwargs"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetProjectResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _get_project_serialize( + self, + project_guid, + expand, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + "expand": "multi", + } - _collection_formats = {} + _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]] = {} + _body_params: Optional[bytes] = None # process the path parameters - _path_params = {} - if _params["project_guid"]: - _path_params["project_guid"] = _params["project_guid"] - + if project_guid is not None: + _path_params["project_guid"] = project_guid # process the query parameters - _query_params = [] - if _params.get("expand") is not None: # noqa: E501 - _query_params.append(("expand", _params["expand"])) - _collection_formats["expand"] = "multi" + if expand is not None: + + _query_params.append(("expand", expand)) # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "GetProjectResponse", - } - - return self.api_client.call_api( - "/v1/projects/{project_guid}", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/projects/{project_guid}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def search_projects( self, query: Optional[StrictStr] = None, limit: Optional[StrictInt] = None, skip: Optional[StrictInt] = None, - expand: Optional[conlist(StrictStr)] = None, - **kwargs, - ) -> SearchProjectsResponse: # noqa: E501 - """search_projects # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + expand: Optional[List[StrictStr]] = None, + _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, + ) -> SearchProjectsResponse: + """search_projects - >>> thread = api.search_projects(query, limit, skip, expand, async_req=True) - >>> result = thread.get() :param query: :type query: str @@ -232,42 +330,147 @@ def search_projects( :type skip: int :param expand: :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: SearchProjectsResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the search_projects_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.search_projects_with_http_info( - query, limit, skip, expand, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._search_projects_serialize( + query=query, + limit=limit, + skip=skip, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - @validate_arguments + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchProjectsResponse", + } + 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 search_projects_with_http_info( self, query: Optional[StrictStr] = None, limit: Optional[StrictInt] = None, skip: Optional[StrictInt] = None, - expand: Optional[conlist(StrictStr)] = None, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """search_projects # noqa: E501 + expand: Optional[List[StrictStr]] = None, + _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[SearchProjectsResponse]: + """search_projects - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.search_projects_with_http_info(query, limit, skip, expand, async_req=True) - >>> result = thread.get() + :param query: + :type query: str + :param limit: + :type limit: int + :param skip: + :type skip: int + :param expand: + :type expand: List[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._search_projects_serialize( + query=query, + limit=limit, + skip=skip, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchProjectsResponse", + } + 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 search_projects_without_preload_content( + self, + query: Optional[StrictStr] = None, + limit: Optional[StrictInt] = None, + skip: Optional[StrictInt] = None, + expand: Optional[List[StrictStr]] = None, + _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: + """search_projects + :param query: :type query: str @@ -277,110 +480,114 @@ def search_projects_with_http_info( :type skip: int :param expand: :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(SearchProjectsResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["query", "limit", "skip", "expand"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] + """ # noqa: E501 + + _param = self._search_projects_serialize( + query=query, + limit=limit, + skip=skip, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, ) - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method search_projects" % _key - ) - _params[_key] = _val - del _params["kwargs"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchProjectsResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response - _collection_formats = {} + def _search_projects_serialize( + self, + query, + limit, + skip, + expand, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + "expand": "multi", + } - # process the path parameters - _path_params = {} + _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]] = {} + _body_params: Optional[bytes] = None + # process the path parameters # process the query parameters - _query_params = [] - if _params.get("query") is not None: # noqa: E501 - _query_params.append(("query", _params["query"])) + if query is not None: + + _query_params.append(("query", query)) + + if limit is not None: - if _params.get("limit") is not None: # noqa: E501 - _query_params.append(("limit", _params["limit"])) + _query_params.append(("limit", limit)) - if _params.get("skip") is not None: # noqa: E501 - _query_params.append(("skip", _params["skip"])) + if skip is not None: - if _params.get("expand") is not None: # noqa: E501 - _query_params.append(("expand", _params["expand"])) - _collection_formats["expand"] = "multi" + _query_params.append(("skip", skip)) + + if expand is not None: + + _query_params.append(("expand", expand)) # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "SearchProjectsResponse", - } - - return self.api_client.call_api( - "/v1/projects/search", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/projects/search", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) diff --git a/src/gretel_client/rest_v1/api/workflows_api.py b/src/gretel_client/rest_v1/api/workflows_api.py index edd2764..265f2f1 100755 --- a/src/gretel_client/rest_v1/api/workflows_api.py +++ b/src/gretel_client/rest_v1/api/workflows_api.py @@ -11,28 +11,22 @@ Do not edit the class manually. """ # noqa: E501 - -import io -import re # noqa: F401 import warnings -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple, Union from pydantic import ( - conlist, - constr, Field, + field_validator, + StrictFloat, StrictInt, StrictStr, - validate_arguments, - ValidationError, - validator, + validate_call, ) from typing_extensions import Annotated -from gretel_client.rest_v1.api_client import ApiClient +from gretel_client.rest_v1.api_client import ApiClient, RequestSerialized from gretel_client.rest_v1.api_response import ApiResponse -from gretel_client.rest_v1.exceptions import ApiTypeError, ApiValueError # noqa: F401 from gretel_client.rest_v1.models.create_workflow_request import CreateWorkflowRequest from gretel_client.rest_v1.models.create_workflow_run_request import ( CreateWorkflowRunRequest, @@ -56,1287 +50,2045 @@ from gretel_client.rest_v1.models.workflow import Workflow from gretel_client.rest_v1.models.workflow_run import WorkflowRun from gretel_client.rest_v1.models.workflow_task import WorkflowTask +from gretel_client.rest_v1.rest import RESTResponseType -class WorkflowsApi(object): +class WorkflowsApi: """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): + def __init__(self, api_client=None) -> None: if api_client is None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def cancel_workflow_run( self, workflow_run_id: Annotated[ - constr(strict=True), - Field(..., description="The ID of the workflow run to cancel."), + str, Field(strict=True, description="The ID of the workflow run to cancel.") ], - **kwargs, - ) -> WorkflowRun: # noqa: E501 - """cancel_workflow_run # noqa: E501 - - Cancel a workflow run. This endpoint is used to cancel a workflow run. This will stop the workflow run and transition it to a `cancelled` state. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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, + ) -> WorkflowRun: + """cancel_workflow_run - >>> thread = api.cancel_workflow_run(workflow_run_id, async_req=True) - >>> result = thread.get() + Cancel a workflow run. This endpoint is used to cancel a workflow run. This will stop the workflow run and transition it to a `cancelled` state. :param workflow_run_id: The ID of the workflow run to cancel. (required) :type workflow_run_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: WorkflowRun - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the cancel_workflow_run_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.cancel_workflow_run_with_http_info( - workflow_run_id, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._cancel_workflow_run_serialize( + workflow_run_id=workflow_run_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRun", + } + 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_arguments + @validate_call def cancel_workflow_run_with_http_info( self, workflow_run_id: Annotated[ - constr(strict=True), - Field(..., description="The ID of the workflow run to cancel."), + str, Field(strict=True, description="The ID of the workflow run to cancel.") ], - **kwargs, - ) -> ApiResponse: # noqa: E501 - """cancel_workflow_run # noqa: E501 + _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[WorkflowRun]: + """cancel_workflow_run + + Cancel a workflow run. This endpoint is used to cancel a workflow run. This will stop the workflow run and transition it to a `cancelled` state. + + :param workflow_run_id: The ID of the workflow run to cancel. (required) + :type workflow_run_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._cancel_workflow_run_serialize( + workflow_run_id=workflow_run_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRun", + } + 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, + ) - Cancel a workflow run. This endpoint is used to cancel a workflow run. This will stop the workflow run and transition it to a `cancelled` state. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def cancel_workflow_run_without_preload_content( + self, + workflow_run_id: Annotated[ + str, Field(strict=True, description="The ID of the workflow run to cancel.") + ], + _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: + """cancel_workflow_run - >>> thread = api.cancel_workflow_run_with_http_info(workflow_run_id, async_req=True) - >>> result = thread.get() + Cancel a workflow run. This endpoint is used to cancel a workflow run. This will stop the workflow run and transition it to a `cancelled` state. :param workflow_run_id: The ID of the workflow run to cancel. (required) :type workflow_run_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(WorkflowRun, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["workflow_run_id"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_workflow_run" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._cancel_workflow_run_serialize( + workflow_run_id=workflow_run_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} - if _params["workflow_run_id"]: - _path_params["workflow_run_id"] = _params["workflow_run_id"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRun", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + def _cancel_workflow_run_serialize( + self, + workflow_run_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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if workflow_run_id is not None: + _path_params["workflow_run_id"] = workflow_run_id # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "WorkflowRun", - } - - return self.api_client.call_api( - "/v1/workflows/runs/{workflow_run_id}/cancel", - "PATCH", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="PATCH", + resource_path="/v1/workflows/runs/{workflow_run_id}/cancel", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def create_workflow( - self, create_workflow_request: CreateWorkflowRequest, **kwargs - ) -> Workflow: # noqa: E501 - """create_workflow # noqa: E501 - - Create a new workflow in the provided project. Providing a config is optional, but workflow runs created from this workflow will require a config be provided. Config can be provided as an object or as a YAML string. String configs will preserve comments and formatting where object configs cannot. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + self, + create_workflow_request: CreateWorkflowRequest, + _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, + ) -> Workflow: + """create_workflow - >>> thread = api.create_workflow(create_workflow_request, async_req=True) - >>> result = thread.get() + Create a new workflow in the provided project. Providing a config is optional, but workflow runs created from this workflow will require a config be provided. Config can be provided as an object or as a YAML string. String configs will preserve comments and formatting where object configs cannot. :param create_workflow_request: (required) :type create_workflow_request: CreateWorkflowRequest - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: Workflow - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the create_workflow_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.create_workflow_with_http_info( - create_workflow_request, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._create_workflow_serialize( + create_workflow_request=create_workflow_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Workflow", + } + 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_arguments + @validate_call def create_workflow_with_http_info( - self, create_workflow_request: CreateWorkflowRequest, **kwargs - ) -> ApiResponse: # noqa: E501 - """create_workflow # noqa: E501 + self, + create_workflow_request: CreateWorkflowRequest, + _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[Workflow]: + """create_workflow + + Create a new workflow in the provided project. Providing a config is optional, but workflow runs created from this workflow will require a config be provided. Config can be provided as an object or as a YAML string. String configs will preserve comments and formatting where object configs cannot. + + :param create_workflow_request: (required) + :type create_workflow_request: CreateWorkflowRequest + :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._create_workflow_serialize( + create_workflow_request=create_workflow_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Workflow", + } + 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, + ) - Create a new workflow in the provided project. Providing a config is optional, but workflow runs created from this workflow will require a config be provided. Config can be provided as an object or as a YAML string. String configs will preserve comments and formatting where object configs cannot. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def create_workflow_without_preload_content( + self, + create_workflow_request: CreateWorkflowRequest, + _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_workflow - >>> thread = api.create_workflow_with_http_info(create_workflow_request, async_req=True) - >>> result = thread.get() + Create a new workflow in the provided project. Providing a config is optional, but workflow runs created from this workflow will require a config be provided. Config can be provided as an object or as a YAML string. String configs will preserve comments and formatting where object configs cannot. :param create_workflow_request: (required) :type create_workflow_request: CreateWorkflowRequest - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(Workflow, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["create_workflow_request"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method create_workflow" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._create_workflow_serialize( + create_workflow_request=create_workflow_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} + _response_types_map: Dict[str, Optional[str]] = { + "200": "Workflow", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _create_workflow_serialize( + self, + create_workflow_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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None - if _params["create_workflow_request"] is not None: - _body_params = _params["create_workflow_request"] + if create_workflow_request is not None: + _body_params = create_workflow_request # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` - _content_types_list = _params.get( - "_content_type", - self.api_client.select_header_content_type(["application/json"]), - ) - if _content_types_list: - _header_params["Content-Type"] = _content_types_list + 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 = [] # noqa: E501 - - _response_types_map = { - "200": "Workflow", - } - - return self.api_client.call_api( - "/v1/workflows", - "POST", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1/workflows", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def create_workflow_run( - self, create_workflow_run_request: CreateWorkflowRunRequest, **kwargs - ) -> WorkflowRun: # noqa: E501 - """create_workflow_run # noqa: E501 - - Create a new workflow run for a given workflow. Providing a config is optional, but the workflow run will require a config be provided. Config can be provided as an object or as a YAML string. String configs will preserve comments and formatting where object configs cannot. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + self, + create_workflow_run_request: CreateWorkflowRunRequest, + _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, + ) -> WorkflowRun: + """create_workflow_run - >>> thread = api.create_workflow_run(create_workflow_run_request, async_req=True) - >>> result = thread.get() + Create a new workflow run for a given workflow. Providing a config is optional, but the workflow run will require a config be provided. Config can be provided as an object or as a YAML string. String configs will preserve comments and formatting where object configs cannot. :param create_workflow_run_request: (required) :type create_workflow_run_request: CreateWorkflowRunRequest - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: WorkflowRun - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the create_workflow_run_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.create_workflow_run_with_http_info( - create_workflow_run_request, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._create_workflow_run_serialize( + create_workflow_run_request=create_workflow_run_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRun", + } + 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_arguments + @validate_call def create_workflow_run_with_http_info( - self, create_workflow_run_request: CreateWorkflowRunRequest, **kwargs - ) -> ApiResponse: # noqa: E501 - """create_workflow_run # noqa: E501 + self, + create_workflow_run_request: CreateWorkflowRunRequest, + _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[WorkflowRun]: + """create_workflow_run + + Create a new workflow run for a given workflow. Providing a config is optional, but the workflow run will require a config be provided. Config can be provided as an object or as a YAML string. String configs will preserve comments and formatting where object configs cannot. + + :param create_workflow_run_request: (required) + :type create_workflow_run_request: CreateWorkflowRunRequest + :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._create_workflow_run_serialize( + create_workflow_run_request=create_workflow_run_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRun", + } + 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, + ) - Create a new workflow run for a given workflow. Providing a config is optional, but the workflow run will require a config be provided. Config can be provided as an object or as a YAML string. String configs will preserve comments and formatting where object configs cannot. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def create_workflow_run_without_preload_content( + self, + create_workflow_run_request: CreateWorkflowRunRequest, + _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_workflow_run - >>> thread = api.create_workflow_run_with_http_info(create_workflow_run_request, async_req=True) - >>> result = thread.get() + Create a new workflow run for a given workflow. Providing a config is optional, but the workflow run will require a config be provided. Config can be provided as an object or as a YAML string. String configs will preserve comments and formatting where object configs cannot. :param create_workflow_run_request: (required) :type create_workflow_run_request: CreateWorkflowRunRequest - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(WorkflowRun, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["create_workflow_run_request"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method create_workflow_run" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._create_workflow_run_serialize( + create_workflow_run_request=create_workflow_run_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRun", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _create_workflow_run_serialize( + self, + create_workflow_run_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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None - if _params["create_workflow_run_request"] is not None: - _body_params = _params["create_workflow_run_request"] + if create_workflow_run_request is not None: + _body_params = create_workflow_run_request # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` - _content_types_list = _params.get( - "_content_type", - self.api_client.select_header_content_type(["application/json"]), - ) - if _content_types_list: - _header_params["Content-Type"] = _content_types_list + 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 = [] # noqa: E501 - - _response_types_map = { - "200": "WorkflowRun", - } - - return self.api_client.call_api( - "/v1/workflows/runs", - "POST", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1/workflows/runs", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def delete_workflow( self, workflow_id: Annotated[ - constr(strict=True), - Field(..., description="The ID of the workflow to delete."), + str, Field(strict=True, description="The ID of the workflow to delete.") ], - **kwargs, - ) -> None: # noqa: E501 - """delete_workflow # noqa: E501 - - Delete a workflow by ID. This will also delete all associated workflow runs and tasks. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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_workflow - >>> thread = api.delete_workflow(workflow_id, async_req=True) - >>> result = thread.get() + Delete a workflow by ID. This will also delete all associated workflow runs and tasks. :param workflow_id: The ID of the workflow to delete. (required) :type workflow_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: None - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the delete_workflow_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.delete_workflow_with_http_info(workflow_id, **kwargs) # noqa: E501 + """ # noqa: E501 + + _param = self._delete_workflow_serialize( + workflow_id=workflow_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + } + 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_arguments + @validate_call def delete_workflow_with_http_info( self, workflow_id: Annotated[ - constr(strict=True), - Field(..., description="The ID of the workflow to delete."), + str, Field(strict=True, description="The ID of the workflow to delete.") ], - **kwargs, - ) -> ApiResponse: # noqa: E501 - """delete_workflow # noqa: E501 + _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_workflow + + Delete a workflow by ID. This will also delete all associated workflow runs and tasks. + + :param workflow_id: The ID of the workflow to delete. (required) + :type workflow_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._delete_workflow_serialize( + workflow_id=workflow_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + } + 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, + ) - Delete a workflow by ID. This will also delete all associated workflow runs and tasks. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def delete_workflow_without_preload_content( + self, + workflow_id: Annotated[ + str, Field(strict=True, description="The ID of the workflow to delete.") + ], + _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_workflow - >>> thread = api.delete_workflow_with_http_info(workflow_id, async_req=True) - >>> result = thread.get() + Delete a workflow by ID. This will also delete all associated workflow runs and tasks. :param workflow_id: The ID of the workflow to delete. (required) :type workflow_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: None - """ - - _params = locals() - - _all_params = ["workflow_id"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method delete_workflow" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._delete_workflow_serialize( + workflow_id=workflow_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} - if _params["workflow_id"]: - _path_params["workflow_id"] = _params["workflow_id"] + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _delete_workflow_serialize( + self, + workflow_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]] = {} + _body_params: Optional[bytes] = None + # process the path parameters + if workflow_id is not None: + _path_params["workflow_id"] = workflow_id # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = {} - - return self.api_client.call_api( - "/v1/workflows/{workflow_id}", - "DELETE", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/v1/workflows/{workflow_id}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def get_workflow( self, workflow_id: Annotated[ - constr(strict=True), - Field(..., description="The ID of the workflow to retrieve."), + str, Field(strict=True, description="The ID of the workflow to retrieve.") ], expand: Annotated[ - Optional[conlist(StrictStr)], + Optional[List[StrictStr]], Field( description="The fields to expand in the response. Supported values are: `project`, `created_by`, `updated_by`, `latest_run`" ), ] = None, - **kwargs, - ) -> Workflow: # noqa: E501 - """get_workflow # noqa: E501 - - Get a single workflow by ID. This endpoint supports expansion. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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, + ) -> Workflow: + """get_workflow - >>> thread = api.get_workflow(workflow_id, expand, async_req=True) - >>> result = thread.get() + Get a single workflow by ID. This endpoint supports expansion. :param workflow_id: The ID of the workflow to retrieve. (required) :type workflow_id: str :param expand: The fields to expand in the response. Supported values are: `project`, `created_by`, `updated_by`, `latest_run` :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: Workflow - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the get_workflow_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.get_workflow_with_http_info( - workflow_id, expand, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._get_workflow_serialize( + workflow_id=workflow_id, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Workflow", + } + 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_arguments + @validate_call def get_workflow_with_http_info( self, workflow_id: Annotated[ - constr(strict=True), - Field(..., description="The ID of the workflow to retrieve."), + str, Field(strict=True, description="The ID of the workflow to retrieve.") ], expand: Annotated[ - Optional[conlist(StrictStr)], + Optional[List[StrictStr]], Field( description="The fields to expand in the response. Supported values are: `project`, `created_by`, `updated_by`, `latest_run`" ), ] = None, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """get_workflow # noqa: E501 - - Get a single workflow by ID. This endpoint supports expansion. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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[Workflow]: + """get_workflow - >>> thread = api.get_workflow_with_http_info(workflow_id, expand, async_req=True) - >>> result = thread.get() + Get a single workflow by ID. This endpoint supports expansion. :param workflow_id: The ID of the workflow to retrieve. (required) :type workflow_id: str :param expand: The fields to expand in the response. Supported values are: `project`, `created_by`, `updated_by`, `latest_run` :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(Workflow, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["workflow_id", "expand"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_workflow" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - if _params["workflow_id"]: - _path_params["workflow_id"] = _params["workflow_id"] - - # process the query parameters - _query_params = [] - if _params.get("expand") is not None: # noqa: E501 - _query_params.append(("expand", _params["expand"])) - _collection_formats["expand"] = "multi" - - # process the header parameters - _header_params = dict(_params.get("_headers", {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 + """ # noqa: E501 + + _param = self._get_workflow_serialize( + workflow_id=workflow_id, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { "200": "Workflow", } - - return self.api_client.call_api( - "/v1/workflows/{workflow_id}", - "GET", - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, + 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, - auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), - collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), ) - @validate_arguments - def get_workflow_run( + @validate_call + def get_workflow_without_preload_content( self, - workflow_run_id: Annotated[ - constr(strict=True), - Field(..., description="The ID of the workflow run to retrieve."), + workflow_id: Annotated[ + str, Field(strict=True, description="The ID of the workflow to retrieve.") ], expand: Annotated[ - Optional[conlist(StrictStr)], + Optional[List[StrictStr]], Field( - description="The fields to expand in the response. Supported values are: `project`, `config.system`, `created_by`" + description="The fields to expand in the response. Supported values are: `project`, `created_by`, `updated_by`, `latest_run`" ), ] = None, - **kwargs, - ) -> WorkflowRun: # noqa: E501 - """get_workflow_run # noqa: E501 - - Get a single workflow run by ID. This endpoint supports expansion. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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_workflow - >>> thread = api.get_workflow_run(workflow_run_id, expand, async_req=True) - >>> result = thread.get() + Get a single workflow by ID. This endpoint supports expansion. - :param workflow_run_id: The ID of the workflow run to retrieve. (required) - :type workflow_run_id: str - :param expand: The fields to expand in the response. Supported values are: `project`, `config.system`, `created_by` + :param workflow_id: The ID of the workflow to retrieve. (required) + :type workflow_id: str + :param expand: The fields to expand in the response. Supported values are: `project`, `created_by`, `updated_by`, `latest_run` :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: WorkflowRun - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the get_workflow_run_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.get_workflow_run_with_http_info( - workflow_run_id, expand, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._get_workflow_serialize( + workflow_id=workflow_id, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - @validate_arguments - def get_workflow_run_with_http_info( + _response_types_map: Dict[str, Optional[str]] = { + "200": "Workflow", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _get_workflow_serialize( + self, + workflow_id, + expand, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + "expand": "multi", + } + + _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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if workflow_id is not None: + _path_params["workflow_id"] = workflow_id + # process the query parameters + if expand is not None: + + _query_params.append(("expand", expand)) + + # 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] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/workflows/{workflow_id}", + 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_workflow_run( + self, + workflow_run_id: Annotated[ + str, + Field(strict=True, description="The ID of the workflow run to retrieve."), + ], + expand: Annotated[ + Optional[List[StrictStr]], + Field( + description="The fields to expand in the response. Supported values are: `project`, `config.system`, `created_by`" + ), + ] = None, + _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, + ) -> WorkflowRun: + """get_workflow_run + + Get a single workflow run by ID. This endpoint supports expansion. + + :param workflow_run_id: The ID of the workflow run to retrieve. (required) + :type workflow_run_id: str + :param expand: The fields to expand in the response. Supported values are: `project`, `config.system`, `created_by` + :type expand: List[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_workflow_run_serialize( + workflow_run_id=workflow_run_id, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRun", + } + 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_workflow_run_with_http_info( self, workflow_run_id: Annotated[ - constr(strict=True), - Field(..., description="The ID of the workflow run to retrieve."), + str, + Field(strict=True, description="The ID of the workflow run to retrieve."), ], expand: Annotated[ - Optional[conlist(StrictStr)], + Optional[List[StrictStr]], Field( description="The fields to expand in the response. Supported values are: `project`, `config.system`, `created_by`" ), ] = None, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """get_workflow_run # noqa: E501 + _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[WorkflowRun]: + """get_workflow_run - Get a single workflow run by ID. This endpoint supports expansion. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + Get a single workflow run by ID. This endpoint supports expansion. - >>> thread = api.get_workflow_run_with_http_info(workflow_run_id, expand, async_req=True) - >>> result = thread.get() + :param workflow_run_id: The ID of the workflow run to retrieve. (required) + :type workflow_run_id: str + :param expand: The fields to expand in the response. Supported values are: `project`, `config.system`, `created_by` + :type expand: List[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_workflow_run_serialize( + workflow_run_id=workflow_run_id, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRun", + } + 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_workflow_run_without_preload_content( + self, + workflow_run_id: Annotated[ + str, + Field(strict=True, description="The ID of the workflow run to retrieve."), + ], + expand: Annotated[ + Optional[List[StrictStr]], + Field( + description="The fields to expand in the response. Supported values are: `project`, `config.system`, `created_by`" + ), + ] = None, + _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_workflow_run + + Get a single workflow run by ID. This endpoint supports expansion. :param workflow_run_id: The ID of the workflow run to retrieve. (required) :type workflow_run_id: str :param expand: The fields to expand in the response. Supported values are: `project`, `config.system`, `created_by` :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(WorkflowRun, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["workflow_run_id", "expand"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_workflow_run" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._get_workflow_run_serialize( + workflow_run_id=workflow_run_id, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} - if _params["workflow_run_id"]: - _path_params["workflow_run_id"] = _params["workflow_run_id"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRun", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + def _get_workflow_run_serialize( + self, + workflow_run_id, + expand, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + "expand": "multi", + } + + _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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if workflow_run_id is not None: + _path_params["workflow_run_id"] = workflow_run_id # process the query parameters - _query_params = [] - if _params.get("expand") is not None: # noqa: E501 - _query_params.append(("expand", _params["expand"])) - _collection_formats["expand"] = "multi" + if expand is not None: + + _query_params.append(("expand", expand)) # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "WorkflowRun", - } - - return self.api_client.call_api( - "/v1/workflows/runs/{workflow_run_id}", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/workflows/runs/{workflow_run_id}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def get_workflow_task( self, workflow_task_id: Annotated[ - StrictStr, - Field(..., description="The ID of the workflow task to retrieve."), + StrictStr, Field(description="The ID of the workflow task to retrieve.") ], - **kwargs, - ) -> WorkflowTask: # noqa: E501 - """get_workflow_task # noqa: E501 - - Get a single workflow task by ID. This endpoint supports expansion. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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, + ) -> WorkflowTask: + """get_workflow_task - >>> thread = api.get_workflow_task(workflow_task_id, async_req=True) - >>> result = thread.get() + Get a single workflow task by ID. This endpoint supports expansion. :param workflow_task_id: The ID of the workflow task to retrieve. (required) :type workflow_task_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: WorkflowTask - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the get_workflow_task_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.get_workflow_task_with_http_info( - workflow_task_id, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._get_workflow_task_serialize( + workflow_task_id=workflow_task_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowTask", + } + 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_arguments + @validate_call def get_workflow_task_with_http_info( self, workflow_task_id: Annotated[ - StrictStr, - Field(..., description="The ID of the workflow task to retrieve."), + StrictStr, Field(description="The ID of the workflow task to retrieve.") ], - **kwargs, - ) -> ApiResponse: # noqa: E501 - """get_workflow_task # noqa: E501 + _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[WorkflowTask]: + """get_workflow_task - Get a single workflow task by ID. This endpoint supports expansion. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + Get a single workflow task by ID. This endpoint supports expansion. - >>> thread = api.get_workflow_task_with_http_info(workflow_task_id, async_req=True) - >>> result = thread.get() + :param workflow_task_id: The ID of the workflow task to retrieve. (required) + :type workflow_task_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._get_workflow_task_serialize( + workflow_task_id=workflow_task_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowTask", + } + 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_workflow_task_without_preload_content( + self, + workflow_task_id: Annotated[ + StrictStr, Field(description="The ID of the workflow task to retrieve.") + ], + _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_workflow_task + + Get a single workflow task by ID. This endpoint supports expansion. :param workflow_task_id: The ID of the workflow task to retrieve. (required) :type workflow_task_id: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(WorkflowTask, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["workflow_task_id"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_workflow_task" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._get_workflow_task_serialize( + workflow_task_id=workflow_task_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} - if _params["workflow_task_id"]: - _path_params["workflow_task_id"] = _params["workflow_task_id"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowTask", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _get_workflow_task_serialize( + self, + workflow_task_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]] = {} + _body_params: Optional[bytes] = None + # process the path parameters + if workflow_task_id is not None: + _path_params["workflow_task_id"] = workflow_task_id # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "WorkflowTask", - } - - return self.api_client.call_api( - "/v1/workflows/runs/tasks/{workflow_task_id}", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/workflows/runs/tasks/{workflow_task_id}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments - def get_workflows(self, **kwargs) -> GetWorkflowsResponse: # noqa: E501 - """get_workflows # noqa: E501 + @validate_call + def get_workflows( + self, + _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, + ) -> GetWorkflowsResponse: + """get_workflows + + + :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_workflows_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetWorkflowsResponse", + } + 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 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def get_workflows_with_http_info( + self, + _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[GetWorkflowsResponse]: + """get_workflows - >>> thread = api.get_workflows(async_req=True) - >>> result = thread.get() - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: GetWorkflowsResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the get_workflows_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.get_workflows_with_http_info(**kwargs) # noqa: E501 - - @validate_arguments - def get_workflows_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 - """get_workflows # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_workflows_with_http_info(async_req=True) - >>> result = thread.get() - - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional + """ # noqa: E501 + + _param = self._get_workflows_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetWorkflowsResponse", + } + 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_workflows_without_preload_content( + self, + _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_workflows + + :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(GetWorkflowsResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_workflows" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 - # process the path parameters - _path_params = {} + _param = self._get_workflows_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetWorkflowsResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _get_workflows_serialize( + self, + _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]] = {} + _body_params: Optional[bytes] = None + # process the path parameters # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "GetWorkflowsResponse", - } - - return self.api_client.call_api( - "/v1/workflows", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/workflows", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def search_workflow_runs( self, query: Annotated[ @@ -1346,7 +2098,7 @@ def search_workflow_runs( ), ] = None, expand: Annotated[ - Optional[conlist(StrictStr)], + Optional[List[StrictStr]], Field( description="The fields to expand in the search results. Supported values are: `project`, `config.system`, `created_by`" ), @@ -1365,16 +2117,21 @@ def search_workflow_runs( Optional[StrictStr], Field(description="The sort order for the search results."), ] = None, - **kwargs, - ) -> SearchWorkflowRunsResponse: # noqa: E501 - """search_workflow_runs # noqa: E501 - - Search for workflow runs. This endpoint supports pagination, querying, and expansion. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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, + ) -> SearchWorkflowRunsResponse: + """search_workflow_runs - >>> thread = api.search_workflow_runs(query, expand, limit, skip, sort, async_req=True) - >>> result = thread.get() + Search for workflow runs. This endpoint supports pagination, querying, and expansion. :param query: The query string for searching workflow runs. Supported fields are: `id`, `workflow_id`, `project_id`, `status`, `runner_mode`, `cancelation_request` :type query: str @@ -1386,27 +2143,53 @@ def search_workflow_runs( :type skip: int :param sort: The sort order for the search results. :type sort: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: SearchWorkflowRunsResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the search_workflow_runs_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.search_workflow_runs_with_http_info( - query, expand, limit, skip, sort, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._search_workflow_runs_serialize( + query=query, + expand=expand, + limit=limit, + skip=skip, + sort=sort, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - @validate_arguments + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchWorkflowRunsResponse", + } + 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 search_workflow_runs_with_http_info( self, query: Annotated[ @@ -1416,7 +2199,7 @@ def search_workflow_runs_with_http_info( ), ] = None, expand: Annotated[ - Optional[conlist(StrictStr)], + Optional[List[StrictStr]], Field( description="The fields to expand in the search results. Supported values are: `project`, `config.system`, `created_by`" ), @@ -1435,16 +2218,122 @@ def search_workflow_runs_with_http_info( Optional[StrictStr], Field(description="The sort order for the search results."), ] = None, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """search_workflow_runs # noqa: E501 + _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[SearchWorkflowRunsResponse]: + """search_workflow_runs - Search for workflow runs. This endpoint supports pagination, querying, and expansion. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + Search for workflow runs. This endpoint supports pagination, querying, and expansion. + + :param query: The query string for searching workflow runs. Supported fields are: `id`, `workflow_id`, `project_id`, `status`, `runner_mode`, `cancelation_request` + :type query: str + :param expand: The fields to expand in the search results. Supported values are: `project`, `config.system`, `created_by` + :type expand: List[str] + :param limit: The maximum number of results to return. + :type limit: int + :param skip: The number of results to skip before applying the limit. + :type skip: int + :param sort: The sort order for the search results. + :type sort: 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._search_workflow_runs_serialize( + query=query, + expand=expand, + limit=limit, + skip=skip, + sort=sort, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchWorkflowRunsResponse", + } + 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 search_workflow_runs_without_preload_content( + self, + query: Annotated[ + Optional[StrictStr], + Field( + description="The query string for searching workflow runs. Supported fields are: `id`, `workflow_id`, `project_id`, `status`, `runner_mode`, `cancelation_request`" + ), + ] = None, + expand: Annotated[ + Optional[List[StrictStr]], + Field( + description="The fields to expand in the search results. Supported values are: `project`, `config.system`, `created_by`" + ), + ] = None, + limit: Annotated[ + Optional[StrictInt], + Field(description="The maximum number of results to return."), + ] = None, + skip: Annotated[ + Optional[StrictInt], + Field( + description="The number of results to skip before applying the limit." + ), + ] = None, + sort: Annotated[ + Optional[StrictStr], + Field(description="The sort order for the search results."), + ] = None, + _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: + """search_workflow_runs - >>> thread = api.search_workflow_runs_with_http_info(query, expand, limit, skip, sort, async_req=True) - >>> result = thread.get() + Search for workflow runs. This endpoint supports pagination, querying, and expansion. :param query: The query string for searching workflow runs. Supported fields are: `id`, `workflow_id`, `project_id`, `status`, `runner_mode`, `cancelation_request` :type query: str @@ -1456,118 +2345,125 @@ def search_workflow_runs_with_http_info( :type skip: int :param sort: The sort order for the search results. :type sort: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(SearchWorkflowRunsResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["query", "expand", "limit", "skip", "sort"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method search_workflow_runs" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._search_workflow_runs_serialize( + query=query, + expand=expand, + limit=limit, + skip=skip, + sort=sort, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchWorkflowRunsResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + def _search_workflow_runs_serialize( + self, + query, + expand, + limit, + skip, + sort, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + "expand": "multi", + } + + _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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters # process the query parameters - _query_params = [] - if _params.get("query") is not None: # noqa: E501 - _query_params.append(("query", _params["query"])) + if query is not None: + + _query_params.append(("query", query)) + + if expand is not None: + + _query_params.append(("expand", expand)) - if _params.get("expand") is not None: # noqa: E501 - _query_params.append(("expand", _params["expand"])) - _collection_formats["expand"] = "multi" + if limit is not None: - if _params.get("limit") is not None: # noqa: E501 - _query_params.append(("limit", _params["limit"])) + _query_params.append(("limit", limit)) - if _params.get("skip") is not None: # noqa: E501 - _query_params.append(("skip", _params["skip"])) + if skip is not None: - if _params.get("sort") is not None: # noqa: E501 - _query_params.append(("sort", _params["sort"])) + _query_params.append(("skip", skip)) + + if sort is not None: + + _query_params.append(("sort", sort)) # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "SearchWorkflowRunsResponse", - } - - return self.api_client.call_api( - "/v1/workflows/runs/search", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/workflows/runs/search", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def search_workflow_tasks( self, query: Annotated[ @@ -1587,21 +2483,120 @@ def search_workflow_tasks( ), ] = None, expand: Annotated[ - Optional[conlist(StrictStr)], + Optional[List[StrictStr]], Field( description="The fields to expand in the search results. Supported values are: `project`, `created_by`" ), ] = None, - **kwargs, - ) -> SearchWorkflowTasksResponse: # noqa: E501 - """search_workflow_tasks # noqa: E501 + _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, + ) -> SearchWorkflowTasksResponse: + """search_workflow_tasks - Search for workflow tasks. This endpoint supports pagination, querying, and expansion. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + Search for workflow tasks. This endpoint supports pagination, querying, and expansion. - >>> thread = api.search_workflow_tasks(query, limit, skip, expand, async_req=True) - >>> result = thread.get() + :param query: The query string for searching workflow tasks. Supported fields are: `workflow_run_id` + :type query: str + :param limit: The maximum number of results to return. + :type limit: int + :param skip: The number of results to skip before applying the limit. + :type skip: int + :param expand: The fields to expand in the search results. Supported values are: `project`, `created_by` + :type expand: List[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._search_workflow_tasks_serialize( + query=query, + limit=limit, + skip=skip, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchWorkflowTasksResponse", + } + 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 search_workflow_tasks_with_http_info( + self, + query: Annotated[ + Optional[StrictStr], + Field( + description="The query string for searching workflow tasks. Supported fields are: `workflow_run_id`" + ), + ] = None, + limit: Annotated[ + Optional[StrictInt], + Field(description="The maximum number of results to return."), + ] = None, + skip: Annotated[ + Optional[StrictInt], + Field( + description="The number of results to skip before applying the limit." + ), + ] = None, + expand: Annotated[ + Optional[List[StrictStr]], + Field( + description="The fields to expand in the search results. Supported values are: `project`, `created_by`" + ), + ] = None, + _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[SearchWorkflowTasksResponse]: + """search_workflow_tasks + + Search for workflow tasks. This endpoint supports pagination, querying, and expansion. :param query: The query string for searching workflow tasks. Supported fields are: `workflow_run_id` :type query: str @@ -1611,35 +2606,225 @@ def search_workflow_tasks( :type skip: int :param expand: The fields to expand in the search results. Supported values are: `project`, `created_by` :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: SearchWorkflowTasksResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the search_workflow_tasks_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" + """ # noqa: E501 + + _param = self._search_workflow_tasks_serialize( + query=query, + limit=limit, + skip=skip, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchWorkflowTasksResponse", + } + 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 search_workflow_tasks_without_preload_content( + self, + query: Annotated[ + Optional[StrictStr], + Field( + description="The query string for searching workflow tasks. Supported fields are: `workflow_run_id`" + ), + ] = None, + limit: Annotated[ + Optional[StrictInt], + Field(description="The maximum number of results to return."), + ] = None, + skip: Annotated[ + Optional[StrictInt], + Field( + description="The number of results to skip before applying the limit." + ), + ] = None, + expand: Annotated[ + Optional[List[StrictStr]], + Field( + description="The fields to expand in the search results. Supported values are: `project`, `created_by`" + ), + ] = None, + _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: + """search_workflow_tasks + + Search for workflow tasks. This endpoint supports pagination, querying, and expansion. + + :param query: The query string for searching workflow tasks. Supported fields are: `workflow_run_id` + :type query: str + :param limit: The maximum number of results to return. + :type limit: int + :param skip: The number of results to skip before applying the limit. + :type skip: int + :param expand: The fields to expand in the search results. Supported values are: `project`, `created_by` + :type expand: List[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._search_workflow_tasks_serialize( + query=query, + limit=limit, + skip=skip, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchWorkflowTasksResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _search_workflow_tasks_serialize( + self, + query, + limit, + skip, + expand, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + "expand": "multi", + } + + _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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if query is not None: + + _query_params.append(("query", query)) + + if limit is not None: + + _query_params.append(("limit", limit)) + + if skip is not None: + + _query_params.append(("skip", skip)) + + if expand is not None: + + _query_params.append(("expand", expand)) + + # 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"] ) - return self.search_workflow_tasks_with_http_info( - query, limit, skip, expand, **kwargs - ) # noqa: E501 - @validate_arguments - def search_workflow_tasks_with_http_info( + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/workflows/runs/tasks/search", + 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 search_workflows( self, query: Annotated[ Optional[StrictStr], Field( - description="The query string for searching workflow tasks. Supported fields are: `workflow_run_id`" + description="The query string for searching workflows. Supported fields are: `id`, `project_id`" ), ] = None, + sort: Annotated[ + Optional[StrictStr], + Field(description="The sort order for the search results."), + ] = None, limit: Annotated[ Optional[StrictInt], Field(description="The maximum number of results to return."), @@ -1651,140 +2836,85 @@ def search_workflow_tasks_with_http_info( ), ] = None, expand: Annotated[ - Optional[conlist(StrictStr)], + Optional[List[StrictStr]], Field( - description="The fields to expand in the search results. Supported values are: `project`, `created_by`" + description="The fields to expand in the search results. Supported values are: `project`, `created_by`, `updated_by`, `latest_run`" ), ] = None, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """search_workflow_tasks # noqa: E501 - - Search for workflow tasks. This endpoint supports pagination, querying, and expansion. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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, + ) -> SearchWorkflowsResponse: + """search_workflows - >>> thread = api.search_workflow_tasks_with_http_info(query, limit, skip, expand, async_req=True) - >>> result = thread.get() + Search for workflows you or other project members have created. This endpoint supports pagination, querying, and expansion. - :param query: The query string for searching workflow tasks. Supported fields are: `workflow_run_id` + :param query: The query string for searching workflows. Supported fields are: `id`, `project_id` :type query: str + :param sort: The sort order for the search results. + :type sort: str :param limit: The maximum number of results to return. :type limit: int :param skip: The number of results to skip before applying the limit. :type skip: int - :param expand: The fields to expand in the search results. Supported values are: `project`, `created_by` + :param expand: The fields to expand in the search results. Supported values are: `project`, `created_by`, `updated_by`, `latest_run` :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(SearchWorkflowTasksResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["query", "limit", "skip", "expand"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method search_workflow_tasks" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - - # process the query parameters - _query_params = [] - if _params.get("query") is not None: # noqa: E501 - _query_params.append(("query", _params["query"])) - - if _params.get("limit") is not None: # noqa: E501 - _query_params.append(("limit", _params["limit"])) - - if _params.get("skip") is not None: # noqa: E501 - _query_params.append(("skip", _params["skip"])) - - if _params.get("expand") is not None: # noqa: E501 - _query_params.append(("expand", _params["expand"])) - _collection_formats["expand"] = "multi" - - # process the header parameters - _header_params = dict(_params.get("_headers", {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 + """ # noqa: E501 + + _param = self._search_workflows_serialize( + query=query, + sort=sort, + limit=limit, + skip=skip, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - _response_types_map = { - "200": "SearchWorkflowTasksResponse", + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchWorkflowsResponse", } - - return self.api_client.call_api( - "/v1/workflows/runs/tasks/search", - "GET", - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), - collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + 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_arguments - def search_workflows( + @validate_call + def search_workflows_with_http_info( self, query: Annotated[ Optional[StrictStr], @@ -1807,21 +2937,26 @@ def search_workflows( ), ] = None, expand: Annotated[ - Optional[conlist(StrictStr)], + Optional[List[StrictStr]], Field( description="The fields to expand in the search results. Supported values are: `project`, `created_by`, `updated_by`, `latest_run`" ), ] = None, - **kwargs, - ) -> SearchWorkflowsResponse: # noqa: E501 - """search_workflows # noqa: E501 - - Search for workflows you or other project members have created. This endpoint supports pagination, querying, and expansion. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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[SearchWorkflowsResponse]: + """search_workflows - >>> thread = api.search_workflows(query, sort, limit, skip, expand, async_req=True) - >>> result = thread.get() + Search for workflows you or other project members have created. This endpoint supports pagination, querying, and expansion. :param query: The query string for searching workflows. Supported fields are: `id`, `project_id` :type query: str @@ -1833,28 +2968,54 @@ def search_workflows( :type skip: int :param expand: The fields to expand in the search results. Supported values are: `project`, `created_by`, `updated_by`, `latest_run` :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: SearchWorkflowsResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the search_workflows_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.search_workflows_with_http_info( - query, sort, limit, skip, expand, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._search_workflows_serialize( + query=query, + sort=sort, + limit=limit, + skip=skip, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - @validate_arguments - def search_workflows_with_http_info( + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchWorkflowsResponse", + } + 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 search_workflows_without_preload_content( self, query: Annotated[ Optional[StrictStr], @@ -1877,21 +3038,26 @@ def search_workflows_with_http_info( ), ] = None, expand: Annotated[ - Optional[conlist(StrictStr)], + Optional[List[StrictStr]], Field( description="The fields to expand in the search results. Supported values are: `project`, `created_by`, `updated_by`, `latest_run`" ), ] = None, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """search_workflows # noqa: E501 - - Search for workflows you or other project members have created. This endpoint supports pagination, querying, and expansion. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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: + """search_workflows - >>> thread = api.search_workflows_with_http_info(query, sort, limit, skip, expand, async_req=True) - >>> result = thread.get() + Search for workflows you or other project members have created. This endpoint supports pagination, querying, and expansion. :param query: The query string for searching workflows. Supported fields are: `id`, `project_id` :type query: str @@ -1903,292 +3069,396 @@ def search_workflows_with_http_info( :type skip: int :param expand: The fields to expand in the search results. Supported values are: `project`, `created_by`, `updated_by`, `latest_run` :type expand: List[str] - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(SearchWorkflowsResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["query", "sort", "limit", "skip", "expand"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method search_workflows" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._search_workflows_serialize( + query=query, + sort=sort, + limit=limit, + skip=skip, + expand=expand, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} + _response_types_map: Dict[str, Optional[str]] = { + "200": "SearchWorkflowsResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _search_workflows_serialize( + self, + query, + sort, + limit, + skip, + expand, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + "expand": "multi", + } + + _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]] = {} + _body_params: Optional[bytes] = None + # process the path parameters # process the query parameters - _query_params = [] - if _params.get("query") is not None: # noqa: E501 - _query_params.append(("query", _params["query"])) + if query is not None: + + _query_params.append(("query", query)) - if _params.get("sort") is not None: # noqa: E501 - _query_params.append(("sort", _params["sort"])) + if sort is not None: - if _params.get("limit") is not None: # noqa: E501 - _query_params.append(("limit", _params["limit"])) + _query_params.append(("sort", sort)) - if _params.get("skip") is not None: # noqa: E501 - _query_params.append(("skip", _params["skip"])) + if limit is not None: - if _params.get("expand") is not None: # noqa: E501 - _query_params.append(("expand", _params["expand"])) - _collection_formats["expand"] = "multi" + _query_params.append(("limit", limit)) + + if skip is not None: + + _query_params.append(("skip", skip)) + + if expand is not None: + + _query_params.append(("expand", expand)) # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None + # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - "200": "SearchWorkflowsResponse", - } - - return self.api_client.call_api( - "/v1/workflows/search", - "GET", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/workflows/search", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def update_workflow_config( self, workflow_id: Annotated[ - constr(strict=True), - Field(..., description="The ID of the workflow to update."), + str, Field(strict=True, description="The ID of the workflow to update.") ], body: StrictStr, - **kwargs, - ) -> Workflow: # noqa: E501 - """update_workflow_config # noqa: E501 - - Update the config of an existing workflow. Future runs will be created with this config, existing runs will keep the config they were created with. Config can be provided as JSON or YAML content types. If provided as JSON, the `config_text` will be replaced with the JSON representation of the config, and any existing formatting or comments will be lost. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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, + ) -> Workflow: + """update_workflow_config - >>> thread = api.update_workflow_config(workflow_id, body, async_req=True) - >>> result = thread.get() + Update the config of an existing workflow. Future runs will be created with this config, existing runs will keep the config they were created with. Config can be provided as JSON or YAML content types. If provided as JSON, the `config_text` will be replaced with the JSON representation of the config, and any existing formatting or comments will be lost. :param workflow_id: The ID of the workflow to update. (required) :type workflow_id: str :param body: (required) :type body: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: Workflow - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the update_workflow_config_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.update_workflow_config_with_http_info( - workflow_id, body, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._update_workflow_config_serialize( + workflow_id=workflow_id, + body=body, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Workflow", + } + 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_arguments + @validate_call def update_workflow_config_with_http_info( self, workflow_id: Annotated[ - constr(strict=True), - Field(..., description="The ID of the workflow to update."), + str, Field(strict=True, description="The ID of the workflow to update.") ], body: StrictStr, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """update_workflow_config # noqa: E501 + _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[Workflow]: + """update_workflow_config + + Update the config of an existing workflow. Future runs will be created with this config, existing runs will keep the config they were created with. Config can be provided as JSON or YAML content types. If provided as JSON, the `config_text` will be replaced with the JSON representation of the config, and any existing formatting or comments will be lost. + + :param workflow_id: The ID of the workflow to update. (required) + :type workflow_id: str + :param body: (required) + :type body: 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._update_workflow_config_serialize( + workflow_id=workflow_id, + body=body, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Workflow", + } + 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, + ) - Update the config of an existing workflow. Future runs will be created with this config, existing runs will keep the config they were created with. Config can be provided as JSON or YAML content types. If provided as JSON, the `config_text` will be replaced with the JSON representation of the config, and any existing formatting or comments will be lost. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def update_workflow_config_without_preload_content( + self, + workflow_id: Annotated[ + str, Field(strict=True, description="The ID of the workflow to update.") + ], + body: StrictStr, + _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: + """update_workflow_config - >>> thread = api.update_workflow_config_with_http_info(workflow_id, body, async_req=True) - >>> result = thread.get() + Update the config of an existing workflow. Future runs will be created with this config, existing runs will keep the config they were created with. Config can be provided as JSON or YAML content types. If provided as JSON, the `config_text` will be replaced with the JSON representation of the config, and any existing formatting or comments will be lost. :param workflow_id: The ID of the workflow to update. (required) :type workflow_id: str :param body: (required) :type body: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(Workflow, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["workflow_id", "body"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method update_workflow_config" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._update_workflow_config_serialize( + workflow_id=workflow_id, + body=body, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} - if _params["workflow_id"]: - _path_params["workflow_id"] = _params["workflow_id"] + _response_types_map: Dict[str, Optional[str]] = { + "200": "Workflow", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _update_workflow_config_serialize( + self, + workflow_id, + body, + _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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if workflow_id is not None: + _path_params["workflow_id"] = workflow_id # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None - if _params["body"] is not None: - _body_params = _params["body"] + if body is not None: + _body_params = body # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` - _content_types_list = _params.get( - "_content_type", - self.api_client.select_header_content_type(["application/json"]), - ) - if _content_types_list: - _header_params["Content-Type"] = _content_types_list + 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 = [] # noqa: E501 - - _response_types_map = { - "200": "Workflow", - } - - return self.api_client.call_api( - "/v1/workflows/{workflow_id}/config", - "POST", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1/workflows/{workflow_id}/config", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def validate_workflow_action( self, body: Dict[str, Any], @@ -2198,42 +3468,70 @@ def validate_workflow_action( description="The runner mode to validate the action for. If this field is not UNSET, take the runner mode (cloud or hybrid) into account. This primarily affects which connections can be used in an action; those with Gretel-managed credentials encryption can't be used in a Hybrid workflow, and vice versa." ), ] = None, - **kwargs, - ) -> ValidateWorkflowActionResponse: # noqa: E501 - """validate_workflow_action # noqa: E501 - - Validate a single workflow action. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + _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, + ) -> ValidateWorkflowActionResponse: + """validate_workflow_action - >>> thread = api.validate_workflow_action(body, runner_mode, async_req=True) - >>> result = thread.get() + Validate a single workflow action. :param body: (required) :type body: object :param runner_mode: The runner mode to validate the action for. If this field is not UNSET, take the runner mode (cloud or hybrid) into account. This primarily affects which connections can be used in an action; those with Gretel-managed credentials encryption can't be used in a Hybrid workflow, and vice versa. :type runner_mode: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: ValidateWorkflowActionResponse - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the validate_workflow_action_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.validate_workflow_action_with_http_info( - body, runner_mode, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._validate_workflow_action_serialize( + body=body, + runner_mode=runner_mode, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ValidateWorkflowActionResponse", + } + 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_arguments + @validate_call def validate_workflow_action_with_http_info( self, body: Dict[str, Any], @@ -2243,280 +3541,451 @@ def validate_workflow_action_with_http_info( description="The runner mode to validate the action for. If this field is not UNSET, take the runner mode (cloud or hybrid) into account. This primarily affects which connections can be used in an action; those with Gretel-managed credentials encryption can't be used in a Hybrid workflow, and vice versa." ), ] = None, - **kwargs, - ) -> ApiResponse: # noqa: E501 - """validate_workflow_action # noqa: E501 + _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[ValidateWorkflowActionResponse]: + """validate_workflow_action + + Validate a single workflow action. - Validate a single workflow action. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + :param body: (required) + :type body: object + :param runner_mode: The runner mode to validate the action for. If this field is not UNSET, take the runner mode (cloud or hybrid) into account. This primarily affects which connections can be used in an action; those with Gretel-managed credentials encryption can't be used in a Hybrid workflow, and vice versa. + :type runner_mode: 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._validate_workflow_action_serialize( + body=body, + runner_mode=runner_mode, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ValidateWorkflowActionResponse", + } + 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 validate_workflow_action_without_preload_content( + self, + body: Dict[str, Any], + runner_mode: Annotated[ + Optional[StrictStr], + Field( + description="The runner mode to validate the action for. If this field is not UNSET, take the runner mode (cloud or hybrid) into account. This primarily affects which connections can be used in an action; those with Gretel-managed credentials encryption can't be used in a Hybrid workflow, and vice versa." + ), + ] = None, + _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: + """validate_workflow_action - >>> thread = api.validate_workflow_action_with_http_info(body, runner_mode, async_req=True) - >>> result = thread.get() + Validate a single workflow action. :param body: (required) :type body: object :param runner_mode: The runner mode to validate the action for. If this field is not UNSET, take the runner mode (cloud or hybrid) into account. This primarily affects which connections can be used in an action; those with Gretel-managed credentials encryption can't be used in a Hybrid workflow, and vice versa. :type runner_mode: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(ValidateWorkflowActionResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = ["body", "runner_mode"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method validate_workflow_action" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._validate_workflow_action_serialize( + body=body, + runner_mode=runner_mode, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} + _response_types_map: Dict[str, Optional[str]] = { + "200": "ValidateWorkflowActionResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _validate_workflow_action_serialize( + self, + body, + runner_mode, + _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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters # process the query parameters - _query_params = [] - if _params.get("runner_mode") is not None: # noqa: E501 - _query_params.append(("runner_mode", _params["runner_mode"])) + if runner_mode is not None: + + _query_params.append(("runner_mode", runner_mode)) # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None - if _params["body"] is not None: - _body_params = _params["body"] + if body is not None: + _body_params = body # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` - _content_types_list = _params.get( - "_content_type", - self.api_client.select_header_content_type(["application/json"]), - ) - if _content_types_list: - _header_params["Content-Type"] = _content_types_list + 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 = [] # noqa: E501 - - _response_types_map = { - "200": "ValidateWorkflowActionResponse", - } - - return self.api_client.call_api( - "/v1/workflows/validate-action", - "POST", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1/workflows/validate-action", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) - @validate_arguments + @validate_call def validate_workflow_config( - self, validate_workflow_config_request: ValidateWorkflowConfigRequest, **kwargs - ) -> None: # noqa: E501 - """validate_workflow_config # noqa: E501 - - Validate a workflow config. This endpoint will validate a workflow config, returning a status and message indicating if the config is valid # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + self, + validate_workflow_config_request: ValidateWorkflowConfigRequest, + _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: + """validate_workflow_config - >>> thread = api.validate_workflow_config(validate_workflow_config_request, async_req=True) - >>> result = thread.get() + Validate a workflow config. This endpoint will validate a workflow config, returning a status and message indicating if the config is valid :param validate_workflow_config_request: (required) :type validate_workflow_config_request: ValidateWorkflowConfigRequest - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional :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. - If the method is called asynchronously, - returns the request thread. - :rtype: None - """ - kwargs["_return_http_data_only"] = True - if "_preload_content" in kwargs: - raise ValueError( - "Error! Please call the validate_workflow_config_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" - ) - return self.validate_workflow_config_with_http_info( - validate_workflow_config_request, **kwargs - ) # noqa: E501 + """ # noqa: E501 + + _param = self._validate_workflow_config_serialize( + validate_workflow_config_request=validate_workflow_config_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + } + 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_arguments + @validate_call def validate_workflow_config_with_http_info( - self, validate_workflow_config_request: ValidateWorkflowConfigRequest, **kwargs - ) -> ApiResponse: # noqa: E501 - """validate_workflow_config # noqa: E501 + self, + validate_workflow_config_request: ValidateWorkflowConfigRequest, + _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]: + """validate_workflow_config + + Validate a workflow config. This endpoint will validate a workflow config, returning a status and message indicating if the config is valid + + :param validate_workflow_config_request: (required) + :type validate_workflow_config_request: ValidateWorkflowConfigRequest + :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._validate_workflow_config_serialize( + validate_workflow_config_request=validate_workflow_config_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + } + 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 a workflow config. This endpoint will validate a workflow config, returning a status and message indicating if the config is valid # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + @validate_call + def validate_workflow_config_without_preload_content( + self, + validate_workflow_config_request: ValidateWorkflowConfigRequest, + _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: + """validate_workflow_config - >>> thread = api.validate_workflow_config_with_http_info(validate_workflow_config_request, async_req=True) - >>> result = thread.get() + Validate a workflow config. This endpoint will validate a workflow config, returning a status and message indicating if the config is valid :param validate_workflow_config_request: (required) :type validate_workflow_config_request: ValidateWorkflowConfigRequest - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional :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. + request; this effectively ignores the + authentication in the spec for a single request. :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request + :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. - If the method is called asynchronously, - returns the request thread. - :rtype: None - """ - - _params = locals() - - _all_params = ["validate_workflow_config_request"] - _all_params.extend( - [ - "async_req", - "_return_http_data_only", - "_preload_content", - "_request_timeout", - "_request_auth", - "_content_type", - "_headers", - ] - ) - - # validate the arguments - for _key, _val in _params["kwargs"].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method validate_workflow_config" % _key - ) - _params[_key] = _val - del _params["kwargs"] - - _collection_formats = {} + """ # noqa: E501 + + _param = self._validate_workflow_config_serialize( + validate_workflow_config_request=validate_workflow_config_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) - # process the path parameters - _path_params = {} + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _validate_workflow_config_serialize( + self, + validate_workflow_config_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]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters # process the query parameters - _query_params = [] # process the header parameters - _header_params = dict(_params.get("_headers", {})) # process the form parameters - _form_params = [] - _files = {} # process the body parameter - _body_params = None - if _params["validate_workflow_config_request"] is not None: - _body_params = _params["validate_workflow_config_request"] + if validate_workflow_config_request is not None: + _body_params = validate_workflow_config_request # set the HTTP header `Accept` - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` - _content_types_list = _params.get( - "_content_type", - self.api_client.select_header_content_type(["application/json"]), - ) - if _content_types_list: - _header_params["Content-Type"] = _content_types_list + 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 = [] # noqa: E501 - - _response_types_map = {} - - return self.api_client.call_api( - "/v1/workflows/validate-config", - "POST", - _path_params, - _query_params, - _header_params, + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1/workflows/validate-config", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, body=_body_params, post_params=_form_params, files=_files, - response_types_map=_response_types_map, auth_settings=_auth_settings, - async_req=_params.get("async_req"), - _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=_params.get("_preload_content", True), - _request_timeout=_params.get("_request_timeout"), collection_formats=_collection_formats, - _request_auth=_params.get("_request_auth"), + _host=_host, + _request_auth=_request_auth, ) diff --git a/src/gretel_client/rest_v1/api_client.py b/src/gretel_client/rest_v1/api_client.py index 77b0e87..54a438d 100755 --- a/src/gretel_client/rest_v1/api_client.py +++ b/src/gretel_client/rest_v1/api_client.py @@ -12,7 +12,6 @@ """ # noqa: E501 -import atexit import datetime import json import mimetypes @@ -20,20 +19,33 @@ import re import tempfile -from multiprocessing.pool import ThreadPool +from enum import Enum +from typing import Dict, List, Optional, Tuple, Union from urllib.parse import quote from dateutil.parser import parse +from pydantic import SecretStr import gretel_client.rest_v1.models from gretel_client.rest_v1 import rest from gretel_client.rest_v1.api_response import ApiResponse +from gretel_client.rest_v1.api_response import T as ApiResponseT from gretel_client.rest_v1.configuration import Configuration -from gretel_client.rest_v1.exceptions import ApiException, ApiValueError +from gretel_client.rest_v1.exceptions import ( + ApiException, + ApiValueError, + BadRequestException, + ForbiddenException, + NotFoundException, + ServiceException, + UnauthorizedException, +) +RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] -class ApiClient(object): + +class ApiClient: """Generic API client for OpenAPI client library builds. OpenAPI generic API client. This client handles the client- @@ -47,8 +59,6 @@ class ApiClient(object): the API. :param cookie: a cookie to include in the header when making calls to the API - :param pool_threads: The number of threads to use for async requests - to the API. More threads means more concurrent API requests. """ PRIMITIVE_TYPES = (float, bool, bytes, str, int) @@ -65,18 +75,12 @@ class ApiClient(object): _pool = None def __init__( - self, - configuration=None, - header_name=None, - header_value=None, - cookie=None, - pool_threads=1, - ): + self, configuration=None, header_name=None, header_value=None, cookie=None + ) -> None: # use default configuration if none is provided if configuration is None: configuration = Configuration.get_default() self.configuration = configuration - self.pool_threads = pool_threads self.rest_client = rest.RESTClientObject(configuration) self.default_headers = {} @@ -91,25 +95,7 @@ def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): - self.close() - - def close(self): - if self._pool: - self._pool.close() - self._pool.join() - self._pool = None - if hasattr(atexit, "unregister"): - atexit.unregister(self.close) - - @property - def pool(self): - """Create thread pool on first request - avoids instantiating unused threadpool for blocking clients. - """ - if self._pool is None: - atexit.register(self.close) - self._pool = ThreadPool(self.pool_threads) - return self._pool + pass @property def user_agent(self): @@ -149,25 +135,42 @@ def set_default(cls, default): """ cls._default = default - def __call_api( + def param_serialize( self, - resource_path, method, + resource_path, path_params=None, query_params=None, header_params=None, body=None, post_params=None, files=None, - response_types_map=None, auth_settings=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, - _request_timeout=None, _host=None, _request_auth=None, - ): + ) -> RequestSerialized: + """Builds the HTTP request params needed by the request. + :param method: Method to call. + :param resource_path: Path to method endpoint. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :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. + :return: tuple of form (path, http_method, query_params, header_params, + body, post_params, files) + """ config = self.configuration @@ -197,7 +200,8 @@ def __call_api( post_params = post_params if post_params else [] post_params = self.sanitize_for_serialization(post_params) post_params = self.parameters_to_tuples(post_params, collection_formats) - post_params.extend(self.files_parameters(files)) + if files: + post_params.extend(self.files_parameters(files)) # auth setting self.update_params_for_auth( @@ -215,7 +219,7 @@ def __call_api( body = self.sanitize_for_serialization(body) # request url - if _host is None: + if _host is None or self.configuration.ignore_operation_servers: url = self.configuration.host + resource_path else: # use server/host defined in path or operation instead @@ -227,62 +231,108 @@ def __call_api( url_query = self.parameters_to_url_query(query_params, collection_formats) url += "?" + url_query + return method, url, header_params, body, post_params + + def call_api( + self, + method, + url, + header_params=None, + body=None, + post_params=None, + _request_timeout=None, + ) -> rest.RESTResponse: + """Makes the HTTP request (synchronous) + :param method: Method to call. + :param url: Path to method endpoint. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param _request_timeout: timeout setting for this request. + :return: RESTResponse + """ + try: # perform request and return response - response_data = self.request( + response_data = self.rest_client.request( method, url, - query_params=query_params, headers=header_params, - post_params=post_params, body=body, - _preload_content=_preload_content, + post_params=post_params, _request_timeout=_request_timeout, ) + except ApiException as e: - if e.body: - e.body = e.body.decode("utf-8") raise e - self.last_response = response_data + return response_data + + def response_deserialize( + self, + response_data: rest.RESTResponse, + response_types_map: Optional[Dict[str, ApiResponseT]] = None, + ) -> ApiResponse[ApiResponseT]: + """Deserializes response into an object. + :param response_data: RESTResponse object to be deserialized. + :param response_types_map: dict of response types. + :return: ApiResponse + """ - return_data = None # assuming derialization is not needed - # data needs deserialization or returns HTTP data (deserialized) only - if _preload_content or _return_http_data_only: - response_type = response_types_map.get(str(response_data.status), None) + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + assert response_data.data is not None, msg + + response_type = response_types_map.get(str(response_data.status), None) + if ( + not response_type + and isinstance(response_data.status, int) + and 100 <= response_data.status <= 599 + ): + # if not found, look for '1XX', '2XX', etc. + response_type = response_types_map.get( + str(response_data.status)[0] + "XX", None + ) + # deserialize response data + response_text = None + return_data = None + try: if response_type == "bytearray": - response_data.data = response_data.data - else: + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: match = None content_type = response_data.getheader("content-type") if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) encoding = match.group(1) if match else "utf-8" - response_data.data = response_data.data.decode(encoding) - - # deserialize response data - if response_type == "bytearray": - return_data = response_data.data - elif response_type: - return_data = self.deserialize(response_data, response_type) - else: - return_data = None + response_text = response_data.data.decode(encoding) + return_data = self.deserialize( + response_text, response_type, content_type + ) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) - if _return_http_data_only: - return return_data - else: - return ApiResponse( - status_code=response_data.status, - data=return_data, - headers=response_data.getheaders(), - raw_data=response_data.data, - ) + return ApiResponse( + status_code=response_data.status, + data=return_data, + headers=response_data.getheaders(), + raw_data=response_data.data, + ) def sanitize_for_serialization(self, obj): """Builds a JSON POST object. If obj is None, return None. + If obj is SecretStr, return obj.get_secret_value() If obj is str, int, long, float, bool, return directly. If obj is datetime.datetime, datetime.date convert to string in iso8601 format. @@ -295,6 +345,10 @@ def sanitize_for_serialization(self, obj): """ if obj is None: return None + elif isinstance(obj, Enum): + return obj.value + elif isinstance(obj, SecretStr): + return obj.get_secret_value() elif isinstance(obj, self.PRIMITIVE_TYPES): return obj elif isinstance(obj, list): @@ -304,7 +358,7 @@ def sanitize_for_serialization(self, obj): elif isinstance(obj, (datetime.datetime, datetime.date)): return obj.isoformat() - if isinstance(obj, dict): + elif isinstance(obj, dict): obj_dict = obj else: # Convert model obj to dict except @@ -312,31 +366,45 @@ def sanitize_for_serialization(self, obj): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - obj_dict = obj.to_dict() + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): + obj_dict = obj.to_dict() + else: + obj_dict = obj.__dict__ return { key: self.sanitize_for_serialization(val) for key, val in obj_dict.items() } - def deserialize(self, response, response_type): + def deserialize( + self, response_text: str, response_type: str, content_type: Optional[str] + ): """Deserializes response into an object. :param response: RESTResponse object to be deserialized. :param response_type: class literal for deserialized object, or string of class name. + :param content_type: content type of response. :return: deserialized object. """ - # handle file downloading - # save response body into a tmp file and return the instance - if response_type == "file": - return self.__deserialize_file(response) # fetch data from response object - try: - data = json.loads(response.data) - except ValueError: - data = response.data + if content_type is None: + try: + data = json.loads(response_text) + except ValueError: + data = response_text + elif content_type.startswith("application/json"): + if response_text == "": + data = "" + else: + data = json.loads(response_text) + elif content_type.startswith("text/plain"): + data = response_text + else: + raise ApiException( + status=0, reason="Unsupported content type: {0}".format(content_type) + ) return self.__deserialize(data, response_type) @@ -351,13 +419,17 @@ def __deserialize(self, data, klass): if data is None: return None - if type(klass) == str: + if isinstance(klass, str): if klass.startswith("List["): - sub_kls = re.match(r"List\[(.*)]", klass).group(1) + m = re.match(r"List\[(.*)]", klass) + assert m is not None, "Malformed List type definition" + sub_kls = m.group(1) return [self.__deserialize(sub_data, sub_kls) for sub_data in data] if klass.startswith("Dict["): - sub_kls = re.match(r"Dict\[([^,]*), (.*)]", klass).group(2) + m = re.match(r"Dict\[([^,]*), (.*)]", klass) + assert m is not None, "Malformed Dict type definition" + sub_kls = m.group(2) return {k: self.__deserialize(v, sub_kls) for k, v in data.items()} # convert str to class @@ -374,193 +446,11 @@ def __deserialize(self, data, klass): return self.__deserialize_date(data) elif klass == datetime.datetime: return self.__deserialize_datetime(data) + elif issubclass(klass, Enum): + return self.__deserialize_enum(data, klass) else: return self.__deserialize_model(data, klass) - def call_api( - self, - resource_path, - method, - path_params=None, - query_params=None, - header_params=None, - body=None, - post_params=None, - files=None, - response_types_map=None, - auth_settings=None, - async_req=None, - _return_http_data_only=None, - collection_formats=None, - _preload_content=True, - _request_timeout=None, - _host=None, - _request_auth=None, - ): - """Makes the HTTP request (synchronous) and returns deserialized data. - - To make an async_req request, set the async_req parameter. - - :param resource_path: Path to method endpoint. - :param method: Method to call. - :param path_params: Path parameters in the url. - :param query_params: Query parameters in the url. - :param header_params: Header parameters to be - placed in the request header. - :param body: Request body. - :param post_params dict: Request post form parameters, - for `application/x-www-form-urlencoded`, `multipart/form-data`. - :param auth_settings list: Auth Settings names for the request. - :param response: Response data type. - :param files dict: key -> filename, value -> filepath, - for `multipart/form-data`. - :param async_req bool: execute request asynchronously - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :param collection_formats: dict of collection formats for path, query, - header, and post parameters. - :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. - :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_token: dict, optional - :return: - If async_req parameter is True, - the request will be called asynchronously. - The method will return the request thread. - If parameter async_req is False or missing, - then the method will return the response directly. - """ - if not async_req: - return self.__call_api( - resource_path, - method, - path_params, - query_params, - header_params, - body, - post_params, - files, - response_types_map, - auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host, - _request_auth, - ) - - return self.pool.apply_async( - self.__call_api, - ( - resource_path, - method, - path_params, - query_params, - header_params, - body, - post_params, - files, - response_types_map, - auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host, - _request_auth, - ), - ) - - def request( - self, - method, - url, - query_params=None, - headers=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - """Makes the HTTP request using RESTClient.""" - if method == "GET": - return self.rest_client.get_request( - url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers, - ) - elif method == "HEAD": - return self.rest_client.head_request( - url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers, - ) - elif method == "OPTIONS": - return self.rest_client.options_request( - url, - query_params=query_params, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - ) - elif method == "POST": - return self.rest_client.post_request( - url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - elif method == "PUT": - return self.rest_client.put_request( - url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - elif method == "PATCH": - return self.rest_client.patch_request( - url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - elif method == "DELETE": - return self.rest_client.delete_request( - url, - query_params=query_params, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - else: - raise ApiValueError( - "http method must be `GET`, `HEAD`, `OPTIONS`," - " `POST`, `PATCH`, `PUT` or `DELETE`." - ) - def parameters_to_tuples(self, params, collection_formats): """Get parameters as list of tuples, formatting collections. @@ -568,12 +458,10 @@ def parameters_to_tuples(self, params, collection_formats): :param dict collection_formats: Parameter collection formats :return: Parameters as list of tuples, collections formatted """ - new_params = [] + new_params: List[Tuple[str, str]] = [] if collection_formats is None: collection_formats = {} - for k, v in ( - params.items() if isinstance(params, dict) else params - ): # noqa: E501 + for k, v in params.items() if isinstance(params, dict) else params: if k in collection_formats: collection_format = collection_formats[k] if collection_format == "multi": @@ -599,23 +487,21 @@ def parameters_to_url_query(self, params, collection_formats): :param dict collection_formats: Parameter collection formats :return: URL query string (e.g. a=Hello%20World&b=123) """ - new_params = [] + new_params: List[Tuple[str, str]] = [] if collection_formats is None: collection_formats = {} - for k, v in ( - params.items() if isinstance(params, dict) else params - ): # noqa: E501 - if isinstance(v, (int, float)): - v = str(v) + for k, v in params.items() if isinstance(params, dict) else params: if isinstance(v, bool): v = str(v).lower() + if isinstance(v, (int, float)): + v = str(v) if isinstance(v, dict): v = json.dumps(v) if k in collection_formats: collection_format = collection_formats[k] if collection_format == "multi": - new_params.extend((k, value) for value in v) + new_params.extend((k, str(value)) for value in v) else: if collection_format == "ssv": delimiter = " " @@ -631,41 +517,37 @@ def parameters_to_url_query(self, params, collection_formats): else: new_params.append((k, quote(str(v)))) - return "&".join(["=".join(item) for item in new_params]) + return "&".join(["=".join(map(str, item)) for item in new_params]) - def files_parameters(self, files=None): + def files_parameters(self, files: Dict[str, Union[str, bytes]]): """Builds form parameters. :param files: File parameters. :return: Form parameters with files. """ params = [] - - if files: - for k, v in files.items(): - if not v: - continue - file_names = v if type(v) is list else [v] - for n in file_names: - with open(n, "rb") as f: - filename = os.path.basename(f.name) - filedata = f.read() - mimetype = ( - mimetypes.guess_type(filename)[0] - or "application/octet-stream" - ) - params.append(tuple([k, tuple([filename, filedata, mimetype])])) - + for k, v in files.items(): + if isinstance(v, str): + with open(v, "rb") as f: + filename = os.path.basename(f.name) + filedata = f.read() + elif isinstance(v, bytes): + filename = k + filedata = v + else: + raise ValueError("Unsupported file value") + mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream" + params.append(tuple([k, tuple([filename, filedata, mimetype])])) return params - def select_header_accept(self, accepts): + def select_header_accept(self, accepts: List[str]) -> Optional[str]: """Returns `Accept` based on an array of accepts provided. :param accepts: List of headers. :return: Accept (e.g. application/json). """ if not accepts: - return + return None for accept in accepts: if re.search("json", accept, re.IGNORECASE): @@ -697,7 +579,7 @@ def update_params_for_auth( method, body, request_auth=None, - ): + ) -> None: """Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. @@ -717,18 +599,17 @@ def update_params_for_auth( self._apply_auth_params( headers, queries, resource_path, method, body, request_auth ) - return - - for auth in auth_settings: - auth_setting = self.configuration.auth_settings().get(auth) - if auth_setting: - self._apply_auth_params( - headers, queries, resource_path, method, body, auth_setting - ) + else: + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + self._apply_auth_params( + headers, queries, resource_path, method, body, auth_setting + ) def _apply_auth_params( self, headers, queries, resource_path, method, body, auth_setting - ): + ) -> None: """Updates the request parameters based on a single auth_setting :param headers: Header parameters dict to be updated. @@ -755,6 +636,9 @@ def __deserialize_file(self, response): Saves response body into a file in a temporary folder, using the filename from the `Content-Disposition` header if provided. + handle file downloading + save response body into a tmp file and return the instance + :param response: RESTResponse. :return: file path. """ @@ -764,9 +648,9 @@ def __deserialize_file(self, response): content_disposition = response.getheader("Content-Disposition") if content_disposition: - filename = re.search( - r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition - ).group(1) + m = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition) + assert m is not None, "Unexpected 'content-disposition' header value" + filename = m.group(1) path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: @@ -829,6 +713,20 @@ def __deserialize_datetime(self, string): reason=("Failed to parse `{0}` as datetime object".format(string)), ) + def __deserialize_enum(self, data, klass): + """Deserializes primitive type to enum. + + :param data: primitive type. + :param klass: class literal. + :return: enum value. + """ + try: + return klass(data) + except ValueError: + raise rest.ApiException( + status=0, reason=("Failed to parse `{0}` as `{1}`".format(data, klass)) + ) + def __deserialize_model(self, data, klass): """Deserializes list or dict to model. diff --git a/src/gretel_client/rest_v1/api_response.py b/src/gretel_client/rest_v1/api_response.py index d1fdefc..ca801da 100755 --- a/src/gretel_client/rest_v1/api_response.py +++ b/src/gretel_client/rest_v1/api_response.py @@ -2,27 +2,21 @@ from __future__ import annotations -from typing import Any, Dict, Optional +from typing import Generic, Mapping, Optional, TypeVar -from pydantic import Field, StrictInt, StrictStr +from pydantic import BaseModel, Field, StrictBytes, StrictInt +T = TypeVar("T") -class ApiResponse: + +class ApiResponse(BaseModel, Generic[T]): """ API response object """ - status_code: Optional[StrictInt] = Field(None, description="HTTP status code") - headers: Optional[Dict[StrictStr, StrictStr]] = Field( - None, description="HTTP headers" - ) - data: Optional[Any] = Field( - None, description="Deserialized data given the data type" - ) - raw_data: Optional[Any] = Field(None, description="Raw data (HTTP response body)") - - def __init__(self, status_code=None, headers=None, data=None, raw_data=None): - self.status_code = status_code - self.headers = headers - self.data = data - self.raw_data = raw_data + status_code: StrictInt = Field(description="HTTP status code") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") + data: T = Field(description="Deserialized data given the data type") + raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") + + model_config = {"arbitrary_types_allowed": True} diff --git a/src/gretel_client/rest_v1/configuration.py b/src/gretel_client/rest_v1/configuration.py index 1a32675..050a513 100755 --- a/src/gretel_client/rest_v1/configuration.py +++ b/src/gretel_client/rest_v1/configuration.py @@ -18,9 +18,10 @@ import multiprocessing import sys -import urllib3 +from logging import FileHandler +from typing import Optional -from gretel_client.rest_v1.exceptions import ApiValueError +import urllib3 JSON_SCHEMA_VALIDATION_KEYWORDS = { "multipleOf", @@ -36,10 +37,13 @@ } -class Configuration(object): +class Configuration: """This class contains various settings of the API client. :param host: Base url. + :param ignore_operation_servers + Boolean to ignore operation servers for the API client. + Config will use `host` as the base url regardless of the operation servers. :param api_key: Dict to store API key(s). Each entry in the dict specifies an API key. The dict key is the name of the security scheme in the OAS specification. @@ -58,9 +62,11 @@ class Configuration(object): configuration. :param server_operation_variables: Mapping from operation ID to a mapping with string values to replace variables in templated server configuration. - The validation of enums is performed for variables with defined enum values before. + The validation of enums is performed for variables with defined enum + values before. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. + :param retries: Number of retries for API requests. """ @@ -78,8 +84,12 @@ def __init__( server_variables=None, server_operation_index=None, server_operation_variables=None, + ignore_operation_servers=False, ssl_ca_cert=None, - ): + retries=None, + *, + debug: Optional[bool] = None, + ) -> None: """Constructor""" self._base_path = "https://api.gretel.cloud" if host is None else host """Default Base url @@ -92,6 +102,9 @@ def __init__( self.server_operation_variables = server_operation_variables or {} """Default server variables """ + self.ignore_operation_servers = ignore_operation_servers + """Ignore operation servers + """ self.temp_folder_path = None """Temp file folder for downloading files """ @@ -129,13 +142,16 @@ def __init__( self.logger_stream_handler = None """Log stream handler """ - self.logger_file_handler = None + self.logger_file_handler: Optional[FileHandler] = None """Log file handler """ self.logger_file = None """Debug file location """ - self.debug = False + if debug is not None: + self.debug = debug + else: + self.__debug = False """Debug switch """ @@ -169,7 +185,7 @@ def __init__( cpu_count * 5 is used as default value to increase performance. """ - self.proxy = None + self.proxy: Optional[str] = None """Proxy URL """ self.proxy_headers = None @@ -178,7 +194,7 @@ def __init__( self.safe_chars_for_path_param = "" """Safe chars for path_param """ - self.retries = None + self.retries = retries """Adding retries to override urllib3 default value 3 """ # Enable client side validation diff --git a/src/gretel_client/rest_v1/exceptions.py b/src/gretel_client/rest_v1/exceptions.py index 42e82bf..148601e 100755 --- a/src/gretel_client/rest_v1/exceptions.py +++ b/src/gretel_client/rest_v1/exceptions.py @@ -11,13 +11,19 @@ Do not edit the class manually. """ # noqa: E501 +from typing import Any, Optional + +from typing_extensions import Self + class OpenApiException(Exception): """The base exception class for all OpenAPIExceptions""" class ApiTypeError(OpenApiException, TypeError): - def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None): + def __init__( + self, msg, path_to_item=None, valid_classes=None, key_type=None + ) -> None: """Raises an exception for TypeErrors Args: @@ -45,7 +51,7 @@ def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None): class ApiValueError(OpenApiException, ValueError): - def __init__(self, msg, path_to_item=None): + def __init__(self, msg, path_to_item=None) -> None: """ Args: msg (str): the exception message @@ -63,7 +69,7 @@ def __init__(self, msg, path_to_item=None): class ApiAttributeError(OpenApiException, AttributeError): - def __init__(self, msg, path_to_item=None): + def __init__(self, msg, path_to_item=None) -> None: """ Raised when an attribute reference or assignment fails. @@ -82,7 +88,7 @@ def __init__(self, msg, path_to_item=None): class ApiKeyError(OpenApiException, KeyError): - def __init__(self, msg, path_to_item=None): + def __init__(self, msg, path_to_item=None) -> None: """ Args: msg (str): the exception message @@ -100,17 +106,56 @@ def __init__(self, msg, path_to_item=None): class ApiException(OpenApiException): - def __init__(self, status=None, reason=None, http_resp=None): + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode("utf-8") + except Exception: + pass self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) def __str__(self): """Custom error messages for exception""" @@ -118,40 +163,30 @@ def __str__(self): if self.headers: error_message += "HTTP response headers: {0}\n".format(self.headers) - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) return error_message class BadRequestException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None): - super(BadRequestException, self).__init__(status, reason, http_resp) + pass class NotFoundException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None): - super(NotFoundException, self).__init__(status, reason, http_resp) + pass class UnauthorizedException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None): - super(UnauthorizedException, self).__init__(status, reason, http_resp) + pass class ForbiddenException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None): - super(ForbiddenException, self).__init__(status, reason, http_resp) + pass class ServiceException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None): - super(ServiceException, self).__init__(status, reason, http_resp) + pass def render_path(path_to_item): diff --git a/src/gretel_client/rest_v1/models/activity_event.py b/src/gretel_client/rest_v1/models/activity_event.py index f830a85..92a012c 100755 --- a/src/gretel_client/rest_v1/models/activity_event.py +++ b/src/gretel_client/rest_v1/models/activity_event.py @@ -19,8 +19,10 @@ import re # noqa: F401 from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, Field, StrictStr, validator +from pydantic import BaseModel, ConfigDict, field_validator, StrictStr +from typing_extensions import Self from gretel_client.rest_v1.models.event_component import EventComponent @@ -28,15 +30,15 @@ class ActivityEvent(BaseModel): """ ActivityEvent - """ - - occurred_at: datetime = Field(...) - occured_at: datetime = Field(...) - subject: EventComponent = Field(...) - predicate: StrictStr = Field(...) - object: EventComponent = Field(...) - status: StrictStr = Field(...) - __properties = [ + """ # noqa: E501 + + occurred_at: datetime + occured_at: datetime + subject: EventComponent + predicate: StrictStr + object: EventComponent + status: StrictStr + __properties: ClassVar[List[str]] = [ "occurred_at", "occured_at", "subject", @@ -45,35 +47,50 @@ class ActivityEvent(BaseModel): "status", ] - @validator("predicate") + @field_validator("predicate") def predicate_validate_enum(cls, value): """Validates the enum""" - if value not in ("PREDICATE_CREATED_AT"): + if value not in set(["PREDICATE_CREATED_AT"]): raise ValueError("must be one of enum values ('PREDICATE_CREATED_AT')") return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> ActivityEvent: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ActivityEvent from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 subject if self.subject: _dict["subject"] = self.subject.to_dict() @@ -83,26 +100,26 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ActivityEvent: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of ActivityEvent from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ActivityEvent.parse_obj(obj) + return cls.model_validate(obj) - _obj = ActivityEvent.parse_obj( + _obj = cls.model_validate( { "occurred_at": obj.get("occurred_at"), "occured_at": obj.get("occured_at"), "subject": ( - EventComponent.from_dict(obj.get("subject")) + EventComponent.from_dict(obj["subject"]) if obj.get("subject") is not None else None ), "predicate": obj.get("predicate"), "object": ( - EventComponent.from_dict(obj.get("object")) + EventComponent.from_dict(obj["object"]) if obj.get("object") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/cluster.py b/src/gretel_client/rest_v1/models/cluster.py index 97163e6..7536a64 100755 --- a/src/gretel_client/rest_v1/models/cluster.py +++ b/src/gretel_client/rest_v1/models/cluster.py @@ -19,9 +19,10 @@ import re # noqa: F401 from datetime import datetime -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, StrictStr, validator +from pydantic import BaseModel, ConfigDict, field_validator, StrictStr +from typing_extensions import Self from gretel_client.rest_v1.models.cluster_cloud_provider_info import ( ClusterCloudProviderInfo, @@ -34,7 +35,7 @@ class Cluster(BaseModel): """ Cluster - """ + """ # noqa: E501 guid: Optional[StrictStr] = None name: Optional[StrictStr] = None @@ -48,7 +49,7 @@ class Cluster(BaseModel): config: Optional[ClusterConfig] = None chart_version: Optional[StrictStr] = None app_version: Optional[StrictStr] = None - __properties = [ + __properties: ClassVar[List[str]] = [ "guid", "name", "owner_guid", @@ -63,40 +64,55 @@ class Cluster(BaseModel): "app_version", ] - @validator("cloud_provider_type") + @field_validator("cloud_provider_type") def cloud_provider_type_validate_enum(cls, value): """Validates the enum""" if value is None: return value - if value not in ("UNKNOWN", "AWS", "GCP", "AZURE"): + if value not in set(["UNKNOWN", "AWS", "GCP", "AZURE"]): raise ValueError( "must be one of enum values ('UNKNOWN', 'AWS', 'GCP', 'AZURE')" ) return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> Cluster: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Cluster from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 owner_profile if self.owner_profile: _dict["owner_profile"] = self.owner_profile.to_dict() @@ -112,39 +128,39 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Cluster: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of Cluster from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Cluster.parse_obj(obj) + return cls.model_validate(obj) - _obj = Cluster.parse_obj( + _obj = cls.model_validate( { "guid": obj.get("guid"), "name": obj.get("name"), "owner_guid": obj.get("owner_guid"), "owner_profile": ( - UserProfile.from_dict(obj.get("owner_profile")) + UserProfile.from_dict(obj["owner_profile"]) if obj.get("owner_profile") is not None else None ), "cloud_provider": ( - ClusterCloudProviderInfo.from_dict(obj.get("cloud_provider")) + ClusterCloudProviderInfo.from_dict(obj["cloud_provider"]) if obj.get("cloud_provider") is not None else None ), "cloud_provider_type": obj.get("cloud_provider_type"), "status": ( - ClusterStatus.from_dict(obj.get("status")) + ClusterStatus.from_dict(obj["status"]) if obj.get("status") is not None else None ), "created_at": obj.get("created_at"), "last_checkin_time": obj.get("last_checkin_time"), "config": ( - ClusterConfig.from_dict(obj.get("config")) + ClusterConfig.from_dict(obj["config"]) if obj.get("config") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/cluster_cloud_provider_info.py b/src/gretel_client/rest_v1/models/cluster_cloud_provider_info.py index 06cd27b..443393b 100755 --- a/src/gretel_client/rest_v1/models/cluster_cloud_provider_info.py +++ b/src/gretel_client/rest_v1/models/cluster_cloud_provider_info.py @@ -18,56 +18,72 @@ import pprint import re # noqa: F401 -from typing import Any, Dict, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, StrictStr +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self class ClusterCloudProviderInfo(BaseModel): """ ClusterCloudProviderInfo - """ + """ # noqa: E501 region: Optional[StrictStr] = None aws: Optional[Dict[str, Any]] = None gcp: Optional[Dict[str, Any]] = None azure: Optional[Dict[str, Any]] = None - __properties = ["region", "aws", "gcp", "azure"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["region", "aws", "gcp", "azure"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> ClusterCloudProviderInfo: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ClusterCloudProviderInfo from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> ClusterCloudProviderInfo: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of ClusterCloudProviderInfo from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ClusterCloudProviderInfo.parse_obj(obj) + return cls.model_validate(obj) - _obj = ClusterCloudProviderInfo.parse_obj( + _obj = cls.model_validate( { "region": obj.get("region"), "aws": obj.get("aws"), diff --git a/src/gretel_client/rest_v1/models/cluster_config.py b/src/gretel_client/rest_v1/models/cluster_config.py index 3b49bfe..72f7b2a 100755 --- a/src/gretel_client/rest_v1/models/cluster_config.py +++ b/src/gretel_client/rest_v1/models/cluster_config.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict +from typing_extensions import Self from gretel_client.rest_v1.models.config_asymmetric_key_metadata import ( ConfigAsymmetricKeyMetadata, @@ -30,51 +31,66 @@ class ClusterConfig(BaseModel): """ ClusterConfig - """ + """ # noqa: E501 asymmetric_key: Optional[ConfigAsymmetricKeyMetadata] = None - __properties = ["asymmetric_key"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["asymmetric_key"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> ClusterConfig: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ClusterConfig from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 asymmetric_key if self.asymmetric_key: _dict["asymmetric_key"] = self.asymmetric_key.to_dict() return _dict @classmethod - def from_dict(cls, obj: dict) -> ClusterConfig: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of ClusterConfig from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ClusterConfig.parse_obj(obj) + return cls.model_validate(obj) - _obj = ClusterConfig.parse_obj( + _obj = cls.model_validate( { "asymmetric_key": ( - ConfigAsymmetricKeyMetadata.from_dict(obj.get("asymmetric_key")) + ConfigAsymmetricKeyMetadata.from_dict(obj["asymmetric_key"]) if obj.get("asymmetric_key") is not None else None ) diff --git a/src/gretel_client/rest_v1/models/cluster_status.py b/src/gretel_client/rest_v1/models/cluster_status.py index 0efd6cd..eae81bc 100755 --- a/src/gretel_client/rest_v1/models/cluster_status.py +++ b/src/gretel_client/rest_v1/models/cluster_status.py @@ -18,68 +18,86 @@ import pprint import re # noqa: F401 -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, StrictStr, validator +from pydantic import BaseModel, ConfigDict, field_validator, StrictStr +from typing_extensions import Self class ClusterStatus(BaseModel): """ ClusterStatus - """ + """ # noqa: E501 health_status: Optional[StrictStr] = None - __properties = ["health_status"] + __properties: ClassVar[List[str]] = ["health_status"] - @validator("health_status") + @field_validator("health_status") def health_status_validate_enum(cls, value): """Validates the enum""" if value is None: return value - if value not in ( - "HEALTH_STATUS_UNKNOWN", - "HEALTH_STATUS_HEALTHY", - "HEALTH_STATUS_DEGRADED", - "HEALTH_STATUS_UNHEALTHY", + if value not in set( + [ + "HEALTH_STATUS_UNKNOWN", + "HEALTH_STATUS_HEALTHY", + "HEALTH_STATUS_DEGRADED", + "HEALTH_STATUS_UNHEALTHY", + ] ): raise ValueError( "must be one of enum values ('HEALTH_STATUS_UNKNOWN', 'HEALTH_STATUS_HEALTHY', 'HEALTH_STATUS_DEGRADED', 'HEALTH_STATUS_UNHEALTHY')" ) return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> ClusterStatus: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ClusterStatus from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> ClusterStatus: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of ClusterStatus from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ClusterStatus.parse_obj(obj) + return cls.model_validate(obj) - _obj = ClusterStatus.parse_obj({"health_status": obj.get("health_status")}) + _obj = cls.model_validate({"health_status": obj.get("health_status")}) return _obj diff --git a/src/gretel_client/rest_v1/models/config_asymmetric_key_metadata.py b/src/gretel_client/rest_v1/models/config_asymmetric_key_metadata.py index 52c6ee7..a8a5695 100755 --- a/src/gretel_client/rest_v1/models/config_asymmetric_key_metadata.py +++ b/src/gretel_client/rest_v1/models/config_asymmetric_key_metadata.py @@ -18,74 +18,91 @@ import pprint import re # noqa: F401 -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, Field, StrictStr, validator +from pydantic import BaseModel, ConfigDict, Field, field_validator, StrictStr +from typing_extensions import Self class ConfigAsymmetricKeyMetadata(BaseModel): """ ConfigAsymmetricKeyMetadata - """ + """ # noqa: E501 key_id: Optional[StrictStr] = Field( - None, + default=None, description="A string to allow identifying the key used for decryption. This may reference a resource within a cloud provider; however, clients may treat this as a fully opaque value.", ) algorithm: Optional[StrictStr] = Field( - None, description="The asymmetric decryption algorithm to use with this key." + default=None, + description="The asymmetric decryption algorithm to use with this key.", ) public_key_pem: Optional[StrictStr] = Field( - None, description="PEM-encoded public key." + default=None, description="PEM-encoded public key." ) - __properties = ["key_id", "algorithm", "public_key_pem"] + __properties: ClassVar[List[str]] = ["key_id", "algorithm", "public_key_pem"] - @validator("algorithm") + @field_validator("algorithm") def algorithm_validate_enum(cls, value): """Validates the enum""" if value is None: return value - if value not in ("UNKNOWN_ALGORITHM", "RSA_4096_OAEP_SHA256"): + if value not in set(["UNKNOWN_ALGORITHM", "RSA_4096_OAEP_SHA256"]): raise ValueError( "must be one of enum values ('UNKNOWN_ALGORITHM', 'RSA_4096_OAEP_SHA256')" ) return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> ConfigAsymmetricKeyMetadata: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ConfigAsymmetricKeyMetadata from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> ConfigAsymmetricKeyMetadata: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of ConfigAsymmetricKeyMetadata from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ConfigAsymmetricKeyMetadata.parse_obj(obj) + return cls.model_validate(obj) - _obj = ConfigAsymmetricKeyMetadata.parse_obj( + _obj = cls.model_validate( { "key_id": obj.get("key_id"), "algorithm": obj.get("algorithm"), diff --git a/src/gretel_client/rest_v1/models/connection.py b/src/gretel_client/rest_v1/models/connection.py index 8e3132d..f12e1c9 100755 --- a/src/gretel_client/rest_v1/models/connection.py +++ b/src/gretel_client/rest_v1/models/connection.py @@ -19,60 +19,63 @@ import re # noqa: F401 from datetime import datetime -from typing import Any, Dict, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, Field, StrictBool, StrictStr, validator +from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator, + StrictBool, + StrictStr, +) +from typing_extensions import Self class Connection(BaseModel): """ Next available tag: 14 - """ + """ # noqa: E501 id: StrictStr = Field( - ..., - description="The id of the connection. Connection id's are prefixed with `c_`.", - ) - type: StrictStr = Field( - ..., description="Type of the connection: aws, gcs, azure etc." + description="The id of the connection. Connection id's are prefixed with `c_`." ) - name: StrictStr = Field(..., description="Name of the connection.") + type: StrictStr = Field(description="Type of the connection: aws, gcs, azure etc.") + name: StrictStr = Field(description="Name of the connection.") validation_status: StrictStr = Field( - ..., - description="Current connection validation status. Possible values are: `COMPLETED`, `ERROR`, or `NONE`.", + description="Current connection validation status. Possible values are: `COMPLETED`, `ERROR`, or `NONE`." ) credentials: Optional[Dict[str, Any]] = Field( - None, description="Connection credentials in plain text." + default=None, description="Connection credentials in plain text." ) config: Optional[Dict[str, Any]] = Field( - None, + default=None, description="The connection configuration. See [connection type documentation](https://docs.gretel.ai/create-synthetic-data/workflows-and-connectors/connectors) for structure.", ) encrypted_credentials: Optional[Dict[str, Any]] = Field( - None, description="Connection credentials in encrypted form." + default=None, description="Connection credentials in encrypted form." ) customer_managed_credentials_encryption: StrictBool = Field( - ..., - description="When true, this connection is using a customer-managed key to encrypt credentials. Otherwise, this connection is using a Gretel-managed key to encrypt credentials.", + description="When true, this connection is using a customer-managed key to encrypt credentials. Otherwise, this connection is using a Gretel-managed key to encrypt credentials." ) created_at: datetime = Field( - ..., description="Timestamp when this connection was created." + description="Timestamp when this connection was created." ) project_id: StrictStr = Field( - ..., description="ID of the project that owns this connection" + description="ID of the project that owns this connection" ) created_by: StrictStr = Field( - ..., description="ID of the user who created this connection" + description="ID of the user who created this connection" ) connection_target_type: Optional[StrictStr] = Field( - None, + default=None, description="The type of workflow action this connection may be used with. If empty or `unspecified`, this connection may be used with any workflow action. Possible values are: `source`, `destination`, `unspecified`", ) auth_strategy: Optional[StrictStr] = Field( - None, + default=None, description="The auth strategy used when supported by a connection type. See [connection type documentation](https://docs.gretel.ai/create-synthetic-data/workflows-and-connectors/connectors) for possible values.", ) - __properties = [ + __properties: ClassVar[List[str]] = [ "id", "type", "name", @@ -88,54 +91,71 @@ class Connection(BaseModel): "auth_strategy", ] - @validator("validation_status") + @field_validator("validation_status") def validation_status_validate_enum(cls, value): """Validates the enum""" - if value not in ( - "VALIDATION_STATUS_UNKNOWN", - "VALIDATION_STATUS_VALIDATING", - "VALIDATION_STATUS_VALID", - "VALIDATION_STATUS_INVALID", + if value not in set( + [ + "VALIDATION_STATUS_UNKNOWN", + "VALIDATION_STATUS_VALIDATING", + "VALIDATION_STATUS_VALID", + "VALIDATION_STATUS_INVALID", + ] ): raise ValueError( "must be one of enum values ('VALIDATION_STATUS_UNKNOWN', 'VALIDATION_STATUS_VALIDATING', 'VALIDATION_STATUS_VALID', 'VALIDATION_STATUS_INVALID')" ) return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> Connection: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Connection from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> Connection: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of Connection from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Connection.parse_obj(obj) + return cls.model_validate(obj) - _obj = Connection.parse_obj( + _obj = cls.model_validate( { "id": obj.get("id"), "type": obj.get("type"), diff --git a/src/gretel_client/rest_v1/models/create_connection_request.py b/src/gretel_client/rest_v1/models/create_connection_request.py index 55825f0..c21df37 100755 --- a/src/gretel_client/rest_v1/models/create_connection_request.py +++ b/src/gretel_client/rest_v1/models/create_connection_request.py @@ -18,34 +18,37 @@ import pprint import re # noqa: F401 -from typing import Any, Dict, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, constr, Field, StrictStr, validator +from pydantic import BaseModel, ConfigDict, Field, field_validator, StrictStr +from typing_extensions import Annotated, Self class CreateConnectionRequest(BaseModel): """ Request message for `CreateConnection` method. - """ + """ # noqa: E501 - project_id: constr(strict=True) = Field(...) - name: Optional[constr(strict=True, max_length=30, min_length=3)] = None - type: StrictStr = Field(...) + project_id: Annotated[str, Field(strict=True)] + name: Optional[Annotated[str, Field(min_length=3, strict=True, max_length=30)]] = ( + None + ) + type: StrictStr credentials: Optional[Dict[str, Any]] = Field( - None, + default=None, description="Plaintext credentials for the connection, to be encrypted in our cloud. If this field is set, encrypted_credentials must be unset. At least one of those fields must be set.", ) encrypted_credentials: Optional[Dict[str, Any]] = Field( - None, + default=None, description="Pre-encrypted credentials for the connection, encrypted by a customer-managed key. If this field is set, credentials must be unset. At least one of those fields must be set.", ) config: Optional[Dict[str, Any]] = None connection_target_type: Optional[StrictStr] = Field( - None, + default=None, description="The type of workflow action this connection may be used with. If empty or `unspecified`, this connection may be used with any workflow action. Possible values are: `source`, `destination`, `unspecified`", ) auth_strategy: Optional[StrictStr] = None - __properties = [ + __properties: ClassVar[List[str]] = [ "project_id", "name", "type", @@ -56,14 +59,14 @@ class CreateConnectionRequest(BaseModel): "auth_strategy", ] - @validator("project_id") + @field_validator("project_id") def project_id_validate_regular_expression(cls, value): """Validates the regular expression""" if not re.match(r"^proj_.*$", value): raise ValueError(r"must validate the regular expression /^proj_.*$/") return value - @validator("name") + @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: @@ -73,40 +76,55 @@ def name_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^[a-z0-9-_]+$/") return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> CreateConnectionRequest: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of CreateConnectionRequest from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> CreateConnectionRequest: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of CreateConnectionRequest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return CreateConnectionRequest.parse_obj(obj) + return cls.model_validate(obj) - _obj = CreateConnectionRequest.parse_obj( + _obj = cls.model_validate( { "project_id": obj.get("project_id"), "name": obj.get("name"), diff --git a/src/gretel_client/rest_v1/models/create_workflow_request.py b/src/gretel_client/rest_v1/models/create_workflow_request.py index b56657a..1b5155a 100755 --- a/src/gretel_client/rest_v1/models/create_workflow_request.py +++ b/src/gretel_client/rest_v1/models/create_workflow_request.py @@ -18,94 +18,118 @@ import pprint import re # noqa: F401 -from typing import Any, Dict, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, constr, Field, StrictStr, validator +from pydantic import BaseModel, ConfigDict, Field, field_validator, StrictStr +from typing_extensions import Annotated, Self class CreateWorkflowRequest(BaseModel): """ CreateWorkflowRequest - """ + """ # noqa: E501 name: Optional[StrictStr] = Field( - None, + default=None, description="The name of the workflow. This field has been deprecated in favor of the `config.name` field.", ) - project_id: constr(strict=True) = Field( - ..., description="The project ID that this workflow should belong to." + project_id: Annotated[str, Field(strict=True)] = Field( + description="The project ID that this workflow should belong to." ) config: Optional[Dict[str, Any]] = Field( - None, + default=None, description="The workflow config object. See production documentation for more information on the structure of this field.", ) config_text: Optional[StrictStr] = Field( - None, description="The workflow config as a YAML string." + default=None, description="The workflow config as a YAML string." ) runner_mode: Optional[StrictStr] = Field( - None, + default=None, description="The runner mode of the workflow. Can be `cloud` or `hybrid`. Some projects may require workflows to run in a specific mode.", ) - __properties = ["name", "project_id", "config", "config_text", "runner_mode"] - - @validator("project_id") + __properties: ClassVar[List[str]] = [ + "name", + "project_id", + "config", + "config_text", + "runner_mode", + ] + + @field_validator("project_id") def project_id_validate_regular_expression(cls, value): """Validates the regular expression""" if not re.match(r"^proj_.*$", value): raise ValueError(r"must validate the regular expression /^proj_.*$/") return value - @validator("runner_mode") + @field_validator("runner_mode") def runner_mode_validate_enum(cls, value): """Validates the enum""" if value is None: return value - if value not in ( - "RUNNER_MODE_UNSET", - "RUNNER_MODE_CLOUD", - "RUNNER_MODE_HYBRID", - "RUNNER_MODE_INVALID", + if value not in set( + [ + "RUNNER_MODE_UNSET", + "RUNNER_MODE_CLOUD", + "RUNNER_MODE_HYBRID", + "RUNNER_MODE_INVALID", + ] ): raise ValueError( "must be one of enum values ('RUNNER_MODE_UNSET', 'RUNNER_MODE_CLOUD', 'RUNNER_MODE_HYBRID', 'RUNNER_MODE_INVALID')" ) return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> CreateWorkflowRequest: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of CreateWorkflowRequest from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> CreateWorkflowRequest: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of CreateWorkflowRequest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return CreateWorkflowRequest.parse_obj(obj) + return cls.model_validate(obj) - _obj = CreateWorkflowRequest.parse_obj( + _obj = cls.model_validate( { "name": obj.get("name"), "project_id": obj.get("project_id"), diff --git a/src/gretel_client/rest_v1/models/create_workflow_run_request.py b/src/gretel_client/rest_v1/models/create_workflow_run_request.py index f9e32d1..8d78614 100755 --- a/src/gretel_client/rest_v1/models/create_workflow_run_request.py +++ b/src/gretel_client/rest_v1/models/create_workflow_run_request.py @@ -18,70 +18,86 @@ import pprint import re # noqa: F401 -from typing import Any, Dict, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, constr, Field, StrictStr, validator +from pydantic import BaseModel, ConfigDict, Field, field_validator, StrictStr +from typing_extensions import Annotated, Self class CreateWorkflowRunRequest(BaseModel): """ CreateWorkflowRunRequest - """ + """ # noqa: E501 - workflow_id: constr(strict=True) = Field( - ..., description="The ID of the workflow to create a run for." + workflow_id: Annotated[str, Field(strict=True)] = Field( + description="The ID of the workflow to create a run for." ) config: Optional[Dict[str, Any]] = Field( - None, + default=None, description="An optional config for the workflow run If provided, this will be used in place of the workflow's config.", ) config_text: Optional[StrictStr] = Field( - None, + default=None, description="An optional config for the workflow run as a YAML string. If provided, this will be used in place of the workflow's config.", ) - __properties = ["workflow_id", "config", "config_text"] + __properties: ClassVar[List[str]] = ["workflow_id", "config", "config_text"] - @validator("workflow_id") + @field_validator("workflow_id") def workflow_id_validate_regular_expression(cls, value): """Validates the regular expression""" if not re.match(r"^w_.*$", value): raise ValueError(r"must validate the regular expression /^w_.*$/") return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> CreateWorkflowRunRequest: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of CreateWorkflowRunRequest from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> CreateWorkflowRunRequest: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of CreateWorkflowRunRequest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return CreateWorkflowRunRequest.parse_obj(obj) + return cls.model_validate(obj) - _obj = CreateWorkflowRunRequest.parse_obj( + _obj = cls.model_validate( { "workflow_id": obj.get("workflow_id"), "config": obj.get("config"), diff --git a/src/gretel_client/rest_v1/models/event_component.py b/src/gretel_client/rest_v1/models/event_component.py index 93d736d..bdc0769 100755 --- a/src/gretel_client/rest_v1/models/event_component.py +++ b/src/gretel_client/rest_v1/models/event_component.py @@ -18,64 +18,78 @@ import pprint import re # noqa: F401 -from typing import Any, Dict, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Self class EventComponent(BaseModel): """ Represents one of a subject or object in a tuple-like data structure. - """ + """ # noqa: E501 name: StrictStr = Field( - ..., - description='Human readable name of the tuple component. Eg a "model" or user "alan".', + description='Human readable name of the tuple component. Eg a "model" or user "alan".' ) id: StrictStr = Field( - ..., - description="Unique id of the component used for display or reference. Eg model_2LJWrMW3xoDy2eY4DYZXFMOpQvd", + description="Unique id of the component used for display or reference. Eg model_2LJWrMW3xoDy2eY4DYZXFMOpQvd" ) meta: Optional[Dict[str, Any]] = Field( - None, + default=None, description="Any additional (untyped) metadata associated with the event. E.g. a user's avatar data", ) - __properties = ["name", "id", "meta"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["name", "id", "meta"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> EventComponent: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of EventComponent from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> EventComponent: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of EventComponent from a dict""" if obj is None: return None if not isinstance(obj, dict): - return EventComponent.parse_obj(obj) + return cls.model_validate(obj) - _obj = EventComponent.parse_obj( + _obj = cls.model_validate( {"name": obj.get("name"), "id": obj.get("id"), "meta": obj.get("meta")} ) return _obj diff --git a/src/gretel_client/rest_v1/models/get_cluster_response.py b/src/gretel_client/rest_v1/models/get_cluster_response.py index 2319422..399d790 100755 --- a/src/gretel_client/rest_v1/models/get_cluster_response.py +++ b/src/gretel_client/rest_v1/models/get_cluster_response.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict +from typing_extensions import Self from gretel_client.rest_v1.models.cluster import Cluster @@ -28,51 +29,66 @@ class GetClusterResponse(BaseModel): """ GetClusterResponse - """ + """ # noqa: E501 cluster: Optional[Cluster] = None - __properties = ["cluster"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["cluster"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> GetClusterResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of GetClusterResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 cluster if self.cluster: _dict["cluster"] = self.cluster.to_dict() return _dict @classmethod - def from_dict(cls, obj: dict) -> GetClusterResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of GetClusterResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return GetClusterResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = GetClusterResponse.parse_obj( + _obj = cls.model_validate( { "cluster": ( - Cluster.from_dict(obj.get("cluster")) + Cluster.from_dict(obj["cluster"]) if obj.get("cluster") is not None else None ) diff --git a/src/gretel_client/rest_v1/models/get_log_response.py b/src/gretel_client/rest_v1/models/get_log_response.py index 5c84171..1ea15c4 100755 --- a/src/gretel_client/rest_v1/models/get_log_response.py +++ b/src/gretel_client/rest_v1/models/get_log_response.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import List, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, conlist, StrictStr +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self from gretel_client.rest_v1.models.log_envelope import LogEnvelope @@ -28,34 +29,49 @@ class GetLogResponse(BaseModel): """ GetLogResponse - """ + """ # noqa: E501 - lines: Optional[conlist(LogEnvelope)] = None + lines: Optional[List[LogEnvelope]] = None next_page_token: Optional[StrictStr] = None - __properties = ["lines", "next_page_token"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["lines", "next_page_token"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> GetLogResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of GetLogResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 lines (list) _items = [] if self.lines: @@ -66,18 +82,18 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> GetLogResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of GetLogResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return GetLogResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = GetLogResponse.parse_obj( + _obj = cls.model_validate( { "lines": ( - [LogEnvelope.from_dict(_item) for _item in obj.get("lines")] + [LogEnvelope.from_dict(_item) for _item in obj["lines"]] if obj.get("lines") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/get_log_upload_url_response.py b/src/gretel_client/rest_v1/models/get_log_upload_url_response.py index 13bf13a..a21c7a9 100755 --- a/src/gretel_client/rest_v1/models/get_log_upload_url_response.py +++ b/src/gretel_client/rest_v1/models/get_log_upload_url_response.py @@ -19,54 +19,70 @@ import re # noqa: F401 from datetime import datetime -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, StrictStr +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self class GetLogUploadURLResponse(BaseModel): """ GetLogUploadURLResponse - """ + """ # noqa: E501 upload_url: Optional[StrictStr] = None valid_until: Optional[datetime] = None - __properties = ["upload_url", "valid_until"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["upload_url", "valid_until"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> GetLogUploadURLResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of GetLogUploadURLResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> GetLogUploadURLResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of GetLogUploadURLResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return GetLogUploadURLResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = GetLogUploadURLResponse.parse_obj( + _obj = cls.model_validate( {"upload_url": obj.get("upload_url"), "valid_until": obj.get("valid_until")} ) return _obj diff --git a/src/gretel_client/rest_v1/models/get_project_response.py b/src/gretel_client/rest_v1/models/get_project_response.py index 43f0961..8ea9186 100755 --- a/src/gretel_client/rest_v1/models/get_project_response.py +++ b/src/gretel_client/rest_v1/models/get_project_response.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict +from typing_extensions import Self from gretel_client.rest_v1.models.project import Project @@ -28,51 +29,66 @@ class GetProjectResponse(BaseModel): """ GetProjectResponse - """ + """ # noqa: E501 project: Optional[Project] = None - __properties = ["project"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["project"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> GetProjectResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of GetProjectResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 project if self.project: _dict["project"] = self.project.to_dict() return _dict @classmethod - def from_dict(cls, obj: dict) -> GetProjectResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of GetProjectResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return GetProjectResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = GetProjectResponse.parse_obj( + _obj = cls.model_validate( { "project": ( - Project.from_dict(obj.get("project")) + Project.from_dict(obj["project"]) if obj.get("project") is not None else None ) diff --git a/src/gretel_client/rest_v1/models/get_workflows_response.py b/src/gretel_client/rest_v1/models/get_workflows_response.py index 3b89e71..36e4ea8 100755 --- a/src/gretel_client/rest_v1/models/get_workflows_response.py +++ b/src/gretel_client/rest_v1/models/get_workflows_response.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import List, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, conlist, Field +from pydantic import BaseModel, ConfigDict, Field +from typing_extensions import Self from gretel_client.rest_v1.models.workflow import Workflow @@ -28,35 +29,50 @@ class GetWorkflowsResponse(BaseModel): """ GetWorkflowsResponse - """ + """ # noqa: E501 - workflows: Optional[conlist(Workflow)] = Field( - None, description="The list of workflows." + workflows: Optional[List[Workflow]] = Field( + default=None, description="The list of workflows." ) - __properties = ["workflows"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["workflows"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> GetWorkflowsResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of GetWorkflowsResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 workflows (list) _items = [] if self.workflows: @@ -67,18 +83,18 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> GetWorkflowsResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of GetWorkflowsResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return GetWorkflowsResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = GetWorkflowsResponse.parse_obj( + _obj = cls.model_validate( { "workflows": ( - [Workflow.from_dict(_item) for _item in obj.get("workflows")] + [Workflow.from_dict(_item) for _item in obj["workflows"]] if obj.get("workflows") is not None else None ) diff --git a/src/gretel_client/rest_v1/models/google_protobuf_any.py b/src/gretel_client/rest_v1/models/google_protobuf_any.py index f391034..38125eb 100755 --- a/src/gretel_client/rest_v1/models/google_protobuf_any.py +++ b/src/gretel_client/rest_v1/models/google_protobuf_any.py @@ -18,45 +18,64 @@ import pprint import re # noqa: F401 -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Self class GoogleProtobufAny(BaseModel): """ Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - """ + """ # noqa: E501 type: Optional[StrictStr] = Field( - None, alias="@type", description="The type of the serialized message." + default=None, description="The type of the serialized message.", alias="@type" ) additional_properties: Dict[str, Any] = {} - __properties = ["@type"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["@type"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> GoogleProtobufAny: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of GoogleProtobufAny from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict( - by_alias=True, exclude={"additional_properties"}, exclude_none=True + 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. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set( + [ + "additional_properties", + ] + ) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, ) # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: @@ -66,15 +85,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> GoogleProtobufAny: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of GoogleProtobufAny from a dict""" if obj is None: return None if not isinstance(obj, dict): - return GoogleProtobufAny.parse_obj(obj) + return cls.model_validate(obj) - _obj = GoogleProtobufAny.parse_obj({"type": obj.get("@type")}) + _obj = cls.model_validate({"@type": obj.get("@type")}) # store additional fields in additional_properties for _key in obj.keys(): if _key not in cls.__properties: diff --git a/src/gretel_client/rest_v1/models/list_clusters_response.py b/src/gretel_client/rest_v1/models/list_clusters_response.py index 42c680d..6ee2a88 100755 --- a/src/gretel_client/rest_v1/models/list_clusters_response.py +++ b/src/gretel_client/rest_v1/models/list_clusters_response.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import List, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, conlist +from pydantic import BaseModel, ConfigDict +from typing_extensions import Self from gretel_client.rest_v1.models.cluster import Cluster @@ -28,33 +29,48 @@ class ListClustersResponse(BaseModel): """ ListClustersResponse - """ - - clusters: Optional[conlist(Cluster)] = None - __properties = ["clusters"] + """ # noqa: E501 - class Config: - """Pydantic configuration""" + clusters: Optional[List[Cluster]] = None + __properties: ClassVar[List[str]] = ["clusters"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> ListClustersResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ListClustersResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 clusters (list) _items = [] if self.clusters: @@ -65,18 +81,18 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ListClustersResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of ListClustersResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ListClustersResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = ListClustersResponse.parse_obj( + _obj = cls.model_validate( { "clusters": ( - [Cluster.from_dict(_item) for _item in obj.get("clusters")] + [Cluster.from_dict(_item) for _item in obj["clusters"]] if obj.get("clusters") is not None else None ) diff --git a/src/gretel_client/rest_v1/models/list_connections_response.py b/src/gretel_client/rest_v1/models/list_connections_response.py index d46f525..81412f8 100755 --- a/src/gretel_client/rest_v1/models/list_connections_response.py +++ b/src/gretel_client/rest_v1/models/list_connections_response.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import List, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, conlist +from pydantic import BaseModel, ConfigDict +from typing_extensions import Self from gretel_client.rest_v1.models.connection import Connection @@ -28,33 +29,48 @@ class ListConnectionsResponse(BaseModel): """ Response message for `ListConnections` method. - """ - - data: Optional[conlist(Connection)] = None - __properties = ["data"] + """ # noqa: E501 - class Config: - """Pydantic configuration""" + data: Optional[List[Connection]] = None + __properties: ClassVar[List[str]] = ["data"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> ListConnectionsResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ListConnectionsResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 data (list) _items = [] if self.data: @@ -65,18 +81,18 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ListConnectionsResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of ListConnectionsResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ListConnectionsResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = ListConnectionsResponse.parse_obj( + _obj = cls.model_validate( { "data": ( - [Connection.from_dict(_item) for _item in obj.get("data")] + [Connection.from_dict(_item) for _item in obj["data"]] if obj.get("data") is not None else None ) diff --git a/src/gretel_client/rest_v1/models/log_envelope.py b/src/gretel_client/rest_v1/models/log_envelope.py index f53b015..5827a8e 100755 --- a/src/gretel_client/rest_v1/models/log_envelope.py +++ b/src/gretel_client/rest_v1/models/log_envelope.py @@ -19,57 +19,73 @@ import re # noqa: F401 from datetime import datetime -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Self class LogEnvelope(BaseModel): """ A LogEnvelope represents a log line suitable for displaying job specific information. These logs are currently used to display workflow and (v2) model related logs across our product. - """ + """ # noqa: E501 msg: Optional[StrictStr] = Field( - None, + default=None, description="The string message for the log line. This message will get displayed across various Gretel products views.", ) ts: Optional[datetime] = Field( - None, description="The timestamp for the associated log message." + default=None, description="The timestamp for the associated log message." ) - __properties = ["msg", "ts"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["msg", "ts"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> LogEnvelope: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of LogEnvelope from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> LogEnvelope: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of LogEnvelope from a dict""" if obj is None: return None if not isinstance(obj, dict): - return LogEnvelope.parse_obj(obj) + return cls.model_validate(obj) - _obj = LogEnvelope.parse_obj({"msg": obj.get("msg"), "ts": obj.get("ts")}) + _obj = cls.model_validate({"msg": obj.get("msg"), "ts": obj.get("ts")}) return _obj diff --git a/src/gretel_client/rest_v1/models/project.py b/src/gretel_client/rest_v1/models/project.py index fff325d..0603fb7 100755 --- a/src/gretel_client/rest_v1/models/project.py +++ b/src/gretel_client/rest_v1/models/project.py @@ -19,9 +19,10 @@ import re # noqa: F401 from datetime import datetime -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, StrictBool, StrictStr, validator +from pydantic import BaseModel, ConfigDict, field_validator, StrictBool, StrictStr +from typing_extensions import Self from gretel_client.rest_v1.models.cluster import Cluster @@ -29,7 +30,7 @@ class Project(BaseModel): """ Project - """ + """ # noqa: E501 id: Optional[StrictStr] = None uid: Optional[StrictStr] = None @@ -46,7 +47,7 @@ class Project(BaseModel): cluster: Optional[Cluster] = None modified: Optional[datetime] = None created: Optional[datetime] = None - __properties = [ + __properties: ClassVar[List[str]] = [ "id", "uid", "name", @@ -64,60 +65,77 @@ class Project(BaseModel): "created", ] - @validator("runner_mode") + @field_validator("runner_mode") def runner_mode_validate_enum(cls, value): """Validates the enum""" if value is None: return value - if value not in ( - "RUNNER_MODE_UNSET", - "RUNNER_MODE_CLOUD", - "RUNNER_MODE_HYBRID", - "RUNNER_MODE_INVALID", + if value not in set( + [ + "RUNNER_MODE_UNSET", + "RUNNER_MODE_CLOUD", + "RUNNER_MODE_HYBRID", + "RUNNER_MODE_INVALID", + ] ): raise ValueError( "must be one of enum values ('RUNNER_MODE_UNSET', 'RUNNER_MODE_CLOUD', 'RUNNER_MODE_HYBRID', 'RUNNER_MODE_INVALID')" ) return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> Project: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Project from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 cluster if self.cluster: _dict["cluster"] = self.cluster.to_dict() return _dict @classmethod - def from_dict(cls, obj: dict) -> Project: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of Project from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Project.parse_obj(obj) + return cls.model_validate(obj) - _obj = Project.parse_obj( + _obj = cls.model_validate( { "id": obj.get("id"), "uid": obj.get("uid"), @@ -132,7 +150,7 @@ def from_dict(cls, obj: dict) -> Project: "runner_mode": obj.get("runner_mode"), "cluster_guid": obj.get("cluster_guid"), "cluster": ( - Cluster.from_dict(obj.get("cluster")) + Cluster.from_dict(obj["cluster"]) if obj.get("cluster") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/search_activity_response.py b/src/gretel_client/rest_v1/models/search_activity_response.py index d1e0322..502e0fc 100755 --- a/src/gretel_client/rest_v1/models/search_activity_response.py +++ b/src/gretel_client/rest_v1/models/search_activity_response.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import List +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, conlist, Field, StrictInt +from pydantic import BaseModel, ConfigDict, StrictInt +from typing_extensions import Self from gretel_client.rest_v1.models.activity_event import ActivityEvent @@ -28,34 +29,49 @@ class SearchActivityResponse(BaseModel): """ SearchActivityResponse - """ - - events: conlist(ActivityEvent) = Field(...) - total: StrictInt = Field(...) - __properties = ["events", "total"] + """ # noqa: E501 - class Config: - """Pydantic configuration""" + events: List[ActivityEvent] + total: StrictInt + __properties: ClassVar[List[str]] = ["events", "total"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> SearchActivityResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SearchActivityResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 events (list) _items = [] if self.events: @@ -66,18 +82,18 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SearchActivityResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of SearchActivityResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SearchActivityResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = SearchActivityResponse.parse_obj( + _obj = cls.model_validate( { "events": ( - [ActivityEvent.from_dict(_item) for _item in obj.get("events")] + [ActivityEvent.from_dict(_item) for _item in obj["events"]] if obj.get("events") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/search_connections_response.py b/src/gretel_client/rest_v1/models/search_connections_response.py index 14449c1..44822b4 100755 --- a/src/gretel_client/rest_v1/models/search_connections_response.py +++ b/src/gretel_client/rest_v1/models/search_connections_response.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import List, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, conlist, Field, StrictInt +from pydantic import BaseModel, ConfigDict, Field, StrictInt +from typing_extensions import Self from gretel_client.rest_v1.models.connection import Connection @@ -28,39 +29,54 @@ class SearchConnectionsResponse(BaseModel): """ SearchConnectionsResponse - """ + """ # noqa: E501 - connections: Optional[conlist(Connection)] = Field( - None, + connections: Optional[List[Connection]] = Field( + default=None, description="List of sorted connections that match the provided query, given the limit and skip.", ) total: StrictInt = Field( - ..., description="Total number of connections that match the provided query." + description="Total number of connections that match the provided query." ) - __properties = ["connections", "total"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["connections", "total"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> SearchConnectionsResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SearchConnectionsResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 connections (list) _items = [] if self.connections: @@ -71,18 +87,18 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SearchConnectionsResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of SearchConnectionsResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SearchConnectionsResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = SearchConnectionsResponse.parse_obj( + _obj = cls.model_validate( { "connections": ( - [Connection.from_dict(_item) for _item in obj.get("connections")] + [Connection.from_dict(_item) for _item in obj["connections"]] if obj.get("connections") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/search_projects_response.py b/src/gretel_client/rest_v1/models/search_projects_response.py index 4045892..c9a6b17 100755 --- a/src/gretel_client/rest_v1/models/search_projects_response.py +++ b/src/gretel_client/rest_v1/models/search_projects_response.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import List, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, conlist +from pydantic import BaseModel, ConfigDict +from typing_extensions import Self from gretel_client.rest_v1.models.project import Project @@ -28,33 +29,48 @@ class SearchProjectsResponse(BaseModel): """ SearchProjectsResponse - """ - - projects: Optional[conlist(Project)] = None - __properties = ["projects"] + """ # noqa: E501 - class Config: - """Pydantic configuration""" + projects: Optional[List[Project]] = None + __properties: ClassVar[List[str]] = ["projects"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> SearchProjectsResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SearchProjectsResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 projects (list) _items = [] if self.projects: @@ -65,18 +81,18 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SearchProjectsResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of SearchProjectsResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SearchProjectsResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = SearchProjectsResponse.parse_obj( + _obj = cls.model_validate( { "projects": ( - [Project.from_dict(_item) for _item in obj.get("projects")] + [Project.from_dict(_item) for _item in obj["projects"]] if obj.get("projects") is not None else None ) diff --git a/src/gretel_client/rest_v1/models/search_workflow_runs_response.py b/src/gretel_client/rest_v1/models/search_workflow_runs_response.py index 170d36f..4c39a07 100755 --- a/src/gretel_client/rest_v1/models/search_workflow_runs_response.py +++ b/src/gretel_client/rest_v1/models/search_workflow_runs_response.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import List, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, conlist, Field, StrictInt +from pydantic import BaseModel, ConfigDict, Field, StrictInt +from typing_extensions import Self from gretel_client.rest_v1.models.workflow_run import WorkflowRun @@ -28,40 +29,54 @@ class SearchWorkflowRunsResponse(BaseModel): """ SearchWorkflowRunsResponse - """ + """ # noqa: E501 - runs: Optional[conlist(WorkflowRun)] = Field( - None, + runs: Optional[List[WorkflowRun]] = Field( + default=None, description="The list of workflow runs that matched the search query in the requested page.", ) total: StrictInt = Field( - ..., - description="The total number of workflow runs that matched the search query.", + description="The total number of workflow runs that matched the search query." ) - __properties = ["runs", "total"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["runs", "total"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> SearchWorkflowRunsResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SearchWorkflowRunsResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 runs (list) _items = [] if self.runs: @@ -72,18 +87,18 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SearchWorkflowRunsResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of SearchWorkflowRunsResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SearchWorkflowRunsResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = SearchWorkflowRunsResponse.parse_obj( + _obj = cls.model_validate( { "runs": ( - [WorkflowRun.from_dict(_item) for _item in obj.get("runs")] + [WorkflowRun.from_dict(_item) for _item in obj["runs"]] if obj.get("runs") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/search_workflow_tasks_response.py b/src/gretel_client/rest_v1/models/search_workflow_tasks_response.py index 51bacb2..1c582fe 100755 --- a/src/gretel_client/rest_v1/models/search_workflow_tasks_response.py +++ b/src/gretel_client/rest_v1/models/search_workflow_tasks_response.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import List, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, conlist, Field, StrictInt +from pydantic import BaseModel, ConfigDict, Field, StrictInt +from typing_extensions import Self from gretel_client.rest_v1.models.workflow_task import WorkflowTask @@ -28,40 +29,54 @@ class SearchWorkflowTasksResponse(BaseModel): """ SearchWorkflowTasksResponse - """ + """ # noqa: E501 - tasks: Optional[conlist(WorkflowTask)] = Field( - None, + tasks: Optional[List[WorkflowTask]] = Field( + default=None, description="The list of workflow tasks that matched the search query in the requested page.", ) total: StrictInt = Field( - ..., - description="The total number of workflow tasks that matched the search query.", + description="The total number of workflow tasks that matched the search query." ) - __properties = ["tasks", "total"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["tasks", "total"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> SearchWorkflowTasksResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SearchWorkflowTasksResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 tasks (list) _items = [] if self.tasks: @@ -72,18 +87,18 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SearchWorkflowTasksResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of SearchWorkflowTasksResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SearchWorkflowTasksResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = SearchWorkflowTasksResponse.parse_obj( + _obj = cls.model_validate( { "tasks": ( - [WorkflowTask.from_dict(_item) for _item in obj.get("tasks")] + [WorkflowTask.from_dict(_item) for _item in obj["tasks"]] if obj.get("tasks") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/search_workflows_response.py b/src/gretel_client/rest_v1/models/search_workflows_response.py index 93aa3e5..8d73387 100755 --- a/src/gretel_client/rest_v1/models/search_workflows_response.py +++ b/src/gretel_client/rest_v1/models/search_workflows_response.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import List, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, conlist, Field, StrictInt +from pydantic import BaseModel, ConfigDict, Field, StrictInt +from typing_extensions import Self from gretel_client.rest_v1.models.workflow import Workflow @@ -28,39 +29,54 @@ class SearchWorkflowsResponse(BaseModel): """ SearchWorkflowsResponse - """ + """ # noqa: E501 - workflows: Optional[conlist(Workflow)] = Field( - None, + workflows: Optional[List[Workflow]] = Field( + default=None, description="The list of workflows that matched the search query in the requested page.", ) total: StrictInt = Field( - ..., description="The total number of workflows that matched the search query." + description="The total number of workflows that matched the search query." ) - __properties = ["workflows", "total"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["workflows", "total"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> SearchWorkflowsResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SearchWorkflowsResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 workflows (list) _items = [] if self.workflows: @@ -71,18 +87,18 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SearchWorkflowsResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of SearchWorkflowsResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SearchWorkflowsResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = SearchWorkflowsResponse.parse_obj( + _obj = cls.model_validate( { "workflows": ( - [Workflow.from_dict(_item) for _item in obj.get("workflows")] + [Workflow.from_dict(_item) for _item in obj["workflows"]] if obj.get("workflows") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/status.py b/src/gretel_client/rest_v1/models/status.py index 9275f7e..84a346f 100755 --- a/src/gretel_client/rest_v1/models/status.py +++ b/src/gretel_client/rest_v1/models/status.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import List, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, conlist, Field, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing_extensions import Self from gretel_client.rest_v1.models.google_protobuf_any import GoogleProtobufAny @@ -28,44 +29,59 @@ class Status(BaseModel): """ The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). - """ + """ # noqa: E501 code: Optional[StrictInt] = Field( - None, + default=None, description="The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].", ) message: Optional[StrictStr] = Field( - None, + default=None, description="A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.", ) - details: Optional[conlist(GoogleProtobufAny)] = Field( - None, + details: Optional[List[GoogleProtobufAny]] = Field( + default=None, description="A list of messages that carry the error details. There is a common set of message types for APIs to use.", ) - __properties = ["code", "message", "details"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["code", "message", "details"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> Status: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Status from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 details (list) _items = [] if self.details: @@ -76,20 +92,20 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Status: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of Status from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Status.parse_obj(obj) + return cls.model_validate(obj) - _obj = Status.parse_obj( + _obj = cls.model_validate( { "code": obj.get("code"), "message": obj.get("message"), "details": ( - [GoogleProtobufAny.from_dict(_item) for _item in obj.get("details")] + [GoogleProtobufAny.from_dict(_item) for _item in obj["details"]] if obj.get("details") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/status_details.py b/src/gretel_client/rest_v1/models/status_details.py index b11b03b..ae64a32 100755 --- a/src/gretel_client/rest_v1/models/status_details.py +++ b/src/gretel_client/rest_v1/models/status_details.py @@ -18,51 +18,67 @@ import pprint import re # noqa: F401 -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, StrictStr +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self class StatusDetails(BaseModel): """ StatusDetails - """ + """ # noqa: E501 message: Optional[StrictStr] = None - __properties = ["message"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["message"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> StatusDetails: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of StatusDetails from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> StatusDetails: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of StatusDetails from a dict""" if obj is None: return None if not isinstance(obj, dict): - return StatusDetails.parse_obj(obj) + return cls.model_validate(obj) - _obj = StatusDetails.parse_obj({"message": obj.get("message")}) + _obj = cls.model_validate({"message": obj.get("message")}) return _obj diff --git a/src/gretel_client/rest_v1/models/update_connection_request.py b/src/gretel_client/rest_v1/models/update_connection_request.py index bb640fe..e04fa8d 100755 --- a/src/gretel_client/rest_v1/models/update_connection_request.py +++ b/src/gretel_client/rest_v1/models/update_connection_request.py @@ -18,40 +18,41 @@ import pprint import re # noqa: F401 -from typing import Any, Dict, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, constr, Field, StrictStr, validator +from pydantic import BaseModel, ConfigDict, Field, field_validator, StrictStr +from typing_extensions import Annotated, Self class UpdateConnectionRequest(BaseModel): """ Request message for `UpdateConnection` - """ + """ # noqa: E501 - name: Optional[constr(strict=True, max_length=30, min_length=3)] = Field( - None, description="A new connection name. (optional)" + name: Optional[Annotated[str, Field(min_length=3, strict=True, max_length=30)]] = ( + Field(default=None, description="A new connection name. (optional)") ) credentials: Optional[Dict[str, Any]] = Field( - None, + default=None, description="Plaintext credentials for the connection, to be encrypted in our cloud. This field may only be set if the existing connection's credentials are encrypted with a Gretel-managed key.", ) encrypted_credentials: Optional[Dict[str, Any]] = Field( - None, + default=None, description="Pre-encrypted credentials for the connection, encrypted by a customer-managed key. This field may only be set if the existing connection's credentials are encrypted with a user-managed key.", ) config: Optional[Dict[str, Any]] = Field( - None, + default=None, description="An updated connection configuration. See [connection type documentation](https://docs.gretel.ai/create-synthetic-data/workflows-and-connectors/connectors) for structure.", ) connection_target_type: Optional[StrictStr] = Field( - None, + default=None, description="An updated workflow action target type for this connection. Possible values are: `source`, `destination`, `unspecified`", ) auth_strategy: Optional[StrictStr] = Field( - None, + default=None, description="An updated connection auth strategy. See [connection type documentation](https://docs.gretel.ai/create-synthetic-data/workflows-and-connectors/connectors) for possible values.", ) - __properties = [ + __properties: ClassVar[List[str]] = [ "name", "credentials", "encrypted_credentials", @@ -60,7 +61,7 @@ class UpdateConnectionRequest(BaseModel): "auth_strategy", ] - @validator("name") + @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: @@ -70,40 +71,55 @@ def name_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^[a-z0-9-_]+$/") return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> UpdateConnectionRequest: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of UpdateConnectionRequest from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> UpdateConnectionRequest: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of UpdateConnectionRequest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return UpdateConnectionRequest.parse_obj(obj) + return cls.model_validate(obj) - _obj = UpdateConnectionRequest.parse_obj( + _obj = cls.model_validate( { "name": obj.get("name"), "credentials": obj.get("credentials"), diff --git a/src/gretel_client/rest_v1/models/user_profile.py b/src/gretel_client/rest_v1/models/user_profile.py index 66a4dfb..0ddf0b8 100755 --- a/src/gretel_client/rest_v1/models/user_profile.py +++ b/src/gretel_client/rest_v1/models/user_profile.py @@ -18,9 +18,10 @@ import pprint import re # noqa: F401 -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, StrictStr +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self from gretel_client.rest_v1.models.user_profile_image import UserProfileImage @@ -28,58 +29,79 @@ class UserProfile(BaseModel): """ Next Tag: 6 - """ + """ # noqa: E501 id: Optional[StrictStr] = None firstname: Optional[StrictStr] = None lastname: Optional[StrictStr] = None image: Optional[UserProfileImage] = None email: Optional[StrictStr] = None - __properties = ["id", "firstname", "lastname", "image", "email"] - - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + __properties: ClassVar[List[str]] = [ + "id", + "firstname", + "lastname", + "image", + "email", + ] + + 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.dict(by_alias=True)) + 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) -> UserProfile: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of UserProfile from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 image if self.image: _dict["image"] = self.image.to_dict() return _dict @classmethod - def from_dict(cls, obj: dict) -> UserProfile: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of UserProfile from a dict""" if obj is None: return None if not isinstance(obj, dict): - return UserProfile.parse_obj(obj) + return cls.model_validate(obj) - _obj = UserProfile.parse_obj( + _obj = cls.model_validate( { "id": obj.get("id"), "firstname": obj.get("firstname"), "lastname": obj.get("lastname"), "image": ( - UserProfileImage.from_dict(obj.get("image")) + UserProfileImage.from_dict(obj["image"]) if obj.get("image") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/user_profile_image.py b/src/gretel_client/rest_v1/models/user_profile_image.py index 33ae1c9..719b7cd 100755 --- a/src/gretel_client/rest_v1/models/user_profile_image.py +++ b/src/gretel_client/rest_v1/models/user_profile_image.py @@ -18,55 +18,71 @@ import pprint import re # noqa: F401 -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, StrictStr +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self class UserProfileImage(BaseModel): """ UserProfileImage - """ + """ # noqa: E501 small: Optional[StrictStr] = None medium: Optional[StrictStr] = None large: Optional[StrictStr] = None - __properties = ["small", "medium", "large"] - - class Config: - """Pydantic configuration""" + __properties: ClassVar[List[str]] = ["small", "medium", "large"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> UserProfileImage: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of UserProfileImage from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> UserProfileImage: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of UserProfileImage from a dict""" if obj is None: return None if not isinstance(obj, dict): - return UserProfileImage.parse_obj(obj) + return cls.model_validate(obj) - _obj = UserProfileImage.parse_obj( + _obj = cls.model_validate( { "small": obj.get("small"), "medium": obj.get("medium"), diff --git a/src/gretel_client/rest_v1/models/validate_connection_credentials_response.py b/src/gretel_client/rest_v1/models/validate_connection_credentials_response.py index b8e9cde..d077299 100755 --- a/src/gretel_client/rest_v1/models/validate_connection_credentials_response.py +++ b/src/gretel_client/rest_v1/models/validate_connection_credentials_response.py @@ -18,71 +18,89 @@ import pprint import re # noqa: F401 -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, StrictStr, validator +from pydantic import BaseModel, ConfigDict, field_validator, StrictStr +from typing_extensions import Self class ValidateConnectionCredentialsResponse(BaseModel): """ Response message for `ValidateConnectionCredentials` method. - """ + """ # noqa: E501 status: Optional[StrictStr] = None message: Optional[StrictStr] = None - __properties = ["status", "message"] + __properties: ClassVar[List[str]] = ["status", "message"] - @validator("status") + @field_validator("status") def status_validate_enum(cls, value): """Validates the enum""" if value is None: return value - if value not in ( - "VALIDATION_STATUS_UNKNOWN", - "VALIDATION_STATUS_VALIDATING", - "VALIDATION_STATUS_VALID", - "VALIDATION_STATUS_INVALID", + if value not in set( + [ + "VALIDATION_STATUS_UNKNOWN", + "VALIDATION_STATUS_VALIDATING", + "VALIDATION_STATUS_VALID", + "VALIDATION_STATUS_INVALID", + ] ): raise ValueError( "must be one of enum values ('VALIDATION_STATUS_UNKNOWN', 'VALIDATION_STATUS_VALIDATING', 'VALIDATION_STATUS_VALID', 'VALIDATION_STATUS_INVALID')" ) return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> ValidateConnectionCredentialsResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ValidateConnectionCredentialsResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> ValidateConnectionCredentialsResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of ValidateConnectionCredentialsResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ValidateConnectionCredentialsResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = ValidateConnectionCredentialsResponse.parse_obj( + _obj = cls.model_validate( {"status": obj.get("status"), "message": obj.get("message")} ) return _obj diff --git a/src/gretel_client/rest_v1/models/validate_workflow_action_response.py b/src/gretel_client/rest_v1/models/validate_workflow_action_response.py index 6a54c73..4cf0035 100755 --- a/src/gretel_client/rest_v1/models/validate_workflow_action_response.py +++ b/src/gretel_client/rest_v1/models/validate_workflow_action_response.py @@ -18,75 +18,93 @@ import pprint import re # noqa: F401 -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, Field, StrictStr, validator +from pydantic import BaseModel, ConfigDict, Field, field_validator, StrictStr +from typing_extensions import Self class ValidateWorkflowActionResponse(BaseModel): """ ValidateWorkflowActionResponse - """ + """ # noqa: E501 status: Optional[StrictStr] = Field( - None, description="The validation status of the action." + default=None, description="The validation status of the action." ) message: Optional[StrictStr] = Field( - None, description="The error message if the action is invalid." + default=None, description="The error message if the action is invalid." ) - __properties = ["status", "message"] + __properties: ClassVar[List[str]] = ["status", "message"] - @validator("status") + @field_validator("status") def status_validate_enum(cls, value): """Validates the enum""" if value is None: return value - if value not in ( - "VALIDATION_STATUS_UNKNOWN", - "VALIDATION_STATUS_VALIDATING", - "VALIDATION_STATUS_VALID", - "VALIDATION_STATUS_INVALID", + if value not in set( + [ + "VALIDATION_STATUS_UNKNOWN", + "VALIDATION_STATUS_VALIDATING", + "VALIDATION_STATUS_VALID", + "VALIDATION_STATUS_INVALID", + ] ): raise ValueError( "must be one of enum values ('VALIDATION_STATUS_UNKNOWN', 'VALIDATION_STATUS_VALIDATING', 'VALIDATION_STATUS_VALID', 'VALIDATION_STATUS_INVALID')" ) return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> ValidateWorkflowActionResponse: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ValidateWorkflowActionResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> ValidateWorkflowActionResponse: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of ValidateWorkflowActionResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ValidateWorkflowActionResponse.parse_obj(obj) + return cls.model_validate(obj) - _obj = ValidateWorkflowActionResponse.parse_obj( + _obj = cls.model_validate( {"status": obj.get("status"), "message": obj.get("message")} ) return _obj diff --git a/src/gretel_client/rest_v1/models/validate_workflow_config_request.py b/src/gretel_client/rest_v1/models/validate_workflow_config_request.py index a255033..37218ba 100755 --- a/src/gretel_client/rest_v1/models/validate_workflow_config_request.py +++ b/src/gretel_client/rest_v1/models/validate_workflow_config_request.py @@ -18,71 +18,89 @@ import pprint import re # noqa: F401 -from typing import Any, Dict, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, Field, StrictStr, validator +from pydantic import BaseModel, ConfigDict, field_validator, StrictStr +from typing_extensions import Self class ValidateWorkflowConfigRequest(BaseModel): """ ValidateWorkflowConfigRequest - """ + """ # noqa: E501 - config: Dict[str, Any] = Field(...) + config: Dict[str, Any] runner_mode: Optional[StrictStr] = None - __properties = ["config", "runner_mode"] + __properties: ClassVar[List[str]] = ["config", "runner_mode"] - @validator("runner_mode") + @field_validator("runner_mode") def runner_mode_validate_enum(cls, value): """Validates the enum""" if value is None: return value - if value not in ( - "RUNNER_MODE_UNSET", - "RUNNER_MODE_CLOUD", - "RUNNER_MODE_HYBRID", - "RUNNER_MODE_INVALID", + if value not in set( + [ + "RUNNER_MODE_UNSET", + "RUNNER_MODE_CLOUD", + "RUNNER_MODE_HYBRID", + "RUNNER_MODE_INVALID", + ] ): raise ValueError( "must be one of enum values ('RUNNER_MODE_UNSET', 'RUNNER_MODE_CLOUD', 'RUNNER_MODE_HYBRID', 'RUNNER_MODE_INVALID')" ) return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> ValidateWorkflowConfigRequest: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ValidateWorkflowConfigRequest from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> ValidateWorkflowConfigRequest: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of ValidateWorkflowConfigRequest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ValidateWorkflowConfigRequest.parse_obj(obj) + return cls.model_validate(obj) - _obj = ValidateWorkflowConfigRequest.parse_obj( + _obj = cls.model_validate( {"config": obj.get("config"), "runner_mode": obj.get("runner_mode")} ) return _obj diff --git a/src/gretel_client/rest_v1/models/workflow.py b/src/gretel_client/rest_v1/models/workflow.py index 80e29a5..34df5b7 100755 --- a/src/gretel_client/rest_v1/models/workflow.py +++ b/src/gretel_client/rest_v1/models/workflow.py @@ -19,9 +19,10 @@ import re # noqa: F401 from datetime import datetime -from typing import Any, Dict, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, Field, StrictStr, validator +from pydantic import BaseModel, ConfigDict, Field, field_validator, StrictStr +from typing_extensions import Self from gretel_client.rest_v1.models.project import Project from gretel_client.rest_v1.models.user_profile import UserProfile @@ -31,42 +32,55 @@ class Workflow(BaseModel): """ Workflow - """ + """ # noqa: E501 - id: StrictStr = Field(..., description="The unique ID of the workflow.") - name: StrictStr = Field(..., description="The name of the workflow.") + id: StrictStr = Field(description="The unique ID of the workflow.") + name: StrictStr = Field(description="The name of the workflow.") project_id: StrictStr = Field( - ..., description="The project ID that this workflow belongs to." + description="The project ID that this workflow belongs to." + ) + project: Optional[Project] = Field( + default=None, + description="The project that this workflow belongs to. Provided when the `expand=project` query param is present.", ) - project: Optional[Project] = None config: Optional[Dict[str, Any]] = Field( - None, description="The config of the workflow." + default=None, description="The config of the workflow." ) config_text: Optional[StrictStr] = Field( - None, description="The config of the workflow as a YAML string." + default=None, description="The config of the workflow as a YAML string." ) runner_mode: Optional[StrictStr] = Field( - None, description="The runner mode of the workflow. Can be `cloud` or `hybrid`." + default=None, + description="The runner mode of the workflow. Can be `cloud` or `hybrid`.", ) - created_by: StrictStr = Field( - ..., description="The user ID that created this workflow." + created_by: StrictStr = Field(description="The user ID that created this workflow.") + created_by_profile: Optional[UserProfile] = Field( + default=None, + description="The user profile of the user that created this workflow. Provided when the `expand=created_by` query param is present.", ) - created_by_profile: Optional[UserProfile] = None updated_by: Optional[StrictStr] = Field( - None, description="The user ID that last updated this workflow." + default=None, description="The user ID that last updated this workflow." + ) + updated_by_profile: Optional[UserProfile] = Field( + default=None, + description="The user profile of the user that last updated this workflow. Provided when the `expand=updated_by` query param is present.", ) - updated_by_profile: Optional[UserProfile] = None created_at: datetime = Field( - ..., description="A timestamp indicating when this workflow was created." + description="A timestamp indicating when this workflow was created." ) updated_at: Optional[datetime] = Field( - None, description="A timestamp indicating when this workflow was last updated." + default=None, + description="A timestamp indicating when this workflow was last updated.", ) next_scheduled_run: Optional[datetime] = Field( - None, description="A timestamp indicating when the next scheduled run is." + default=None, + description="A timestamp indicating when the next scheduled run is.", ) - latest_run: Optional[WorkflowRun] = None - __properties = [ + latest_run: Optional[WorkflowRun] = Field( + default=None, + description="The latest run of this workflow. Provided when the `expand=latest_run` query param is present.", + ) + __properties: ClassVar[List[str]] = [ "id", "name", "project_id", @@ -84,45 +98,62 @@ class Workflow(BaseModel): "latest_run", ] - @validator("runner_mode") + @field_validator("runner_mode") def runner_mode_validate_enum(cls, value): """Validates the enum""" if value is None: return value - if value not in ( - "RUNNER_MODE_UNSET", - "RUNNER_MODE_CLOUD", - "RUNNER_MODE_HYBRID", - "RUNNER_MODE_INVALID", + if value not in set( + [ + "RUNNER_MODE_UNSET", + "RUNNER_MODE_CLOUD", + "RUNNER_MODE_HYBRID", + "RUNNER_MODE_INVALID", + ] ): raise ValueError( "must be one of enum values ('RUNNER_MODE_UNSET', 'RUNNER_MODE_CLOUD', 'RUNNER_MODE_HYBRID', 'RUNNER_MODE_INVALID')" ) return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> Workflow: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Workflow from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 project if self.project: _dict["project"] = self.project.to_dict() @@ -138,21 +169,21 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Workflow: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of Workflow from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Workflow.parse_obj(obj) + return cls.model_validate(obj) - _obj = Workflow.parse_obj( + _obj = cls.model_validate( { "id": obj.get("id"), "name": obj.get("name"), "project_id": obj.get("project_id"), "project": ( - Project.from_dict(obj.get("project")) + Project.from_dict(obj["project"]) if obj.get("project") is not None else None ), @@ -161,13 +192,13 @@ def from_dict(cls, obj: dict) -> Workflow: "runner_mode": obj.get("runner_mode"), "created_by": obj.get("created_by"), "created_by_profile": ( - UserProfile.from_dict(obj.get("created_by_profile")) + UserProfile.from_dict(obj["created_by_profile"]) if obj.get("created_by_profile") is not None else None ), "updated_by": obj.get("updated_by"), "updated_by_profile": ( - UserProfile.from_dict(obj.get("updated_by_profile")) + UserProfile.from_dict(obj["updated_by_profile"]) if obj.get("updated_by_profile") is not None else None ), @@ -175,7 +206,7 @@ def from_dict(cls, obj: dict) -> Workflow: "updated_at": obj.get("updated_at"), "next_scheduled_run": obj.get("next_scheduled_run"), "latest_run": ( - WorkflowRun.from_dict(obj.get("latest_run")) + WorkflowRun.from_dict(obj["latest_run"]) if obj.get("latest_run") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/workflow_run.py b/src/gretel_client/rest_v1/models/workflow_run.py index c19d9c4..9038db1 100755 --- a/src/gretel_client/rest_v1/models/workflow_run.py +++ b/src/gretel_client/rest_v1/models/workflow_run.py @@ -19,9 +19,10 @@ import re # noqa: F401 from datetime import datetime -from typing import Any, Dict, Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, Field, StrictInt, StrictStr, validator +from pydantic import BaseModel, ConfigDict, Field, field_validator, StrictInt, StrictStr +from typing_extensions import Self from gretel_client.rest_v1.models.project import Project from gretel_client.rest_v1.models.status_details import StatusDetails @@ -34,70 +35,83 @@ class WorkflowRun(BaseModel): """ WorkflowRun - """ + """ # noqa: E501 - id: StrictStr = Field(..., description="The unique ID of the workflow run.") + id: StrictStr = Field(description="The unique ID of the workflow run.") workflow_id: StrictStr = Field( - ..., description="The ID of the workflow that this run belongs to." + description="The ID of the workflow that this run belongs to." ) project_id: StrictStr = Field( - ..., - description="The project ID that this workflow run belongs to. This will be the same as the project ID of the workflow.", + description="The project ID that this workflow run belongs to. This will be the same as the project ID of the workflow." + ) + project: Optional[Project] = Field( + default=None, + description="The project that this workflow run belongs to. Provided when the `expand=project` query param is present.", ) - project: Optional[Project] = None cluster_guid: Optional[StrictStr] = Field( - None, description="The GUID of the cluster where the workflow run is executed." + default=None, + description="The GUID of the cluster where the workflow run is executed.", ) config: Optional[Dict[str, Any]] = Field( - None, description="The config of the workflow run." + default=None, description="The config of the workflow run." ) config_text: Optional[StrictStr] = Field( - None, description="The config of the workflow run as a YAML string." + default=None, description="The config of the workflow run as a YAML string." ) runner_mode: StrictStr = Field( - ..., - description="The runner mode of the workflow run. Can be `cloud` or `hybrid`.", + description="The runner mode of the workflow run. Can be `cloud` or `hybrid`." + ) + status: StrictStr = Field(description="The status of the workflow run.") + status_details: Optional[StatusDetails] = Field( + default=None, + description="Additional details about the status of the workflow run.", ) - status: StrictStr = Field(..., description="The status of the workflow run.") - status_details: Optional[StatusDetails] = None created_by: StrictStr = Field( - ..., description="The user ID that created this workflow run." + description="The user ID that created this workflow run." ) created_at: datetime = Field( - ..., description="A timestamp indicating when this workflow run was created." + description="A timestamp indicating when this workflow run was created." ) updated_at: Optional[datetime] = Field( - None, + default=None, description="A timestamp indicating when this workflow run was last updated.", ) pending_at: Optional[datetime] = Field( - None, + default=None, description="A timestamp indicating when this workflow run entered the pending state.", ) active_at: Optional[datetime] = Field( - None, + default=None, description="A timestamp indicating when this workflow run entered the active state.", ) error_at: Optional[datetime] = Field( - None, + default=None, description="A timestamp indicating when an error occurred in this workflow run.", ) lost_at: Optional[datetime] = Field( - None, description="A timestamp indicating when this workflow run was lost." + default=None, + description="A timestamp indicating when this workflow run was lost.", ) cancelled_at: Optional[datetime] = Field( - None, description="A timestamp indicating when this workflow run was cancelled." + default=None, + description="A timestamp indicating when this workflow run was cancelled.", ) lease_expires_at: Optional[datetime] = Field( - None, + default=None, description="A timestamp indicating when the lease for this workflow run expires.", ) - cancellation_request: Optional[WorkflowRunCancellationRequest] = None - created_by_profile: Optional[UserProfile] = None + cancellation_request: Optional[WorkflowRunCancellationRequest] = Field( + default=None, description="The cancellation request for this workflow run." + ) + created_by_profile: Optional[UserProfile] = Field( + default=None, + description="The user profile of the user that created this workflow run. Provided when the `expand=created_by` query param is present.", + ) total_compute_time_sconds: Optional[StrictInt] = Field( - None, description="The total compute time in seconds for this workflow run." + default=None, + description="The total compute time in seconds for this workflow run.", ) - __properties = [ + __properties: ClassVar[List[str]] = [ "id", "workflow_id", "project_id", @@ -122,61 +136,80 @@ class WorkflowRun(BaseModel): "total_compute_time_sconds", ] - @validator("runner_mode") + @field_validator("runner_mode") def runner_mode_validate_enum(cls, value): """Validates the enum""" - if value not in ( - "RUNNER_MODE_UNSET", - "RUNNER_MODE_CLOUD", - "RUNNER_MODE_HYBRID", - "RUNNER_MODE_INVALID", + if value not in set( + [ + "RUNNER_MODE_UNSET", + "RUNNER_MODE_CLOUD", + "RUNNER_MODE_HYBRID", + "RUNNER_MODE_INVALID", + ] ): raise ValueError( "must be one of enum values ('RUNNER_MODE_UNSET', 'RUNNER_MODE_CLOUD', 'RUNNER_MODE_HYBRID', 'RUNNER_MODE_INVALID')" ) return value - @validator("status") + @field_validator("status") def status_validate_enum(cls, value): """Validates the enum""" - if value not in ( - "RUN_STATUS_UNKNOWN", - "RUN_STATUS_CREATED", - "RUN_STATUS_PENDING", - "RUN_STATUS_ACTIVE", - "RUN_STATUS_ERROR", - "RUN_STATUS_LOST", - "RUN_STATUS_COMPLETED", - "RUN_STATUS_CANCELLING", - "RUN_STATUS_CANCELLED", + if value not in set( + [ + "RUN_STATUS_UNKNOWN", + "RUN_STATUS_CREATED", + "RUN_STATUS_PENDING", + "RUN_STATUS_ACTIVE", + "RUN_STATUS_ERROR", + "RUN_STATUS_LOST", + "RUN_STATUS_COMPLETED", + "RUN_STATUS_CANCELLING", + "RUN_STATUS_CANCELLED", + ] ): raise ValueError( "must be one of enum values ('RUN_STATUS_UNKNOWN', 'RUN_STATUS_CREATED', 'RUN_STATUS_PENDING', 'RUN_STATUS_ACTIVE', 'RUN_STATUS_ERROR', 'RUN_STATUS_LOST', 'RUN_STATUS_COMPLETED', 'RUN_STATUS_CANCELLING', 'RUN_STATUS_CANCELLED')" ) return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> WorkflowRun: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of WorkflowRun from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 project if self.project: _dict["project"] = self.project.to_dict() @@ -192,21 +225,21 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> WorkflowRun: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of WorkflowRun from a dict""" if obj is None: return None if not isinstance(obj, dict): - return WorkflowRun.parse_obj(obj) + return cls.model_validate(obj) - _obj = WorkflowRun.parse_obj( + _obj = cls.model_validate( { "id": obj.get("id"), "workflow_id": obj.get("workflow_id"), "project_id": obj.get("project_id"), "project": ( - Project.from_dict(obj.get("project")) + Project.from_dict(obj["project"]) if obj.get("project") is not None else None ), @@ -216,7 +249,7 @@ def from_dict(cls, obj: dict) -> WorkflowRun: "runner_mode": obj.get("runner_mode"), "status": obj.get("status"), "status_details": ( - StatusDetails.from_dict(obj.get("status_details")) + StatusDetails.from_dict(obj["status_details"]) if obj.get("status_details") is not None else None ), @@ -231,13 +264,13 @@ def from_dict(cls, obj: dict) -> WorkflowRun: "lease_expires_at": obj.get("lease_expires_at"), "cancellation_request": ( WorkflowRunCancellationRequest.from_dict( - obj.get("cancellation_request") + obj["cancellation_request"] ) if obj.get("cancellation_request") is not None else None ), "created_by_profile": ( - UserProfile.from_dict(obj.get("created_by_profile")) + UserProfile.from_dict(obj["created_by_profile"]) if obj.get("created_by_profile") is not None else None ), diff --git a/src/gretel_client/rest_v1/models/workflow_run_cancellation_request.py b/src/gretel_client/rest_v1/models/workflow_run_cancellation_request.py index 40b6fb3..948d381 100755 --- a/src/gretel_client/rest_v1/models/workflow_run_cancellation_request.py +++ b/src/gretel_client/rest_v1/models/workflow_run_cancellation_request.py @@ -19,53 +19,70 @@ import re # noqa: F401 from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, Field, StrictStr +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self class WorkflowRunCancellationRequest(BaseModel): """ WorkflowRunCancellationRequest - """ - - requested_by: StrictStr = Field(...) - requested_at: datetime = Field(...) - __properties = ["requested_by", "requested_at"] + """ # noqa: E501 - class Config: - """Pydantic configuration""" + requested_by: StrictStr + requested_at: datetime + __properties: ClassVar[List[str]] = ["requested_by", "requested_at"] - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> WorkflowRunCancellationRequest: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of WorkflowRunCancellationRequest from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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: dict) -> WorkflowRunCancellationRequest: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of WorkflowRunCancellationRequest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return WorkflowRunCancellationRequest.parse_obj(obj) + return cls.model_validate(obj) - _obj = WorkflowRunCancellationRequest.parse_obj( + _obj = cls.model_validate( { "requested_by": obj.get("requested_by"), "requested_at": obj.get("requested_at"), diff --git a/src/gretel_client/rest_v1/models/workflow_task.py b/src/gretel_client/rest_v1/models/workflow_task.py index b24d070..a9b6df1 100755 --- a/src/gretel_client/rest_v1/models/workflow_task.py +++ b/src/gretel_client/rest_v1/models/workflow_task.py @@ -19,9 +19,10 @@ import re # noqa: F401 from datetime import datetime -from typing import Optional +from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, Field, StrictInt, StrictStr, validator +from pydantic import BaseModel, ConfigDict, Field, field_validator, StrictInt, StrictStr +from typing_extensions import Self from gretel_client.rest_v1.models.project import Project from gretel_client.rest_v1.models.user_profile import UserProfile @@ -30,72 +31,76 @@ class WorkflowTask(BaseModel): """ Next Tag: 24 - """ + """ # noqa: E501 - id: StrictStr = Field(..., description="The unique ID of the workflow task.") + id: StrictStr = Field(description="The unique ID of the workflow task.") workflow_run_id: StrictStr = Field( - ..., description="The ID of the workflow run that this task belongs to." + description="The ID of the workflow run that this task belongs to." ) project_id: StrictStr = Field( - ..., description="The project ID that this workflow task belongs to." + description="The project ID that this workflow task belongs to." + ) + project: Optional[Project] = Field( + default=None, + description="The project that this workflow task belongs to. Provided when the `expand=project` query param is present.", ) - project: Optional[Project] = None log_location: StrictStr = Field( - ..., description="The location of the log for this workflow task." + description="The location of the log for this workflow task." ) - status: StrictStr = Field(..., description="The status of the workflow task.") + status: StrictStr = Field(description="The status of the workflow task.") action_name: StrictStr = Field( - ..., - description="The user supplied name of the workflow action that produced this task. The name can be mapped back to the original workflow config.", + description="The user supplied name of the workflow action that produced this task. The name can be mapped back to the original workflow config." ) action_type: StrictStr = Field( - ..., - description="The type of workflow action running the task. Eg `s3_source` or `gretel_model`.", + description="The type of workflow action running the task. Eg `s3_source` or `gretel_model`." ) error_msg: Optional[StrictStr] = Field( - None, + default=None, description="If the task is in an error state, this field will get populated with an error message suitable for displaying in the console. These error messages are meant to span a single line, and will be human readable.", ) error_code: Optional[StrictInt] = Field( - None, + default=None, description="The code associated with an error message. These codes can be used to group like errors together.", ) stack_trace: Optional[StrictStr] = Field( - None, + default=None, description="A more detailed stack trace that can be used for root cause analysis. This stack trace generally shouldn't be shown in the UI and will span many lines.", ) - created_by: StrictStr = Field( - ..., description="The user ID that created this workflow." + created_by: StrictStr = Field(description="The user ID that created this workflow.") + created_by_profile: Optional[UserProfile] = Field( + default=None, + description="The user profile of the user that created this workflow. Provided when the `expand=created_by` query param is present.", ) - created_by_profile: Optional[UserProfile] = None created_at: datetime = Field( - ..., description="A timestamp indicating when this workflow was created." + description="A timestamp indicating when this workflow was created." ) updated_at: Optional[datetime] = Field( - None, description="A timestamp indicating when this workflow was last updated." + default=None, + description="A timestamp indicating when this workflow was last updated.", ) pending_at: Optional[datetime] = Field( - None, + default=None, description="A timestamp indicating when this workflow entered the pending state.", ) active_at: Optional[datetime] = Field( - None, + default=None, description="A timestamp indicating when this workflow entered the active state.", ) error_at: Optional[datetime] = Field( - None, + default=None, description="A timestamp indicating when an error occurred in this workflow.", ) lost_at: Optional[datetime] = Field( - None, description="A timestamp indicating when this workflow was lost." + default=None, description="A timestamp indicating when this workflow was lost." ) completed_at: Optional[datetime] = Field( - None, description="A timestamp indicating when this workflow was completed." + default=None, + description="A timestamp indicating when this workflow was completed.", ) total_compute_time_sconds: Optional[StrictInt] = Field( - None, description="The total compute time in seconds for this workflow." + default=None, description="The total compute time in seconds for this workflow." ) - __properties = [ + __properties: ClassVar[List[str]] = [ "id", "workflow_run_id", "project_id", @@ -119,47 +124,64 @@ class WorkflowTask(BaseModel): "total_compute_time_sconds", ] - @validator("status") + @field_validator("status") def status_validate_enum(cls, value): """Validates the enum""" - if value not in ( - "RUN_STATUS_UNKNOWN", - "RUN_STATUS_CREATED", - "RUN_STATUS_PENDING", - "RUN_STATUS_ACTIVE", - "RUN_STATUS_ERROR", - "RUN_STATUS_LOST", - "RUN_STATUS_COMPLETED", - "RUN_STATUS_CANCELLING", - "RUN_STATUS_CANCELLED", + if value not in set( + [ + "RUN_STATUS_UNKNOWN", + "RUN_STATUS_CREATED", + "RUN_STATUS_PENDING", + "RUN_STATUS_ACTIVE", + "RUN_STATUS_ERROR", + "RUN_STATUS_LOST", + "RUN_STATUS_COMPLETED", + "RUN_STATUS_CANCELLING", + "RUN_STATUS_CANCELLED", + ] ): raise ValueError( "must be one of enum values ('RUN_STATUS_UNKNOWN', 'RUN_STATUS_CREATED', 'RUN_STATUS_PENDING', 'RUN_STATUS_ACTIVE', 'RUN_STATUS_ERROR', 'RUN_STATUS_LOST', 'RUN_STATUS_COMPLETED', 'RUN_STATUS_CANCELLING', 'RUN_STATUS_CANCELLED')" ) return value - class Config: - """Pydantic configuration""" - - allow_population_by_field_name = True - validate_assignment = True + 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.dict(by_alias=True)) + 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) -> WorkflowTask: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of WorkflowTask from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + 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 project if self.project: _dict["project"] = self.project.to_dict() @@ -169,21 +191,21 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> WorkflowTask: + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of WorkflowTask from a dict""" if obj is None: return None if not isinstance(obj, dict): - return WorkflowTask.parse_obj(obj) + return cls.model_validate(obj) - _obj = WorkflowTask.parse_obj( + _obj = cls.model_validate( { "id": obj.get("id"), "workflow_run_id": obj.get("workflow_run_id"), "project_id": obj.get("project_id"), "project": ( - Project.from_dict(obj.get("project")) + Project.from_dict(obj["project"]) if obj.get("project") is not None else None ), @@ -196,7 +218,7 @@ def from_dict(cls, obj: dict) -> WorkflowTask: "stack_trace": obj.get("stack_trace"), "created_by": obj.get("created_by"), "created_by_profile": ( - UserProfile.from_dict(obj.get("created_by_profile")) + UserProfile.from_dict(obj["created_by_profile"]) if obj.get("created_by_profile") is not None else None ), diff --git a/src/gretel_client/rest_v1/rest.py b/src/gretel_client/rest_v1/rest.py index e4c66e2..1656db0 100755 --- a/src/gretel_client/rest_v1/rest.py +++ b/src/gretel_client/rest_v1/rest.py @@ -14,51 +14,55 @@ import io import json -import logging import re import ssl -from urllib.parse import quote_plus, urlencode - import urllib3 -from gretel_client.rest_v1.exceptions import ( - ApiException, - ApiValueError, - BadRequestException, - ForbiddenException, - NotFoundException, - ServiceException, - UnauthorizedException, -) +from gretel_client.rest_v1.exceptions import ApiException, ApiValueError + +SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"} +RESTResponseType = urllib3.HTTPResponse + -logger = logging.getLogger(__name__) +def is_socks_proxy_url(url): + if url is None: + return False + split_section = url.split("://") + if len(split_section) < 2: + return False + else: + return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES class RESTResponse(io.IOBase): - def __init__(self, resp): - self.urllib3_response = resp + def __init__(self, resp) -> None: + self.response = resp self.status = resp.status self.reason = resp.reason - self.data = resp.data + self.data = None + + def read(self): + if self.data is None: + self.data = self.response.data + return self.data def getheaders(self): """Returns a dictionary of the response headers.""" - return self.urllib3_response.headers + return self.response.headers def getheader(self, name, default=None): """Returns a given response header.""" - return self.urllib3_response.headers.get(name, default) + return self.response.headers.get(name, default) -class RESTClientObject(object): +class RESTClientObject: - def __init__(self, configuration, pools_size=4, maxsize=None): + def __init__(self, configuration) -> None: # urllib3.PoolManager will pass all kw parameters to connectionpool # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 - # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 # cert_reqs @@ -67,75 +71,62 @@ def __init__(self, configuration, pools_size=4, maxsize=None): else: cert_reqs = ssl.CERT_NONE - addition_pool_args = {} + pool_args = { + "cert_reqs": cert_reqs, + "ca_certs": configuration.ssl_ca_cert, + "cert_file": configuration.cert_file, + "key_file": configuration.key_file, + } if configuration.assert_hostname is not None: - addition_pool_args["assert_hostname"] = ( - configuration.assert_hostname - ) # noqa: E501 + pool_args["assert_hostname"] = configuration.assert_hostname if configuration.retries is not None: - addition_pool_args["retries"] = configuration.retries + pool_args["retries"] = configuration.retries if configuration.tls_server_name: - addition_pool_args["server_hostname"] = configuration.tls_server_name + pool_args["server_hostname"] = configuration.tls_server_name if configuration.socket_options is not None: - addition_pool_args["socket_options"] = configuration.socket_options + pool_args["socket_options"] = configuration.socket_options - if maxsize is None: - if configuration.connection_pool_maxsize is not None: - maxsize = configuration.connection_pool_maxsize - else: - maxsize = 4 + if configuration.connection_pool_maxsize is not None: + pool_args["maxsize"] = configuration.connection_pool_maxsize # https pool manager + self.pool_manager: urllib3.PoolManager + if configuration.proxy: - self.pool_manager = urllib3.ProxyManager( - num_pools=pools_size, - maxsize=maxsize, - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - proxy_headers=configuration.proxy_headers, - **addition_pool_args, - ) + if is_socks_proxy_url(configuration.proxy): + from urllib3.contrib.socks import SOCKSProxyManager + + pool_args["proxy_url"] = configuration.proxy + pool_args["headers"] = configuration.proxy_headers + self.pool_manager = SOCKSProxyManager(**pool_args) + else: + pool_args["proxy_url"] = configuration.proxy + pool_args["proxy_headers"] = configuration.proxy_headers + self.pool_manager = urllib3.ProxyManager(**pool_args) else: - self.pool_manager = urllib3.PoolManager( - num_pools=pools_size, - maxsize=maxsize, - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - **addition_pool_args, - ) + self.pool_manager = urllib3.PoolManager(**pool_args) def request( self, method, url, - query_params=None, headers=None, body=None, post_params=None, - _preload_content=True, _request_timeout=None, ): """Perform requests. :param method: http request method :param url: http request url - :param query_params: query parameters in the url :param headers: http request headers :param body: request json body, for `application/json` :param post_params: request post parameters, `application/x-www-form-urlencoded` and `multipart/form-data` - :param _preload_content: if False, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -151,13 +142,10 @@ def request( post_params = post_params or {} headers = headers or {} - # url already contains the URL query string - # so reset query_params to empty dict - query_params = {} timeout = None if _request_timeout: - if isinstance(_request_timeout, (int, float)): # noqa: E501,F821 + if isinstance(_request_timeout, (int, float)): timeout = urllib3.Timeout(total=_request_timeout) elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: timeout = urllib3.Timeout( @@ -169,9 +157,8 @@ def request( if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: # no content type provided or payload is json - if not headers.get("Content-Type") or re.search( - "json", headers["Content-Type"], re.IGNORECASE - ): + content_type = headers.get("Content-Type") + if not content_type or re.search("json", content_type, re.IGNORECASE): request_body = None if body is not None: request_body = json.dumps(body) @@ -179,46 +166,58 @@ def request( method, url, body=request_body, - preload_content=_preload_content, timeout=timeout, headers=headers, + preload_content=False, ) - elif ( - headers["Content-Type"] == "application/x-www-form-urlencoded" - ): # noqa: E501 + elif content_type == "application/x-www-form-urlencoded": r = self.pool_manager.request( method, url, fields=post_params, encode_multipart=False, - preload_content=_preload_content, timeout=timeout, headers=headers, + preload_content=False, ) - elif headers["Content-Type"] == "multipart/form-data": + elif content_type == "multipart/form-data": # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. del headers["Content-Type"] + # Ensures that dict objects are serialized + post_params = [ + (a, json.dumps(b)) if isinstance(b, dict) else (a, b) + for a, b in post_params + ] r = self.pool_manager.request( method, url, fields=post_params, encode_multipart=True, - preload_content=_preload_content, timeout=timeout, headers=headers, + preload_content=False, ) # Pass a `string` parameter directly in the body to support - # other content types than Json when `body` argument is - # provided in serialized form + # other content types than JSON when `body` argument is + # provided in serialized form. elif isinstance(body, str) or isinstance(body, bytes): - request_body = body + r = self.pool_manager.request( + method, + url, + body=body, + timeout=timeout, + headers=headers, + preload_content=False, + ) + elif headers["Content-Type"] == "text/plain" and isinstance(body, bool): + request_body = "true" if body else "false" r = self.pool_manager.request( method, url, body=request_body, - preload_content=_preload_content, + preload_content=False, timeout=timeout, headers=headers, ) @@ -234,173 +233,12 @@ def request( method, url, fields={}, - preload_content=_preload_content, timeout=timeout, headers=headers, + preload_content=False, ) except urllib3.exceptions.SSLError as e: - msg = "{0}\n{1}".format(type(e).__name__, str(e)) + msg = "\n".join([type(e).__name__, str(e)]) raise ApiException(status=0, reason=msg) - if _preload_content: - r = RESTResponse(r) - - # log response body - logger.debug("response body: %s", r.data) - - if not 200 <= r.status <= 299: - if r.status == 400: - raise BadRequestException(http_resp=r) - - if r.status == 401: - raise UnauthorizedException(http_resp=r) - - if r.status == 403: - raise ForbiddenException(http_resp=r) - - if r.status == 404: - raise NotFoundException(http_resp=r) - - if 500 <= r.status <= 599: - raise ServiceException(http_resp=r) - - raise ApiException(http_resp=r) - - return r - - def get_request( - self, - url, - headers=None, - query_params=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "GET", - url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params, - ) - - def head_request( - self, - url, - headers=None, - query_params=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "HEAD", - url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params, - ) - - def options_request( - self, - url, - headers=None, - query_params=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "OPTIONS", - url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - - def delete_request( - self, - url, - headers=None, - query_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "DELETE", - url, - headers=headers, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - - def post_request( - self, - url, - headers=None, - query_params=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "POST", - url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - - def put_request( - self, - url, - headers=None, - query_params=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "PUT", - url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - - def patch_request( - self, - url, - headers=None, - query_params=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "PATCH", - url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + return RESTResponse(r)