diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 2e2e6198..00000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "hatchet"] - path = hatchet - url = git@github.com:hatchet-dev/hatchet.git - branch = main diff --git a/README.md b/README.md index 08adafcb..958a7d55 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Hatchet Python SDK -This is the [Hatchet](https://hatchet.run) Python SDK. For usage, see the [docs](https://docs.hatchet.run/sdks/python-sdk/). +This is the [Hatchet](https://hatchet.run) Python SDK. For usage, see the [docs](https://docs.hatchet.run). diff --git a/branch-sync.sh b/branch-sync.sh deleted file mode 100755 index e0ea9f87..00000000 --- a/branch-sync.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# 1. Get the current branch name -current_branch=$(echo $GITHUB_HEAD_REF | sed 's/refs\/heads\///') - -if [ -z "$current_branch" ]; then - current_branch=$(git rev-parse --abbrev-ref HEAD) -fi - -# 2. Check a different repo and determine if a branch with the same name exists -git ls-remote --heads https://github.com/hatchet-dev/hatchet.git $current_branch | grep -q refs/heads/$current_branch -branch_exists=$? - -# 3. If it does, update the .gitmodules to set `branch = {the branch name}` -if [ $branch_exists -eq 0 ]; then - git config -f .gitmodules submodule.hatchet.branch $current_branch - git add .gitmodules - echo "Updated .gitmodules with branch $current_branch" -else - echo "Branch $current_branch does not exist in the remote repository. Pulling main branch instead." - git config -f .gitmodules submodule.hatchet.branch main - git add .gitmodules - echo "Updated .gitmodules with branch main" -fi - -# 4. Initialize and update the submodule -git submodule init -git submodule update --remote --merge diff --git a/examples/cron/programatic-async.py b/examples/cron/programatic-async.py new file mode 100644 index 00000000..910f60ee --- /dev/null +++ b/examples/cron/programatic-async.py @@ -0,0 +1,37 @@ +from dotenv import load_dotenv + +from hatchet_sdk import Hatchet + +load_dotenv() + +hatchet = Hatchet() + + +async def create_cron(): + # ❓ Create + cron_trigger = await hatchet.cron.aio.create( + workflow_name="simple-cron-workflow", + cron_name="customer-a-daily-report", + expression="0 12 * * *", + input={ + "name": "John Doe", + }, + additional_metadata={ + "customer_id": "customer-a", + }, + ) + + id = cron_trigger.metadata.id # the id of the cron trigger + # !! + + # ❓ Delete + await hatchet.cron.aio.delete(cron_trigger=cron_trigger.metadata.id) + # !! + + # ❓ List + cron_triggers = await hatchet.cron.aio.list() + # !! + + # ❓ Get + cron_trigger = await hatchet.cron.aio.get(cron_trigger=cron_trigger.metadata.id) + # !! diff --git a/examples/cron/programatic-sync.py b/examples/cron/programatic-sync.py new file mode 100644 index 00000000..c5e69c24 --- /dev/null +++ b/examples/cron/programatic-sync.py @@ -0,0 +1,35 @@ +from dotenv import load_dotenv + +from hatchet_sdk import Hatchet + +load_dotenv() + +hatchet = Hatchet() + +# ❓ Create +cron_trigger = hatchet.cron.create( + workflow_name="simple-cron-workflow", + cron_name="customer-a-daily-report", + expression="0 12 * * *", + input={ + "name": "John Doe", + }, + additional_metadata={ + "customer_id": "customer-a", + }, +) + +id = cron_trigger.metadata.id # the id of the cron trigger +# !! + +# ❓ Delete +hatchet.cron.delete(cron_trigger=cron_trigger.metadata.id) +# !! + +# ❓ List +cron_triggers = hatchet.cron.list() +# !! + +# ❓ Get +cron_trigger = hatchet.cron.get(cron_trigger=cron_trigger.metadata.id) +# !! diff --git a/examples/cron/workflow-definition.py b/examples/cron/workflow-definition.py new file mode 100644 index 00000000..e88bf1d1 --- /dev/null +++ b/examples/cron/workflow-definition.py @@ -0,0 +1,37 @@ +import time + +from dotenv import load_dotenv + +from hatchet_sdk import Context, Hatchet + +load_dotenv() + +hatchet = Hatchet(debug=True) + + +# ❓ Workflow Definition Cron Trigger +# Adding a cron trigger to a workflow is as simple +# as adding a `cron expression` to the `on_cron` +# prop of the workflow definition +@hatchet.workflow(on_cron="* * * * *") +class CronWorkflow: + @hatchet.step() + def step1(self, context: Context): + + return { + "time": "step1", + } + + +# !! + + +def main(): + workflow = CronWorkflow() + worker = hatchet.worker("test-worker", max_runs=1) + worker.register_workflow(workflow) + worker.start() + + +if __name__ == "__main__": + main() diff --git a/examples/scheduled/programatic-async.py b/examples/scheduled/programatic-async.py new file mode 100644 index 00000000..4a324abe --- /dev/null +++ b/examples/scheduled/programatic-async.py @@ -0,0 +1,39 @@ +from datetime import datetime, timedelta + +from dotenv import load_dotenv + +from hatchet_sdk import Hatchet +from hatchet_sdk.clients.rest.models.scheduled_workflows import ScheduledWorkflows + +load_dotenv() + +hatchet = Hatchet() + + +async def create_scheduled(): + # ❓ Create + scheduled_run = await hatchet.scheduled.aio.create( + workflow_name="simple-workflow", + trigger_at=datetime.now() + timedelta(seconds=10), + input={ + "data": "simple-workflow-data", + }, + additional_metadata={ + "customer_id": "customer-a", + }, + ) + + id = scheduled_run.metadata.id # the id of the scheduled run trigger + # !! + + # ❓ Delete + await hatchet.scheduled.aio.delete(scheduled=scheduled_run.metadata.id) + # !! + + # ❓ List + scheduled_runs = await hatchet.scheduled.aio.list() + # !! + + # ❓ Get + scheduled_run = await hatchet.scheduled.aio.get(scheduled=scheduled_run.metadata.id) + # !! diff --git a/examples/scheduled/programatic-sync.py b/examples/scheduled/programatic-sync.py new file mode 100644 index 00000000..13a52ee8 --- /dev/null +++ b/examples/scheduled/programatic-sync.py @@ -0,0 +1,36 @@ +from datetime import datetime, timedelta + +from dotenv import load_dotenv + +from hatchet_sdk import Hatchet + +load_dotenv() + +hatchet = Hatchet() + +# ❓ Create +scheduled_run = hatchet.scheduled.create( + workflow_name="simple-workflow", + trigger_at=datetime.now() + timedelta(seconds=10), + input={ + "data": "simple-workflow-data", + }, + additional_metadata={ + "customer_id": "customer-a", + }, +) + +id = scheduled_run.metadata.id # the id of the scheduled run trigger +# !! + +# ❓ Delete +hatchet.scheduled.delete(scheduled=scheduled_run.metadata.id) +# !! + +# ❓ List +scheduled_runs = hatchet.scheduled.list() +# !! + +# ❓ Get +scheduled_run = hatchet.scheduled.get(scheduled=scheduled_run.metadata.id) +# !! diff --git a/generate.sh b/generate.sh index fb57d131..52c84a22 100755 --- a/generate.sh +++ b/generate.sh @@ -16,7 +16,7 @@ openapi-generator-cli version || npm install @openapitools/openapi-generator-cli # fi # generate deps from hatchet repo -cd hatchet/ && sh ./hack/oas/generate-server.sh && cd $ROOT_DIR +cd ../oss/ && sh ./hack/oas/generate-server.sh && cd $ROOT_DIR # generate python rest client @@ -27,7 +27,7 @@ mkdir -p $dst_dir tmp_dir=./tmp # generate into tmp folder -openapi-generator-cli generate -i ./hatchet/bin/oas/openapi.yaml -g python -o ./tmp --skip-validate-spec \ +openapi-generator-cli generate -i ../oss/bin/oas/openapi.yaml -g python -o ./tmp --skip-validate-spec \ --library asyncio \ --global-property=apiTests=false \ --global-property=apiDocs=true \ @@ -42,7 +42,7 @@ mv $tmp_dir/hatchet_sdk/clients/rest/exceptions.py $dst_dir/exceptions.py mv $tmp_dir/hatchet_sdk/clients/rest/__init__.py $dst_dir/__init__.py mv $tmp_dir/hatchet_sdk/clients/rest/rest.py $dst_dir/rest.py -openapi-generator-cli generate -i ./hatchet/bin/oas/openapi.yaml -g python -o . --skip-validate-spec \ +openapi-generator-cli generate -i ../oss/bin/oas/openapi.yaml -g python -o . --skip-validate-spec \ --library asyncio \ --global-property=apis,models \ --global-property=apiTests=false \ diff --git a/hatchet b/hatchet deleted file mode 160000 index f8213799..00000000 --- a/hatchet +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f82137999796e115691805bd79bf9a16c7a191df diff --git a/hatchet_sdk/clients/rest/__init__.py b/hatchet_sdk/clients/rest/__init__.py index 31cf4825..f09b3362 100644 --- a/hatchet_sdk/clients/rest/__init__.py +++ b/hatchet_sdk/clients/rest/__init__.py @@ -70,6 +70,9 @@ from hatchet_sdk.clients.rest.models.create_api_token_response import ( CreateAPITokenResponse, ) +from hatchet_sdk.clients.rest.models.create_cron_workflow_trigger_request import ( + CreateCronWorkflowTriggerRequest, +) from hatchet_sdk.clients.rest.models.create_event_request import CreateEventRequest from hatchet_sdk.clients.rest.models.create_pull_request_from_step_run import ( CreatePullRequestFromStepRun, @@ -84,6 +87,11 @@ CreateTenantInviteRequest, ) from hatchet_sdk.clients.rest.models.create_tenant_request import CreateTenantRequest +from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows +from hatchet_sdk.clients.rest.models.cron_workflows_list import CronWorkflowsList +from hatchet_sdk.clients.rest.models.cron_workflows_order_by_field import ( + CronWorkflowsOrderByField, +) from hatchet_sdk.clients.rest.models.event import Event from hatchet_sdk.clients.rest.models.event_data import EventData from hatchet_sdk.clients.rest.models.event_key_list import EventKeyList @@ -141,6 +149,17 @@ ReplayWorkflowRunsResponse, ) from hatchet_sdk.clients.rest.models.rerun_step_run_request import RerunStepRunRequest +from hatchet_sdk.clients.rest.models.schedule_workflow_run_request import ( + ScheduleWorkflowRunRequest, +) +from hatchet_sdk.clients.rest.models.scheduled_run_status import ScheduledRunStatus +from hatchet_sdk.clients.rest.models.scheduled_workflows import ScheduledWorkflows +from hatchet_sdk.clients.rest.models.scheduled_workflows_list import ( + ScheduledWorkflowsList, +) +from hatchet_sdk.clients.rest.models.scheduled_workflows_order_by_field import ( + ScheduledWorkflowsOrderByField, +) from hatchet_sdk.clients.rest.models.semaphore_slots import SemaphoreSlots from hatchet_sdk.clients.rest.models.slack_webhook import SlackWebhook from hatchet_sdk.clients.rest.models.sns_integration import SNSIntegration @@ -219,6 +238,8 @@ from hatchet_sdk.clients.rest.models.worker import Worker from hatchet_sdk.clients.rest.models.worker_label import WorkerLabel from hatchet_sdk.clients.rest.models.worker_list import WorkerList +from hatchet_sdk.clients.rest.models.worker_runtime_info import WorkerRuntimeInfo +from hatchet_sdk.clients.rest.models.worker_runtime_sdks import WorkerRuntimeSDKs from hatchet_sdk.clients.rest.models.workflow import Workflow from hatchet_sdk.clients.rest.models.workflow_concurrency import WorkflowConcurrency from hatchet_sdk.clients.rest.models.workflow_kind import WorkflowKind diff --git a/hatchet_sdk/clients/rest/api/workflow_api.py b/hatchet_sdk/clients/rest/api/workflow_api.py index 87532339..415899e8 100644 --- a/hatchet_sdk/clients/rest/api/workflow_api.py +++ b/hatchet_sdk/clients/rest/api/workflow_api.py @@ -20,6 +20,19 @@ from hatchet_sdk.clients.rest.api_client import ApiClient, RequestSerialized from hatchet_sdk.clients.rest.api_response import ApiResponse +from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows +from hatchet_sdk.clients.rest.models.cron_workflows_list import CronWorkflowsList +from hatchet_sdk.clients.rest.models.cron_workflows_order_by_field import ( + CronWorkflowsOrderByField, +) +from hatchet_sdk.clients.rest.models.scheduled_run_status import ScheduledRunStatus +from hatchet_sdk.clients.rest.models.scheduled_workflows import ScheduledWorkflows +from hatchet_sdk.clients.rest.models.scheduled_workflows_list import ( + ScheduledWorkflowsList, +) +from hatchet_sdk.clients.rest.models.scheduled_workflows_order_by_field import ( + ScheduledWorkflowsOrderByField, +) from hatchet_sdk.clients.rest.models.tenant_queue_metrics import TenantQueueMetrics from hatchet_sdk.clients.rest.models.workflow import Workflow from hatchet_sdk.clients.rest.models.workflow_kind import WorkflowKind @@ -57,7 +70,7 @@ def __init__(self, api_client=None) -> None: self.api_client = api_client @validate_call - async def tenant_get_queue_metrics( + async def cron_workflow_list( self, tenant: Annotated[ str, @@ -65,14 +78,27 @@ async def tenant_get_queue_metrics( min_length=36, strict=True, max_length=36, description="The tenant id" ), ], - workflows: Annotated[ - Optional[List[StrictStr]], - Field(description="A list of workflow IDs to filter by"), + offset: Annotated[ + Optional[StrictInt], Field(description="The number to skip") + ] = None, + limit: Annotated[ + Optional[StrictInt], Field(description="The number to limit by") + ] = None, + workflow_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The workflow id to get runs for."), ] = None, additional_metadata: Annotated[ Optional[List[StrictStr]], Field(description="A list of metadata key value pairs to filter by"), ] = None, + order_by_field: Annotated[ + Optional[CronWorkflowsOrderByField], Field(description="The order by field") + ] = None, + order_by_direction: Annotated[ + Optional[WorkflowRunOrderByDirection], + Field(description="The order by direction"), + ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -84,17 +110,25 @@ async def tenant_get_queue_metrics( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> TenantQueueMetrics: - """Get workflow metrics + ) -> CronWorkflowsList: + """Get cron job workflows - Get the queue metrics for the tenant + Get all cron job workflow triggers for a tenant :param tenant: The tenant id (required) :type tenant: str - :param workflows: A list of workflow IDs to filter by - :type workflows: List[str] + :param offset: The number to skip + :type offset: int + :param limit: The number to limit by + :type limit: int + :param workflow_id: The workflow id to get runs for. + :type workflow_id: str :param additional_metadata: A list of metadata key value pairs to filter by :type additional_metadata: List[str] + :param order_by_field: The order by field + :type order_by_field: CronWorkflowsOrderByField + :param order_by_direction: The order by direction + :type order_by_direction: WorkflowRunOrderByDirection :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 @@ -117,10 +151,14 @@ async def tenant_get_queue_metrics( :return: Returns the result object. """ # noqa: E501 - _param = self._tenant_get_queue_metrics_serialize( + _param = self._cron_workflow_list_serialize( tenant=tenant, - workflows=workflows, + offset=offset, + limit=limit, + workflow_id=workflow_id, additional_metadata=additional_metadata, + order_by_field=order_by_field, + order_by_direction=order_by_direction, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -128,10 +166,9 @@ async def tenant_get_queue_metrics( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "TenantQueueMetrics", + "200": "CronWorkflowsList", "400": "APIErrors", "403": "APIErrors", - "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -143,7 +180,7 @@ async def tenant_get_queue_metrics( ).data @validate_call - async def tenant_get_queue_metrics_with_http_info( + async def cron_workflow_list_with_http_info( self, tenant: Annotated[ str, @@ -151,14 +188,27 @@ async def tenant_get_queue_metrics_with_http_info( min_length=36, strict=True, max_length=36, description="The tenant id" ), ], - workflows: Annotated[ - Optional[List[StrictStr]], - Field(description="A list of workflow IDs to filter by"), + offset: Annotated[ + Optional[StrictInt], Field(description="The number to skip") + ] = None, + limit: Annotated[ + Optional[StrictInt], Field(description="The number to limit by") + ] = None, + workflow_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The workflow id to get runs for."), ] = None, additional_metadata: Annotated[ Optional[List[StrictStr]], Field(description="A list of metadata key value pairs to filter by"), ] = None, + order_by_field: Annotated[ + Optional[CronWorkflowsOrderByField], Field(description="The order by field") + ] = None, + order_by_direction: Annotated[ + Optional[WorkflowRunOrderByDirection], + Field(description="The order by direction"), + ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -170,17 +220,25 @@ async def tenant_get_queue_metrics_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[TenantQueueMetrics]: - """Get workflow metrics + ) -> ApiResponse[CronWorkflowsList]: + """Get cron job workflows - Get the queue metrics for the tenant + Get all cron job workflow triggers for a tenant :param tenant: The tenant id (required) :type tenant: str - :param workflows: A list of workflow IDs to filter by - :type workflows: List[str] + :param offset: The number to skip + :type offset: int + :param limit: The number to limit by + :type limit: int + :param workflow_id: The workflow id to get runs for. + :type workflow_id: str :param additional_metadata: A list of metadata key value pairs to filter by :type additional_metadata: List[str] + :param order_by_field: The order by field + :type order_by_field: CronWorkflowsOrderByField + :param order_by_direction: The order by direction + :type order_by_direction: WorkflowRunOrderByDirection :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 @@ -203,10 +261,14 @@ async def tenant_get_queue_metrics_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._tenant_get_queue_metrics_serialize( + _param = self._cron_workflow_list_serialize( tenant=tenant, - workflows=workflows, + offset=offset, + limit=limit, + workflow_id=workflow_id, additional_metadata=additional_metadata, + order_by_field=order_by_field, + order_by_direction=order_by_direction, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -214,10 +276,9 @@ async def tenant_get_queue_metrics_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "TenantQueueMetrics", + "200": "CronWorkflowsList", "400": "APIErrors", "403": "APIErrors", - "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -229,7 +290,7 @@ async def tenant_get_queue_metrics_with_http_info( ) @validate_call - async def tenant_get_queue_metrics_without_preload_content( + async def cron_workflow_list_without_preload_content( self, tenant: Annotated[ str, @@ -237,14 +298,27 @@ async def tenant_get_queue_metrics_without_preload_content( min_length=36, strict=True, max_length=36, description="The tenant id" ), ], - workflows: Annotated[ - Optional[List[StrictStr]], - Field(description="A list of workflow IDs to filter by"), + offset: Annotated[ + Optional[StrictInt], Field(description="The number to skip") + ] = None, + limit: Annotated[ + Optional[StrictInt], Field(description="The number to limit by") + ] = None, + workflow_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The workflow id to get runs for."), ] = None, additional_metadata: Annotated[ Optional[List[StrictStr]], Field(description="A list of metadata key value pairs to filter by"), ] = None, + order_by_field: Annotated[ + Optional[CronWorkflowsOrderByField], Field(description="The order by field") + ] = None, + order_by_direction: Annotated[ + Optional[WorkflowRunOrderByDirection], + Field(description="The order by direction"), + ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -257,16 +331,24 @@ async def tenant_get_queue_metrics_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get workflow metrics + """Get cron job workflows - Get the queue metrics for the tenant + Get all cron job workflow triggers for a tenant :param tenant: The tenant id (required) :type tenant: str - :param workflows: A list of workflow IDs to filter by - :type workflows: List[str] + :param offset: The number to skip + :type offset: int + :param limit: The number to limit by + :type limit: int + :param workflow_id: The workflow id to get runs for. + :type workflow_id: str :param additional_metadata: A list of metadata key value pairs to filter by :type additional_metadata: List[str] + :param order_by_field: The order by field + :type order_by_field: CronWorkflowsOrderByField + :param order_by_direction: The order by direction + :type order_by_direction: WorkflowRunOrderByDirection :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 @@ -289,10 +371,14 @@ async def tenant_get_queue_metrics_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._tenant_get_queue_metrics_serialize( + _param = self._cron_workflow_list_serialize( tenant=tenant, - workflows=workflows, + offset=offset, + limit=limit, + workflow_id=workflow_id, additional_metadata=additional_metadata, + order_by_field=order_by_field, + order_by_direction=order_by_direction, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -300,21 +386,24 @@ async def tenant_get_queue_metrics_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "TenantQueueMetrics", + "200": "CronWorkflowsList", "400": "APIErrors", "403": "APIErrors", - "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout ) return response_data.response - def _tenant_get_queue_metrics_serialize( + def _cron_workflow_list_serialize( self, tenant, - workflows, + offset, + limit, + workflow_id, additional_metadata, + order_by_field, + order_by_direction, _request_auth, _content_type, _headers, @@ -324,7 +413,6 @@ def _tenant_get_queue_metrics_serialize( _host = None _collection_formats: Dict[str, str] = { - "workflows": "multi", "additionalMetadata": "multi", } @@ -341,14 +429,30 @@ def _tenant_get_queue_metrics_serialize( if tenant is not None: _path_params["tenant"] = tenant # process the query parameters - if workflows is not None: + if offset is not None: - _query_params.append(("workflows", workflows)) + _query_params.append(("offset", offset)) + + if limit is not None: + + _query_params.append(("limit", limit)) + + if workflow_id is not None: + + _query_params.append(("workflowId", workflow_id)) if additional_metadata is not None: _query_params.append(("additionalMetadata", additional_metadata)) + if order_by_field is not None: + + _query_params.append(("orderByField", order_by_field.value)) + + if order_by_direction is not None: + + _query_params.append(("orderByDirection", order_by_direction.value)) + # process the header parameters # process the form parameters # process the body parameter @@ -364,7 +468,7 @@ def _tenant_get_queue_metrics_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/api/v1/tenants/{tenant}/queue-metrics", + resource_path="/api/v1/tenants/{tenant}/workflows/crons", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -378,14 +482,22 @@ def _tenant_get_queue_metrics_serialize( ) @validate_call - async def workflow_delete( + async def tenant_get_queue_metrics( self, - workflow: Annotated[ + tenant: Annotated[ str, Field( - min_length=36, strict=True, max_length=36, description="The workflow id" + min_length=36, strict=True, max_length=36, description="The tenant id" ), ], + workflows: Annotated[ + Optional[List[StrictStr]], + Field(description="A list of workflow IDs to filter by"), + ] = None, + additional_metadata: Annotated[ + Optional[List[StrictStr]], + Field(description="A list of metadata key value pairs to filter by"), + ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -397,13 +509,17 @@ async def workflow_delete( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> None: - """Delete workflow + ) -> TenantQueueMetrics: + """Get workflow metrics - Delete a workflow for a tenant + Get the queue metrics for the tenant - :param workflow: The workflow id (required) - :type workflow: str + :param tenant: The tenant id (required) + :type tenant: str + :param workflows: A list of workflow IDs to filter by + :type workflows: List[str] + :param additional_metadata: A list of metadata key value pairs to filter by + :type additional_metadata: 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 @@ -426,8 +542,10 @@ async def workflow_delete( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_delete_serialize( - workflow=workflow, + _param = self._tenant_get_queue_metrics_serialize( + tenant=tenant, + workflows=workflows, + additional_metadata=additional_metadata, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -435,7 +553,7 @@ async def workflow_delete( ) _response_types_map: Dict[str, Optional[str]] = { - "204": None, + "200": "TenantQueueMetrics", "400": "APIErrors", "403": "APIErrors", "404": "APIErrors", @@ -450,14 +568,22 @@ async def workflow_delete( ).data @validate_call - async def workflow_delete_with_http_info( + async def tenant_get_queue_metrics_with_http_info( self, - workflow: Annotated[ + tenant: Annotated[ str, Field( - min_length=36, strict=True, max_length=36, description="The workflow id" + min_length=36, strict=True, max_length=36, description="The tenant id" ), ], + workflows: Annotated[ + Optional[List[StrictStr]], + Field(description="A list of workflow IDs to filter by"), + ] = None, + additional_metadata: Annotated[ + Optional[List[StrictStr]], + Field(description="A list of metadata key value pairs to filter by"), + ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -469,13 +595,17 @@ async def workflow_delete_with_http_info( _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 + ) -> ApiResponse[TenantQueueMetrics]: + """Get workflow metrics - Delete a workflow for a tenant + Get the queue metrics for the tenant - :param workflow: The workflow id (required) - :type workflow: str + :param tenant: The tenant id (required) + :type tenant: str + :param workflows: A list of workflow IDs to filter by + :type workflows: List[str] + :param additional_metadata: A list of metadata key value pairs to filter by + :type additional_metadata: 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 @@ -498,8 +628,10 @@ async def workflow_delete_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_delete_serialize( - workflow=workflow, + _param = self._tenant_get_queue_metrics_serialize( + tenant=tenant, + workflows=workflows, + additional_metadata=additional_metadata, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -507,7 +639,7 @@ async def workflow_delete_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "204": None, + "200": "TenantQueueMetrics", "400": "APIErrors", "403": "APIErrors", "404": "APIErrors", @@ -522,14 +654,22 @@ async def workflow_delete_with_http_info( ) @validate_call - async def workflow_delete_without_preload_content( + async def tenant_get_queue_metrics_without_preload_content( self, - workflow: Annotated[ + tenant: Annotated[ str, Field( - min_length=36, strict=True, max_length=36, description="The workflow id" + min_length=36, strict=True, max_length=36, description="The tenant id" ), ], + workflows: Annotated[ + Optional[List[StrictStr]], + Field(description="A list of workflow IDs to filter by"), + ] = None, + additional_metadata: Annotated[ + Optional[List[StrictStr]], + Field(description="A list of metadata key value pairs to filter by"), + ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -542,12 +682,16 @@ async def workflow_delete_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Delete workflow + """Get workflow metrics - Delete a workflow for a tenant + Get the queue metrics for the tenant - :param workflow: The workflow id (required) - :type workflow: str + :param tenant: The tenant id (required) + :type tenant: str + :param workflows: A list of workflow IDs to filter by + :type workflows: List[str] + :param additional_metadata: A list of metadata key value pairs to filter by + :type additional_metadata: 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 @@ -570,8 +714,10 @@ async def workflow_delete_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_delete_serialize( - workflow=workflow, + _param = self._tenant_get_queue_metrics_serialize( + tenant=tenant, + workflows=workflows, + additional_metadata=additional_metadata, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -579,7 +725,7 @@ async def workflow_delete_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "204": None, + "200": "TenantQueueMetrics", "400": "APIErrors", "403": "APIErrors", "404": "APIErrors", @@ -589,9 +735,11 @@ async def workflow_delete_without_preload_content( ) return response_data.response - def _workflow_delete_serialize( + def _tenant_get_queue_metrics_serialize( self, - workflow, + tenant, + workflows, + additional_metadata, _request_auth, _content_type, _headers, @@ -600,7 +748,10 @@ def _workflow_delete_serialize( _host = None - _collection_formats: Dict[str, str] = {} + _collection_formats: Dict[str, str] = { + "workflows": "multi", + "additionalMetadata": "multi", + } _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] @@ -612,9 +763,17 @@ def _workflow_delete_serialize( _body_params: Optional[bytes] = None # process the path parameters - if workflow is not None: - _path_params["workflow"] = workflow + if tenant is not None: + _path_params["tenant"] = tenant # process the query parameters + if workflows is not None: + + _query_params.append(("workflows", workflows)) + + if additional_metadata is not None: + + _query_params.append(("additionalMetadata", additional_metadata)) + # process the header parameters # process the form parameters # process the body parameter @@ -629,8 +788,8 @@ def _workflow_delete_serialize( _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] return self.api_client.param_serialize( - method="DELETE", - resource_path="/api/v1/workflows/{workflow}", + method="GET", + resource_path="/api/v1/tenants/{tenant}/queue-metrics", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -644,12 +803,18 @@ def _workflow_delete_serialize( ) @validate_call - async def workflow_get( + async def workflow_cron_delete( self, - workflow: Annotated[ + tenant: Annotated[ str, Field( - min_length=36, strict=True, max_length=36, description="The workflow id" + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + cron_workflow: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The cron job id" ), ], _request_timeout: Union[ @@ -663,13 +828,15 @@ async def workflow_get( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> Workflow: - """Get workflow + ) -> None: + """Delete cron job workflow run - Get a workflow for a tenant + Delete a cron job workflow run for a tenant - :param workflow: The workflow id (required) - :type workflow: str + :param tenant: The tenant id (required) + :type tenant: str + :param cron_workflow: The cron job id (required) + :type cron_workflow: 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 @@ -692,8 +859,9 @@ async def workflow_get( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_get_serialize( - workflow=workflow, + _param = self._workflow_cron_delete_serialize( + tenant=tenant, + cron_workflow=cron_workflow, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -701,10 +869,9 @@ async def workflow_get( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "Workflow", + "204": None, "400": "APIErrors", - "403": "APIErrors", - "404": "APIErrors", + "403": "APIError", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -716,12 +883,18 @@ async def workflow_get( ).data @validate_call - async def workflow_get_with_http_info( + async def workflow_cron_delete_with_http_info( self, - workflow: Annotated[ + tenant: Annotated[ str, Field( - min_length=36, strict=True, max_length=36, description="The workflow id" + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + cron_workflow: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The cron job id" ), ], _request_timeout: Union[ @@ -735,13 +908,15 @@ async def workflow_get_with_http_info( _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 + ) -> ApiResponse[None]: + """Delete cron job workflow run - Get a workflow for a tenant + Delete a cron job workflow run for a tenant - :param workflow: The workflow id (required) - :type workflow: str + :param tenant: The tenant id (required) + :type tenant: str + :param cron_workflow: The cron job id (required) + :type cron_workflow: 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 @@ -764,8 +939,9 @@ async def workflow_get_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_get_serialize( - workflow=workflow, + _param = self._workflow_cron_delete_serialize( + tenant=tenant, + cron_workflow=cron_workflow, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -773,10 +949,9 @@ async def workflow_get_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "Workflow", + "204": None, "400": "APIErrors", - "403": "APIErrors", - "404": "APIErrors", + "403": "APIError", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -788,12 +963,18 @@ async def workflow_get_with_http_info( ) @validate_call - async def workflow_get_without_preload_content( + async def workflow_cron_delete_without_preload_content( self, - workflow: Annotated[ + tenant: Annotated[ str, Field( - min_length=36, strict=True, max_length=36, description="The workflow id" + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + cron_workflow: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The cron job id" ), ], _request_timeout: Union[ @@ -808,12 +989,14 @@ async def workflow_get_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get workflow + """Delete cron job workflow run - Get a workflow for a tenant + Delete a cron job workflow run for a tenant - :param workflow: The workflow id (required) - :type workflow: str + :param tenant: The tenant id (required) + :type tenant: str + :param cron_workflow: The cron job id (required) + :type cron_workflow: 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 @@ -836,8 +1019,9 @@ async def workflow_get_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_get_serialize( - workflow=workflow, + _param = self._workflow_cron_delete_serialize( + tenant=tenant, + cron_workflow=cron_workflow, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -845,19 +1029,19 @@ async def workflow_get_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "Workflow", + "204": None, "400": "APIErrors", - "403": "APIErrors", - "404": "APIErrors", + "403": "APIError", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout ) return response_data.response - def _workflow_get_serialize( + def _workflow_cron_delete_serialize( self, - workflow, + tenant, + cron_workflow, _request_auth, _content_type, _headers, @@ -878,8 +1062,10 @@ def _workflow_get_serialize( _body_params: Optional[bytes] = None # process the path parameters - if workflow is not None: - _path_params["workflow"] = workflow + if tenant is not None: + _path_params["tenant"] = tenant + if cron_workflow is not None: + _path_params["cron-workflow"] = cron_workflow # process the query parameters # process the header parameters # process the form parameters @@ -895,8 +1081,8 @@ def _workflow_get_serialize( _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] return self.api_client.param_serialize( - method="GET", - resource_path="/api/v1/workflows/{workflow}", + method="DELETE", + resource_path="/api/v1/tenants/{tenant}/workflows/crons/{cron-workflow}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -910,21 +1096,20 @@ def _workflow_get_serialize( ) @validate_call - async def workflow_get_metrics( + async def workflow_cron_get( self, - workflow: Annotated[ + tenant: Annotated[ str, Field( - min_length=36, strict=True, max_length=36, description="The workflow id" + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + cron_workflow: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The cron job id" ), ], - status: Annotated[ - Optional[WorkflowRunStatus], - Field(description="A status of workflow run statuses to filter by"), - ] = None, - group_key: Annotated[ - Optional[StrictStr], Field(description="A group key to filter metrics by") - ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -936,17 +1121,15 @@ async def workflow_get_metrics( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> WorkflowMetrics: - """Get workflow metrics + ) -> CronWorkflows: + """Get cron job workflow run - Get the metrics for a workflow version + Get a cron job workflow run for a tenant - :param workflow: The workflow id (required) - :type workflow: str - :param status: A status of workflow run statuses to filter by - :type status: WorkflowRunStatus - :param group_key: A group key to filter metrics by - :type group_key: str + :param tenant: The tenant id (required) + :type tenant: str + :param cron_workflow: The cron job id (required) + :type cron_workflow: 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 @@ -969,10 +1152,9 @@ async def workflow_get_metrics( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_get_metrics_serialize( - workflow=workflow, - status=status, - group_key=group_key, + _param = self._workflow_cron_get_serialize( + tenant=tenant, + cron_workflow=cron_workflow, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -980,7 +1162,7 @@ async def workflow_get_metrics( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowMetrics", + "200": "CronWorkflows", "400": "APIErrors", "403": "APIErrors", "404": "APIErrors", @@ -995,21 +1177,20 @@ async def workflow_get_metrics( ).data @validate_call - async def workflow_get_metrics_with_http_info( + async def workflow_cron_get_with_http_info( self, - workflow: Annotated[ + tenant: Annotated[ str, Field( - min_length=36, strict=True, max_length=36, description="The workflow id" + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + cron_workflow: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The cron job id" ), ], - status: Annotated[ - Optional[WorkflowRunStatus], - Field(description="A status of workflow run statuses to filter by"), - ] = None, - group_key: Annotated[ - Optional[StrictStr], Field(description="A group key to filter metrics by") - ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1021,17 +1202,15 @@ async def workflow_get_metrics_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[WorkflowMetrics]: - """Get workflow metrics + ) -> ApiResponse[CronWorkflows]: + """Get cron job workflow run - Get the metrics for a workflow version + Get a cron job workflow run for a tenant - :param workflow: The workflow id (required) - :type workflow: str - :param status: A status of workflow run statuses to filter by - :type status: WorkflowRunStatus - :param group_key: A group key to filter metrics by - :type group_key: str + :param tenant: The tenant id (required) + :type tenant: str + :param cron_workflow: The cron job id (required) + :type cron_workflow: 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 @@ -1054,10 +1233,9 @@ async def workflow_get_metrics_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_get_metrics_serialize( - workflow=workflow, - status=status, - group_key=group_key, + _param = self._workflow_cron_get_serialize( + tenant=tenant, + cron_workflow=cron_workflow, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1065,7 +1243,7 @@ async def workflow_get_metrics_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowMetrics", + "200": "CronWorkflows", "400": "APIErrors", "403": "APIErrors", "404": "APIErrors", @@ -1080,21 +1258,20 @@ async def workflow_get_metrics_with_http_info( ) @validate_call - async def workflow_get_metrics_without_preload_content( + async def workflow_cron_get_without_preload_content( self, - workflow: Annotated[ + tenant: Annotated[ str, Field( - min_length=36, strict=True, max_length=36, description="The workflow id" + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + cron_workflow: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The cron job id" ), ], - status: Annotated[ - Optional[WorkflowRunStatus], - Field(description="A status of workflow run statuses to filter by"), - ] = None, - group_key: Annotated[ - Optional[StrictStr], Field(description="A group key to filter metrics by") - ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1107,16 +1284,14 @@ async def workflow_get_metrics_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get workflow metrics + """Get cron job workflow run - Get the metrics for a workflow version + Get a cron job workflow run for a tenant - :param workflow: The workflow id (required) - :type workflow: str - :param status: A status of workflow run statuses to filter by - :type status: WorkflowRunStatus - :param group_key: A group key to filter metrics by - :type group_key: str + :param tenant: The tenant id (required) + :type tenant: str + :param cron_workflow: The cron job id (required) + :type cron_workflow: 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 @@ -1139,10 +1314,9 @@ async def workflow_get_metrics_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_get_metrics_serialize( - workflow=workflow, - status=status, - group_key=group_key, + _param = self._workflow_cron_get_serialize( + tenant=tenant, + cron_workflow=cron_workflow, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1150,7 +1324,7 @@ async def workflow_get_metrics_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowMetrics", + "200": "CronWorkflows", "400": "APIErrors", "403": "APIErrors", "404": "APIErrors", @@ -1160,11 +1334,10 @@ async def workflow_get_metrics_without_preload_content( ) return response_data.response - def _workflow_get_metrics_serialize( + def _workflow_cron_get_serialize( self, - workflow, - status, - group_key, + tenant, + cron_workflow, _request_auth, _content_type, _headers, @@ -1185,17 +1358,11 @@ def _workflow_get_metrics_serialize( _body_params: Optional[bytes] = None # process the path parameters - if workflow is not None: - _path_params["workflow"] = workflow + if tenant is not None: + _path_params["tenant"] = tenant + if cron_workflow is not None: + _path_params["cron-workflow"] = cron_workflow # process the query parameters - if status is not None: - - _query_params.append(("status", status.value)) - - if group_key is not None: - - _query_params.append(("groupKey", group_key)) - # process the header parameters # process the form parameters # process the body parameter @@ -1211,7 +1378,7 @@ def _workflow_get_metrics_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/api/v1/workflows/{workflow}/metrics", + resource_path="/api/v1/tenants/{tenant}/workflows/crons/{cron-workflow}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1225,14 +1392,8 @@ def _workflow_get_metrics_serialize( ) @validate_call - async def workflow_get_workers_count( + async def workflow_delete( self, - tenant: Annotated[ - str, - Field( - min_length=36, strict=True, max_length=36, description="The tenant id" - ), - ], workflow: Annotated[ str, Field( @@ -1250,13 +1411,11 @@ async def workflow_get_workers_count( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> WorkflowWorkersCount: - """Get workflow worker count + ) -> None: + """Delete workflow - Get a count of the workers available for workflow + Delete a workflow for a tenant - :param tenant: The tenant id (required) - :type tenant: str :param workflow: The workflow id (required) :type workflow: str :param _request_timeout: timeout setting for this request. If one @@ -1281,8 +1440,7 @@ async def workflow_get_workers_count( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_get_workers_count_serialize( - tenant=tenant, + _param = self._workflow_delete_serialize( workflow=workflow, _request_auth=_request_auth, _content_type=_content_type, @@ -1291,9 +1449,10 @@ async def workflow_get_workers_count( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowWorkersCount", + "204": None, "400": "APIErrors", "403": "APIErrors", + "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -1305,15 +1464,9 @@ async def workflow_get_workers_count( ).data @validate_call - async def workflow_get_workers_count_with_http_info( + async def workflow_delete_with_http_info( self, - tenant: Annotated[ - str, - Field( - min_length=36, strict=True, max_length=36, description="The tenant id" - ), - ], - workflow: Annotated[ + workflow: Annotated[ str, Field( min_length=36, strict=True, max_length=36, description="The workflow id" @@ -1330,13 +1483,11 @@ async def workflow_get_workers_count_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[WorkflowWorkersCount]: - """Get workflow worker count + ) -> ApiResponse[None]: + """Delete workflow - Get a count of the workers available for workflow + Delete a workflow for a tenant - :param tenant: The tenant id (required) - :type tenant: str :param workflow: The workflow id (required) :type workflow: str :param _request_timeout: timeout setting for this request. If one @@ -1361,8 +1512,7 @@ async def workflow_get_workers_count_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_get_workers_count_serialize( - tenant=tenant, + _param = self._workflow_delete_serialize( workflow=workflow, _request_auth=_request_auth, _content_type=_content_type, @@ -1371,9 +1521,10 @@ async def workflow_get_workers_count_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowWorkersCount", + "204": None, "400": "APIErrors", "403": "APIErrors", + "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -1385,14 +1536,8 @@ async def workflow_get_workers_count_with_http_info( ) @validate_call - async def workflow_get_workers_count_without_preload_content( + async def workflow_delete_without_preload_content( self, - tenant: Annotated[ - str, - Field( - min_length=36, strict=True, max_length=36, description="The tenant id" - ), - ], workflow: Annotated[ str, Field( @@ -1411,12 +1556,10 @@ async def workflow_get_workers_count_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get workflow worker count + """Delete workflow - Get a count of the workers available for workflow + Delete a workflow for a tenant - :param tenant: The tenant id (required) - :type tenant: str :param workflow: The workflow id (required) :type workflow: str :param _request_timeout: timeout setting for this request. If one @@ -1441,8 +1584,7 @@ async def workflow_get_workers_count_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_get_workers_count_serialize( - tenant=tenant, + _param = self._workflow_delete_serialize( workflow=workflow, _request_auth=_request_auth, _content_type=_content_type, @@ -1451,18 +1593,18 @@ async def workflow_get_workers_count_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowWorkersCount", + "204": None, "400": "APIErrors", "403": "APIErrors", + "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout ) return response_data.response - def _workflow_get_workers_count_serialize( + def _workflow_delete_serialize( self, - tenant, workflow, _request_auth, _content_type, @@ -1484,8 +1626,6 @@ def _workflow_get_workers_count_serialize( _body_params: Optional[bytes] = None # process the path parameters - if tenant is not None: - _path_params["tenant"] = tenant if workflow is not None: _path_params["workflow"] = workflow # process the query parameters @@ -1503,8 +1643,8 @@ def _workflow_get_workers_count_serialize( _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] return self.api_client.param_serialize( - method="GET", - resource_path="/api/v1/tenants/{tenant}/workflows/{workflow}/worker-count", + method="DELETE", + resource_path="/api/v1/workflows/{workflow}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1518,12 +1658,12 @@ def _workflow_get_workers_count_serialize( ) @validate_call - async def workflow_list( + async def workflow_get( self, - tenant: Annotated[ + workflow: Annotated[ str, Field( - min_length=36, strict=True, max_length=36, description="The tenant id" + min_length=36, strict=True, max_length=36, description="The workflow id" ), ], _request_timeout: Union[ @@ -1537,13 +1677,13 @@ async def workflow_list( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> WorkflowList: - """Get workflows + ) -> Workflow: + """Get workflow - Get all workflows for a tenant + Get a workflow for a tenant - :param tenant: The tenant id (required) - :type tenant: str + :param workflow: The workflow id (required) + :type workflow: 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 @@ -1566,8 +1706,8 @@ async def workflow_list( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_list_serialize( - tenant=tenant, + _param = self._workflow_get_serialize( + workflow=workflow, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1575,9 +1715,10 @@ async def workflow_list( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowList", + "200": "Workflow", "400": "APIErrors", "403": "APIErrors", + "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -1589,12 +1730,12 @@ async def workflow_list( ).data @validate_call - async def workflow_list_with_http_info( + async def workflow_get_with_http_info( self, - tenant: Annotated[ + workflow: Annotated[ str, Field( - min_length=36, strict=True, max_length=36, description="The tenant id" + min_length=36, strict=True, max_length=36, description="The workflow id" ), ], _request_timeout: Union[ @@ -1608,13 +1749,13 @@ async def workflow_list_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[WorkflowList]: - """Get workflows + ) -> ApiResponse[Workflow]: + """Get workflow - Get all workflows for a tenant + Get a workflow for a tenant - :param tenant: The tenant id (required) - :type tenant: str + :param workflow: The workflow id (required) + :type workflow: 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 @@ -1637,8 +1778,8 @@ async def workflow_list_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_list_serialize( - tenant=tenant, + _param = self._workflow_get_serialize( + workflow=workflow, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1646,9 +1787,10 @@ async def workflow_list_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowList", + "200": "Workflow", "400": "APIErrors", "403": "APIErrors", + "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -1660,12 +1802,12 @@ async def workflow_list_with_http_info( ) @validate_call - async def workflow_list_without_preload_content( + async def workflow_get_without_preload_content( self, - tenant: Annotated[ + workflow: Annotated[ str, Field( - min_length=36, strict=True, max_length=36, description="The tenant id" + min_length=36, strict=True, max_length=36, description="The workflow id" ), ], _request_timeout: Union[ @@ -1680,12 +1822,12 @@ async def workflow_list_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get workflows + """Get workflow - Get all workflows for a tenant + Get a workflow for a tenant - :param tenant: The tenant id (required) - :type tenant: str + :param workflow: The workflow id (required) + :type workflow: 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 @@ -1708,8 +1850,8 @@ async def workflow_list_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_list_serialize( - tenant=tenant, + _param = self._workflow_get_serialize( + workflow=workflow, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1717,18 +1859,19 @@ async def workflow_list_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowList", + "200": "Workflow", "400": "APIErrors", "403": "APIErrors", + "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout ) return response_data.response - def _workflow_list_serialize( + def _workflow_get_serialize( self, - tenant, + workflow, _request_auth, _content_type, _headers, @@ -1749,8 +1892,8 @@ def _workflow_list_serialize( _body_params: Optional[bytes] = None # process the path parameters - if tenant is not None: - _path_params["tenant"] = tenant + if workflow is not None: + _path_params["workflow"] = workflow # process the query parameters # process the header parameters # process the form parameters @@ -1767,7 +1910,7 @@ def _workflow_list_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/api/v1/tenants/{tenant}/workflows", + resource_path="/api/v1/workflows/{workflow}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1781,23 +1924,21 @@ def _workflow_list_serialize( ) @validate_call - async def workflow_run_get( + async def workflow_get_metrics( self, - tenant: Annotated[ - str, - Field( - min_length=36, strict=True, max_length=36, description="The tenant id" - ), - ], - workflow_run: Annotated[ + workflow: Annotated[ str, Field( - min_length=36, - strict=True, - max_length=36, - description="The workflow run id", + min_length=36, strict=True, max_length=36, description="The workflow id" ), ], + status: Annotated[ + Optional[WorkflowRunStatus], + Field(description="A status of workflow run statuses to filter by"), + ] = None, + group_key: Annotated[ + Optional[StrictStr], Field(description="A group key to filter metrics by") + ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1809,15 +1950,17 @@ async def workflow_run_get( _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 + ) -> WorkflowMetrics: + """Get workflow metrics - Get a workflow run for a tenant + Get the metrics for a workflow version - :param tenant: The tenant id (required) - :type tenant: str - :param workflow_run: The workflow run id (required) - :type workflow_run: str + :param workflow: The workflow id (required) + :type workflow: str + :param status: A status of workflow run statuses to filter by + :type status: WorkflowRunStatus + :param group_key: A group key to filter metrics by + :type group_key: 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 @@ -1840,9 +1983,10 @@ async def workflow_run_get( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_run_get_serialize( - tenant=tenant, - workflow_run=workflow_run, + _param = self._workflow_get_metrics_serialize( + workflow=workflow, + status=status, + group_key=group_key, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1850,9 +1994,10 @@ async def workflow_run_get( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowRun", + "200": "WorkflowMetrics", "400": "APIErrors", "403": "APIErrors", + "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -1864,23 +2009,21 @@ async def workflow_run_get( ).data @validate_call - async def workflow_run_get_with_http_info( + async def workflow_get_metrics_with_http_info( self, - tenant: Annotated[ - str, - Field( - min_length=36, strict=True, max_length=36, description="The tenant id" - ), - ], - workflow_run: Annotated[ + workflow: Annotated[ str, Field( - min_length=36, - strict=True, - max_length=36, - description="The workflow run id", + min_length=36, strict=True, max_length=36, description="The workflow id" ), ], + status: Annotated[ + Optional[WorkflowRunStatus], + Field(description="A status of workflow run statuses to filter by"), + ] = None, + group_key: Annotated[ + Optional[StrictStr], Field(description="A group key to filter metrics by") + ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1892,15 +2035,17 @@ async def workflow_run_get_with_http_info( _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 + ) -> ApiResponse[WorkflowMetrics]: + """Get workflow metrics - Get a workflow run for a tenant + Get the metrics for a workflow version - :param tenant: The tenant id (required) - :type tenant: str - :param workflow_run: The workflow run id (required) - :type workflow_run: str + :param workflow: The workflow id (required) + :type workflow: str + :param status: A status of workflow run statuses to filter by + :type status: WorkflowRunStatus + :param group_key: A group key to filter metrics by + :type group_key: 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 @@ -1923,9 +2068,10 @@ async def workflow_run_get_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_run_get_serialize( - tenant=tenant, - workflow_run=workflow_run, + _param = self._workflow_get_metrics_serialize( + workflow=workflow, + status=status, + group_key=group_key, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1933,9 +2079,10 @@ async def workflow_run_get_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowRun", + "200": "WorkflowMetrics", "400": "APIErrors", "403": "APIErrors", + "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -1947,23 +2094,21 @@ async def workflow_run_get_with_http_info( ) @validate_call - async def workflow_run_get_without_preload_content( + async def workflow_get_metrics_without_preload_content( self, - tenant: Annotated[ - str, - Field( - min_length=36, strict=True, max_length=36, description="The tenant id" - ), - ], - workflow_run: Annotated[ + workflow: Annotated[ str, Field( - min_length=36, - strict=True, - max_length=36, - description="The workflow run id", + min_length=36, strict=True, max_length=36, description="The workflow id" ), ], + status: Annotated[ + Optional[WorkflowRunStatus], + Field(description="A status of workflow run statuses to filter by"), + ] = None, + group_key: Annotated[ + Optional[StrictStr], Field(description="A group key to filter metrics by") + ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1976,18 +2121,2212 @@ async def workflow_run_get_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get workflow run + """Get workflow metrics - Get a workflow run for a tenant + Get the metrics for a workflow version - :param tenant: The tenant id (required) - :type tenant: str - :param workflow_run: The workflow run id (required) - :type workflow_run: 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. + :param workflow: The workflow id (required) + :type workflow: str + :param status: A status of workflow run statuses to filter by + :type status: WorkflowRunStatus + :param group_key: A group key to filter metrics by + :type group_key: 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._workflow_get_metrics_serialize( + workflow=workflow, + status=status, + group_key=group_key, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowMetrics", + "400": "APIErrors", + "403": "APIErrors", + "404": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _workflow_get_metrics_serialize( + self, + workflow, + status, + group_key, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if workflow is not None: + _path_params["workflow"] = workflow + # process the query parameters + if status is not None: + + _query_params.append(("status", status.value)) + + if group_key is not None: + + _query_params.append(("groupKey", group_key)) + + # 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] = ["cookieAuth", "bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/v1/workflows/{workflow}/metrics", + 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 + async def workflow_get_workers_count( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The workflow id" + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> WorkflowWorkersCount: + """Get workflow worker count + + Get a count of the workers available for workflow + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow: The workflow id (required) + :type workflow: 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._workflow_get_workers_count_serialize( + tenant=tenant, + workflow=workflow, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowWorkersCount", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def workflow_get_workers_count_with_http_info( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The workflow id" + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[WorkflowWorkersCount]: + """Get workflow worker count + + Get a count of the workers available for workflow + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow: The workflow id (required) + :type workflow: 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._workflow_get_workers_count_serialize( + tenant=tenant, + workflow=workflow, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowWorkersCount", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def workflow_get_workers_count_without_preload_content( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The workflow id" + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get workflow worker count + + Get a count of the workers available for workflow + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow: The workflow id (required) + :type workflow: 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._workflow_get_workers_count_serialize( + tenant=tenant, + workflow=workflow, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowWorkersCount", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _workflow_get_workers_count_serialize( + self, + tenant, + workflow, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if tenant is not None: + _path_params["tenant"] = tenant + if workflow is not None: + _path_params["workflow"] = workflow + # 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] = ["cookieAuth", "bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/v1/tenants/{tenant}/workflows/{workflow}/worker-count", + 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 + async def workflow_list( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> WorkflowList: + """Get workflows + + Get all workflows for a tenant + + :param tenant: The tenant id (required) + :type tenant: 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._workflow_list_serialize( + tenant=tenant, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowList", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def workflow_list_with_http_info( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[WorkflowList]: + """Get workflows + + Get all workflows for a tenant + + :param tenant: The tenant id (required) + :type tenant: 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._workflow_list_serialize( + tenant=tenant, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowList", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def workflow_list_without_preload_content( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get workflows + + Get all workflows for a tenant + + :param tenant: The tenant id (required) + :type tenant: 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._workflow_list_serialize( + tenant=tenant, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowList", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _workflow_list_serialize( + self, + tenant, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if tenant is not None: + _path_params["tenant"] = tenant + # 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] = ["cookieAuth", "bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/v1/tenants/{tenant}/workflows", + 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 + async def workflow_run_get( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow_run: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The workflow run id", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> WorkflowRun: + """Get workflow run + + Get a workflow run for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow_run: The workflow run id (required) + :type workflow_run: 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._workflow_run_get_serialize( + tenant=tenant, + workflow_run=workflow_run, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRun", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def workflow_run_get_with_http_info( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow_run: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The workflow run id", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[WorkflowRun]: + """Get workflow run + + Get a workflow run for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow_run: The workflow run id (required) + :type workflow_run: 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._workflow_run_get_serialize( + tenant=tenant, + workflow_run=workflow_run, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRun", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def workflow_run_get_without_preload_content( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow_run: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The workflow run id", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get workflow run + + Get a workflow run for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow_run: The workflow run id (required) + :type workflow_run: 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._workflow_run_get_serialize( + tenant=tenant, + workflow_run=workflow_run, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRun", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _workflow_run_get_serialize( + self, + tenant, + workflow_run, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if tenant is not None: + _path_params["tenant"] = tenant + if workflow_run is not None: + _path_params["workflow-run"] = workflow_run + # 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] = ["cookieAuth", "bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}", + 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 + async def workflow_run_get_metrics( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + event_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The event id to get runs for."), + ] = None, + workflow_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The workflow id to get runs for."), + ] = None, + parent_workflow_run_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The parent workflow run id"), + ] = None, + parent_step_run_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The parent step run id"), + ] = None, + additional_metadata: Annotated[ + Optional[List[StrictStr]], + Field(description="A list of metadata key value pairs to filter by"), + ] = None, + created_after: Annotated[ + Optional[datetime], + Field(description="The time after the workflow run was created"), + ] = None, + created_before: Annotated[ + Optional[datetime], + Field(description="The time before the workflow run was created"), + ] = 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, + ) -> WorkflowRunsMetrics: + """Get workflow runs metrics + + Get a summary of workflow run metrics for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param event_id: The event id to get runs for. + :type event_id: str + :param workflow_id: The workflow id to get runs for. + :type workflow_id: str + :param parent_workflow_run_id: The parent workflow run id + :type parent_workflow_run_id: str + :param parent_step_run_id: The parent step run id + :type parent_step_run_id: str + :param additional_metadata: A list of metadata key value pairs to filter by + :type additional_metadata: List[str] + :param created_after: The time after the workflow run was created + :type created_after: datetime + :param created_before: The time before the workflow run was created + :type created_before: datetime + :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._workflow_run_get_metrics_serialize( + tenant=tenant, + event_id=event_id, + workflow_id=workflow_id, + parent_workflow_run_id=parent_workflow_run_id, + parent_step_run_id=parent_step_run_id, + additional_metadata=additional_metadata, + created_after=created_after, + created_before=created_before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRunsMetrics", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def workflow_run_get_metrics_with_http_info( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + event_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The event id to get runs for."), + ] = None, + workflow_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The workflow id to get runs for."), + ] = None, + parent_workflow_run_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The parent workflow run id"), + ] = None, + parent_step_run_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The parent step run id"), + ] = None, + additional_metadata: Annotated[ + Optional[List[StrictStr]], + Field(description="A list of metadata key value pairs to filter by"), + ] = None, + created_after: Annotated[ + Optional[datetime], + Field(description="The time after the workflow run was created"), + ] = None, + created_before: Annotated[ + Optional[datetime], + Field(description="The time before the workflow run was created"), + ] = 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[WorkflowRunsMetrics]: + """Get workflow runs metrics + + Get a summary of workflow run metrics for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param event_id: The event id to get runs for. + :type event_id: str + :param workflow_id: The workflow id to get runs for. + :type workflow_id: str + :param parent_workflow_run_id: The parent workflow run id + :type parent_workflow_run_id: str + :param parent_step_run_id: The parent step run id + :type parent_step_run_id: str + :param additional_metadata: A list of metadata key value pairs to filter by + :type additional_metadata: List[str] + :param created_after: The time after the workflow run was created + :type created_after: datetime + :param created_before: The time before the workflow run was created + :type created_before: datetime + :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._workflow_run_get_metrics_serialize( + tenant=tenant, + event_id=event_id, + workflow_id=workflow_id, + parent_workflow_run_id=parent_workflow_run_id, + parent_step_run_id=parent_step_run_id, + additional_metadata=additional_metadata, + created_after=created_after, + created_before=created_before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRunsMetrics", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def workflow_run_get_metrics_without_preload_content( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + event_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The event id to get runs for."), + ] = None, + workflow_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The workflow id to get runs for."), + ] = None, + parent_workflow_run_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The parent workflow run id"), + ] = None, + parent_step_run_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The parent step run id"), + ] = None, + additional_metadata: Annotated[ + Optional[List[StrictStr]], + Field(description="A list of metadata key value pairs to filter by"), + ] = None, + created_after: Annotated[ + Optional[datetime], + Field(description="The time after the workflow run was created"), + ] = None, + created_before: Annotated[ + Optional[datetime], + Field(description="The time before the workflow run was created"), + ] = 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 runs metrics + + Get a summary of workflow run metrics for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param event_id: The event id to get runs for. + :type event_id: str + :param workflow_id: The workflow id to get runs for. + :type workflow_id: str + :param parent_workflow_run_id: The parent workflow run id + :type parent_workflow_run_id: str + :param parent_step_run_id: The parent step run id + :type parent_step_run_id: str + :param additional_metadata: A list of metadata key value pairs to filter by + :type additional_metadata: List[str] + :param created_after: The time after the workflow run was created + :type created_after: datetime + :param created_before: The time before the workflow run was created + :type created_before: datetime + :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._workflow_run_get_metrics_serialize( + tenant=tenant, + event_id=event_id, + workflow_id=workflow_id, + parent_workflow_run_id=parent_workflow_run_id, + parent_step_run_id=parent_step_run_id, + additional_metadata=additional_metadata, + created_after=created_after, + created_before=created_before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRunsMetrics", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _workflow_run_get_metrics_serialize( + self, + tenant, + event_id, + workflow_id, + parent_workflow_run_id, + parent_step_run_id, + additional_metadata, + created_after, + created_before, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + "additionalMetadata": "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, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if tenant is not None: + _path_params["tenant"] = tenant + # process the query parameters + if event_id is not None: + + _query_params.append(("eventId", event_id)) + + if workflow_id is not None: + + _query_params.append(("workflowId", workflow_id)) + + if parent_workflow_run_id is not None: + + _query_params.append(("parentWorkflowRunId", parent_workflow_run_id)) + + if parent_step_run_id is not None: + + _query_params.append(("parentStepRunId", parent_step_run_id)) + + if additional_metadata is not None: + + _query_params.append(("additionalMetadata", additional_metadata)) + + if created_after is not None: + if isinstance(created_after, datetime): + _query_params.append( + ( + "createdAfter", + created_after.strftime( + self.api_client.configuration.datetime_format + ), + ) + ) + else: + _query_params.append(("createdAfter", created_after)) + + if created_before is not None: + if isinstance(created_before, datetime): + _query_params.append( + ( + "createdBefore", + created_before.strftime( + self.api_client.configuration.datetime_format + ), + ) + ) + else: + _query_params.append(("createdBefore", created_before)) + + # 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] = ["cookieAuth", "bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/v1/tenants/{tenant}/workflows/runs/metrics", + 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 + async def workflow_run_get_shape( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow_run: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The workflow run id", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> WorkflowRunShape: + """Get workflow run + + Get a workflow run for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow_run: The workflow run id (required) + :type workflow_run: 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._workflow_run_get_shape_serialize( + tenant=tenant, + workflow_run=workflow_run, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRunShape", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def workflow_run_get_shape_with_http_info( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow_run: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The workflow run id", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[WorkflowRunShape]: + """Get workflow run + + Get a workflow run for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow_run: The workflow run id (required) + :type workflow_run: 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._workflow_run_get_shape_serialize( + tenant=tenant, + workflow_run=workflow_run, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRunShape", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def workflow_run_get_shape_without_preload_content( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow_run: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The workflow run id", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get workflow run + + Get a workflow run for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow_run: The workflow run id (required) + :type workflow_run: 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._workflow_run_get_shape_serialize( + tenant=tenant, + workflow_run=workflow_run, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRunShape", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _workflow_run_get_shape_serialize( + self, + tenant, + workflow_run, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if tenant is not None: + _path_params["tenant"] = tenant + if workflow_run is not None: + _path_params["workflow-run"] = workflow_run + # 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] = ["cookieAuth", "bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}/shape", + 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 + async def workflow_run_list( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + offset: Annotated[ + Optional[StrictInt], Field(description="The number to skip") + ] = None, + limit: Annotated[ + Optional[StrictInt], Field(description="The number to limit by") + ] = None, + event_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The event id to get runs for."), + ] = None, + workflow_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The workflow id to get runs for."), + ] = None, + parent_workflow_run_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The parent workflow run id"), + ] = None, + parent_step_run_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The parent step run id"), + ] = None, + statuses: Annotated[ + Optional[List[WorkflowRunStatus]], + Field(description="A list of workflow run statuses to filter by"), + ] = None, + kinds: Annotated[ + Optional[List[WorkflowKind]], + Field(description="A list of workflow kinds to filter by"), + ] = None, + additional_metadata: Annotated[ + Optional[List[StrictStr]], + Field(description="A list of metadata key value pairs to filter by"), + ] = None, + created_after: Annotated[ + Optional[datetime], + Field(description="The time after the workflow run was created"), + ] = None, + created_before: Annotated[ + Optional[datetime], + Field(description="The time before the workflow run was created"), + ] = None, + finished_after: Annotated[ + Optional[datetime], + Field(description="The time after the workflow run was finished"), + ] = None, + finished_before: Annotated[ + Optional[datetime], + Field(description="The time before the workflow run was finished"), + ] = None, + order_by_field: Annotated[ + Optional[WorkflowRunOrderByField], Field(description="The order by field") + ] = None, + order_by_direction: Annotated[ + Optional[WorkflowRunOrderByDirection], + Field(description="The order by direction"), + ] = 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, + ) -> WorkflowRunList: + """Get workflow runs + + Get all workflow runs for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param offset: The number to skip + :type offset: int + :param limit: The number to limit by + :type limit: int + :param event_id: The event id to get runs for. + :type event_id: str + :param workflow_id: The workflow id to get runs for. + :type workflow_id: str + :param parent_workflow_run_id: The parent workflow run id + :type parent_workflow_run_id: str + :param parent_step_run_id: The parent step run id + :type parent_step_run_id: str + :param statuses: A list of workflow run statuses to filter by + :type statuses: List[WorkflowRunStatus] + :param kinds: A list of workflow kinds to filter by + :type kinds: List[WorkflowKind] + :param additional_metadata: A list of metadata key value pairs to filter by + :type additional_metadata: List[str] + :param created_after: The time after the workflow run was created + :type created_after: datetime + :param created_before: The time before the workflow run was created + :type created_before: datetime + :param finished_after: The time after the workflow run was finished + :type finished_after: datetime + :param finished_before: The time before the workflow run was finished + :type finished_before: datetime + :param order_by_field: The order by field + :type order_by_field: WorkflowRunOrderByField + :param order_by_direction: The order by direction + :type order_by_direction: WorkflowRunOrderByDirection + :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._workflow_run_list_serialize( + tenant=tenant, + offset=offset, + limit=limit, + event_id=event_id, + workflow_id=workflow_id, + parent_workflow_run_id=parent_workflow_run_id, + parent_step_run_id=parent_step_run_id, + statuses=statuses, + kinds=kinds, + additional_metadata=additional_metadata, + created_after=created_after, + created_before=created_before, + finished_after=finished_after, + finished_before=finished_before, + order_by_field=order_by_field, + order_by_direction=order_by_direction, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRunList", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def workflow_run_list_with_http_info( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + offset: Annotated[ + Optional[StrictInt], Field(description="The number to skip") + ] = None, + limit: Annotated[ + Optional[StrictInt], Field(description="The number to limit by") + ] = None, + event_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The event id to get runs for."), + ] = None, + workflow_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The workflow id to get runs for."), + ] = None, + parent_workflow_run_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The parent workflow run id"), + ] = None, + parent_step_run_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The parent step run id"), + ] = None, + statuses: Annotated[ + Optional[List[WorkflowRunStatus]], + Field(description="A list of workflow run statuses to filter by"), + ] = None, + kinds: Annotated[ + Optional[List[WorkflowKind]], + Field(description="A list of workflow kinds to filter by"), + ] = None, + additional_metadata: Annotated[ + Optional[List[StrictStr]], + Field(description="A list of metadata key value pairs to filter by"), + ] = None, + created_after: Annotated[ + Optional[datetime], + Field(description="The time after the workflow run was created"), + ] = None, + created_before: Annotated[ + Optional[datetime], + Field(description="The time before the workflow run was created"), + ] = None, + finished_after: Annotated[ + Optional[datetime], + Field(description="The time after the workflow run was finished"), + ] = None, + finished_before: Annotated[ + Optional[datetime], + Field(description="The time before the workflow run was finished"), + ] = None, + order_by_field: Annotated[ + Optional[WorkflowRunOrderByField], Field(description="The order by field") + ] = None, + order_by_direction: Annotated[ + Optional[WorkflowRunOrderByDirection], + Field(description="The order by direction"), + ] = 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[WorkflowRunList]: + """Get workflow runs + + Get all workflow runs for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param offset: The number to skip + :type offset: int + :param limit: The number to limit by + :type limit: int + :param event_id: The event id to get runs for. + :type event_id: str + :param workflow_id: The workflow id to get runs for. + :type workflow_id: str + :param parent_workflow_run_id: The parent workflow run id + :type parent_workflow_run_id: str + :param parent_step_run_id: The parent step run id + :type parent_step_run_id: str + :param statuses: A list of workflow run statuses to filter by + :type statuses: List[WorkflowRunStatus] + :param kinds: A list of workflow kinds to filter by + :type kinds: List[WorkflowKind] + :param additional_metadata: A list of metadata key value pairs to filter by + :type additional_metadata: List[str] + :param created_after: The time after the workflow run was created + :type created_after: datetime + :param created_before: The time before the workflow run was created + :type created_before: datetime + :param finished_after: The time after the workflow run was finished + :type finished_after: datetime + :param finished_before: The time before the workflow run was finished + :type finished_before: datetime + :param order_by_field: The order by field + :type order_by_field: WorkflowRunOrderByField + :param order_by_direction: The order by direction + :type order_by_direction: WorkflowRunOrderByDirection + :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._workflow_run_list_serialize( + tenant=tenant, + offset=offset, + limit=limit, + event_id=event_id, + workflow_id=workflow_id, + parent_workflow_run_id=parent_workflow_run_id, + parent_step_run_id=parent_step_run_id, + statuses=statuses, + kinds=kinds, + additional_metadata=additional_metadata, + created_after=created_after, + created_before=created_before, + finished_after=finished_after, + finished_before=finished_before, + order_by_field=order_by_field, + order_by_direction=order_by_direction, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRunList", + "400": "APIErrors", + "403": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def workflow_run_list_without_preload_content( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + offset: Annotated[ + Optional[StrictInt], Field(description="The number to skip") + ] = None, + limit: Annotated[ + Optional[StrictInt], Field(description="The number to limit by") + ] = None, + event_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The event id to get runs for."), + ] = None, + workflow_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The workflow id to get runs for."), + ] = None, + parent_workflow_run_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The parent workflow run id"), + ] = None, + parent_step_run_id: Annotated[ + Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], + Field(description="The parent step run id"), + ] = None, + statuses: Annotated[ + Optional[List[WorkflowRunStatus]], + Field(description="A list of workflow run statuses to filter by"), + ] = None, + kinds: Annotated[ + Optional[List[WorkflowKind]], + Field(description="A list of workflow kinds to filter by"), + ] = None, + additional_metadata: Annotated[ + Optional[List[StrictStr]], + Field(description="A list of metadata key value pairs to filter by"), + ] = None, + created_after: Annotated[ + Optional[datetime], + Field(description="The time after the workflow run was created"), + ] = None, + created_before: Annotated[ + Optional[datetime], + Field(description="The time before the workflow run was created"), + ] = None, + finished_after: Annotated[ + Optional[datetime], + Field(description="The time after the workflow run was finished"), + ] = None, + finished_before: Annotated[ + Optional[datetime], + Field(description="The time before the workflow run was finished"), + ] = None, + order_by_field: Annotated[ + Optional[WorkflowRunOrderByField], Field(description="The order by field") + ] = None, + order_by_direction: Annotated[ + Optional[WorkflowRunOrderByDirection], + Field(description="The order by direction"), + ] = 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 runs + + Get all workflow runs for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param offset: The number to skip + :type offset: int + :param limit: The number to limit by + :type limit: int + :param event_id: The event id to get runs for. + :type event_id: str + :param workflow_id: The workflow id to get runs for. + :type workflow_id: str + :param parent_workflow_run_id: The parent workflow run id + :type parent_workflow_run_id: str + :param parent_step_run_id: The parent step run id + :type parent_step_run_id: str + :param statuses: A list of workflow run statuses to filter by + :type statuses: List[WorkflowRunStatus] + :param kinds: A list of workflow kinds to filter by + :type kinds: List[WorkflowKind] + :param additional_metadata: A list of metadata key value pairs to filter by + :type additional_metadata: List[str] + :param created_after: The time after the workflow run was created + :type created_after: datetime + :param created_before: The time before the workflow run was created + :type created_before: datetime + :param finished_after: The time after the workflow run was finished + :type finished_after: datetime + :param finished_before: The time before the workflow run was finished + :type finished_before: datetime + :param order_by_field: The order by field + :type order_by_field: WorkflowRunOrderByField + :param order_by_direction: The order by direction + :type order_by_direction: WorkflowRunOrderByDirection + :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 @@ -2006,9 +4345,23 @@ async def workflow_run_get_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_run_get_serialize( + _param = self._workflow_run_list_serialize( tenant=tenant, - workflow_run=workflow_run, + offset=offset, + limit=limit, + event_id=event_id, + workflow_id=workflow_id, + parent_workflow_run_id=parent_workflow_run_id, + parent_step_run_id=parent_step_run_id, + statuses=statuses, + kinds=kinds, + additional_metadata=additional_metadata, + created_after=created_after, + created_before=created_before, + finished_after=finished_after, + finished_before=finished_before, + order_by_field=order_by_field, + order_by_direction=order_by_direction, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2016,7 +4369,7 @@ async def workflow_run_get_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowRun", + "200": "WorkflowRunList", "400": "APIErrors", "403": "APIErrors", } @@ -2025,10 +4378,24 @@ async def workflow_run_get_without_preload_content( ) return response_data.response - def _workflow_run_get_serialize( + def _workflow_run_list_serialize( self, tenant, - workflow_run, + offset, + limit, + event_id, + workflow_id, + parent_workflow_run_id, + parent_step_run_id, + statuses, + kinds, + additional_metadata, + created_after, + created_before, + finished_after, + finished_before, + order_by_field, + order_by_direction, _request_auth, _content_type, _headers, @@ -2037,7 +4404,11 @@ def _workflow_run_get_serialize( _host = None - _collection_formats: Dict[str, str] = {} + _collection_formats: Dict[str, str] = { + "statuses": "multi", + "kinds": "multi", + "additionalMetadata": "multi", + } _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] @@ -2051,9 +4422,103 @@ def _workflow_run_get_serialize( # process the path parameters if tenant is not None: _path_params["tenant"] = tenant - if workflow_run is not None: - _path_params["workflow-run"] = workflow_run # process the query parameters + if offset is not None: + + _query_params.append(("offset", offset)) + + if limit is not None: + + _query_params.append(("limit", limit)) + + if event_id is not None: + + _query_params.append(("eventId", event_id)) + + if workflow_id is not None: + + _query_params.append(("workflowId", workflow_id)) + + if parent_workflow_run_id is not None: + + _query_params.append(("parentWorkflowRunId", parent_workflow_run_id)) + + if parent_step_run_id is not None: + + _query_params.append(("parentStepRunId", parent_step_run_id)) + + if statuses is not None: + + _query_params.append(("statuses", statuses)) + + if kinds is not None: + + _query_params.append(("kinds", kinds)) + + if additional_metadata is not None: + + _query_params.append(("additionalMetadata", additional_metadata)) + + if created_after is not None: + if isinstance(created_after, datetime): + _query_params.append( + ( + "createdAfter", + created_after.strftime( + self.api_client.configuration.datetime_format + ), + ) + ) + else: + _query_params.append(("createdAfter", created_after)) + + if created_before is not None: + if isinstance(created_before, datetime): + _query_params.append( + ( + "createdBefore", + created_before.strftime( + self.api_client.configuration.datetime_format + ), + ) + ) + else: + _query_params.append(("createdBefore", created_before)) + + if finished_after is not None: + if isinstance(finished_after, datetime): + _query_params.append( + ( + "finishedAfter", + finished_after.strftime( + self.api_client.configuration.datetime_format + ), + ) + ) + else: + _query_params.append(("finishedAfter", finished_after)) + + if finished_before is not None: + if isinstance(finished_before, datetime): + _query_params.append( + ( + "finishedBefore", + finished_before.strftime( + self.api_client.configuration.datetime_format + ), + ) + ) + else: + _query_params.append(("finishedBefore", finished_before)) + + if order_by_field is not None: + + _query_params.append(("orderByField", order_by_field.value)) + + if order_by_direction is not None: + + _query_params.append(("orderByDirection", order_by_direction.value)) + # process the header parameters # process the form parameters # process the body parameter @@ -2069,7 +4534,7 @@ def _workflow_run_get_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}", + resource_path="/api/v1/tenants/{tenant}/workflows/runs", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -2083,7 +4548,7 @@ def _workflow_run_get_serialize( ) @validate_call - async def workflow_run_get_metrics( + async def workflow_scheduled_delete( self, tenant: Annotated[ str, @@ -2091,34 +4556,15 @@ async def workflow_run_get_metrics( min_length=36, strict=True, max_length=36, description="The tenant id" ), ], - event_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The event id to get runs for."), - ] = None, - workflow_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The workflow id to get runs for."), - ] = None, - parent_workflow_run_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The parent workflow run id"), - ] = None, - parent_step_run_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The parent step run id"), - ] = None, - additional_metadata: Annotated[ - Optional[List[StrictStr]], - Field(description="A list of metadata key value pairs to filter by"), - ] = None, - created_after: Annotated[ - Optional[datetime], - Field(description="The time after the workflow run was created"), - ] = None, - created_before: Annotated[ - Optional[datetime], - Field(description="The time before the workflow run was created"), - ] = None, + scheduled_workflow_run: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The scheduled workflow id", + ), + ], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2130,27 +4576,15 @@ async def workflow_run_get_metrics( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> WorkflowRunsMetrics: - """Get workflow runs + ) -> None: + """Delete scheduled workflow run - Get a summary of workflow run metrics for a tenant + Delete a scheduled workflow run for a tenant :param tenant: The tenant id (required) :type tenant: str - :param event_id: The event id to get runs for. - :type event_id: str - :param workflow_id: The workflow id to get runs for. - :type workflow_id: str - :param parent_workflow_run_id: The parent workflow run id - :type parent_workflow_run_id: str - :param parent_step_run_id: The parent step run id - :type parent_step_run_id: str - :param additional_metadata: A list of metadata key value pairs to filter by - :type additional_metadata: List[str] - :param created_after: The time after the workflow run was created - :type created_after: datetime - :param created_before: The time before the workflow run was created - :type created_before: datetime + :param scheduled_workflow_run: The scheduled workflow id (required) + :type scheduled_workflow_run: 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 @@ -2173,15 +4607,9 @@ async def workflow_run_get_metrics( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_run_get_metrics_serialize( + _param = self._workflow_scheduled_delete_serialize( tenant=tenant, - event_id=event_id, - workflow_id=workflow_id, - parent_workflow_run_id=parent_workflow_run_id, - parent_step_run_id=parent_step_run_id, - additional_metadata=additional_metadata, - created_after=created_after, - created_before=created_before, + scheduled_workflow_run=scheduled_workflow_run, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2189,9 +4617,9 @@ async def workflow_run_get_metrics( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowRunsMetrics", + "204": None, "400": "APIErrors", - "403": "APIErrors", + "403": "APIError", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -2203,7 +4631,7 @@ async def workflow_run_get_metrics( ).data @validate_call - async def workflow_run_get_metrics_with_http_info( + async def workflow_scheduled_delete_with_http_info( self, tenant: Annotated[ str, @@ -2211,34 +4639,15 @@ async def workflow_run_get_metrics_with_http_info( min_length=36, strict=True, max_length=36, description="The tenant id" ), ], - event_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The event id to get runs for."), - ] = None, - workflow_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The workflow id to get runs for."), - ] = None, - parent_workflow_run_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The parent workflow run id"), - ] = None, - parent_step_run_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The parent step run id"), - ] = None, - additional_metadata: Annotated[ - Optional[List[StrictStr]], - Field(description="A list of metadata key value pairs to filter by"), - ] = None, - created_after: Annotated[ - Optional[datetime], - Field(description="The time after the workflow run was created"), - ] = None, - created_before: Annotated[ - Optional[datetime], - Field(description="The time before the workflow run was created"), - ] = None, + scheduled_workflow_run: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The scheduled workflow id", + ), + ], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2250,27 +4659,15 @@ async def workflow_run_get_metrics_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[WorkflowRunsMetrics]: - """Get workflow runs + ) -> ApiResponse[None]: + """Delete scheduled workflow run - Get a summary of workflow run metrics for a tenant + Delete a scheduled workflow run for a tenant :param tenant: The tenant id (required) :type tenant: str - :param event_id: The event id to get runs for. - :type event_id: str - :param workflow_id: The workflow id to get runs for. - :type workflow_id: str - :param parent_workflow_run_id: The parent workflow run id - :type parent_workflow_run_id: str - :param parent_step_run_id: The parent step run id - :type parent_step_run_id: str - :param additional_metadata: A list of metadata key value pairs to filter by - :type additional_metadata: List[str] - :param created_after: The time after the workflow run was created - :type created_after: datetime - :param created_before: The time before the workflow run was created - :type created_before: datetime + :param scheduled_workflow_run: The scheduled workflow id (required) + :type scheduled_workflow_run: 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 @@ -2293,15 +4690,9 @@ async def workflow_run_get_metrics_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_run_get_metrics_serialize( + _param = self._workflow_scheduled_delete_serialize( tenant=tenant, - event_id=event_id, - workflow_id=workflow_id, - parent_workflow_run_id=parent_workflow_run_id, - parent_step_run_id=parent_step_run_id, - additional_metadata=additional_metadata, - created_after=created_after, - created_before=created_before, + scheduled_workflow_run=scheduled_workflow_run, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2309,9 +4700,9 @@ async def workflow_run_get_metrics_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowRunsMetrics", + "204": None, "400": "APIErrors", - "403": "APIErrors", + "403": "APIError", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -2323,7 +4714,7 @@ async def workflow_run_get_metrics_with_http_info( ) @validate_call - async def workflow_run_get_metrics_without_preload_content( + async def workflow_scheduled_delete_without_preload_content( self, tenant: Annotated[ str, @@ -2331,34 +4722,15 @@ async def workflow_run_get_metrics_without_preload_content( min_length=36, strict=True, max_length=36, description="The tenant id" ), ], - event_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The event id to get runs for."), - ] = None, - workflow_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The workflow id to get runs for."), - ] = None, - parent_workflow_run_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The parent workflow run id"), - ] = None, - parent_step_run_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The parent step run id"), - ] = None, - additional_metadata: Annotated[ - Optional[List[StrictStr]], - Field(description="A list of metadata key value pairs to filter by"), - ] = None, - created_after: Annotated[ - Optional[datetime], - Field(description="The time after the workflow run was created"), - ] = None, - created_before: Annotated[ - Optional[datetime], - Field(description="The time before the workflow run was created"), - ] = None, + scheduled_workflow_run: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The scheduled workflow id", + ), + ], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2371,26 +4743,14 @@ async def workflow_run_get_metrics_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get workflow runs + """Delete scheduled workflow run - Get a summary of workflow run metrics for a tenant + Delete a scheduled workflow run for a tenant :param tenant: The tenant id (required) :type tenant: str - :param event_id: The event id to get runs for. - :type event_id: str - :param workflow_id: The workflow id to get runs for. - :type workflow_id: str - :param parent_workflow_run_id: The parent workflow run id - :type parent_workflow_run_id: str - :param parent_step_run_id: The parent step run id - :type parent_step_run_id: str - :param additional_metadata: A list of metadata key value pairs to filter by - :type additional_metadata: List[str] - :param created_after: The time after the workflow run was created - :type created_after: datetime - :param created_before: The time before the workflow run was created - :type created_before: datetime + :param scheduled_workflow_run: The scheduled workflow id (required) + :type scheduled_workflow_run: 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 @@ -2413,15 +4773,9 @@ async def workflow_run_get_metrics_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_run_get_metrics_serialize( + _param = self._workflow_scheduled_delete_serialize( tenant=tenant, - event_id=event_id, - workflow_id=workflow_id, - parent_workflow_run_id=parent_workflow_run_id, - parent_step_run_id=parent_step_run_id, - additional_metadata=additional_metadata, - created_after=created_after, - created_before=created_before, + scheduled_workflow_run=scheduled_workflow_run, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2429,25 +4783,19 @@ async def workflow_run_get_metrics_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowRunsMetrics", + "204": None, "400": "APIErrors", - "403": "APIErrors", + "403": "APIError", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout ) return response_data.response - def _workflow_run_get_metrics_serialize( + def _workflow_scheduled_delete_serialize( self, tenant, - event_id, - workflow_id, - parent_workflow_run_id, - parent_step_run_id, - additional_metadata, - created_after, - created_before, + scheduled_workflow_run, _request_auth, _content_type, _headers, @@ -2456,9 +4804,7 @@ def _workflow_run_get_metrics_serialize( _host = None - _collection_formats: Dict[str, str] = { - "additionalMetadata": "multi", - } + _collection_formats: Dict[str, str] = {} _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] @@ -2472,49 +4818,9 @@ def _workflow_run_get_metrics_serialize( # process the path parameters if tenant is not None: _path_params["tenant"] = tenant + if scheduled_workflow_run is not None: + _path_params["scheduled-workflow-run"] = scheduled_workflow_run # process the query parameters - if event_id is not None: - - _query_params.append(("eventId", event_id)) - - if workflow_id is not None: - - _query_params.append(("workflowId", workflow_id)) - - if parent_workflow_run_id is not None: - - _query_params.append(("parentWorkflowRunId", parent_workflow_run_id)) - - if parent_step_run_id is not None: - - _query_params.append(("parentStepRunId", parent_step_run_id)) - - if additional_metadata is not None: - - _query_params.append(("additionalMetadata", additional_metadata)) - - if created_after is not None: - if isinstance(created_after, datetime): - _query_params.append( - ( - "createdAfter", - created_after.isoformat(), - ) - ) - else: - _query_params.append(("createdAfter", created_after)) - - if created_before is not None: - if isinstance(created_before, datetime): - _query_params.append( - ( - "createdBefore", - created_before.isoformat(), - ) - ) - else: - _query_params.append(("createdBefore", created_before)) - # process the header parameters # process the form parameters # process the body parameter @@ -2529,8 +4835,8 @@ def _workflow_run_get_metrics_serialize( _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] return self.api_client.param_serialize( - method="GET", - resource_path="/api/v1/tenants/{tenant}/workflows/runs/metrics", + method="DELETE", + resource_path="/api/v1/tenants/{tenant}/workflows/scheduled/{scheduled-workflow-run}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -2544,7 +4850,7 @@ def _workflow_run_get_metrics_serialize( ) @validate_call - async def workflow_run_get_shape( + async def workflow_scheduled_get( self, tenant: Annotated[ str, @@ -2552,13 +4858,13 @@ async def workflow_run_get_shape( min_length=36, strict=True, max_length=36, description="The tenant id" ), ], - workflow_run: Annotated[ + scheduled_workflow_run: Annotated[ str, Field( min_length=36, strict=True, max_length=36, - description="The workflow run id", + description="The scheduled workflow id", ), ], _request_timeout: Union[ @@ -2572,15 +4878,15 @@ async def workflow_run_get_shape( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> WorkflowRunShape: - """Get workflow run + ) -> ScheduledWorkflows: + """Get scheduled workflow run - Get a workflow run for a tenant + Get a scheduled workflow run for a tenant :param tenant: The tenant id (required) :type tenant: str - :param workflow_run: The workflow run id (required) - :type workflow_run: str + :param scheduled_workflow_run: The scheduled workflow id (required) + :type scheduled_workflow_run: 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 @@ -2603,9 +4909,9 @@ async def workflow_run_get_shape( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_run_get_shape_serialize( + _param = self._workflow_scheduled_get_serialize( tenant=tenant, - workflow_run=workflow_run, + scheduled_workflow_run=scheduled_workflow_run, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2613,9 +4919,10 @@ async def workflow_run_get_shape( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowRunShape", + "200": "ScheduledWorkflows", "400": "APIErrors", "403": "APIErrors", + "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -2627,7 +4934,7 @@ async def workflow_run_get_shape( ).data @validate_call - async def workflow_run_get_shape_with_http_info( + async def workflow_scheduled_get_with_http_info( self, tenant: Annotated[ str, @@ -2635,13 +4942,13 @@ async def workflow_run_get_shape_with_http_info( min_length=36, strict=True, max_length=36, description="The tenant id" ), ], - workflow_run: Annotated[ + scheduled_workflow_run: Annotated[ str, Field( min_length=36, strict=True, max_length=36, - description="The workflow run id", + description="The scheduled workflow id", ), ], _request_timeout: Union[ @@ -2655,15 +4962,15 @@ async def workflow_run_get_shape_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[WorkflowRunShape]: - """Get workflow run + ) -> ApiResponse[ScheduledWorkflows]: + """Get scheduled workflow run - Get a workflow run for a tenant + Get a scheduled workflow run for a tenant :param tenant: The tenant id (required) :type tenant: str - :param workflow_run: The workflow run id (required) - :type workflow_run: str + :param scheduled_workflow_run: The scheduled workflow id (required) + :type scheduled_workflow_run: 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 @@ -2686,9 +4993,9 @@ async def workflow_run_get_shape_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_run_get_shape_serialize( + _param = self._workflow_scheduled_get_serialize( tenant=tenant, - workflow_run=workflow_run, + scheduled_workflow_run=scheduled_workflow_run, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2696,9 +5003,10 @@ async def workflow_run_get_shape_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowRunShape", + "200": "ScheduledWorkflows", "400": "APIErrors", "403": "APIErrors", + "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout @@ -2710,7 +5018,7 @@ async def workflow_run_get_shape_with_http_info( ) @validate_call - async def workflow_run_get_shape_without_preload_content( + async def workflow_scheduled_get_without_preload_content( self, tenant: Annotated[ str, @@ -2718,13 +5026,13 @@ async def workflow_run_get_shape_without_preload_content( min_length=36, strict=True, max_length=36, description="The tenant id" ), ], - workflow_run: Annotated[ + scheduled_workflow_run: Annotated[ str, Field( min_length=36, strict=True, max_length=36, - description="The workflow run id", + description="The scheduled workflow id", ), ], _request_timeout: Union[ @@ -2739,14 +5047,14 @@ async def workflow_run_get_shape_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get workflow run + """Get scheduled workflow run - Get a workflow run for a tenant + Get a scheduled workflow run for a tenant :param tenant: The tenant id (required) :type tenant: str - :param workflow_run: The workflow run id (required) - :type workflow_run: str + :param scheduled_workflow_run: The scheduled workflow id (required) + :type scheduled_workflow_run: 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 @@ -2769,9 +5077,9 @@ async def workflow_run_get_shape_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_run_get_shape_serialize( + _param = self._workflow_scheduled_get_serialize( tenant=tenant, - workflow_run=workflow_run, + scheduled_workflow_run=scheduled_workflow_run, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2779,19 +5087,20 @@ async def workflow_run_get_shape_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowRunShape", + "200": "ScheduledWorkflows", "400": "APIErrors", "403": "APIErrors", + "404": "APIErrors", } response_data = await self.api_client.call_api( *_param, _request_timeout=_request_timeout ) return response_data.response - def _workflow_run_get_shape_serialize( + def _workflow_scheduled_get_serialize( self, tenant, - workflow_run, + scheduled_workflow_run, _request_auth, _content_type, _headers, @@ -2814,8 +5123,8 @@ def _workflow_run_get_shape_serialize( # process the path parameters if tenant is not None: _path_params["tenant"] = tenant - if workflow_run is not None: - _path_params["workflow-run"] = workflow_run + if scheduled_workflow_run is not None: + _path_params["scheduled-workflow-run"] = scheduled_workflow_run # process the query parameters # process the header parameters # process the form parameters @@ -2832,7 +5141,7 @@ def _workflow_run_get_shape_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}/shape", + resource_path="/api/v1/tenants/{tenant}/workflows/scheduled/{scheduled-workflow-run}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -2846,7 +5155,7 @@ def _workflow_run_get_shape_serialize( ) @validate_call - async def workflow_run_list( + async def workflow_scheduled_list( self, tenant: Annotated[ str, @@ -2860,9 +5169,13 @@ async def workflow_run_list( limit: Annotated[ Optional[StrictInt], Field(description="The number to limit by") ] = None, - event_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The event id to get runs for."), + order_by_field: Annotated[ + Optional[ScheduledWorkflowsOrderByField], + Field(description="The order by field"), + ] = None, + order_by_direction: Annotated[ + Optional[WorkflowRunOrderByDirection], + Field(description="The order by direction"), ] = None, workflow_id: Annotated[ Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], @@ -2876,40 +5189,13 @@ async def workflow_run_list( Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], Field(description="The parent step run id"), ] = None, - statuses: Annotated[ - Optional[List[WorkflowRunStatus]], - Field(description="A list of workflow run statuses to filter by"), - ] = None, - kinds: Annotated[ - Optional[List[WorkflowKind]], - Field(description="A list of workflow kinds to filter by"), - ] = None, additional_metadata: Annotated[ Optional[List[StrictStr]], Field(description="A list of metadata key value pairs to filter by"), ] = None, - created_after: Annotated[ - Optional[datetime], - Field(description="The time after the workflow run was created"), - ] = None, - created_before: Annotated[ - Optional[datetime], - Field(description="The time before the workflow run was created"), - ] = None, - finished_after: Annotated[ - Optional[datetime], - Field(description="The time after the workflow run was finished"), - ] = None, - finished_before: Annotated[ - Optional[datetime], - Field(description="The time before the workflow run was finished"), - ] = None, - order_by_field: Annotated[ - Optional[WorkflowRunOrderByField], Field(description="The order by field") - ] = None, - order_by_direction: Annotated[ - Optional[WorkflowRunOrderByDirection], - Field(description="The order by direction"), + statuses: Annotated[ + Optional[List[ScheduledRunStatus]], + Field(description="A list of scheduled run statuses to filter by"), ] = None, _request_timeout: Union[ None, @@ -2922,10 +5208,10 @@ async def workflow_run_list( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> WorkflowRunList: - """Get workflow runs + ) -> ScheduledWorkflowsList: + """Get scheduled workflow runs - Get all workflow runs for a tenant + Get all scheduled workflow runs for a tenant :param tenant: The tenant id (required) :type tenant: str @@ -2933,32 +5219,20 @@ async def workflow_run_list( :type offset: int :param limit: The number to limit by :type limit: int - :param event_id: The event id to get runs for. - :type event_id: str + :param order_by_field: The order by field + :type order_by_field: ScheduledWorkflowsOrderByField + :param order_by_direction: The order by direction + :type order_by_direction: WorkflowRunOrderByDirection :param workflow_id: The workflow id to get runs for. :type workflow_id: str :param parent_workflow_run_id: The parent workflow run id :type parent_workflow_run_id: str :param parent_step_run_id: The parent step run id :type parent_step_run_id: str - :param statuses: A list of workflow run statuses to filter by - :type statuses: List[WorkflowRunStatus] - :param kinds: A list of workflow kinds to filter by - :type kinds: List[WorkflowKind] :param additional_metadata: A list of metadata key value pairs to filter by :type additional_metadata: List[str] - :param created_after: The time after the workflow run was created - :type created_after: datetime - :param created_before: The time before the workflow run was created - :type created_before: datetime - :param finished_after: The time after the workflow run was finished - :type finished_after: datetime - :param finished_before: The time before the workflow run was finished - :type finished_before: datetime - :param order_by_field: The order by field - :type order_by_field: WorkflowRunOrderByField - :param order_by_direction: The order by direction - :type order_by_direction: WorkflowRunOrderByDirection + :param statuses: A list of scheduled run statuses to filter by + :type statuses: List[ScheduledRunStatus] :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 @@ -2981,23 +5255,17 @@ async def workflow_run_list( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_run_list_serialize( + _param = self._workflow_scheduled_list_serialize( tenant=tenant, offset=offset, limit=limit, - event_id=event_id, + order_by_field=order_by_field, + order_by_direction=order_by_direction, workflow_id=workflow_id, parent_workflow_run_id=parent_workflow_run_id, parent_step_run_id=parent_step_run_id, - statuses=statuses, - kinds=kinds, additional_metadata=additional_metadata, - created_after=created_after, - created_before=created_before, - finished_after=finished_after, - finished_before=finished_before, - order_by_field=order_by_field, - order_by_direction=order_by_direction, + statuses=statuses, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -3005,7 +5273,7 @@ async def workflow_run_list( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowRunList", + "200": "ScheduledWorkflowsList", "400": "APIErrors", "403": "APIErrors", } @@ -3019,7 +5287,7 @@ async def workflow_run_list( ).data @validate_call - async def workflow_run_list_with_http_info( + async def workflow_scheduled_list_with_http_info( self, tenant: Annotated[ str, @@ -3033,9 +5301,13 @@ async def workflow_run_list_with_http_info( limit: Annotated[ Optional[StrictInt], Field(description="The number to limit by") ] = None, - event_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The event id to get runs for."), + order_by_field: Annotated[ + Optional[ScheduledWorkflowsOrderByField], + Field(description="The order by field"), + ] = None, + order_by_direction: Annotated[ + Optional[WorkflowRunOrderByDirection], + Field(description="The order by direction"), ] = None, workflow_id: Annotated[ Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], @@ -3049,40 +5321,13 @@ async def workflow_run_list_with_http_info( Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], Field(description="The parent step run id"), ] = None, - statuses: Annotated[ - Optional[List[WorkflowRunStatus]], - Field(description="A list of workflow run statuses to filter by"), - ] = None, - kinds: Annotated[ - Optional[List[WorkflowKind]], - Field(description="A list of workflow kinds to filter by"), - ] = None, additional_metadata: Annotated[ Optional[List[StrictStr]], Field(description="A list of metadata key value pairs to filter by"), ] = None, - created_after: Annotated[ - Optional[datetime], - Field(description="The time after the workflow run was created"), - ] = None, - created_before: Annotated[ - Optional[datetime], - Field(description="The time before the workflow run was created"), - ] = None, - finished_after: Annotated[ - Optional[datetime], - Field(description="The time after the workflow run was finished"), - ] = None, - finished_before: Annotated[ - Optional[datetime], - Field(description="The time before the workflow run was finished"), - ] = None, - order_by_field: Annotated[ - Optional[WorkflowRunOrderByField], Field(description="The order by field") - ] = None, - order_by_direction: Annotated[ - Optional[WorkflowRunOrderByDirection], - Field(description="The order by direction"), + statuses: Annotated[ + Optional[List[ScheduledRunStatus]], + Field(description="A list of scheduled run statuses to filter by"), ] = None, _request_timeout: Union[ None, @@ -3095,10 +5340,10 @@ async def workflow_run_list_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[WorkflowRunList]: - """Get workflow runs + ) -> ApiResponse[ScheduledWorkflowsList]: + """Get scheduled workflow runs - Get all workflow runs for a tenant + Get all scheduled workflow runs for a tenant :param tenant: The tenant id (required) :type tenant: str @@ -3106,32 +5351,20 @@ async def workflow_run_list_with_http_info( :type offset: int :param limit: The number to limit by :type limit: int - :param event_id: The event id to get runs for. - :type event_id: str + :param order_by_field: The order by field + :type order_by_field: ScheduledWorkflowsOrderByField + :param order_by_direction: The order by direction + :type order_by_direction: WorkflowRunOrderByDirection :param workflow_id: The workflow id to get runs for. :type workflow_id: str :param parent_workflow_run_id: The parent workflow run id :type parent_workflow_run_id: str :param parent_step_run_id: The parent step run id :type parent_step_run_id: str - :param statuses: A list of workflow run statuses to filter by - :type statuses: List[WorkflowRunStatus] - :param kinds: A list of workflow kinds to filter by - :type kinds: List[WorkflowKind] :param additional_metadata: A list of metadata key value pairs to filter by :type additional_metadata: List[str] - :param created_after: The time after the workflow run was created - :type created_after: datetime - :param created_before: The time before the workflow run was created - :type created_before: datetime - :param finished_after: The time after the workflow run was finished - :type finished_after: datetime - :param finished_before: The time before the workflow run was finished - :type finished_before: datetime - :param order_by_field: The order by field - :type order_by_field: WorkflowRunOrderByField - :param order_by_direction: The order by direction - :type order_by_direction: WorkflowRunOrderByDirection + :param statuses: A list of scheduled run statuses to filter by + :type statuses: List[ScheduledRunStatus] :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 @@ -3154,23 +5387,17 @@ async def workflow_run_list_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_run_list_serialize( + _param = self._workflow_scheduled_list_serialize( tenant=tenant, offset=offset, limit=limit, - event_id=event_id, + order_by_field=order_by_field, + order_by_direction=order_by_direction, workflow_id=workflow_id, parent_workflow_run_id=parent_workflow_run_id, parent_step_run_id=parent_step_run_id, - statuses=statuses, - kinds=kinds, additional_metadata=additional_metadata, - created_after=created_after, - created_before=created_before, - finished_after=finished_after, - finished_before=finished_before, - order_by_field=order_by_field, - order_by_direction=order_by_direction, + statuses=statuses, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -3178,7 +5405,7 @@ async def workflow_run_list_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowRunList", + "200": "ScheduledWorkflowsList", "400": "APIErrors", "403": "APIErrors", } @@ -3192,7 +5419,7 @@ async def workflow_run_list_with_http_info( ) @validate_call - async def workflow_run_list_without_preload_content( + async def workflow_scheduled_list_without_preload_content( self, tenant: Annotated[ str, @@ -3206,9 +5433,13 @@ async def workflow_run_list_without_preload_content( limit: Annotated[ Optional[StrictInt], Field(description="The number to limit by") ] = None, - event_id: Annotated[ - Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], - Field(description="The event id to get runs for."), + order_by_field: Annotated[ + Optional[ScheduledWorkflowsOrderByField], + Field(description="The order by field"), + ] = None, + order_by_direction: Annotated[ + Optional[WorkflowRunOrderByDirection], + Field(description="The order by direction"), ] = None, workflow_id: Annotated[ Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], @@ -3222,40 +5453,13 @@ async def workflow_run_list_without_preload_content( Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]], Field(description="The parent step run id"), ] = None, - statuses: Annotated[ - Optional[List[WorkflowRunStatus]], - Field(description="A list of workflow run statuses to filter by"), - ] = None, - kinds: Annotated[ - Optional[List[WorkflowKind]], - Field(description="A list of workflow kinds to filter by"), - ] = None, additional_metadata: Annotated[ Optional[List[StrictStr]], Field(description="A list of metadata key value pairs to filter by"), ] = None, - created_after: Annotated[ - Optional[datetime], - Field(description="The time after the workflow run was created"), - ] = None, - created_before: Annotated[ - Optional[datetime], - Field(description="The time before the workflow run was created"), - ] = None, - finished_after: Annotated[ - Optional[datetime], - Field(description="The time after the workflow run was finished"), - ] = None, - finished_before: Annotated[ - Optional[datetime], - Field(description="The time before the workflow run was finished"), - ] = None, - order_by_field: Annotated[ - Optional[WorkflowRunOrderByField], Field(description="The order by field") - ] = None, - order_by_direction: Annotated[ - Optional[WorkflowRunOrderByDirection], - Field(description="The order by direction"), + statuses: Annotated[ + Optional[List[ScheduledRunStatus]], + Field(description="A list of scheduled run statuses to filter by"), ] = None, _request_timeout: Union[ None, @@ -3269,9 +5473,9 @@ async def workflow_run_list_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get workflow runs + """Get scheduled workflow runs - Get all workflow runs for a tenant + Get all scheduled workflow runs for a tenant :param tenant: The tenant id (required) :type tenant: str @@ -3279,32 +5483,20 @@ async def workflow_run_list_without_preload_content( :type offset: int :param limit: The number to limit by :type limit: int - :param event_id: The event id to get runs for. - :type event_id: str + :param order_by_field: The order by field + :type order_by_field: ScheduledWorkflowsOrderByField + :param order_by_direction: The order by direction + :type order_by_direction: WorkflowRunOrderByDirection :param workflow_id: The workflow id to get runs for. :type workflow_id: str :param parent_workflow_run_id: The parent workflow run id :type parent_workflow_run_id: str :param parent_step_run_id: The parent step run id :type parent_step_run_id: str - :param statuses: A list of workflow run statuses to filter by - :type statuses: List[WorkflowRunStatus] - :param kinds: A list of workflow kinds to filter by - :type kinds: List[WorkflowKind] :param additional_metadata: A list of metadata key value pairs to filter by :type additional_metadata: List[str] - :param created_after: The time after the workflow run was created - :type created_after: datetime - :param created_before: The time before the workflow run was created - :type created_before: datetime - :param finished_after: The time after the workflow run was finished - :type finished_after: datetime - :param finished_before: The time before the workflow run was finished - :type finished_before: datetime - :param order_by_field: The order by field - :type order_by_field: WorkflowRunOrderByField - :param order_by_direction: The order by direction - :type order_by_direction: WorkflowRunOrderByDirection + :param statuses: A list of scheduled run statuses to filter by + :type statuses: List[ScheduledRunStatus] :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 @@ -3327,23 +5519,17 @@ async def workflow_run_list_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._workflow_run_list_serialize( + _param = self._workflow_scheduled_list_serialize( tenant=tenant, offset=offset, limit=limit, - event_id=event_id, + order_by_field=order_by_field, + order_by_direction=order_by_direction, workflow_id=workflow_id, parent_workflow_run_id=parent_workflow_run_id, parent_step_run_id=parent_step_run_id, - statuses=statuses, - kinds=kinds, additional_metadata=additional_metadata, - created_after=created_after, - created_before=created_before, - finished_after=finished_after, - finished_before=finished_before, - order_by_field=order_by_field, - order_by_direction=order_by_direction, + statuses=statuses, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -3351,7 +5537,7 @@ async def workflow_run_list_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkflowRunList", + "200": "ScheduledWorkflowsList", "400": "APIErrors", "403": "APIErrors", } @@ -3360,24 +5546,18 @@ async def workflow_run_list_without_preload_content( ) return response_data.response - def _workflow_run_list_serialize( + def _workflow_scheduled_list_serialize( self, tenant, offset, limit, - event_id, + order_by_field, + order_by_direction, workflow_id, parent_workflow_run_id, parent_step_run_id, - statuses, - kinds, additional_metadata, - created_after, - created_before, - finished_after, - finished_before, - order_by_field, - order_by_direction, + statuses, _request_auth, _content_type, _headers, @@ -3387,9 +5567,8 @@ def _workflow_run_list_serialize( _host = None _collection_formats: Dict[str, str] = { - "statuses": "multi", - "kinds": "multi", "additionalMetadata": "multi", + "statuses": "multi", } _path_params: Dict[str, str] = {} @@ -3413,9 +5592,13 @@ def _workflow_run_list_serialize( _query_params.append(("limit", limit)) - if event_id is not None: + if order_by_field is not None: - _query_params.append(("eventId", event_id)) + _query_params.append(("orderByField", order_by_field.value)) + + if order_by_direction is not None: + + _query_params.append(("orderByDirection", order_by_direction.value)) if workflow_id is not None: @@ -3429,73 +5612,13 @@ def _workflow_run_list_serialize( _query_params.append(("parentStepRunId", parent_step_run_id)) - if statuses is not None: - - _query_params.append(("statuses", statuses)) - - if kinds is not None: - - _query_params.append(("kinds", kinds)) - if additional_metadata is not None: _query_params.append(("additionalMetadata", additional_metadata)) - if created_after is not None: - if isinstance(created_after, datetime): - _query_params.append( - ( - "createdAfter", - created_after.isoformat(), - ) - ) - else: - _query_params.append(("createdAfter", created_after)) - - if created_before is not None: - if isinstance(created_before, datetime): - _query_params.append( - ( - "createdBefore", - created_before.isoformat(), - ) - ) - else: - _query_params.append(("createdBefore", created_before)) - - if finished_after is not None: - if isinstance(finished_after, datetime): - _query_params.append( - ( - "finishedAfter", - finished_after.strftime( - self.api_client.configuration.datetime_format - ), - ) - ) - else: - _query_params.append(("finishedAfter", finished_after)) - - if finished_before is not None: - if isinstance(finished_before, datetime): - _query_params.append( - ( - "finishedBefore", - finished_before.strftime( - self.api_client.configuration.datetime_format - ), - ) - ) - else: - _query_params.append(("finishedBefore", finished_before)) - - if order_by_field is not None: - - _query_params.append(("orderByField", order_by_field.value)) - - if order_by_direction is not None: + if statuses is not None: - _query_params.append(("orderByDirection", order_by_direction.value)) + _query_params.append(("statuses", statuses)) # process the header parameters # process the form parameters @@ -3512,7 +5635,7 @@ def _workflow_run_list_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/api/v1/tenants/{tenant}/workflows/runs", + resource_path="/api/v1/tenants/{tenant}/workflows/scheduled", path_params=_path_params, query_params=_query_params, header_params=_header_params, diff --git a/hatchet_sdk/clients/rest/api/workflow_run_api.py b/hatchet_sdk/clients/rest/api/workflow_run_api.py index d0e1aeb4..e7feb9f4 100644 --- a/hatchet_sdk/clients/rest/api/workflow_run_api.py +++ b/hatchet_sdk/clients/rest/api/workflow_run_api.py @@ -19,6 +19,10 @@ from hatchet_sdk.clients.rest.api_client import ApiClient, RequestSerialized from hatchet_sdk.clients.rest.api_response import ApiResponse +from hatchet_sdk.clients.rest.models.create_cron_workflow_trigger_request import ( + CreateCronWorkflowTriggerRequest, +) +from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows from hatchet_sdk.clients.rest.models.event_update_cancel200_response import ( EventUpdateCancel200Response, ) @@ -28,6 +32,10 @@ from hatchet_sdk.clients.rest.models.replay_workflow_runs_response import ( ReplayWorkflowRunsResponse, ) +from hatchet_sdk.clients.rest.models.schedule_workflow_run_request import ( + ScheduleWorkflowRunRequest, +) +from hatchet_sdk.clients.rest.models.scheduled_workflows import ScheduledWorkflows from hatchet_sdk.clients.rest.models.trigger_workflow_run_request import ( TriggerWorkflowRunRequest, ) @@ -50,6 +58,642 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client + @validate_call + async def cron_workflow_trigger_create( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow: Annotated[StrictStr, Field(description="The workflow name")], + create_cron_workflow_trigger_request: Annotated[ + CreateCronWorkflowTriggerRequest, + Field(description="The input to the cron job workflow trigger"), + ], + _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, + ) -> CronWorkflows: + """Create cron job workflow trigger + + Create a new cron job workflow trigger for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow: The workflow name (required) + :type workflow: str + :param create_cron_workflow_trigger_request: The input to the cron job workflow trigger (required) + :type create_cron_workflow_trigger_request: CreateCronWorkflowTriggerRequest + :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._cron_workflow_trigger_create_serialize( + tenant=tenant, + workflow=workflow, + create_cron_workflow_trigger_request=create_cron_workflow_trigger_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CronWorkflows", + "400": "APIErrors", + "403": "APIErrors", + "404": "APIErrors", + "429": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def cron_workflow_trigger_create_with_http_info( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow: Annotated[StrictStr, Field(description="The workflow name")], + create_cron_workflow_trigger_request: Annotated[ + CreateCronWorkflowTriggerRequest, + Field(description="The input to the cron job workflow trigger"), + ], + _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[CronWorkflows]: + """Create cron job workflow trigger + + Create a new cron job workflow trigger for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow: The workflow name (required) + :type workflow: str + :param create_cron_workflow_trigger_request: The input to the cron job workflow trigger (required) + :type create_cron_workflow_trigger_request: CreateCronWorkflowTriggerRequest + :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._cron_workflow_trigger_create_serialize( + tenant=tenant, + workflow=workflow, + create_cron_workflow_trigger_request=create_cron_workflow_trigger_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CronWorkflows", + "400": "APIErrors", + "403": "APIErrors", + "404": "APIErrors", + "429": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def cron_workflow_trigger_create_without_preload_content( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow: Annotated[StrictStr, Field(description="The workflow name")], + create_cron_workflow_trigger_request: Annotated[ + CreateCronWorkflowTriggerRequest, + Field(description="The input to the cron job workflow trigger"), + ], + _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 cron job workflow trigger + + Create a new cron job workflow trigger for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow: The workflow name (required) + :type workflow: str + :param create_cron_workflow_trigger_request: The input to the cron job workflow trigger (required) + :type create_cron_workflow_trigger_request: CreateCronWorkflowTriggerRequest + :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._cron_workflow_trigger_create_serialize( + tenant=tenant, + workflow=workflow, + create_cron_workflow_trigger_request=create_cron_workflow_trigger_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CronWorkflows", + "400": "APIErrors", + "403": "APIErrors", + "404": "APIErrors", + "429": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _cron_workflow_trigger_create_serialize( + self, + tenant, + workflow, + create_cron_workflow_trigger_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if tenant is not None: + _path_params["tenant"] = tenant + if workflow is not None: + _path_params["workflow"] = workflow + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_cron_workflow_trigger_request is not None: + _body_params = create_cron_workflow_trigger_request + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type( + ["application/json"] + ) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] + + return self.api_client.param_serialize( + method="POST", + resource_path="/api/v1/tenants/{tenant}/workflows/{workflow}/crons", + 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 + async def scheduled_workflow_run_create( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow: Annotated[StrictStr, Field(description="The workflow name")], + schedule_workflow_run_request: Annotated[ + ScheduleWorkflowRunRequest, + Field(description="The input to the scheduled workflow run"), + ], + _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, + ) -> ScheduledWorkflows: + """Trigger workflow run + + Schedule a new workflow run for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow: The workflow name (required) + :type workflow: str + :param schedule_workflow_run_request: The input to the scheduled workflow run (required) + :type schedule_workflow_run_request: ScheduleWorkflowRunRequest + :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._scheduled_workflow_run_create_serialize( + tenant=tenant, + workflow=workflow, + schedule_workflow_run_request=schedule_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": "ScheduledWorkflows", + "400": "APIErrors", + "403": "APIErrors", + "404": "APIErrors", + "429": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def scheduled_workflow_run_create_with_http_info( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow: Annotated[StrictStr, Field(description="The workflow name")], + schedule_workflow_run_request: Annotated[ + ScheduleWorkflowRunRequest, + Field(description="The input to the scheduled workflow run"), + ], + _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[ScheduledWorkflows]: + """Trigger workflow run + + Schedule a new workflow run for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow: The workflow name (required) + :type workflow: str + :param schedule_workflow_run_request: The input to the scheduled workflow run (required) + :type schedule_workflow_run_request: ScheduleWorkflowRunRequest + :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._scheduled_workflow_run_create_serialize( + tenant=tenant, + workflow=workflow, + schedule_workflow_run_request=schedule_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": "ScheduledWorkflows", + "400": "APIErrors", + "403": "APIErrors", + "404": "APIErrors", + "429": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def scheduled_workflow_run_create_without_preload_content( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + workflow: Annotated[StrictStr, Field(description="The workflow name")], + schedule_workflow_run_request: Annotated[ + ScheduleWorkflowRunRequest, + Field(description="The input to the scheduled workflow run"), + ], + _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: + """Trigger workflow run + + Schedule a new workflow run for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param workflow: The workflow name (required) + :type workflow: str + :param schedule_workflow_run_request: The input to the scheduled workflow run (required) + :type schedule_workflow_run_request: ScheduleWorkflowRunRequest + :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._scheduled_workflow_run_create_serialize( + tenant=tenant, + workflow=workflow, + schedule_workflow_run_request=schedule_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": "ScheduledWorkflows", + "400": "APIErrors", + "403": "APIErrors", + "404": "APIErrors", + "429": "APIErrors", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _scheduled_workflow_run_create_serialize( + self, + tenant, + workflow, + schedule_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, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if tenant is not None: + _path_params["tenant"] = tenant + if workflow is not None: + _path_params["workflow"] = workflow + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if schedule_workflow_run_request is not None: + _body_params = schedule_workflow_run_request + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type( + ["application/json"] + ) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] + + return self.api_client.param_serialize( + method="POST", + resource_path="/api/v1/tenants/{tenant}/workflows/{workflow}/scheduled", + 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 async def workflow_run_cancel( self, diff --git a/hatchet_sdk/clients/rest/configuration.py b/hatchet_sdk/clients/rest/configuration.py index 03743d0b..635209d2 100644 --- a/hatchet_sdk/clients/rest/configuration.py +++ b/hatchet_sdk/clients/rest/configuration.py @@ -17,9 +17,10 @@ import logging import sys from logging import FileHandler -from typing import Optional +from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict import urllib3 +from typing_extensions import NotRequired, Self JSON_SCHEMA_VALIDATION_KEYWORDS = { "multipleOf", @@ -34,6 +35,107 @@ "minItems", } +ServerVariablesT = Dict[str, str] + +GenericAuthSetting = TypedDict( + "GenericAuthSetting", + { + "type": str, + "in": str, + "key": str, + "value": str, + }, +) + + +OAuth2AuthSetting = TypedDict( + "OAuth2AuthSetting", + { + "type": Literal["oauth2"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +APIKeyAuthSetting = TypedDict( + "APIKeyAuthSetting", + { + "type": Literal["api_key"], + "in": str, + "key": str, + "value": Optional[str], + }, +) + + +BasicAuthSetting = TypedDict( + "BasicAuthSetting", + { + "type": Literal["basic"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": Optional[str], + }, +) + + +BearerFormatAuthSetting = TypedDict( + "BearerFormatAuthSetting", + { + "type": Literal["bearer"], + "in": Literal["header"], + "format": Literal["JWT"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +BearerAuthSetting = TypedDict( + "BearerAuthSetting", + { + "type": Literal["bearer"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +HTTPSignatureAuthSetting = TypedDict( + "HTTPSignatureAuthSetting", + { + "type": Literal["http-signature"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": None, + }, +) + + +AuthSettings = TypedDict( + "AuthSettings", + { + "bearerAuth": BearerAuthSetting, + "cookieAuth": APIKeyAuthSetting, + }, + total=False, +) + + +class HostSettingVariable(TypedDict): + description: str + default_value: str + enum_values: List[str] + + +class HostSetting(TypedDict): + url: str + description: str + variables: NotRequired[Dict[str, HostSettingVariable]] + class Configuration: """This class contains various settings of the API client. @@ -88,25 +190,25 @@ class Configuration: Cookie: JSESSIONID abc123 """ - _default = None + _default: ClassVar[Optional[Self]] = None def __init__( self, - host=None, - api_key=None, - api_key_prefix=None, - username=None, - password=None, - access_token=None, - server_index=None, - server_variables=None, - server_operation_index=None, - server_operation_variables=None, - ignore_operation_servers=False, - ssl_ca_cert=None, - retries=None, + host: Optional[str] = None, + api_key: Optional[Dict[str, str]] = None, + api_key_prefix: Optional[Dict[str, str]] = None, + username: Optional[str] = None, + password: Optional[str] = None, + access_token: Optional[str] = None, + server_index: Optional[int] = None, + server_variables: Optional[ServerVariablesT] = None, + server_operation_index: Optional[Dict[int, int]] = None, + server_operation_variables: Optional[Dict[int, ServerVariablesT]] = None, + ignore_operation_servers: bool = False, + ssl_ca_cert: Optional[str] = None, + retries: Optional[int] = None, *, - debug: Optional[bool] = None + debug: Optional[bool] = None, ) -> None: """Constructor""" self._base_path = "http://localhost" if host is None else host @@ -227,7 +329,7 @@ def __init__( """date format """ - def __deepcopy__(self, memo): + def __deepcopy__(self, memo: Dict[int, Any]) -> Self: cls = self.__class__ result = cls.__new__(cls) memo[id(self)] = result @@ -241,11 +343,11 @@ def __deepcopy__(self, memo): result.debug = self.debug return result - def __setattr__(self, name, value): + def __setattr__(self, name: str, value: Any) -> None: object.__setattr__(self, name, value) @classmethod - def set_default(cls, default): + def set_default(cls, default: Optional[Self]) -> None: """Set default instance of configuration. It stores default configuration, which can be @@ -256,7 +358,7 @@ def set_default(cls, default): cls._default = default @classmethod - def get_default_copy(cls): + def get_default_copy(cls) -> Self: """Deprecated. Please use `get_default` instead. Deprecated. Please use `get_default` instead. @@ -266,7 +368,7 @@ def get_default_copy(cls): return cls.get_default() @classmethod - def get_default(cls): + def get_default(cls) -> Self: """Return the default configuration. This method returns newly created, based on default constructor, @@ -276,11 +378,11 @@ def get_default(cls): :return: The configuration object. """ if cls._default is None: - cls._default = Configuration() + cls._default = cls() return cls._default @property - def logger_file(self): + def logger_file(self) -> Optional[str]: """The logger file. If the logger_file is None, then add stream handler and remove file @@ -292,7 +394,7 @@ def logger_file(self): return self.__logger_file @logger_file.setter - def logger_file(self, value): + def logger_file(self, value: Optional[str]) -> None: """The logger file. If the logger_file is None, then add stream handler and remove file @@ -311,7 +413,7 @@ def logger_file(self, value): logger.addHandler(self.logger_file_handler) @property - def debug(self): + def debug(self) -> bool: """Debug status :param value: The debug status, True or False. @@ -320,7 +422,7 @@ def debug(self): return self.__debug @debug.setter - def debug(self, value): + def debug(self, value: bool) -> None: """Debug status :param value: The debug status, True or False. @@ -342,7 +444,7 @@ def debug(self, value): httplib.HTTPConnection.debuglevel = 0 @property - def logger_format(self): + def logger_format(self) -> str: """The logger format. The logger_formatter will be updated when sets logger_format. @@ -353,7 +455,7 @@ def logger_format(self): return self.__logger_format @logger_format.setter - def logger_format(self, value): + def logger_format(self, value: str) -> None: """The logger format. The logger_formatter will be updated when sets logger_format. @@ -364,7 +466,9 @@ def logger_format(self, value): self.__logger_format = value self.logger_formatter = logging.Formatter(self.__logger_format) - def get_api_key_with_prefix(self, identifier, alias=None): + def get_api_key_with_prefix( + self, identifier: str, alias: Optional[str] = None + ) -> Optional[str]: """Gets API key (with prefix if set). :param identifier: The identifier of apiKey. @@ -383,7 +487,9 @@ def get_api_key_with_prefix(self, identifier, alias=None): else: return key - def get_basic_auth_token(self): + return None + + def get_basic_auth_token(self) -> Optional[str]: """Gets HTTP basic authentication header (string). :return: The token for basic HTTP authentication. @@ -398,12 +504,12 @@ def get_basic_auth_token(self): "authorization" ) - def auth_settings(self): + def auth_settings(self) -> AuthSettings: """Gets Auth Settings dict for api client. :return: The Auth Settings information dict. """ - auth = {} + auth: AuthSettings = {} if self.access_token is not None: auth["bearerAuth"] = { "type": "bearer", @@ -422,7 +528,7 @@ def auth_settings(self): } return auth - def to_debug_report(self): + def to_debug_report(self) -> str: """Gets the essential information for debugging. :return: The report for debugging. @@ -435,7 +541,7 @@ def to_debug_report(self): "SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version) ) - def get_host_settings(self): + def get_host_settings(self) -> List[HostSetting]: """Gets an array of host settings :return: An array of host settings @@ -447,7 +553,12 @@ def get_host_settings(self): } ] - def get_host_from_settings(self, index, variables=None, servers=None): + def get_host_from_settings( + self, + index: Optional[int], + variables: Optional[ServerVariablesT] = None, + servers: Optional[List[HostSetting]] = None, + ) -> str: """Gets host URL based on the index and variables :param index: array index of the host settings :param variables: hash of variable and the corresponding value @@ -487,14 +598,14 @@ def get_host_from_settings(self, index, variables=None, servers=None): return url @property - def host(self): + def host(self) -> str: """Return generated host.""" return self.get_host_from_settings( self.server_index, variables=self.server_variables ) @host.setter - def host(self, value): + def host(self, value: str) -> None: """Fix base path.""" self._base_path = value self.server_index = None diff --git a/hatchet_sdk/clients/rest/models/__init__.py b/hatchet_sdk/clients/rest/models/__init__.py index 9c550c2e..9a98f75a 100644 --- a/hatchet_sdk/clients/rest/models/__init__.py +++ b/hatchet_sdk/clients/rest/models/__init__.py @@ -37,6 +37,9 @@ from hatchet_sdk.clients.rest.models.create_api_token_response import ( CreateAPITokenResponse, ) +from hatchet_sdk.clients.rest.models.create_cron_workflow_trigger_request import ( + CreateCronWorkflowTriggerRequest, +) from hatchet_sdk.clients.rest.models.create_event_request import CreateEventRequest from hatchet_sdk.clients.rest.models.create_pull_request_from_step_run import ( CreatePullRequestFromStepRun, @@ -51,6 +54,11 @@ CreateTenantInviteRequest, ) from hatchet_sdk.clients.rest.models.create_tenant_request import CreateTenantRequest +from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows +from hatchet_sdk.clients.rest.models.cron_workflows_list import CronWorkflowsList +from hatchet_sdk.clients.rest.models.cron_workflows_order_by_field import ( + CronWorkflowsOrderByField, +) from hatchet_sdk.clients.rest.models.event import Event from hatchet_sdk.clients.rest.models.event_data import EventData from hatchet_sdk.clients.rest.models.event_key_list import EventKeyList @@ -108,6 +116,17 @@ ReplayWorkflowRunsResponse, ) from hatchet_sdk.clients.rest.models.rerun_step_run_request import RerunStepRunRequest +from hatchet_sdk.clients.rest.models.schedule_workflow_run_request import ( + ScheduleWorkflowRunRequest, +) +from hatchet_sdk.clients.rest.models.scheduled_run_status import ScheduledRunStatus +from hatchet_sdk.clients.rest.models.scheduled_workflows import ScheduledWorkflows +from hatchet_sdk.clients.rest.models.scheduled_workflows_list import ( + ScheduledWorkflowsList, +) +from hatchet_sdk.clients.rest.models.scheduled_workflows_order_by_field import ( + ScheduledWorkflowsOrderByField, +) from hatchet_sdk.clients.rest.models.semaphore_slots import SemaphoreSlots from hatchet_sdk.clients.rest.models.slack_webhook import SlackWebhook from hatchet_sdk.clients.rest.models.sns_integration import SNSIntegration @@ -186,6 +205,8 @@ from hatchet_sdk.clients.rest.models.worker import Worker from hatchet_sdk.clients.rest.models.worker_label import WorkerLabel from hatchet_sdk.clients.rest.models.worker_list import WorkerList +from hatchet_sdk.clients.rest.models.worker_runtime_info import WorkerRuntimeInfo +from hatchet_sdk.clients.rest.models.worker_runtime_sdks import WorkerRuntimeSDKs from hatchet_sdk.clients.rest.models.workflow import Workflow from hatchet_sdk.clients.rest.models.workflow_concurrency import WorkflowConcurrency from hatchet_sdk.clients.rest.models.workflow_kind import WorkflowKind diff --git a/hatchet_sdk/clients/rest/models/create_cron_workflow_trigger_request.py b/hatchet_sdk/clients/rest/models/create_cron_workflow_trigger_request.py new file mode 100644 index 00000000..e2b49df0 --- /dev/null +++ b/hatchet_sdk/clients/rest/models/create_cron_workflow_trigger_request.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + Hatchet API + + The Hatchet API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Self + + +class CreateCronWorkflowTriggerRequest(BaseModel): + """ + CreateCronWorkflowTriggerRequest + """ # noqa: E501 + + input: Dict[str, Any] + additional_metadata: Dict[str, Any] = Field(alias="additionalMetadata") + cron_name: StrictStr = Field(alias="cronName") + cron_expression: StrictStr = Field(alias="cronExpression") + __properties: ClassVar[List[str]] = [ + "input", + "additionalMetadata", + "cronName", + "cronExpression", + ] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateCronWorkflowTriggerRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateCronWorkflowTriggerRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "input": obj.get("input"), + "additionalMetadata": obj.get("additionalMetadata"), + "cronName": obj.get("cronName"), + "cronExpression": obj.get("cronExpression"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/rest/models/cron_workflows.py b/hatchet_sdk/clients/rest/models/cron_workflows.py new file mode 100644 index 00000000..13f7ed3b --- /dev/null +++ b/hatchet_sdk/clients/rest/models/cron_workflows.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + Hatchet API + + The Hatchet API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictStr, + field_validator, +) +from typing_extensions import Self + +from hatchet_sdk.clients.rest.models.api_resource_meta import APIResourceMeta + + +class CronWorkflows(BaseModel): + """ + CronWorkflows + """ # noqa: E501 + + metadata: APIResourceMeta + tenant_id: StrictStr = Field(alias="tenantId") + workflow_version_id: StrictStr = Field(alias="workflowVersionId") + workflow_id: StrictStr = Field(alias="workflowId") + workflow_name: StrictStr = Field(alias="workflowName") + cron: StrictStr + name: Optional[StrictStr] = None + input: Optional[Dict[str, Any]] = None + additional_metadata: Optional[Dict[str, Any]] = Field( + default=None, alias="additionalMetadata" + ) + enabled: StrictBool + method: StrictStr + __properties: ClassVar[List[str]] = [ + "metadata", + "tenantId", + "workflowVersionId", + "workflowId", + "workflowName", + "cron", + "name", + "input", + "additionalMetadata", + "enabled", + "method", + ] + + @field_validator("method") + def method_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["DEFAULT", "API"]): + raise ValueError("must be one of enum values ('DEFAULT', 'API')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CronWorkflows from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of metadata + if self.metadata: + _dict["metadata"] = self.metadata.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CronWorkflows from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "metadata": ( + APIResourceMeta.from_dict(obj["metadata"]) + if obj.get("metadata") is not None + else None + ), + "tenantId": obj.get("tenantId"), + "workflowVersionId": obj.get("workflowVersionId"), + "workflowId": obj.get("workflowId"), + "workflowName": obj.get("workflowName"), + "cron": obj.get("cron"), + "name": obj.get("name"), + "input": obj.get("input"), + "additionalMetadata": obj.get("additionalMetadata"), + "enabled": obj.get("enabled"), + "method": obj.get("method"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/rest/models/cron_workflows_list.py b/hatchet_sdk/clients/rest/models/cron_workflows_list.py new file mode 100644 index 00000000..b0ab6967 --- /dev/null +++ b/hatchet_sdk/clients/rest/models/cron_workflows_list.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + Hatchet API + + The Hatchet API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict +from typing_extensions import Self + +from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows +from hatchet_sdk.clients.rest.models.pagination_response import PaginationResponse + + +class CronWorkflowsList(BaseModel): + """ + CronWorkflowsList + """ # noqa: E501 + + rows: Optional[List[CronWorkflows]] = None + pagination: Optional[PaginationResponse] = None + __properties: ClassVar[List[str]] = ["rows", "pagination"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CronWorkflowsList from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in rows (list) + _items = [] + if self.rows: + for _item_rows in self.rows: + if _item_rows: + _items.append(_item_rows.to_dict()) + _dict["rows"] = _items + # override the default output from pydantic by calling `to_dict()` of pagination + if self.pagination: + _dict["pagination"] = self.pagination.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CronWorkflowsList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "rows": ( + [CronWorkflows.from_dict(_item) for _item in obj["rows"]] + if obj.get("rows") is not None + else None + ), + "pagination": ( + PaginationResponse.from_dict(obj["pagination"]) + if obj.get("pagination") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/rest/models/cron_workflows_order_by_field.py b/hatchet_sdk/clients/rest/models/cron_workflows_order_by_field.py new file mode 100644 index 00000000..b95d199a --- /dev/null +++ b/hatchet_sdk/clients/rest/models/cron_workflows_order_by_field.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Hatchet API + + The Hatchet API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations + +import json +from enum import Enum + +from typing_extensions import Self + + +class CronWorkflowsOrderByField(str, Enum): + """ + CronWorkflowsOrderByField + """ + + """ + allowed enum values + """ + NAME = "name" + CREATEDAT = "createdAt" + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of CronWorkflowsOrderByField from a JSON string""" + return cls(json.loads(json_str)) diff --git a/hatchet_sdk/clients/rest/models/schedule_workflow_run_request.py b/hatchet_sdk/clients/rest/models/schedule_workflow_run_request.py new file mode 100644 index 00000000..c5b4753f --- /dev/null +++ b/hatchet_sdk/clients/rest/models/schedule_workflow_run_request.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + Hatchet API + + The Hatchet API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field +from typing_extensions import Self + + +class ScheduleWorkflowRunRequest(BaseModel): + """ + ScheduleWorkflowRunRequest + """ # noqa: E501 + + input: Dict[str, Any] + additional_metadata: Dict[str, Any] = Field(alias="additionalMetadata") + trigger_at: datetime = Field(alias="triggerAt") + __properties: ClassVar[List[str]] = ["input", "additionalMetadata", "triggerAt"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ScheduleWorkflowRunRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ScheduleWorkflowRunRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "input": obj.get("input"), + "additionalMetadata": obj.get("additionalMetadata"), + "triggerAt": obj.get("triggerAt"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/rest/models/scheduled_run_status.py b/hatchet_sdk/clients/rest/models/scheduled_run_status.py new file mode 100644 index 00000000..f0f2a17f --- /dev/null +++ b/hatchet_sdk/clients/rest/models/scheduled_run_status.py @@ -0,0 +1,42 @@ +# coding: utf-8 + +""" + Hatchet API + + The Hatchet API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations + +import json +from enum import Enum + +from typing_extensions import Self + + +class ScheduledRunStatus(str, Enum): + """ + ScheduledRunStatus + """ + + """ + allowed enum values + """ + PENDING = "PENDING" + RUNNING = "RUNNING" + SUCCEEDED = "SUCCEEDED" + FAILED = "FAILED" + CANCELLED = "CANCELLED" + QUEUED = "QUEUED" + SCHEDULED = "SCHEDULED" + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of ScheduledRunStatus from a JSON string""" + return cls(json.loads(json_str)) diff --git a/hatchet_sdk/clients/rest/models/scheduled_workflows.py b/hatchet_sdk/clients/rest/models/scheduled_workflows.py new file mode 100644 index 00000000..3b76fc5e --- /dev/null +++ b/hatchet_sdk/clients/rest/models/scheduled_workflows.py @@ -0,0 +1,153 @@ +# coding: utf-8 + +""" + Hatchet API + + The Hatchet API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing_extensions import Annotated, Self + +from hatchet_sdk.clients.rest.models.api_resource_meta import APIResourceMeta +from hatchet_sdk.clients.rest.models.workflow_run_status import WorkflowRunStatus + + +class ScheduledWorkflows(BaseModel): + """ + ScheduledWorkflows + """ # noqa: E501 + + metadata: APIResourceMeta + tenant_id: StrictStr = Field(alias="tenantId") + workflow_version_id: StrictStr = Field(alias="workflowVersionId") + workflow_id: StrictStr = Field(alias="workflowId") + workflow_name: StrictStr = Field(alias="workflowName") + trigger_at: datetime = Field(alias="triggerAt") + input: Optional[Dict[str, Any]] = None + additional_metadata: Optional[Dict[str, Any]] = Field( + default=None, alias="additionalMetadata" + ) + workflow_run_created_at: Optional[datetime] = Field( + default=None, alias="workflowRunCreatedAt" + ) + workflow_run_name: Optional[StrictStr] = Field( + default=None, alias="workflowRunName" + ) + workflow_run_status: Optional[WorkflowRunStatus] = Field( + default=None, alias="workflowRunStatus" + ) + workflow_run_id: Optional[ + Annotated[str, Field(min_length=36, strict=True, max_length=36)] + ] = Field(default=None, alias="workflowRunId") + method: StrictStr + __properties: ClassVar[List[str]] = [ + "metadata", + "tenantId", + "workflowVersionId", + "workflowId", + "workflowName", + "triggerAt", + "input", + "additionalMetadata", + "workflowRunCreatedAt", + "workflowRunName", + "workflowRunStatus", + "workflowRunId", + "method", + ] + + @field_validator("method") + def method_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["DEFAULT", "API"]): + raise ValueError("must be one of enum values ('DEFAULT', 'API')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ScheduledWorkflows from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of metadata + if self.metadata: + _dict["metadata"] = self.metadata.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ScheduledWorkflows from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "metadata": ( + APIResourceMeta.from_dict(obj["metadata"]) + if obj.get("metadata") is not None + else None + ), + "tenantId": obj.get("tenantId"), + "workflowVersionId": obj.get("workflowVersionId"), + "workflowId": obj.get("workflowId"), + "workflowName": obj.get("workflowName"), + "triggerAt": obj.get("triggerAt"), + "input": obj.get("input"), + "additionalMetadata": obj.get("additionalMetadata"), + "workflowRunCreatedAt": obj.get("workflowRunCreatedAt"), + "workflowRunName": obj.get("workflowRunName"), + "workflowRunStatus": obj.get("workflowRunStatus"), + "workflowRunId": obj.get("workflowRunId"), + "method": obj.get("method"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/rest/models/scheduled_workflows_list.py b/hatchet_sdk/clients/rest/models/scheduled_workflows_list.py new file mode 100644 index 00000000..67468b5e --- /dev/null +++ b/hatchet_sdk/clients/rest/models/scheduled_workflows_list.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + Hatchet API + + The Hatchet API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict +from typing_extensions import Self + +from hatchet_sdk.clients.rest.models.pagination_response import PaginationResponse +from hatchet_sdk.clients.rest.models.scheduled_workflows import ScheduledWorkflows + + +class ScheduledWorkflowsList(BaseModel): + """ + ScheduledWorkflowsList + """ # noqa: E501 + + rows: Optional[List[ScheduledWorkflows]] = None + pagination: Optional[PaginationResponse] = None + __properties: ClassVar[List[str]] = ["rows", "pagination"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ScheduledWorkflowsList from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in rows (list) + _items = [] + if self.rows: + for _item_rows in self.rows: + if _item_rows: + _items.append(_item_rows.to_dict()) + _dict["rows"] = _items + # override the default output from pydantic by calling `to_dict()` of pagination + if self.pagination: + _dict["pagination"] = self.pagination.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ScheduledWorkflowsList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "rows": ( + [ScheduledWorkflows.from_dict(_item) for _item in obj["rows"]] + if obj.get("rows") is not None + else None + ), + "pagination": ( + PaginationResponse.from_dict(obj["pagination"]) + if obj.get("pagination") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/rest/models/scheduled_workflows_order_by_field.py b/hatchet_sdk/clients/rest/models/scheduled_workflows_order_by_field.py new file mode 100644 index 00000000..0372abd3 --- /dev/null +++ b/hatchet_sdk/clients/rest/models/scheduled_workflows_order_by_field.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Hatchet API + + The Hatchet API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations + +import json +from enum import Enum + +from typing_extensions import Self + + +class ScheduledWorkflowsOrderByField(str, Enum): + """ + ScheduledWorkflowsOrderByField + """ + + """ + allowed enum values + """ + TRIGGERAT = "triggerAt" + CREATEDAT = "createdAt" + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of ScheduledWorkflowsOrderByField from a JSON string""" + return cls(json.loads(json_str)) diff --git a/hatchet_sdk/clients/rest/models/worker.py b/hatchet_sdk/clients/rest/models/worker.py index 0d89492a..7f117ea1 100644 --- a/hatchet_sdk/clients/rest/models/worker.py +++ b/hatchet_sdk/clients/rest/models/worker.py @@ -27,6 +27,7 @@ from hatchet_sdk.clients.rest.models.recent_step_runs import RecentStepRuns from hatchet_sdk.clients.rest.models.semaphore_slots import SemaphoreSlots from hatchet_sdk.clients.rest.models.worker_label import WorkerLabel +from hatchet_sdk.clients.rest.models.worker_runtime_info import WorkerRuntimeInfo class Worker(BaseModel): @@ -87,6 +88,7 @@ class Worker(BaseModel): webhook_id: Optional[StrictStr] = Field( default=None, description="The webhook ID for the worker.", alias="webhookId" ) + runtime_info: Optional[WorkerRuntimeInfo] = Field(default=None, alias="runtimeInfo") __properties: ClassVar[List[str]] = [ "metadata", "name", @@ -103,6 +105,7 @@ class Worker(BaseModel): "labels", "webhookUrl", "webhookId", + "runtimeInfo", ] @field_validator("type") @@ -187,6 +190,9 @@ def to_dict(self) -> Dict[str, Any]: if _item_labels: _items.append(_item_labels.to_dict()) _dict["labels"] = _items + # override the default output from pydantic by calling `to_dict()` of runtime_info + if self.runtime_info: + _dict["runtimeInfo"] = self.runtime_info.to_dict() return _dict @classmethod @@ -231,6 +237,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: ), "webhookUrl": obj.get("webhookUrl"), "webhookId": obj.get("webhookId"), + "runtimeInfo": ( + WorkerRuntimeInfo.from_dict(obj["runtimeInfo"]) + if obj.get("runtimeInfo") is not None + else None + ), } ) return _obj diff --git a/hatchet_sdk/clients/rest/models/worker_runtime_info.py b/hatchet_sdk/clients/rest/models/worker_runtime_info.py new file mode 100644 index 00000000..82db1f4a --- /dev/null +++ b/hatchet_sdk/clients/rest/models/worker_runtime_info.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + Hatchet API + + The Hatchet API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Self + +from hatchet_sdk.clients.rest.models.worker_runtime_sdks import WorkerRuntimeSDKs + + +class WorkerRuntimeInfo(BaseModel): + """ + WorkerRuntimeInfo + """ # noqa: E501 + + sdk_version: Optional[StrictStr] = Field(default=None, alias="sdkVersion") + language: Optional[WorkerRuntimeSDKs] = None + language_version: Optional[StrictStr] = Field(default=None, alias="languageVersion") + os: Optional[StrictStr] = None + runtime_extra: Optional[StrictStr] = Field(default=None, alias="runtimeExtra") + __properties: ClassVar[List[str]] = [ + "sdkVersion", + "language", + "languageVersion", + "os", + "runtimeExtra", + ] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WorkerRuntimeInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WorkerRuntimeInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "sdkVersion": obj.get("sdkVersion"), + "language": obj.get("language"), + "languageVersion": obj.get("languageVersion"), + "os": obj.get("os"), + "runtimeExtra": obj.get("runtimeExtra"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/rest/models/worker_runtime_sdks.py b/hatchet_sdk/clients/rest/models/worker_runtime_sdks.py new file mode 100644 index 00000000..5716086e --- /dev/null +++ b/hatchet_sdk/clients/rest/models/worker_runtime_sdks.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + Hatchet API + + The Hatchet API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations + +import json +from enum import Enum + +from typing_extensions import Self + + +class WorkerRuntimeSDKs(str, Enum): + """ + WorkerRuntimeSDKs + """ + + """ + allowed enum values + """ + GOLANG = "GOLANG" + PYTHON = "PYTHON" + TYPESCRIPT = "TYPESCRIPT" + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of WorkerRuntimeSDKs from a JSON string""" + return cls(json.loads(json_str)) diff --git a/hatchet_sdk/clients/rest/models/workflow_runs_metrics.py b/hatchet_sdk/clients/rest/models/workflow_runs_metrics.py index 5f70c441..71b6351b 100644 --- a/hatchet_sdk/clients/rest/models/workflow_runs_metrics.py +++ b/hatchet_sdk/clients/rest/models/workflow_runs_metrics.py @@ -22,17 +22,13 @@ from pydantic import BaseModel, ConfigDict from typing_extensions import Self -from hatchet_sdk.clients.rest.models.workflow_runs_metrics_counts import ( - WorkflowRunsMetricsCounts, -) - class WorkflowRunsMetrics(BaseModel): """ WorkflowRunsMetrics """ # noqa: E501 - counts: Optional[WorkflowRunsMetricsCounts] = None + counts: Optional[Dict[str, Any]] = None __properties: ClassVar[List[str]] = ["counts"] model_config = ConfigDict( diff --git a/hatchet_sdk/clients/rest_client.py b/hatchet_sdk/clients/rest_client.py index b3d502e0..dbfa5c6c 100644 --- a/hatchet_sdk/clients/rest_client.py +++ b/hatchet_sdk/clients/rest_client.py @@ -1,7 +1,10 @@ import asyncio import atexit +import datetime import threading -from typing import Any +from typing import Any, Coroutine, List + +from pydantic import StrictInt from hatchet_sdk.clients.rest.api.event_api import EventApi from hatchet_sdk.clients.rest.api.log_api import LogApi @@ -12,6 +15,13 @@ from hatchet_sdk.clients.rest.api_client import ApiClient from hatchet_sdk.clients.rest.configuration import Configuration from hatchet_sdk.clients.rest.models import TriggerWorkflowRunRequest +from hatchet_sdk.clients.rest.models.create_cron_workflow_trigger_request import ( + CreateCronWorkflowTriggerRequest, +) +from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows +from hatchet_sdk.clients.rest.models.cron_workflows_order_by_field import ( + CronWorkflowsOrderByField, +) from hatchet_sdk.clients.rest.models.event_list import EventList from hatchet_sdk.clients.rest.models.event_order_by_direction import ( EventOrderByDirection, @@ -30,6 +40,13 @@ from hatchet_sdk.clients.rest.models.replay_workflow_runs_response import ( ReplayWorkflowRunsResponse, ) +from hatchet_sdk.clients.rest.models.schedule_workflow_run_request import ( + ScheduleWorkflowRunRequest, +) +from hatchet_sdk.clients.rest.models.scheduled_workflows import ScheduledWorkflows +from hatchet_sdk.clients.rest.models.scheduled_workflows_order_by_field import ( + ScheduledWorkflowsOrderByField, +) from hatchet_sdk.clients.rest.models.workflow import Workflow from hatchet_sdk.clients.rest.models.workflow_kind import WorkflowKind from hatchet_sdk.clients.rest.models.workflow_list import WorkflowList @@ -203,9 +220,112 @@ async def workflow_run_create( version=version, trigger_workflow_run_request=TriggerWorkflowRunRequest( input=input, + additional_metadata=additional_metadata, + ), + ) + + async def cron_create( + self, + workflow_name: str, + cron_name: str, + expression: str, + input: dict[str, Any], + additional_metadata: dict[str, str], + ): + return await self.workflow_run_api.cron_workflow_trigger_create( + tenant=self.tenant_id, + workflow=workflow_name, + create_cron_workflow_trigger_request=CreateCronWorkflowTriggerRequest( + cronName=cron_name, + expression=expression, + input=input, + additional_metadata=additional_metadata, + ), + ) + + async def cron_delete(self, cron_trigger_id: str): + return await self.workflow_api.workflow_cron_delete( + tenant=self.tenant_id, + cron_workflow=cron_trigger_id, + ) + + async def cron_list( + self, + offset: StrictInt | None = None, + limit: StrictInt | None = None, + workflow_id: str | None = None, + additional_metadata: list[str] | None = None, + order_by_field: CronWorkflowsOrderByField | None = None, + order_by_direction: WorkflowRunOrderByDirection | None = None, + ): + return await self.workflow_api.cron_workflow_list( + tenant=self.tenant_id, + offset=offset, + limit=limit, + workflow_id=workflow_id, + additional_metadata=additional_metadata, + order_by_field=order_by_field, + order_by_direction=order_by_direction, + ) + + async def cron_get(self, cron_trigger_id: str): + return await self.workflow_api.workflow_cron_get( + tenant=self.tenant_id, + cron_workflow=cron_trigger_id, + ) + + async def schedule_create( + self, + name: str, + trigger_at: datetime.datetime, + input: dict[str, Any], + additional_metadata: dict[str, str], + ): + return await self.workflow_run_api.scheduled_workflow_run_create( + tenant=self.tenant_id, + workflow=name, + create_schedule_workflow_trigger_request=ScheduleWorkflowRunRequest( + triggerAt=trigger_at, + input=input, + additional_metadata=additional_metadata, ), ) + async def schedule_delete(self, scheduled_trigger_id: str): + return await self.workflow_api.workflow_scheduled_delete( + tenant=self.tenant_id, + scheduled_workflow_run=scheduled_trigger_id, + ) + + async def schedule_list( + self, + offset: StrictInt | None = None, + limit: StrictInt | None = None, + workflow_id: str | None = None, + additional_metadata: list[str] | None = None, + parent_workflow_run_id: str | None = None, + parent_step_run_id: str | None = None, + order_by_field: ScheduledWorkflowsOrderByField | None = None, + order_by_direction: WorkflowRunOrderByDirection | None = None, + ): + return await self.workflow_api.workflow_scheduled_list( + tenant=self.tenant_id, + offset=offset, + limit=limit, + workflow_id=workflow_id, + parent_workflow_run_id=parent_workflow_run_id, + parent_step_run_id=parent_step_run_id, + additional_metadata=additional_metadata, + order_by_field=order_by_field, + order_by_direction=order_by_direction, + ) + + async def schedule_get(self, scheduled_trigger_id: str): + return await self.workflow_api.workflow_scheduled_get( + tenant=self.tenant_id, + scheduled_workflow_run=scheduled_trigger_id, + ) + async def list_logs( self, step_run_id: str, @@ -360,6 +480,85 @@ def workflow_run_create( ) ) + def cron_create( + self, + workflow_name: str, + cron_name: str, + expression: str, + input: dict[str, Any], + additional_metadata: dict[str, str], + ) -> CronWorkflows: + return self._run_coroutine( + self.aio.cron_create( + workflow_name, cron_name, expression, input, additional_metadata + ) + ) + + def cron_delete(self, cron_trigger_id: str): + return self._run_coroutine(self.aio.cron_delete(cron_trigger_id)) + + def cron_list( + self, + offset: int | None = None, + limit: int | None = None, + workflow_id: str | None = None, + additional_metadata: list[str] | None = None, + order_by_field: CronWorkflowsOrderByField | None = None, + order_by_direction: WorkflowRunOrderByDirection | None = None, + ): + return self._run_coroutine( + self.aio.cron_list( + offset, + limit, + workflow_id, + additional_metadata, + order_by_field, + order_by_direction, + ) + ) + + def cron_get(self, cron_trigger_id: str): + return self._run_coroutine(self.aio.cron_get(cron_trigger_id)) + + def schedule_create( + self, + workflow_name: str, + trigger_at: datetime.datetime, + input: dict[str, Any], + additional_metadata: dict[str, str], + ): + return self._run_coroutine( + self.aio.schedule_create( + workflow_name, trigger_at, input, additional_metadata + ) + ) + + def schedule_delete(self, scheduled_trigger_id: str): + return self._run_coroutine(self.aio.schedule_delete(scheduled_trigger_id)) + + def schedule_list( + self, + offset: int | None = None, + limit: int | None = None, + workflow_id: str | None = None, + additional_metadata: list[str] | None = None, + order_by_field: CronWorkflowsOrderByField | None = None, + order_by_direction: WorkflowRunOrderByDirection | None = None, + ): + return self._run_coroutine( + self.aio.schedule_list( + offset, + limit, + workflow_id, + additional_metadata, + order_by_field, + order_by_direction, + ) + ) + + def schedule_get(self, scheduled_trigger_id: str): + return self._run_coroutine(self.aio.schedule_get(scheduled_trigger_id)) + def list_logs( self, step_run_id: str, diff --git a/hatchet_sdk/features/cron.py b/hatchet_sdk/features/cron.py new file mode 100644 index 00000000..c54e5b3b --- /dev/null +++ b/hatchet_sdk/features/cron.py @@ -0,0 +1,286 @@ +from typing import Union + +from pydantic import BaseModel, field_validator + +from hatchet_sdk.client import Client +from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows +from hatchet_sdk.clients.rest.models.cron_workflows_list import CronWorkflowsList +from hatchet_sdk.clients.rest.models.cron_workflows_order_by_field import ( + CronWorkflowsOrderByField, +) +from hatchet_sdk.clients.rest.models.workflow_run_order_by_direction import ( + WorkflowRunOrderByDirection, +) + + +class CreateCronTriggerInput(BaseModel): + """ + Schema for creating a workflow run triggered by a cron. + + Attributes: + expression (str): The cron expression defining the schedule. + input (dict): The input data for the cron workflow. + additional_metadata (dict[str, str]): Additional metadata associated with the cron trigger (e.g. {"key1": "value1", "key2": "value2"}). + """ + + expression: str = None + input: dict = {} + additional_metadata: dict[str, str] = {} + + @field_validator("expression") + def validate_cron_expression(cls, v): + """ + Validates the cron expression to ensure it adheres to the expected format. + + Args: + v (str): The cron expression to validate. + + Raises: + ValueError: If the expression is invalid. + + Returns: + str: The validated cron expression. + """ + if not v: + raise ValueError("Cron expression is required") + + parts = v.split() + if len(parts) != 5: + raise ValueError( + "Cron expression must have 5 parts: minute hour day month weekday" + ) + + for part in parts: + if not ( + part == "*" + or part.replace("*/", "").replace("-", "").replace(",", "").isdigit() + ): + raise ValueError(f"Invalid cron expression part: {part}") + + return v + + +class CronClient: + """ + Client for managing workflow cron triggers synchronously. + + Attributes: + _client (Client): The underlying client used to interact with the REST API. + aio (CronClientAsync): Asynchronous counterpart of CronClient. + """ + + _client: Client + + def __init__(self, _client: Client): + """ + Initializes the CronClient with a given Client instance. + + Args: + _client (Client): The client instance to be used for REST interactions. + """ + self._client = _client + self.aio = CronClientAsync(_client) + + def create( + self, + workflow_name: str, + cron_name: str, + expression: str, + input: dict, + additional_metadata: dict[str, str], + ) -> CronWorkflows: + """ + Creates a new workflow cron trigger. + + Args: + workflow_name (str): The name of the workflow to trigger. + cron_name (str): The name of the cron trigger. + expression (str): The cron expression defining the schedule. + input (dict): The input data for the cron workflow. + additional_metadata (dict[str, str]): Additional metadata associated with the cron trigger (e.g. {"key1": "value1", "key2": "value2"}). + + Returns: + CronWorkflows: The created cron workflow instance. + """ + validated_input = CreateCronTriggerInput( + expression=expression, input=input, additional_metadata=additional_metadata + ) + + return self._client.rest.cron_create( + workflow_name, + cron_name, + validated_input.expression, + validated_input.input, + validated_input.additional_metadata, + ) + + def delete(self, cron_trigger: Union[str, CronWorkflows]) -> None: + """ + Deletes a workflow cron trigger. + + Args: + cron_trigger (Union[str, CronWorkflows]): The cron trigger ID or CronWorkflows instance to delete. + """ + id_ = cron_trigger + if isinstance(cron_trigger, CronWorkflows): + id_ = cron_trigger.metadata.id + self._client.rest.cron_delete(id_) + + def list( + self, + offset: int | None = None, + limit: int | None = None, + workflow_id: str | None = None, + additional_metadata: list[str] | None = None, + order_by_field: CronWorkflowsOrderByField | None = None, + order_by_direction: WorkflowRunOrderByDirection | None = None, + ) -> CronWorkflowsList: + """ + Retrieves a list of all workflow cron triggers matching the criteria. + + Args: + offset (int | None): The offset to start the list from. + limit (int | None): The maximum number of items to return. + workflow_id (str | None): The ID of the workflow to filter by. + additional_metadata (list[str] | None): Filter by additional metadata keys (e.g. ["key1:value1", "key2:value2"]). + order_by_field (CronWorkflowsOrderByField | None): The field to order the list by. + order_by_direction (WorkflowRunOrderByDirection | None): The direction to order the list by. + + Returns: + CronWorkflowsList: A list of cron workflows. + """ + return self._client.rest.cron_list( + offset=offset, + limit=limit, + workflow_id=workflow_id, + additional_metadata=additional_metadata, + order_by_field=order_by_field, + order_by_direction=order_by_direction, + ) + + def get(self, cron_trigger: Union[str, CronWorkflows]) -> CronWorkflows: + """ + Retrieves a specific workflow cron trigger by ID. + + Args: + cron_trigger (Union[str, CronWorkflows]): The cron trigger ID or CronWorkflows instance to retrieve. + + Returns: + CronWorkflows: The requested cron workflow instance. + """ + id_ = cron_trigger + if isinstance(cron_trigger, CronWorkflows): + id_ = cron_trigger.metadata.id + return self._client.rest.cron_get(id_) + + +class CronClientAsync: + """ + Asynchronous client for managing workflow cron triggers. + + Attributes: + _client (Client): The underlying client used to interact with the REST API asynchronously. + """ + + _client: Client + + def __init__(self, _client: Client): + """ + Initializes the CronClientAsync with a given Client instance. + + Args: + _client (Client): The client instance to be used for asynchronous REST interactions. + """ + self._client = _client + + async def create( + self, + workflow_name: str, + cron_name: str, + expression: str, + input: dict, + additional_metadata: dict[str, str], + ) -> CronWorkflows: + """ + Asynchronously creates a new workflow cron trigger. + + Args: + workflow_name (str): The name of the workflow to trigger. + cron_name (str): The name of the cron trigger. + expression (str): The cron expression defining the schedule. + input (dict): The input data for the cron workflow. + additional_metadata (dict[str, str]): Additional metadata associated with the cron trigger (e.g. {"key1": "value1", "key2": "value2"}). + + Returns: + CronWorkflows: The created cron workflow instance. + """ + validated_input = CreateCronTriggerInput( + expression=expression, input=input, additional_metadata=additional_metadata + ) + + return await self._client.rest.aio.cron_create( + workflow_name=workflow_name, + cron_name=cron_name, + expression=validated_input.expression, + input=validated_input.input, + additional_metadata=validated_input.additional_metadata, + ) + + async def delete(self, cron_trigger: Union[str, CronWorkflows]) -> None: + """ + Asynchronously deletes a workflow cron trigger. + + Args: + cron_trigger (Union[str, CronWorkflows]): The cron trigger ID or CronWorkflows instance to delete. + """ + id_ = cron_trigger + if isinstance(cron_trigger, CronWorkflows): + id_ = cron_trigger.metadata.id + await self._client.rest.aio.cron_delete(id_) + + async def list( + self, + offset: int | None = None, + limit: int | None = None, + workflow_id: str | None = None, + additional_metadata: list[str] | None = None, + order_by_field: CronWorkflowsOrderByField | None = None, + order_by_direction: WorkflowRunOrderByDirection | None = None, + ) -> CronWorkflowsList: + """ + Asynchronously retrieves a list of all workflow cron triggers matching the criteria. + + Args: + offset (int | None): The offset to start the list from. + limit (int | None): The maximum number of items to return. + workflow_id (str | None): The ID of the workflow to filter by. + additional_metadata (list[str] | None): Filter by additional metadata keys (e.g. ["key1:value1", "key2:value2"]). + order_by_field (CronWorkflowsOrderByField | None): The field to order the list by. + order_by_direction (WorkflowRunOrderByDirection | None): The direction to order the list by. + + Returns: + CronWorkflowsList: A list of cron workflows. + """ + return await self._client.rest.aio.cron_list( + offset=offset, + limit=limit, + workflow_id=workflow_id, + additional_metadata=additional_metadata, + order_by_field=order_by_field, + order_by_direction=order_by_direction, + ) + + async def get(self, cron_trigger: Union[str, CronWorkflows]) -> CronWorkflows: + """ + Asynchronously retrieves a specific workflow cron trigger by ID. + + Args: + cron_trigger (Union[str, CronWorkflows]): The cron trigger ID or CronWorkflows instance to retrieve. + + Returns: + CronWorkflows: The requested cron workflow instance. + """ + id_ = cron_trigger + if isinstance(cron_trigger, CronWorkflows): + id_ = cron_trigger.metadata.id + return await self._client.rest.aio.cron_get(id_) diff --git a/hatchet_sdk/features/scheduled.py b/hatchet_sdk/features/scheduled.py new file mode 100644 index 00000000..45af2609 --- /dev/null +++ b/hatchet_sdk/features/scheduled.py @@ -0,0 +1,248 @@ +import datetime +from typing import Any, Coroutine, Dict, List, Optional, Union + +from pydantic import BaseModel + +from hatchet_sdk.client import Client +from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows +from hatchet_sdk.clients.rest.models.cron_workflows_order_by_field import ( + CronWorkflowsOrderByField, +) +from hatchet_sdk.clients.rest.models.scheduled_workflows import ScheduledWorkflows +from hatchet_sdk.clients.rest.models.scheduled_workflows_list import ( + ScheduledWorkflowsList, +) +from hatchet_sdk.clients.rest.models.workflow_run_order_by_direction import ( + WorkflowRunOrderByDirection, +) + + +class CreateScheduledTriggerInput(BaseModel): + """ + Schema for creating a scheduled workflow run. + + Attributes: + input (Dict[str, Any]): The input data for the scheduled workflow. + additional_metadata (Dict[str, str]): Additional metadata associated with the future run (e.g. ["key1:value1", "key2:value2"]). + trigger_at (Optional[datetime.datetime]): The datetime when the run should be triggered. + """ + + input: Dict[str, Any] = {} + additional_metadata: Dict[str, str] = {} + trigger_at: Optional[datetime.datetime] = None + + +class ScheduledClient: + """ + Client for managing scheduled workflows synchronously. + + Attributes: + _client (Client): The underlying client used to interact with the REST API. + aio (ScheduledClientAsync): Asynchronous counterpart of ScheduledClient. + """ + + _client: Client + + def __init__(self, _client: Client) -> None: + """ + Initializes the ScheduledClient with a given Client instance. + + Args: + _client (Client): The client instance to be used for REST interactions. + """ + self._client = _client + self.aio: "ScheduledClientAsync" = ScheduledClientAsync(_client) + + def create( + self, + workflow_name: str, + trigger_at: datetime.datetime, + input: Dict[str, Any], + additional_metadata: Dict[str, str], + ) -> ScheduledWorkflows: + """ + Creates a new scheduled workflow run asynchronously. + + Args: + workflow_name (str): The name of the scheduled workflow. + trigger_at (datetime.datetime): The datetime when the run should be triggered. + input (Dict[str, Any]): The input data for the scheduled workflow. + additional_metadata (Dict[str, str]): Additional metadata associated with the future run as a key-value pair (e.g. {"key1": "value1", "key2": "value2"}). + + Returns: + ScheduledWorkflows: The created scheduled workflow instance. + """ + + validated_input = CreateScheduledTriggerInput( + trigger_at=trigger_at, input=input, additional_metadata=additional_metadata + ) + + return self._client.rest.schedule_create( + workflow_name, + validated_input.trigger_at, + validated_input.input, + validated_input.additional_metadata, + ) + + def delete(self, scheduled: Union[str, ScheduledWorkflows]) -> None: + """ + Deletes a scheduled workflow run. + + Args: + scheduled (Union[str, ScheduledWorkflows]): The scheduled workflow trigger ID or ScheduledWorkflows instance to delete. + """ + id_ = scheduled + if isinstance(scheduled, ScheduledWorkflows): + id_ = scheduled.metadata.id + self._client.rest.schedule_delete(id_) + + def list( + self, + offset: Optional[int] = None, + limit: Optional[int] = None, + workflow_id: Optional[str] = None, + additional_metadata: Optional[List[str]] = None, + order_by_field: Optional[CronWorkflowsOrderByField] = None, + order_by_direction: Optional[WorkflowRunOrderByDirection] = None, + ) -> ScheduledWorkflowsList: + """ + Retrieves a list of scheduled workflows based on provided filters. + + Args: + offset (Optional[int]): The starting point for the list. + limit (Optional[int]): The maximum number of items to return. + workflow_id (Optional[str]): Filter by specific workflow ID. + additional_metadata (Optional[List[str]]): Filter by additional metadata keys (e.g. ["key1:value1", "key2:value2"]). + order_by_field (Optional[CronWorkflowsOrderByField]): Field to order the results by. + order_by_direction (Optional[WorkflowRunOrderByDirection]): Direction to order the results. + + Returns: + List[ScheduledWorkflows]: A list of scheduled workflows matching the criteria. + """ + return self._client.rest.schedule_list( + offset=offset, + limit=limit, + workflow_id=workflow_id, + additional_metadata=additional_metadata, + order_by_field=order_by_field, + order_by_direction=order_by_direction, + ) + + def get(self, scheduled: Union[str, ScheduledWorkflows]) -> ScheduledWorkflows: + """ + Retrieves a specific scheduled workflow by scheduled run trigger ID. + + Args: + scheduled (Union[str, ScheduledWorkflows]): The scheduled workflow trigger ID or ScheduledWorkflows instance to retrieve. + + Returns: + ScheduledWorkflows: The requested scheduled workflow instance. + """ + id_ = scheduled + if isinstance(scheduled, ScheduledWorkflows): + id_ = scheduled.metadata.id + return self._client.rest.schedule_get(id_) + + +class ScheduledClientAsync: + """ + Asynchronous client for managing scheduled workflows. + + Attributes: + _client (Client): The underlying client used to interact with the REST API asynchronously. + """ + + _client: Client + + def __init__(self, _client: Client) -> None: + """ + Initializes the ScheduledClientAsync with a given Client instance. + + Args: + _client (Client): The client instance to be used for asynchronous REST interactions. + """ + self._client = _client + + async def create( + self, + workflow_name: str, + trigger_at: datetime.datetime, + input: Dict[str, Any], + additional_metadata: Dict[str, str], + ) -> ScheduledWorkflows: + """ + Creates a new scheduled workflow run asynchronously. + + Args: + workflow_name (str): The name of the scheduled workflow. + trigger_at (datetime.datetime): The datetime when the run should be triggered. + input (Dict[str, Any]): The input data for the scheduled workflow. + additional_metadata (Dict[str, str]): Additional metadata associated with the future run. + + Returns: + ScheduledWorkflows: The created scheduled workflow instance. + """ + return await self._client.rest.aio.schedule_create( + workflow_name, trigger_at, input, additional_metadata + ) + + async def delete(self, scheduled: Union[str, ScheduledWorkflows]) -> None: + """ + Deletes a scheduled workflow asynchronously. + + Args: + scheduled (Union[str, ScheduledWorkflows]): The scheduled workflow trigger ID or ScheduledWorkflows instance to delete. + """ + id_ = scheduled + if isinstance(scheduled, ScheduledWorkflows): + id_ = scheduled.metadata.id + await self._client.rest.aio.schedule_delete(id_) + + async def list( + self, + offset: Optional[int] = None, + limit: Optional[int] = None, + workflow_id: Optional[str] = None, + additional_metadata: Optional[List[str]] = None, + order_by_field: Optional[CronWorkflowsOrderByField] = None, + order_by_direction: Optional[WorkflowRunOrderByDirection] = None, + ) -> ScheduledWorkflowsList: + """ + Retrieves a list of scheduled workflows based on provided filters asynchronously. + + Args: + offset (Optional[int]): The starting point for the list. + limit (Optional[int]): The maximum number of items to return. + workflow_id (Optional[str]): Filter by specific workflow ID. + additional_metadata (Optional[List[str]]): Filter by additional metadata keys (e.g. ["key1:value1", "key2:value2"]). + order_by_field (Optional[CronWorkflowsOrderByField]): Field to order the results by. + order_by_direction (Optional[WorkflowRunOrderByDirection]): Direction to order the results. + + Returns: + ScheduledWorkflowsList: A list of scheduled workflows matching the criteria. + """ + return await self._client.rest.aio.schedule_list( + offset=offset, + limit=limit, + workflow_id=workflow_id, + additional_metadata=additional_metadata, + order_by_field=order_by_field, + order_by_direction=order_by_direction, + ) + + async def get( + self, scheduled: Union[str, ScheduledWorkflows] + ) -> ScheduledWorkflows: + """ + Retrieves a specific scheduled workflow by scheduled run trigger ID asynchronously. + + Args: + scheduled (Union[str, ScheduledWorkflows]): The scheduled workflow trigger ID or ScheduledWorkflows instance to retrieve. + + Returns: + ScheduledWorkflows: The requested scheduled workflow instance. + """ + id_ = scheduled + if isinstance(scheduled, ScheduledWorkflows): + id_ = scheduled.metadata.id + return await self._client.rest.aio.schedule_get(id_) diff --git a/hatchet_sdk/hatchet.py b/hatchet_sdk/hatchet.py index c08a2803..d8d79a39 100644 --- a/hatchet_sdk/hatchet.py +++ b/hatchet_sdk/hatchet.py @@ -14,6 +14,8 @@ DesiredWorkerLabels, StickyStrategy, ) +from hatchet_sdk.features.cron import CronClient +from hatchet_sdk.features.scheduled import ScheduledClient from hatchet_sdk.labels import DesiredWorkerLabel from hatchet_sdk.loader import ClientConfig, ConfigLoader from hatchet_sdk.rate_limit import RateLimit @@ -173,6 +175,8 @@ class Hatchet: for working with Hatchet workers, workflows, and steps. Attributes: + cron (CronClient): Interface for cron trigger operations. + admin (AdminClient): Interface for administrative operations. dispatcher (DispatcherClient): Interface for dispatching operations. event (EventClient): Interface for event-related operations. @@ -180,6 +184,8 @@ class Hatchet: """ _client: Client + cron: CronClient + scheduled: ScheduledClient @classmethod def from_environment( @@ -213,6 +219,9 @@ def __init__( if debug: logger.setLevel(logging.DEBUG) + self.cron = CronClient(self._client) + self.scheduled = ScheduledClient(self._client) + @property @deprecated( "Direct access to client is deprecated and will be removed in a future version. Use specific client properties (Hatchet.admin, Hatchet.dispatcher, Hatchet.event, Hatchet.rest) instead. [0.32.0]", diff --git a/pyproject.toml b/pyproject.toml index 1c6b6744..bd8dbf27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "hatchet-sdk" -version = "0.40.1" +version = "0.41.0" description = "" authors = ["Alexander Belanger "] readme = "README.md"