diff --git a/.gitignore b/.gitignore index 6b15a2af..4f69d1e7 100644 --- a/.gitignore +++ b/.gitignore @@ -162,3 +162,6 @@ cython_debug/ #.idea/ openapitools.json + +hatchet-cloud/ +hatchet/ diff --git a/.gitmodules b/.gitmodules index 2e2e6198..dc9476d0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,8 @@ [submodule "hatchet"] path = hatchet - url = git@github.com:hatchet-dev/hatchet.git + url = https://github.com/hatchet-dev/hatchet.git branch = main +[submodule "hatchet-cloud"] + path = hatchet-cloud + url = https://github.com/hatchet-dev/hatchet-cloud.git + branch = feat/iac diff --git a/branch-sync.sh b/branch-sync.sh index e0ea9f87..c3b113e0 100755 --- a/branch-sync.sh +++ b/branch-sync.sh @@ -1,5 +1,40 @@ #!/bin/bash +# Default values +mode="oss" +repo_url="https://github.com/hatchet-dev/hatchet.git" +submodule_name="hatchet" + +# Parse command line options +while getopts ":n:" opt; do + case $opt in + n) + mode=$OPTARG + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + esac +done + +# Set the repository URL and submodule name based on the mode +if [ "$mode" = "cloud" ]; then + repo_url="https://github.com/hatchet-dev/hatchet-cloud.git" + submodule_name="hatchet-cloud" +else + repo_url="https://github.com/hatchet-dev/hatchet.git" + submodule_name="hatchet" +fi + +echo "Mode: $mode" +echo "Repository URL: $repo_url" +echo "Submodule name: $submodule_name" + # 1. Get the current branch name current_branch=$(echo $GITHUB_HEAD_REF | sed 's/refs\/heads\///') @@ -7,22 +42,38 @@ 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 +echo "Current branch: $current_branch" + +# 2. Check the repo and determine if a branch with the same name exists +git ls-remote --heads $repo_url $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 config -f .gitmodules submodule.$submodule_name.branch $current_branch + git config -f .gitmodules submodule.$submodule_name.path $submodule_name + git config -f .gitmodules submodule.$submodule_name.url $repo_url 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 + echo "Branch $current_branch does not exist in the remote repository. Using main branch instead." + git config -f .gitmodules submodule.$submodule_name.branch main + git config -f .gitmodules submodule.$submodule_name.path $submodule_name + git config -f .gitmodules submodule.$submodule_name.url $repo_url git add .gitmodules echo "Updated .gitmodules with branch main" fi -# 4. Initialize and update the submodule +# 4. Remove existing submodule if it exists +git submodule deinit -f -- $submodule_name +rm -rf .git/modules/$submodule_name +git rm -f $submodule_name + +# 5. Re-add and initialize the submodule +git submodule add -b $(git config -f .gitmodules submodule.$submodule_name.branch) $repo_url $submodule_name git submodule init + +# 6. Update the submodule git submodule update --remote --merge + +echo "Hatchet submodule ($mode mode) updated successfully" diff --git a/examples/blocked_check/worker.py b/examples/blocked_check/worker.py new file mode 100644 index 00000000..c70713c2 --- /dev/null +++ b/examples/blocked_check/worker.py @@ -0,0 +1,52 @@ +import asyncio +import time + +from dotenv import load_dotenv + +from hatchet_sdk import Context, Hatchet + +load_dotenv() + +hatchet = Hatchet(debug=True) + + +async def check_blocking_workers(context: Context): + start_time = time.time() + context.log("Starting blocking worker check") + + await asyncio.sleep(30) + + end_time = time.time() + elapsed_time = end_time - start_time + + if 25 <= elapsed_time <= 35: + context.log(f"Check completed in {elapsed_time:.2f} seconds") + else: + raise ValueError( + f"Blockage detected: Task took {elapsed_time:.2f} seconds, expected 25-35" + " seconds" + ) + + +@hatchet.workflow(on_crons=["*/5 * * * *"]) +class CheckBlockingWorkersWorkflow: + @hatchet.step(timeout="1m") + async def iter_1(self, context: Context): + await check_blocking_workers(context) + + @hatchet.step(parents=["iter_1"], timeout="1m") + async def iter_2(self, context): + await check_blocking_workers(context) + + @hatchet.step(parents=["iter_2"], timeout="1m") + async def iter_3(self, context): + await check_blocking_workers(context) + +def main(): + workflow = CheckBlockingWorkersWorkflow() + worker = hatchet.worker("test-worker", max_runs=1) + worker.register_workflow(workflow) + worker.start() + +if __name__ == "__main__": + main() diff --git a/examples/managed/event.py b/examples/managed/event.py new file mode 100644 index 00000000..c2d0178a --- /dev/null +++ b/examples/managed/event.py @@ -0,0 +1,41 @@ +from typing import List + +from dotenv import load_dotenv + +from hatchet_sdk import new_client +from hatchet_sdk.clients.events import BulkPushEventWithMetadata + +load_dotenv() + +client = new_client() + +# client.event.push("user:create", {"test": "test"}) +client.event.push( + "user:create", {"test": "test"}, options={"additional_metadata": {"hello": "moon"}} +) + +events: List[BulkPushEventWithMetadata] = [ + { + "key": "event1", + "payload": {"message": "This is event 1"}, + "additional_metadata": {"source": "test", "user_id": "user123"}, + }, + { + "key": "event2", + "payload": {"message": "This is event 2"}, + "additional_metadata": {"source": "test", "user_id": "user456"}, + }, + { + "key": "event3", + "payload": {"message": "This is event 3"}, + "additional_metadata": {"source": "test", "user_id": "user789"}, + }, +] + + +result = client.event.bulk_push( + events, + options={"namespace": "bulk-test"}, +) + +print(result) diff --git a/examples/managed/worker.py b/examples/managed/worker.py new file mode 100644 index 00000000..1f74973b --- /dev/null +++ b/examples/managed/worker.py @@ -0,0 +1,72 @@ +import time + +from dotenv import load_dotenv + +from hatchet_sdk import Context, Hatchet +from hatchet_sdk.compute.configs import Compute + +load_dotenv() + +hatchet = Hatchet() + +# Default compute + +default_compute = Compute(cpu_kind="shared", cpus=1, memory_mb=1024, regions=["ewr"]) + +blocked_compute = Compute( + pool="blocked-pool", + cpu_kind="shared", + cpus=1, + memory_mb=1024, + regions=["ewr"], +) + +gpu_compute = Compute(cpu_kind="gpu", cpus=2, memory_mb=1024, regions=["ewr"]) + + +@hatchet.workflow(on_events=["user:create"]) +class ManagedWorkflow: + @hatchet.step(timeout="11s", retries=3, compute=default_compute) + def step1(self, context: Context): + print("executed step1") + time.sleep(10) + # raise Exception("test") + return { + "step1": "step1", + } + + @hatchet.step(timeout="11s", retries=3, compute=gpu_compute) + def step2(self, context: Context): + print("executed step2") + time.sleep(10) + # raise Exception("test") + return { + "step2": "step2", + } + + @hatchet.step(timeout="11s", retries=3, compute=blocked_compute) + def step3(self, context: Context): + print("executed step3") + + return { + "step3": "step3", + } + + @hatchet.step(timeout="11s", retries=3, compute=default_compute) + def step4(self, context: Context): + print("executed step4") + time.sleep(10) + return { + "step4": "step4", + } + + +def main(): + workflow = ManagedWorkflow() + worker = hatchet.worker("test-worker", max_runs=1) + worker.register_workflow(workflow) + worker.start() + + +if __name__ == "__main__": + main() diff --git a/examples/simple/worker.py b/examples/simple/worker.py index 1eca4c79..f3d23c14 100644 --- a/examples/simple/worker.py +++ b/examples/simple/worker.py @@ -20,6 +20,14 @@ def step1(self, context: Context): "step1": "step1", } + @hatchet.step(timeout="11s", retries=3) + def step2(self, context: Context): + print("executed step2") + time.sleep(10) + return { + "step2": "step2", + } + def main(): workflow = MyWorkflow() diff --git a/generate.sh b/generate.sh index fb57d131..1f66a7f1 100755 --- a/generate.sh +++ b/generate.sh @@ -6,6 +6,15 @@ set -eux ROOT_DIR=$(pwd) +# Check if hatchet-cloud submodule exists and has been pulled +if [ -d "hatchet-cloud" ] && [ "$(ls -A hatchet-cloud)" ]; then + echo "hatchet-cloud submodule detected" + CLOUD_MODE=true +else + echo "hatchet-cloud submodule not detected or empty" + CLOUD_MODE=false +fi + # deps version=7.3.0 @@ -58,9 +67,20 @@ cp $tmp_dir/hatchet_sdk/clients/rest/api/__init__.py $dst_dir/api/__init__.py # remove tmp folder rm -rf $tmp_dir -poetry run python -m grpc_tools.protoc --proto_path=hatchet/api-contracts/dispatcher --python_out=./hatchet_sdk/contracts --pyi_out=./hatchet_sdk/contracts --grpc_python_out=./hatchet_sdk/contracts dispatcher.proto -poetry run python -m grpc_tools.protoc --proto_path=hatchet/api-contracts/events --python_out=./hatchet_sdk/contracts --pyi_out=./hatchet_sdk/contracts --grpc_python_out=./hatchet_sdk/contracts events.proto -poetry run python -m grpc_tools.protoc --proto_path=hatchet/api-contracts/workflows --python_out=./hatchet_sdk/contracts --pyi_out=./hatchet_sdk/contracts --grpc_python_out=./hatchet_sdk/contracts workflows.proto +# Generate protobuf files for both hatchet and hatchet-cloud (if exists) +generate_proto() { + local submodule=$1 + local proto_file=$2 + poetry run python -m grpc_tools.protoc --proto_path=$submodule/api-contracts/$proto_file \ + --python_out=./hatchet_sdk/contracts --pyi_out=./hatchet_sdk/contracts \ + --grpc_python_out=./hatchet_sdk/contracts $proto_file.proto +} + +proto_files=("dispatcher" "events" "workflows") + +for proto in "${proto_files[@]}"; do + generate_proto "hatchet" $proto +done # Fix relative imports in _grpc.py files if [[ "$OSTYPE" == "darwin"* ]]; then @@ -71,6 +91,52 @@ else find ./hatchet_sdk/contracts -type f -name '*_grpc.py' -print0 | xargs -0 sed -i 's/^import \([^ ]*\)_pb2/from . import \1_pb2/' fi +if [ "$CLOUD_MODE" = true ]; then + echo "Generating cloud-specific OpenAPI" + + # Generate cloud-specific OpenAPI + cloud_dst_dir=./hatchet_sdk/clients/cloud_rest + cloud_tmp_dir=./cloud_tmp + + mkdir -p $cloud_dst_dir + + # generate into cloud tmp folder + openapi-generator-cli generate -i ./hatchet-cloud/api-contracts/openapi/openapi.yaml -g python -o ./cloud_tmp --skip-validate-spec \ + --library asyncio \ + --global-property=apiTests=false \ + --global-property=apiDocs=true \ + --global-property=modelTests=false \ + --global-property=modelDocs=true \ + --package-name hatchet_sdk.clients.cloud_rest + + mv $cloud_tmp_dir/hatchet_sdk/clients/cloud_rest/api_client.py $cloud_dst_dir/api_client.py + mv $cloud_tmp_dir/hatchet_sdk/clients/cloud_rest/configuration.py $cloud_dst_dir/configuration.py + mv $cloud_tmp_dir/hatchet_sdk/clients/cloud_rest/api_response.py $cloud_dst_dir/api_response.py + mv $cloud_tmp_dir/hatchet_sdk/clients/cloud_rest/exceptions.py $cloud_dst_dir/exceptions.py + mv $cloud_tmp_dir/hatchet_sdk/clients/cloud_rest/__init__.py $cloud_dst_dir/__init__.py + mv $cloud_tmp_dir/hatchet_sdk/clients/cloud_rest/rest.py $cloud_dst_dir/rest.py + + openapi-generator-cli generate -i ./hatchet-cloud/api-contracts/openapi/openapi.yaml -g python -o . --skip-validate-spec \ + --library asyncio \ + --global-property=apis,models \ + --global-property=apiTests=false \ + --global-property=apiDocs=false \ + --global-property=modelTests=false \ + --global-property=modelDocs=false \ + --package-name hatchet_sdk.clients.cloud_rest + + # copy the __init__ files from cloud tmp to the destination since they are not generated for some reason + cp $cloud_tmp_dir/hatchet_sdk/clients/cloud_rest/models/__init__.py $cloud_dst_dir/models/__init__.py + cp $cloud_tmp_dir/hatchet_sdk/clients/cloud_rest/api/__init__.py $cloud_dst_dir/api/__init__.py + + # remove cloud tmp folder + rm -rf $cloud_tmp_dir + + echo "Generation completed for both OSS and Cloud versions" +else + echo "Generation completed for OSS version only" +fi + # ensure that pre-commit is applied without errors pre-commit run --all-files || pre-commit run --all-files diff --git a/hatchet b/hatchet deleted file mode 160000 index 8a3c8b57..00000000 --- a/hatchet +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8a3c8b573c2a800a7ce8018deab20a4c27d7e5d5 diff --git a/hatchet_sdk/clients/cloud_rest/__init__.py b/hatchet_sdk/clients/cloud_rest/__init__.py new file mode 100644 index 00000000..4c794689 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/__init__.py @@ -0,0 +1,186 @@ +# coding: utf-8 + +# flake8: noqa + +""" + 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 + + +__version__ = "1.0.0" + +# import apis into sdk package +from hatchet_sdk.clients.cloud_rest.api.billing_api import BillingApi +from hatchet_sdk.clients.cloud_rest.api.build_api import BuildApi +from hatchet_sdk.clients.cloud_rest.api.feature_flags_api import FeatureFlagsApi +from hatchet_sdk.clients.cloud_rest.api.github_api import GithubApi +from hatchet_sdk.clients.cloud_rest.api.log_api import LogApi +from hatchet_sdk.clients.cloud_rest.api.managed_worker_api import ManagedWorkerApi +from hatchet_sdk.clients.cloud_rest.api.metadata_api import MetadataApi +from hatchet_sdk.clients.cloud_rest.api.metrics_api import MetricsApi +from hatchet_sdk.clients.cloud_rest.api.tenant_api import TenantApi +from hatchet_sdk.clients.cloud_rest.api.user_api import UserApi +from hatchet_sdk.clients.cloud_rest.api.workflow_api import WorkflowApi +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient + +# import ApiClient +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.configuration import Configuration +from hatchet_sdk.clients.cloud_rest.exceptions import ( + ApiAttributeError, + ApiException, + ApiKeyError, + ApiTypeError, + ApiValueError, + OpenApiException, +) + +# import models into sdk package +from hatchet_sdk.clients.cloud_rest.models.billing_portal_link_get200_response import ( + BillingPortalLinkGet200Response, +) +from hatchet_sdk.clients.cloud_rest.models.build_get200_response import ( + BuildGet200Response, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_branches200_response_inner import ( + GithubAppListBranches200ResponseInner, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response import ( + GithubAppListInstallations200Response, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response_pagination import ( + GithubAppListInstallations200ResponsePagination, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response_rows_inner import ( + GithubAppListInstallations200ResponseRowsInner, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response_rows_inner_metadata import ( + GithubAppListInstallations200ResponseRowsInnerMetadata, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_repos200_response_inner import ( + GithubAppListRepos200ResponseInner, +) +from hatchet_sdk.clients.cloud_rest.models.infra_as_code_create_request import ( + InfraAsCodeCreateRequest, +) +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner import ( + LogCreateRequestInner, +) +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner_event import ( + LogCreateRequestInnerEvent, +) +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner_fly import ( + LogCreateRequestInnerFly, +) +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner_fly_app import ( + LogCreateRequestInnerFlyApp, +) +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner_log import ( + LogCreateRequestInnerLog, +) +from hatchet_sdk.clients.cloud_rest.models.log_list200_response import ( + LogList200Response, +) +from hatchet_sdk.clients.cloud_rest.models.log_list200_response_rows_inner import ( + LogList200ResponseRowsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request import ( + ManagedWorkerCreateRequest, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_build_config import ( + ManagedWorkerCreateRequestBuildConfig, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_build_config_steps_inner import ( + ManagedWorkerCreateRequestBuildConfigStepsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_runtime_config import ( + ManagedWorkerCreateRequestRuntimeConfig, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_events_list200_response import ( + ManagedWorkerEventsList200Response, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_events_list200_response_rows_inner import ( + ManagedWorkerEventsList200ResponseRowsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_instances_list200_response import ( + ManagedWorkerInstancesList200Response, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_instances_list200_response_rows_inner import ( + ManagedWorkerInstancesList200ResponseRowsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response import ( + ManagedWorkerList200Response, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner import ( + ManagedWorkerList200ResponseRowsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner_build_config import ( + ManagedWorkerList200ResponseRowsInnerBuildConfig, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner_build_config_steps_inner import ( + ManagedWorkerList200ResponseRowsInnerBuildConfigStepsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner_runtime_configs_inner import ( + ManagedWorkerList200ResponseRowsInnerRuntimeConfigsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_update_request import ( + ManagedWorkerUpdateRequest, +) +from hatchet_sdk.clients.cloud_rest.models.metadata_get200_response import ( + MetadataGet200Response, +) +from hatchet_sdk.clients.cloud_rest.models.metadata_get400_response import ( + MetadataGet400Response, +) +from hatchet_sdk.clients.cloud_rest.models.metadata_get400_response_errors_inner import ( + MetadataGet400ResponseErrorsInner, +) +from hatchet_sdk.clients.cloud_rest.models.metrics_cpu_get200_response_inner import ( + MetricsCpuGet200ResponseInner, +) +from hatchet_sdk.clients.cloud_rest.models.metrics_cpu_get200_response_inner_histograms_inner import ( + MetricsCpuGet200ResponseInnerHistogramsInner, +) +from hatchet_sdk.clients.cloud_rest.models.metrics_cpu_get200_response_inner_histograms_inner_histogram import ( + MetricsCpuGet200ResponseInnerHistogramsInnerHistogram, +) +from hatchet_sdk.clients.cloud_rest.models.metrics_cpu_get200_response_inner_histograms_inner_histogram_buckets_inner import ( + MetricsCpuGet200ResponseInnerHistogramsInnerHistogramBucketsInner, +) +from hatchet_sdk.clients.cloud_rest.models.runtime_config_list_actions200_response import ( + RuntimeConfigListActions200Response, +) +from hatchet_sdk.clients.cloud_rest.models.subscription_upsert200_response import ( + SubscriptionUpsert200Response, +) +from hatchet_sdk.clients.cloud_rest.models.subscription_upsert_request import ( + SubscriptionUpsertRequest, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response import ( + TenantBillingStateGet200Response, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response_coupons_inner import ( + TenantBillingStateGet200ResponseCouponsInner, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response_payment_methods_inner import ( + TenantBillingStateGet200ResponsePaymentMethodsInner, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response_plans_inner import ( + TenantBillingStateGet200ResponsePlansInner, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response_subscription import ( + TenantBillingStateGet200ResponseSubscription, +) +from hatchet_sdk.clients.cloud_rest.models.workflow_run_events_get_metrics200_response import ( + WorkflowRunEventsGetMetrics200Response, +) +from hatchet_sdk.clients.cloud_rest.models.workflow_run_events_get_metrics200_response_results_inner import ( + WorkflowRunEventsGetMetrics200ResponseResultsInner, +) diff --git a/hatchet_sdk/clients/cloud_rest/api/__init__.py b/hatchet_sdk/clients/cloud_rest/api/__init__.py new file mode 100644 index 00000000..eaab484b --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api/__init__.py @@ -0,0 +1,14 @@ +# flake8: noqa + +# import apis into api package +from hatchet_sdk.clients.cloud_rest.api.billing_api import BillingApi +from hatchet_sdk.clients.cloud_rest.api.build_api import BuildApi +from hatchet_sdk.clients.cloud_rest.api.feature_flags_api import FeatureFlagsApi +from hatchet_sdk.clients.cloud_rest.api.github_api import GithubApi +from hatchet_sdk.clients.cloud_rest.api.log_api import LogApi +from hatchet_sdk.clients.cloud_rest.api.managed_worker_api import ManagedWorkerApi +from hatchet_sdk.clients.cloud_rest.api.metadata_api import MetadataApi +from hatchet_sdk.clients.cloud_rest.api.metrics_api import MetricsApi +from hatchet_sdk.clients.cloud_rest.api.tenant_api import TenantApi +from hatchet_sdk.clients.cloud_rest.api.user_api import UserApi +from hatchet_sdk.clients.cloud_rest.api.workflow_api import WorkflowApi diff --git a/hatchet_sdk/clients/cloud_rest/api/billing_api.py b/hatchet_sdk/clients/cloud_rest/api/billing_api.py new file mode 100644 index 00000000..019e3378 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api/billing_api.py @@ -0,0 +1,819 @@ +# 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 + +import warnings +from typing import Any, Dict, List, Optional, Tuple, Union + +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call +from typing_extensions import Annotated + +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient, RequestSerialized +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.models.billing_portal_link_get200_response import ( + BillingPortalLinkGet200Response, +) +from hatchet_sdk.clients.cloud_rest.models.subscription_upsert200_response import ( + SubscriptionUpsert200Response, +) +from hatchet_sdk.clients.cloud_rest.models.subscription_upsert_request import ( + SubscriptionUpsertRequest, +) +from hatchet_sdk.clients.cloud_rest.rest import RESTResponseType + + +class BillingApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + async def billing_portal_link_get( + 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, + ) -> BillingPortalLinkGet200Response: + """Create a link to the billing portal + + Get the billing portal link + + :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._billing_portal_link_get_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": "BillingPortalLinkGet200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 billing_portal_link_get_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[BillingPortalLinkGet200Response]: + """Create a link to the billing portal + + Get the billing portal link + + :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._billing_portal_link_get_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": "BillingPortalLinkGet200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 billing_portal_link_get_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: + """Create a link to the billing portal + + Get the billing portal link + + :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._billing_portal_link_get_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": "BillingPortalLinkGet200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _billing_portal_link_get_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]] = {} + _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` + _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/billing/tenants/{tenant}/billing-portal-link", + 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 lago_message_create( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Receive a webhook message from Lago + + Receive a webhook message from Lago + + :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._lago_message_create_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 lago_message_create_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Receive a webhook message from Lago + + Receive a webhook message from Lago + + :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._lago_message_create_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 lago_message_create_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Receive a webhook message from Lago + + Receive a webhook message from Lago + + :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._lago_message_create_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _lago_message_create_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/api/v1/billing/lago/webhook", + 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 subscription_upsert( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + subscription_upsert_request: Optional[SubscriptionUpsertRequest] = 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, + ) -> SubscriptionUpsert200Response: + """Create a new subscription + + Update a subscription + + :param tenant: The tenant id (required) + :type tenant: str + :param subscription_upsert_request: + :type subscription_upsert_request: SubscriptionUpsertRequest + :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._subscription_upsert_serialize( + tenant=tenant, + subscription_upsert_request=subscription_upsert_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SubscriptionUpsert200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 subscription_upsert_with_http_info( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + subscription_upsert_request: Optional[SubscriptionUpsertRequest] = 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[SubscriptionUpsert200Response]: + """Create a new subscription + + Update a subscription + + :param tenant: The tenant id (required) + :type tenant: str + :param subscription_upsert_request: + :type subscription_upsert_request: SubscriptionUpsertRequest + :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._subscription_upsert_serialize( + tenant=tenant, + subscription_upsert_request=subscription_upsert_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SubscriptionUpsert200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 subscription_upsert_without_preload_content( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + subscription_upsert_request: Optional[SubscriptionUpsertRequest] = 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: + """Create a new subscription + + Update a subscription + + :param tenant: The tenant id (required) + :type tenant: str + :param subscription_upsert_request: + :type subscription_upsert_request: SubscriptionUpsertRequest + :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._subscription_upsert_serialize( + tenant=tenant, + subscription_upsert_request=subscription_upsert_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SubscriptionUpsert200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _subscription_upsert_serialize( + self, + tenant, + subscription_upsert_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if tenant is not None: + _path_params["tenant"] = tenant + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if subscription_upsert_request is not None: + _body_params = subscription_upsert_request + + # set the HTTP header `Accept` + _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="PATCH", + resource_path="/api/v1/billing/tenants/{tenant}/subscription", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/hatchet_sdk/clients/cloud_rest/api/build_api.py b/hatchet_sdk/clients/cloud_rest/api/build_api.py new file mode 100644 index 00000000..dca1a4a7 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api/build_api.py @@ -0,0 +1,298 @@ +# 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 + +import warnings +from typing import Any, Dict, List, Optional, Tuple, Union + +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call +from typing_extensions import Annotated + +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient, RequestSerialized +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.models.build_get200_response import ( + BuildGet200Response, +) +from hatchet_sdk.clients.cloud_rest.rest import RESTResponseType + + +class BuildApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + async def build_get( + self, + build: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The build 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, + ) -> BuildGet200Response: + """Get Build + + Get a build + + :param build: The build id (required) + :type build: 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._build_get_serialize( + build=build, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "BuildGet200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 build_get_with_http_info( + self, + build: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The build 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[BuildGet200Response]: + """Get Build + + Get a build + + :param build: The build id (required) + :type build: 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._build_get_serialize( + build=build, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "BuildGet200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 build_get_without_preload_content( + self, + build: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The build 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 Build + + Get a build + + :param build: The build id (required) + :type build: 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._build_get_serialize( + build=build, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "BuildGet200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _build_get_serialize( + self, + build, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if build is not None: + _path_params["build"] = build + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _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/cloud/build/{build}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/hatchet_sdk/clients/cloud_rest/api/feature_flags_api.py b/hatchet_sdk/clients/cloud_rest/api/feature_flags_api.py new file mode 100644 index 00000000..885679b2 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api/feature_flags_api.py @@ -0,0 +1,295 @@ +# 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 + +import warnings +from typing import Any, Dict, List, Optional, Tuple, Union + +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call +from typing_extensions import Annotated + +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient, RequestSerialized +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.rest import RESTResponseType + + +class FeatureFlagsApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + async def feature_flags_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, + ) -> Dict[str, str]: + """List Feature Flags + + Get all feature flags for the 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._feature_flags_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": "Dict[str, str]", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 feature_flags_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[Dict[str, str]]: + """List Feature Flags + + Get all feature flags for the 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._feature_flags_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": "Dict[str, str]", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 feature_flags_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: + """List Feature Flags + + Get all feature flags for the 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._feature_flags_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": "Dict[str, str]", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _feature_flags_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]] = {} + _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` + _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/cloud/tenants/{tenant}/feature-flags", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/hatchet_sdk/clients/cloud_rest/api/github_api.py b/hatchet_sdk/clients/cloud_rest/api/github_api.py new file mode 100644 index 00000000..cc94f03f --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api/github_api.py @@ -0,0 +1,1347 @@ +# 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 + +import warnings +from typing import Any, Dict, List, Optional, Tuple, Union + +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call +from typing_extensions import Annotated + +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient, RequestSerialized +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.models.github_app_list_branches200_response_inner import ( + GithubAppListBranches200ResponseInner, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response import ( + GithubAppListInstallations200Response, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_repos200_response_inner import ( + GithubAppListRepos200ResponseInner, +) +from hatchet_sdk.clients.cloud_rest.rest import RESTResponseType + + +class GithubApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + async def github_app_list_branches( + self, + gh_installation: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The installation id", + ), + ], + gh_repo_owner: Annotated[StrictStr, Field(description="The repository owner")], + gh_repo_name: Annotated[StrictStr, Field(description="The repository name")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> List[GithubAppListBranches200ResponseInner]: + """List Github App branches + + List Github App branches + + :param gh_installation: The installation id (required) + :type gh_installation: str + :param gh_repo_owner: The repository owner (required) + :type gh_repo_owner: str + :param gh_repo_name: The repository name (required) + :type gh_repo_name: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._github_app_list_branches_serialize( + gh_installation=gh_installation, + gh_repo_owner=gh_repo_owner, + gh_repo_name=gh_repo_name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[GithubAppListBranches200ResponseInner]", + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + 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 github_app_list_branches_with_http_info( + self, + gh_installation: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The installation id", + ), + ], + gh_repo_owner: Annotated[StrictStr, Field(description="The repository owner")], + gh_repo_name: Annotated[StrictStr, Field(description="The repository name")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[List[GithubAppListBranches200ResponseInner]]: + """List Github App branches + + List Github App branches + + :param gh_installation: The installation id (required) + :type gh_installation: str + :param gh_repo_owner: The repository owner (required) + :type gh_repo_owner: str + :param gh_repo_name: The repository name (required) + :type gh_repo_name: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._github_app_list_branches_serialize( + gh_installation=gh_installation, + gh_repo_owner=gh_repo_owner, + gh_repo_name=gh_repo_name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[GithubAppListBranches200ResponseInner]", + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + 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 github_app_list_branches_without_preload_content( + self, + gh_installation: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The installation id", + ), + ], + gh_repo_owner: Annotated[StrictStr, Field(description="The repository owner")], + gh_repo_name: Annotated[StrictStr, Field(description="The repository name")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List Github App branches + + List Github App branches + + :param gh_installation: The installation id (required) + :type gh_installation: str + :param gh_repo_owner: The repository owner (required) + :type gh_repo_owner: str + :param gh_repo_name: The repository name (required) + :type gh_repo_name: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._github_app_list_branches_serialize( + gh_installation=gh_installation, + gh_repo_owner=gh_repo_owner, + gh_repo_name=gh_repo_name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[GithubAppListBranches200ResponseInner]", + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _github_app_list_branches_serialize( + self, + gh_installation, + gh_repo_owner, + gh_repo_name, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if gh_installation is not None: + _path_params["gh-installation"] = gh_installation + if gh_repo_owner is not None: + _path_params["gh-repo-owner"] = gh_repo_owner + if gh_repo_name is not None: + _path_params["gh-repo-name"] = gh_repo_name + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) + + # authentication setting + _auth_settings: List[str] = ["cookieAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/v1/cloud/github-app/installations/{gh-installation}/repos/{gh-repo-owner}/{gh-repo-name}/branches", + 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 github_app_list_installations( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GithubAppListInstallations200Response: + """List Github App installations + + List Github App installations + + :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._github_app_list_installations_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GithubAppListInstallations200Response", + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + 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 github_app_list_installations_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GithubAppListInstallations200Response]: + """List Github App installations + + List Github App installations + + :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._github_app_list_installations_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GithubAppListInstallations200Response", + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + 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 github_app_list_installations_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List Github App installations + + List Github App installations + + :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._github_app_list_installations_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GithubAppListInstallations200Response", + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _github_app_list_installations_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) + + # authentication setting + _auth_settings: List[str] = ["cookieAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/v1/cloud/github-app/installations", + 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 github_app_list_repos( + self, + gh_installation: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The installation 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, + ) -> List[GithubAppListRepos200ResponseInner]: + """List Github App repositories + + List Github App repositories + + :param gh_installation: The installation id (required) + :type gh_installation: 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._github_app_list_repos_serialize( + gh_installation=gh_installation, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[GithubAppListRepos200ResponseInner]", + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + 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 github_app_list_repos_with_http_info( + self, + gh_installation: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The installation 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[List[GithubAppListRepos200ResponseInner]]: + """List Github App repositories + + List Github App repositories + + :param gh_installation: The installation id (required) + :type gh_installation: 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._github_app_list_repos_serialize( + gh_installation=gh_installation, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[GithubAppListRepos200ResponseInner]", + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + 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 github_app_list_repos_without_preload_content( + self, + gh_installation: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The installation id", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List Github App repositories + + List Github App repositories + + :param gh_installation: The installation id (required) + :type gh_installation: 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._github_app_list_repos_serialize( + gh_installation=gh_installation, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[GithubAppListRepos200ResponseInner]", + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _github_app_list_repos_serialize( + self, + gh_installation, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if gh_installation is not None: + _path_params["gh-installation"] = gh_installation + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) + + # authentication setting + _auth_settings: List[str] = ["cookieAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/v1/cloud/github-app/installations/{gh-installation}/repos", + 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 github_update_global_webhook( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Github app global webhook + + Github App global webhook + + :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._github_update_global_webhook_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + 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 github_update_global_webhook_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Github app global webhook + + Github App global webhook + + :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._github_update_global_webhook_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + 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 github_update_global_webhook_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Github app global webhook + + Github App global webhook + + :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._github_update_global_webhook_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _github_update_global_webhook_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/api/v1/cloud/github/webhook", + 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 github_update_tenant_webhook( + self, + webhook: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The webhook 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, + ) -> None: + """Github app tenant webhook + + Github App tenant webhook + + :param webhook: The webhook id (required) + :type webhook: 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._github_update_tenant_webhook_serialize( + webhook=webhook, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + 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 github_update_tenant_webhook_with_http_info( + self, + webhook: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The webhook 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[None]: + """Github app tenant webhook + + Github App tenant webhook + + :param webhook: The webhook id (required) + :type webhook: 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._github_update_tenant_webhook_serialize( + webhook=webhook, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + 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 github_update_tenant_webhook_without_preload_content( + self, + webhook: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The webhook 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: + """Github app tenant webhook + + Github App tenant webhook + + :param webhook: The webhook id (required) + :type webhook: 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._github_update_tenant_webhook_serialize( + webhook=webhook, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "401": "MetadataGet400Response", + "405": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _github_update_tenant_webhook_serialize( + self, + webhook, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if webhook is not None: + _path_params["webhook"] = webhook + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/api/v1/cloud/github/webhook/{webhook}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/hatchet_sdk/clients/cloud_rest/api/log_api.py b/hatchet_sdk/clients/cloud_rest/api/log_api.py new file mode 100644 index 00000000..eefc22ae --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api/log_api.py @@ -0,0 +1,971 @@ +# 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 + +import warnings +from datetime import datetime +from typing import Any, Dict, List, Optional, Tuple, Union + +from pydantic import ( + Field, + StrictFloat, + StrictInt, + StrictStr, + field_validator, + validate_call, +) +from typing_extensions import Annotated + +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient, RequestSerialized +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner import ( + LogCreateRequestInner, +) +from hatchet_sdk.clients.cloud_rest.models.log_list200_response import ( + LogList200Response, +) +from hatchet_sdk.clients.cloud_rest.rest import RESTResponseType + + +class LogApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + async def build_logs_list( + self, + build: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The build 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, + ) -> LogList200Response: + """Get Build Logs + + Get the build logs for a specific build of a managed worker + + :param build: The build id (required) + :type build: 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._build_logs_list_serialize( + build=build, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "LogList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 build_logs_list_with_http_info( + self, + build: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The build 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[LogList200Response]: + """Get Build Logs + + Get the build logs for a specific build of a managed worker + + :param build: The build id (required) + :type build: 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._build_logs_list_serialize( + build=build, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "LogList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 build_logs_list_without_preload_content( + self, + build: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The build 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 Build Logs + + Get the build logs for a specific build of a managed worker + + :param build: The build id (required) + :type build: 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._build_logs_list_serialize( + build=build, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "LogList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _build_logs_list_serialize( + self, + build, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if build is not None: + _path_params["build"] = build + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _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/cloud/build/{build}/logs", + 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 log_create( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + log_create_request_inner: Optional[List[LogCreateRequestInner]] = 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, + ) -> None: + """Push Log Entry + + Push a log entry for the tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param log_create_request_inner: + :type log_create_request_inner: List[LogCreateRequestInner] + :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._log_create_serialize( + tenant=tenant, + log_create_request_inner=log_create_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 log_create_with_http_info( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + log_create_request_inner: Optional[List[LogCreateRequestInner]] = 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[None]: + """Push Log Entry + + Push a log entry for the tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param log_create_request_inner: + :type log_create_request_inner: List[LogCreateRequestInner] + :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._log_create_serialize( + tenant=tenant, + log_create_request_inner=log_create_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 log_create_without_preload_content( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + log_create_request_inner: Optional[List[LogCreateRequestInner]] = 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: + """Push Log Entry + + Push a log entry for the tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param log_create_request_inner: + :type log_create_request_inner: List[LogCreateRequestInner] + :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._log_create_serialize( + tenant=tenant, + log_create_request_inner=log_create_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _log_create_serialize( + self, + tenant, + log_create_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + "LogCreateRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if tenant is not None: + _path_params["tenant"] = tenant + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if log_create_request_inner is not None: + _body_params = log_create_request_inner + + # set the HTTP header `Accept` + _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] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="POST", + resource_path="/api/v1/cloud/tenants/{tenant}/logs", + 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 log_list( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + after: Annotated[ + Optional[datetime], Field(description="When the logs should start") + ] = None, + before: Annotated[ + Optional[datetime], Field(description="When the logs should end") + ] = None, + search: Annotated[ + Optional[StrictStr], Field(description="The search query to filter for") + ] = None, + direction: Annotated[ + Optional[StrictStr], Field(description="The direction to sort the logs") + ] = 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, + ) -> LogList200Response: + """List Logs + + Lists logs for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param after: When the logs should start + :type after: datetime + :param before: When the logs should end + :type before: datetime + :param search: The search query to filter for + :type search: str + :param direction: The direction to sort the logs + :type direction: 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._log_list_serialize( + managed_worker=managed_worker, + after=after, + before=before, + search=search, + direction=direction, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "LogList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 log_list_with_http_info( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + after: Annotated[ + Optional[datetime], Field(description="When the logs should start") + ] = None, + before: Annotated[ + Optional[datetime], Field(description="When the logs should end") + ] = None, + search: Annotated[ + Optional[StrictStr], Field(description="The search query to filter for") + ] = None, + direction: Annotated[ + Optional[StrictStr], Field(description="The direction to sort the logs") + ] = 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[LogList200Response]: + """List Logs + + Lists logs for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param after: When the logs should start + :type after: datetime + :param before: When the logs should end + :type before: datetime + :param search: The search query to filter for + :type search: str + :param direction: The direction to sort the logs + :type direction: 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._log_list_serialize( + managed_worker=managed_worker, + after=after, + before=before, + search=search, + direction=direction, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "LogList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 log_list_without_preload_content( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + after: Annotated[ + Optional[datetime], Field(description="When the logs should start") + ] = None, + before: Annotated[ + Optional[datetime], Field(description="When the logs should end") + ] = None, + search: Annotated[ + Optional[StrictStr], Field(description="The search query to filter for") + ] = None, + direction: Annotated[ + Optional[StrictStr], Field(description="The direction to sort the logs") + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List Logs + + Lists logs for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param after: When the logs should start + :type after: datetime + :param before: When the logs should end + :type before: datetime + :param search: The search query to filter for + :type search: str + :param direction: The direction to sort the logs + :type direction: 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._log_list_serialize( + managed_worker=managed_worker, + after=after, + before=before, + search=search, + direction=direction, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "LogList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _log_list_serialize( + self, + managed_worker, + after, + before, + search, + direction, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if managed_worker is not None: + _path_params["managed-worker"] = managed_worker + # process the query parameters + if after is not None: + if isinstance(after, datetime): + _query_params.append( + ( + "after", + after.strftime(self.api_client.configuration.datetime_format), + ) + ) + else: + _query_params.append(("after", after)) + + if before is not None: + if isinstance(before, datetime): + _query_params.append( + ( + "before", + before.strftime(self.api_client.configuration.datetime_format), + ) + ) + else: + _query_params.append(("before", before)) + + if search is not None: + + _query_params.append(("search", search)) + + if direction is not None: + + _query_params.append(("direction", direction)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _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/cloud/managed-worker/{managed-worker}/logs", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/hatchet_sdk/clients/cloud_rest/api/managed_worker_api.py b/hatchet_sdk/clients/cloud_rest/api/managed_worker_api.py new file mode 100644 index 00000000..840a93d4 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api/managed_worker_api.py @@ -0,0 +1,2546 @@ +# 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 + +import warnings +from typing import Any, Dict, List, Optional, Tuple, Union + +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call +from typing_extensions import Annotated + +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient, RequestSerialized +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.models.infra_as_code_create_request import ( + InfraAsCodeCreateRequest, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request import ( + ManagedWorkerCreateRequest, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_events_list200_response import ( + ManagedWorkerEventsList200Response, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_instances_list200_response import ( + ManagedWorkerInstancesList200Response, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response import ( + ManagedWorkerList200Response, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner import ( + ManagedWorkerList200ResponseRowsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_update_request import ( + ManagedWorkerUpdateRequest, +) +from hatchet_sdk.clients.cloud_rest.models.runtime_config_list_actions200_response import ( + RuntimeConfigListActions200Response, +) +from hatchet_sdk.clients.cloud_rest.rest import RESTResponseType + + +class ManagedWorkerApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + async def infra_as_code_create( + self, + infra_as_code_request: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The infra as code request id", + ), + ], + infra_as_code_create_request: Optional[InfraAsCodeCreateRequest] = 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, + ) -> None: + """Create Infra as Code + + Registers runtime configs via infra-as-code + + :param infra_as_code_request: The infra as code request id (required) + :type infra_as_code_request: str + :param infra_as_code_create_request: + :type infra_as_code_create_request: InfraAsCodeCreateRequest + :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._infra_as_code_create_serialize( + infra_as_code_request=infra_as_code_request, + infra_as_code_create_request=infra_as_code_create_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 infra_as_code_create_with_http_info( + self, + infra_as_code_request: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The infra as code request id", + ), + ], + infra_as_code_create_request: Optional[InfraAsCodeCreateRequest] = 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[None]: + """Create Infra as Code + + Registers runtime configs via infra-as-code + + :param infra_as_code_request: The infra as code request id (required) + :type infra_as_code_request: str + :param infra_as_code_create_request: + :type infra_as_code_create_request: InfraAsCodeCreateRequest + :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._infra_as_code_create_serialize( + infra_as_code_request=infra_as_code_request, + infra_as_code_create_request=infra_as_code_create_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 infra_as_code_create_without_preload_content( + self, + infra_as_code_request: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The infra as code request id", + ), + ], + infra_as_code_create_request: Optional[InfraAsCodeCreateRequest] = 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: + """Create Infra as Code + + Registers runtime configs via infra-as-code + + :param infra_as_code_request: The infra as code request id (required) + :type infra_as_code_request: str + :param infra_as_code_create_request: + :type infra_as_code_create_request: InfraAsCodeCreateRequest + :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._infra_as_code_create_serialize( + infra_as_code_request=infra_as_code_request, + infra_as_code_create_request=infra_as_code_create_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _infra_as_code_create_serialize( + self, + infra_as_code_request, + infra_as_code_create_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if infra_as_code_request is not None: + _path_params["infra-as-code-request"] = infra_as_code_request + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if infra_as_code_create_request is not None: + _body_params = infra_as_code_create_request + + # set the HTTP header `Accept` + _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/cloud/infra-as-code/{infra-as-code-request}", + 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 managed_worker_create( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + managed_worker_create_request: Optional[ManagedWorkerCreateRequest] = 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, + ) -> ManagedWorkerList200ResponseRowsInner: + """Create Managed Worker + + Create a managed worker for the tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param managed_worker_create_request: + :type managed_worker_create_request: ManagedWorkerCreateRequest + :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._managed_worker_create_serialize( + tenant=tenant, + managed_worker_create_request=managed_worker_create_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerList200ResponseRowsInner", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 managed_worker_create_with_http_info( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + managed_worker_create_request: Optional[ManagedWorkerCreateRequest] = 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[ManagedWorkerList200ResponseRowsInner]: + """Create Managed Worker + + Create a managed worker for the tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param managed_worker_create_request: + :type managed_worker_create_request: ManagedWorkerCreateRequest + :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._managed_worker_create_serialize( + tenant=tenant, + managed_worker_create_request=managed_worker_create_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerList200ResponseRowsInner", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 managed_worker_create_without_preload_content( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + managed_worker_create_request: Optional[ManagedWorkerCreateRequest] = 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: + """Create Managed Worker + + Create a managed worker for the tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param managed_worker_create_request: + :type managed_worker_create_request: ManagedWorkerCreateRequest + :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._managed_worker_create_serialize( + tenant=tenant, + managed_worker_create_request=managed_worker_create_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerList200ResponseRowsInner", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _managed_worker_create_serialize( + self, + tenant, + managed_worker_create_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if tenant is not None: + _path_params["tenant"] = tenant + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if managed_worker_create_request is not None: + _body_params = managed_worker_create_request + + # set the HTTP header `Accept` + _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/cloud/tenants/{tenant}/managed-worker", + 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 managed_worker_delete( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker 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, + ) -> ManagedWorkerList200ResponseRowsInner: + """Delete Managed Worker + + Delete a managed worker for the tenant + + :param managed_worker: The managed worker id (required) + :type managed_worker: 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._managed_worker_delete_serialize( + managed_worker=managed_worker, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerList200ResponseRowsInner", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + "404": "MetadataGet400Response", + } + 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 managed_worker_delete_with_http_info( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker 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[ManagedWorkerList200ResponseRowsInner]: + """Delete Managed Worker + + Delete a managed worker for the tenant + + :param managed_worker: The managed worker id (required) + :type managed_worker: 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._managed_worker_delete_serialize( + managed_worker=managed_worker, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerList200ResponseRowsInner", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + "404": "MetadataGet400Response", + } + 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 managed_worker_delete_without_preload_content( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker 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: + """Delete Managed Worker + + Delete a managed worker for the tenant + + :param managed_worker: The managed worker id (required) + :type managed_worker: 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._managed_worker_delete_serialize( + managed_worker=managed_worker, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerList200ResponseRowsInner", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + "404": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _managed_worker_delete_serialize( + self, + managed_worker, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if managed_worker is not None: + _path_params["managed-worker"] = managed_worker + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _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="DELETE", + resource_path="/api/v1/cloud/managed-worker/{managed-worker}", + 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 managed_worker_events_list( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker 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, + ) -> ManagedWorkerEventsList200Response: + """Get Managed Worker Events + + Get events for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: 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._managed_worker_events_list_serialize( + managed_worker=managed_worker, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerEventsList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 managed_worker_events_list_with_http_info( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker 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[ManagedWorkerEventsList200Response]: + """Get Managed Worker Events + + Get events for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: 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._managed_worker_events_list_serialize( + managed_worker=managed_worker, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerEventsList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 managed_worker_events_list_without_preload_content( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker 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 Managed Worker Events + + Get events for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: 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._managed_worker_events_list_serialize( + managed_worker=managed_worker, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerEventsList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _managed_worker_events_list_serialize( + self, + managed_worker, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if managed_worker is not None: + _path_params["managed-worker"] = managed_worker + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _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/cloud/managed-worker/{managed-worker}/events", + 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 managed_worker_get( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker 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, + ) -> ManagedWorkerList200ResponseRowsInner: + """Get Managed Worker + + Get a managed worker for the tenant + + :param managed_worker: The managed worker id (required) + :type managed_worker: 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._managed_worker_get_serialize( + managed_worker=managed_worker, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerList200ResponseRowsInner", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + "404": "MetadataGet400Response", + } + 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 managed_worker_get_with_http_info( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker 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[ManagedWorkerList200ResponseRowsInner]: + """Get Managed Worker + + Get a managed worker for the tenant + + :param managed_worker: The managed worker id (required) + :type managed_worker: 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._managed_worker_get_serialize( + managed_worker=managed_worker, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerList200ResponseRowsInner", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + "404": "MetadataGet400Response", + } + 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 managed_worker_get_without_preload_content( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker 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 Managed Worker + + Get a managed worker for the tenant + + :param managed_worker: The managed worker id (required) + :type managed_worker: 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._managed_worker_get_serialize( + managed_worker=managed_worker, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerList200ResponseRowsInner", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + "404": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _managed_worker_get_serialize( + self, + managed_worker, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if managed_worker is not None: + _path_params["managed-worker"] = managed_worker + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _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/cloud/managed-worker/{managed-worker}", + 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 managed_worker_instances_list( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker 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, + ) -> ManagedWorkerInstancesList200Response: + """List Instances + + Get all instances for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: 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._managed_worker_instances_list_serialize( + managed_worker=managed_worker, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerInstancesList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 managed_worker_instances_list_with_http_info( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker 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[ManagedWorkerInstancesList200Response]: + """List Instances + + Get all instances for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: 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._managed_worker_instances_list_serialize( + managed_worker=managed_worker, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerInstancesList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 managed_worker_instances_list_without_preload_content( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List Instances + + Get all instances for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: 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._managed_worker_instances_list_serialize( + managed_worker=managed_worker, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerInstancesList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _managed_worker_instances_list_serialize( + self, + managed_worker, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if managed_worker is not None: + _path_params["managed-worker"] = managed_worker + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _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/cloud/managed-worker/{managed-worker}/instances", + 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 managed_worker_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, + ) -> ManagedWorkerList200Response: + """List Managed Workers + + Get all managed workers for the 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._managed_worker_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": "ManagedWorkerList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 managed_worker_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[ManagedWorkerList200Response]: + """List Managed Workers + + Get all managed workers for the 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._managed_worker_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": "ManagedWorkerList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 managed_worker_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: + """List Managed Workers + + Get all managed workers for the 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._managed_worker_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": "ManagedWorkerList200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _managed_worker_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]] = {} + _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` + _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/cloud/tenants/{tenant}/managed-worker", + 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 managed_worker_update( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + managed_worker_update_request: Optional[ManagedWorkerUpdateRequest] = 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, + ) -> ManagedWorkerList200ResponseRowsInner: + """Update Managed Worker + + Update a managed worker for the tenant + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param managed_worker_update_request: + :type managed_worker_update_request: ManagedWorkerUpdateRequest + :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._managed_worker_update_serialize( + managed_worker=managed_worker, + managed_worker_update_request=managed_worker_update_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerList200ResponseRowsInner", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + "404": "MetadataGet400Response", + } + 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 managed_worker_update_with_http_info( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + managed_worker_update_request: Optional[ManagedWorkerUpdateRequest] = 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[ManagedWorkerList200ResponseRowsInner]: + """Update Managed Worker + + Update a managed worker for the tenant + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param managed_worker_update_request: + :type managed_worker_update_request: ManagedWorkerUpdateRequest + :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._managed_worker_update_serialize( + managed_worker=managed_worker, + managed_worker_update_request=managed_worker_update_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerList200ResponseRowsInner", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + "404": "MetadataGet400Response", + } + 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 managed_worker_update_without_preload_content( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + managed_worker_update_request: Optional[ManagedWorkerUpdateRequest] = 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: + """Update Managed Worker + + Update a managed worker for the tenant + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param managed_worker_update_request: + :type managed_worker_update_request: ManagedWorkerUpdateRequest + :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._managed_worker_update_serialize( + managed_worker=managed_worker, + managed_worker_update_request=managed_worker_update_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ManagedWorkerList200ResponseRowsInner", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + "404": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _managed_worker_update_serialize( + self, + managed_worker, + managed_worker_update_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if managed_worker is not None: + _path_params["managed-worker"] = managed_worker + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if managed_worker_update_request is not None: + _body_params = managed_worker_update_request + + # set the HTTP header `Accept` + _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/cloud/managed-worker/{managed-worker}", + 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 runtime_config_list_actions( + self, + runtime_config: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The runtime config 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, + ) -> RuntimeConfigListActions200Response: + """Get Runtime Config Actions + + Get a list of runtime config actions for a managed worker + + :param runtime_config: The runtime config id (required) + :type runtime_config: 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._runtime_config_list_actions_serialize( + runtime_config=runtime_config, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "RuntimeConfigListActions200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 runtime_config_list_actions_with_http_info( + self, + runtime_config: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The runtime config 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[RuntimeConfigListActions200Response]: + """Get Runtime Config Actions + + Get a list of runtime config actions for a managed worker + + :param runtime_config: The runtime config id (required) + :type runtime_config: 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._runtime_config_list_actions_serialize( + runtime_config=runtime_config, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "RuntimeConfigListActions200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 runtime_config_list_actions_without_preload_content( + self, + runtime_config: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The runtime config 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 Runtime Config Actions + + Get a list of runtime config actions for a managed worker + + :param runtime_config: The runtime config id (required) + :type runtime_config: 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._runtime_config_list_actions_serialize( + runtime_config=runtime_config, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "RuntimeConfigListActions200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _runtime_config_list_actions_serialize( + self, + runtime_config, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if runtime_config is not None: + _path_params["runtime-config"] = runtime_config + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _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/cloud/runtime-config/{runtime-config}/actions", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/hatchet_sdk/clients/cloud_rest/api/metadata_api.py b/hatchet_sdk/clients/cloud_rest/api/metadata_api.py new file mode 100644 index 00000000..3eafac47 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api/metadata_api.py @@ -0,0 +1,265 @@ +# 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 + +import warnings +from typing import Any, Dict, List, Optional, Tuple, Union + +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call +from typing_extensions import Annotated + +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient, RequestSerialized +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.models.metadata_get200_response import ( + MetadataGet200Response, +) +from hatchet_sdk.clients.cloud_rest.rest import RESTResponseType + + +class MetadataApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + async def metadata_get( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> MetadataGet200Response: + """Get metadata + + Gets metadata for the Hatchet instance + + :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._metadata_get_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "MetadataGet200Response", + "400": "MetadataGet400Response", + } + 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 metadata_get_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[MetadataGet200Response]: + """Get metadata + + Gets metadata for the Hatchet instance + + :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._metadata_get_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "MetadataGet200Response", + "400": "MetadataGet400Response", + } + 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 metadata_get_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get metadata + + Gets metadata for the Hatchet instance + + :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._metadata_get_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "MetadataGet200Response", + "400": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _metadata_get_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/v1/cloud/metadata", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/hatchet_sdk/clients/cloud_rest/api/metrics_api.py b/hatchet_sdk/clients/cloud_rest/api/metrics_api.py new file mode 100644 index 00000000..872304d8 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api/metrics_api.py @@ -0,0 +1,1026 @@ +# 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 + +import warnings +from datetime import datetime +from typing import Any, Dict, List, Optional, Tuple, Union + +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call +from typing_extensions import Annotated + +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient, RequestSerialized +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.models.metrics_cpu_get200_response_inner import ( + MetricsCpuGet200ResponseInner, +) +from hatchet_sdk.clients.cloud_rest.rest import RESTResponseType + + +class MetricsApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + async def metrics_cpu_get( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + after: Annotated[ + Optional[datetime], Field(description="When the metrics should start") + ] = None, + before: Annotated[ + Optional[datetime], Field(description="When the metrics should end") + ] = 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, + ) -> List[MetricsCpuGet200ResponseInner]: + """Get CPU Metrics + + Get CPU metrics for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param after: When the metrics should start + :type after: datetime + :param before: When the metrics should end + :type 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._metrics_cpu_get_serialize( + managed_worker=managed_worker, + after=after, + before=before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[MetricsCpuGet200ResponseInner]", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 metrics_cpu_get_with_http_info( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + after: Annotated[ + Optional[datetime], Field(description="When the metrics should start") + ] = None, + before: Annotated[ + Optional[datetime], Field(description="When the metrics should end") + ] = 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[List[MetricsCpuGet200ResponseInner]]: + """Get CPU Metrics + + Get CPU metrics for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param after: When the metrics should start + :type after: datetime + :param before: When the metrics should end + :type 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._metrics_cpu_get_serialize( + managed_worker=managed_worker, + after=after, + before=before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[MetricsCpuGet200ResponseInner]", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 metrics_cpu_get_without_preload_content( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + after: Annotated[ + Optional[datetime], Field(description="When the metrics should start") + ] = None, + before: Annotated[ + Optional[datetime], Field(description="When the metrics should end") + ] = 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 CPU Metrics + + Get CPU metrics for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param after: When the metrics should start + :type after: datetime + :param before: When the metrics should end + :type 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._metrics_cpu_get_serialize( + managed_worker=managed_worker, + after=after, + before=before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[MetricsCpuGet200ResponseInner]", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _metrics_cpu_get_serialize( + self, + managed_worker, + after, + before, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if managed_worker is not None: + _path_params["managed-worker"] = managed_worker + # process the query parameters + if after is not None: + if isinstance(after, datetime): + _query_params.append( + ( + "after", + after.strftime(self.api_client.configuration.datetime_format), + ) + ) + else: + _query_params.append(("after", after)) + + if before is not None: + if isinstance(before, datetime): + _query_params.append( + ( + "before", + before.strftime(self.api_client.configuration.datetime_format), + ) + ) + else: + _query_params.append(("before", before)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _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/cloud/managed-worker/{managed-worker}/metrics/cpu", + 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 metrics_disk_get( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + after: Annotated[ + Optional[datetime], Field(description="When the metrics should start") + ] = None, + before: Annotated[ + Optional[datetime], Field(description="When the metrics should end") + ] = 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, + ) -> List[MetricsCpuGet200ResponseInner]: + """Get Disk Metrics + + Get disk metrics for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param after: When the metrics should start + :type after: datetime + :param before: When the metrics should end + :type 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._metrics_disk_get_serialize( + managed_worker=managed_worker, + after=after, + before=before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[MetricsCpuGet200ResponseInner]", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 metrics_disk_get_with_http_info( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + after: Annotated[ + Optional[datetime], Field(description="When the metrics should start") + ] = None, + before: Annotated[ + Optional[datetime], Field(description="When the metrics should end") + ] = 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[List[MetricsCpuGet200ResponseInner]]: + """Get Disk Metrics + + Get disk metrics for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param after: When the metrics should start + :type after: datetime + :param before: When the metrics should end + :type 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._metrics_disk_get_serialize( + managed_worker=managed_worker, + after=after, + before=before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[MetricsCpuGet200ResponseInner]", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 metrics_disk_get_without_preload_content( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + after: Annotated[ + Optional[datetime], Field(description="When the metrics should start") + ] = None, + before: Annotated[ + Optional[datetime], Field(description="When the metrics should end") + ] = 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 Disk Metrics + + Get disk metrics for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param after: When the metrics should start + :type after: datetime + :param before: When the metrics should end + :type 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._metrics_disk_get_serialize( + managed_worker=managed_worker, + after=after, + before=before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[MetricsCpuGet200ResponseInner]", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _metrics_disk_get_serialize( + self, + managed_worker, + after, + before, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if managed_worker is not None: + _path_params["managed-worker"] = managed_worker + # process the query parameters + if after is not None: + if isinstance(after, datetime): + _query_params.append( + ( + "after", + after.strftime(self.api_client.configuration.datetime_format), + ) + ) + else: + _query_params.append(("after", after)) + + if before is not None: + if isinstance(before, datetime): + _query_params.append( + ( + "before", + before.strftime(self.api_client.configuration.datetime_format), + ) + ) + else: + _query_params.append(("before", before)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _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/cloud/managed-worker/{managed-worker}/metrics/disk", + 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 metrics_memory_get( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + after: Annotated[ + Optional[datetime], Field(description="When the metrics should start") + ] = None, + before: Annotated[ + Optional[datetime], Field(description="When the metrics should end") + ] = 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, + ) -> List[MetricsCpuGet200ResponseInner]: + """Get Memory Metrics + + Get memory metrics for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param after: When the metrics should start + :type after: datetime + :param before: When the metrics should end + :type 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._metrics_memory_get_serialize( + managed_worker=managed_worker, + after=after, + before=before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[MetricsCpuGet200ResponseInner]", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 metrics_memory_get_with_http_info( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + after: Annotated[ + Optional[datetime], Field(description="When the metrics should start") + ] = None, + before: Annotated[ + Optional[datetime], Field(description="When the metrics should end") + ] = 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[List[MetricsCpuGet200ResponseInner]]: + """Get Memory Metrics + + Get memory metrics for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param after: When the metrics should start + :type after: datetime + :param before: When the metrics should end + :type 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._metrics_memory_get_serialize( + managed_worker=managed_worker, + after=after, + before=before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[MetricsCpuGet200ResponseInner]", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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 metrics_memory_get_without_preload_content( + self, + managed_worker: Annotated[ + str, + Field( + min_length=36, + strict=True, + max_length=36, + description="The managed worker id", + ), + ], + after: Annotated[ + Optional[datetime], Field(description="When the metrics should start") + ] = None, + before: Annotated[ + Optional[datetime], Field(description="When the metrics should end") + ] = 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 Memory Metrics + + Get memory metrics for a managed worker + + :param managed_worker: The managed worker id (required) + :type managed_worker: str + :param after: When the metrics should start + :type after: datetime + :param before: When the metrics should end + :type 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._metrics_memory_get_serialize( + managed_worker=managed_worker, + after=after, + before=before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "List[MetricsCpuGet200ResponseInner]", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _metrics_memory_get_serialize( + self, + managed_worker, + after, + before, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if managed_worker is not None: + _path_params["managed-worker"] = managed_worker + # process the query parameters + if after is not None: + if isinstance(after, datetime): + _query_params.append( + ( + "after", + after.strftime(self.api_client.configuration.datetime_format), + ) + ) + else: + _query_params.append(("after", after)) + + if before is not None: + if isinstance(before, datetime): + _query_params.append( + ( + "before", + before.strftime(self.api_client.configuration.datetime_format), + ) + ) + else: + _query_params.append(("before", before)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _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/cloud/managed-worker/{managed-worker}/metrics/memory", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/hatchet_sdk/clients/cloud_rest/api/tenant_api.py b/hatchet_sdk/clients/cloud_rest/api/tenant_api.py new file mode 100644 index 00000000..ff558e41 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api/tenant_api.py @@ -0,0 +1,301 @@ +# 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 + +import warnings +from typing import Any, Dict, List, Optional, Tuple, Union + +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call +from typing_extensions import Annotated + +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient, RequestSerialized +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response import ( + TenantBillingStateGet200Response, +) +from hatchet_sdk.clients.cloud_rest.rest import RESTResponseType + + +class TenantApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + async def tenant_billing_state_get( + 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, + ) -> TenantBillingStateGet200Response: + """Get the billing state for a tenant + + Gets the billing state 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._tenant_billing_state_get_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": "TenantBillingStateGet200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400ResponseErrorsInner", + "405": "MetadataGet400Response", + } + 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 tenant_billing_state_get_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[TenantBillingStateGet200Response]: + """Get the billing state for a tenant + + Gets the billing state 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._tenant_billing_state_get_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": "TenantBillingStateGet200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400ResponseErrorsInner", + "405": "MetadataGet400Response", + } + 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 tenant_billing_state_get_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 the billing state for a tenant + + Gets the billing state 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._tenant_billing_state_get_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": "TenantBillingStateGet200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400ResponseErrorsInner", + "405": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _tenant_billing_state_get_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]] = {} + _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` + _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/billing/tenants/{tenant}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/hatchet_sdk/clients/cloud_rest/api/user_api.py b/hatchet_sdk/clients/cloud_rest/api/user_api.py new file mode 100644 index 00000000..d0c56de3 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api/user_api.py @@ -0,0 +1,473 @@ +# 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 + +import warnings +from typing import Any, Dict, List, Optional, Tuple, Union + +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call +from typing_extensions import Annotated + +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient, RequestSerialized +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.rest import RESTResponseType + + +class UserApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + async def user_update_github_app_oauth_callback( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Complete OAuth flow + + Completes the OAuth flow + + :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._user_update_github_app_oauth_callback_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "302": None, + } + 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 user_update_github_app_oauth_callback_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Complete OAuth flow + + Completes the OAuth flow + + :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._user_update_github_app_oauth_callback_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "302": None, + } + 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 user_update_github_app_oauth_callback_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Complete OAuth flow + + Completes the OAuth flow + + :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._user_update_github_app_oauth_callback_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "302": None, + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _user_update_github_app_oauth_callback_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # authentication setting + _auth_settings: List[str] = ["cookieAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/v1/cloud/users/github-app/callback", + 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 user_update_github_app_oauth_start( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Start OAuth flow + + Starts the OAuth flow + + :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._user_update_github_app_oauth_start_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "302": None, + } + 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 user_update_github_app_oauth_start_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Start OAuth flow + + Starts the OAuth flow + + :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._user_update_github_app_oauth_start_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "302": None, + } + 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 user_update_github_app_oauth_start_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Start OAuth flow + + Starts the OAuth flow + + :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._user_update_github_app_oauth_start_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "302": None, + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _user_update_github_app_oauth_start_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # authentication setting + _auth_settings: List[str] = ["cookieAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/v1/cloud/users/github-app/start", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/hatchet_sdk/clients/cloud_rest/api/workflow_api.py b/hatchet_sdk/clients/cloud_rest/api/workflow_api.py new file mode 100644 index 00000000..9deb7400 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api/workflow_api.py @@ -0,0 +1,369 @@ +# 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 + +import warnings +from datetime import datetime +from typing import Any, Dict, List, Optional, Tuple, Union + +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call +from typing_extensions import Annotated + +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient, RequestSerialized +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.models.workflow_run_events_get_metrics200_response import ( + WorkflowRunEventsGetMetrics200Response, +) +from hatchet_sdk.clients.cloud_rest.rest import RESTResponseType + + +class WorkflowApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + async def workflow_run_events_get_metrics( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + created_after: Annotated[ + Optional[datetime], + Field(description="The time after the workflow run was created"), + ] = None, + finished_before: Annotated[ + Optional[datetime], + Field(description="The time before the workflow run was completed"), + ] = 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, + ) -> WorkflowRunEventsGetMetrics200Response: + """Get workflow runs + + Get a minute by minute breakdown of workflow run metrics for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param created_after: The time after the workflow run was created + :type created_after: datetime + :param finished_before: The time before the workflow run was completed + :type finished_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_events_get_metrics_serialize( + tenant=tenant, + created_after=created_after, + finished_before=finished_before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRunEventsGetMetrics200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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_events_get_metrics_with_http_info( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + created_after: Annotated[ + Optional[datetime], + Field(description="The time after the workflow run was created"), + ] = None, + finished_before: Annotated[ + Optional[datetime], + Field(description="The time before the workflow run was completed"), + ] = 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[WorkflowRunEventsGetMetrics200Response]: + """Get workflow runs + + Get a minute by minute breakdown of workflow run metrics for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param created_after: The time after the workflow run was created + :type created_after: datetime + :param finished_before: The time before the workflow run was completed + :type finished_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_events_get_metrics_serialize( + tenant=tenant, + created_after=created_after, + finished_before=finished_before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRunEventsGetMetrics200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + 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_events_get_metrics_without_preload_content( + self, + tenant: Annotated[ + str, + Field( + min_length=36, strict=True, max_length=36, description="The tenant id" + ), + ], + created_after: Annotated[ + Optional[datetime], + Field(description="The time after the workflow run was created"), + ] = None, + finished_before: Annotated[ + Optional[datetime], + Field(description="The time before the workflow run was completed"), + ] = 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 a minute by minute breakdown of workflow run metrics for a tenant + + :param tenant: The tenant id (required) + :type tenant: str + :param created_after: The time after the workflow run was created + :type created_after: datetime + :param finished_before: The time before the workflow run was completed + :type finished_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_events_get_metrics_serialize( + tenant=tenant, + created_after=created_after, + finished_before=finished_before, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WorkflowRunEventsGetMetrics200Response", + "400": "MetadataGet400Response", + "403": "MetadataGet400Response", + } + response_data = await self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _workflow_run_events_get_metrics_serialize( + self, + tenant, + created_after, + finished_before, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if tenant is not None: + _path_params["tenant"] = tenant + # process the query parameters + 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 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)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _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/cloud/tenants/{tenant}/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, + ) diff --git a/hatchet_sdk/clients/cloud_rest/api_client.py b/hatchet_sdk/clients/cloud_rest/api_client.py new file mode 100644 index 00000000..04b3f909 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api_client.py @@ -0,0 +1,727 @@ +# 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 + + +import datetime +import json +import mimetypes +import os +import re +import tempfile +from enum import Enum +from typing import Dict, List, Optional, Tuple, Union +from urllib.parse import quote + +from dateutil.parser import parse +from pydantic import SecretStr + +import hatchet_sdk.clients.cloud_rest.models +from hatchet_sdk.clients.cloud_rest import rest +from hatchet_sdk.clients.cloud_rest.api_response import ApiResponse +from hatchet_sdk.clients.cloud_rest.api_response import T as ApiResponseT +from hatchet_sdk.clients.cloud_rest.configuration import Configuration +from hatchet_sdk.clients.cloud_rest.exceptions import ( + ApiException, + ApiValueError, + BadRequestException, + ForbiddenException, + NotFoundException, + ServiceException, + UnauthorizedException, +) + +RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] + + +class ApiClient: + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + """ + + PRIMITIVE_TYPES = (float, bool, bytes, str, int) + NATIVE_TYPES_MAPPING = { + "int": int, + "long": int, # TODO remove as only py3 is supported? + "float": float, + "str": str, + "bool": bool, + "date": datetime.date, + "datetime": datetime.datetime, + "object": object, + } + _pool = None + + def __init__( + self, configuration=None, header_name=None, header_value=None, cookie=None + ) -> None: + # use default configuration if none is provided + if configuration is None: + configuration = Configuration.get_default() + self.configuration = configuration + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = "OpenAPI-Generator/1.0.0/python" + self.client_side_validation = configuration.client_side_validation + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc_value, traceback): + await self.close() + + async def close(self): + await self.rest_client.close() + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers["User-Agent"] + + @user_agent.setter + def user_agent(self, value): + self.default_headers["User-Agent"] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + _default = None + + @classmethod + def get_default(cls): + """Return new instance of ApiClient. + + This method returns newly created, based on default constructor, + object of ApiClient class or returns a copy of default + ApiClient. + + :return: The ApiClient object. + """ + if cls._default is None: + cls._default = ApiClient() + return cls._default + + @classmethod + def set_default(cls, default): + """Set default instance of ApiClient. + + It stores default ApiClient. + + :param default: object of ApiClient. + """ + cls._default = default + + def param_serialize( + self, + method, + resource_path, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, + auth_settings=None, + collection_formats=None, + _host=None, + _request_auth=None, + ) -> RequestSerialized: + """Builds the HTTP request params needed by the request. + :param method: Method to call. + :param resource_path: Path to method endpoint. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :return: tuple of form (path, http_method, query_params, header_params, + body, post_params, files) + """ + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params["Cookie"] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict( + self.parameters_to_tuples(header_params, collection_formats) + ) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples(path_params, collection_formats) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace( + "{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param) + ) + + # post parameters + if post_params or files: + post_params = post_params if post_params else [] + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples(post_params, collection_formats) + if files: + post_params.extend(self.files_parameters(files)) + + # auth setting + self.update_params_for_auth( + header_params, + query_params, + auth_settings, + resource_path, + method, + body, + request_auth=_request_auth, + ) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + if _host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + url_query = self.parameters_to_url_query(query_params, collection_formats) + url += "?" + url_query + + return method, url, header_params, body, post_params + + async def call_api( + self, + method, + url, + header_params=None, + body=None, + post_params=None, + _request_timeout=None, + ) -> rest.RESTResponse: + """Makes the HTTP request (synchronous) + :param method: Method to call. + :param url: Path to method endpoint. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param _request_timeout: timeout setting for this request. + :return: RESTResponse + """ + + try: + # perform request and return response + response_data = await self.rest_client.request( + method, + url, + headers=header_params, + body=body, + post_params=post_params, + _request_timeout=_request_timeout, + ) + + except ApiException as e: + raise e + + return response_data + + def response_deserialize( + self, + response_data: rest.RESTResponse, + response_types_map: Optional[Dict[str, ApiResponseT]] = None, + ) -> ApiResponse[ApiResponseT]: + """Deserializes response into an object. + :param response_data: RESTResponse object to be deserialized. + :param response_types_map: dict of response types. + :return: ApiResponse + """ + + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + assert response_data.data is not None, msg + + response_type = response_types_map.get(str(response_data.status), None) + if ( + not response_type + and isinstance(response_data.status, int) + and 100 <= response_data.status <= 599 + ): + # if not found, look for '1XX', '2XX', etc. + response_type = response_types_map.get( + str(response_data.status)[0] + "XX", None + ) + + # deserialize response data + response_text = None + return_data = None + try: + if response_type == "bytearray": + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: + match = None + content_type = response_data.getheader("content-type") + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_text = response_data.data.decode(encoding) + if response_type in ["bytearray", "str"]: + return_data = self.__deserialize_primitive( + response_text, response_type + ) + else: + return_data = self.deserialize(response_text, response_type) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) + + return ApiResponse( + status_code=response_data.status, + data=return_data, + headers=response_data.getheaders(), + raw_data=response_data.data, + ) + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is SecretStr, return obj.get_secret_value() + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is OpenAPI model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, Enum): + return obj.value + elif isinstance(obj, SecretStr): + return obj.get_secret_value() + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, list): + return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] + elif isinstance(obj, tuple): + return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + + elif isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): + obj_dict = obj.to_dict() + else: + obj_dict = obj.__dict__ + + return { + key: self.sanitize_for_serialization(val) for key, val in obj_dict.items() + } + + def deserialize(self, response_text, response_type): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + + :return: deserialized object. + """ + + # fetch data from response object + try: + data = json.loads(response_text) + except ValueError: + data = response_text + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if isinstance(klass, str): + if klass.startswith("List["): + m = re.match(r"List\[(.*)]", klass) + assert m is not None, "Malformed List type definition" + sub_kls = m.group(1) + return [self.__deserialize(sub_data, sub_kls) for sub_data in data] + + if klass.startswith("Dict["): + m = re.match(r"Dict\[([^,]*), (.*)]", klass) + assert m is not None, "Malformed Dict type definition" + sub_kls = m.group(2) + return {k: self.__deserialize(v, sub_kls) for k, v in data.items()} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + else: + klass = getattr(hatchet_sdk.clients.cloud_rest.models, klass) + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass == object: + return self.__deserialize_object(data) + elif klass == datetime.date: + return self.__deserialize_date(data) + elif klass == datetime.datetime: + return self.__deserialize_datetime(data) + elif issubclass(klass, Enum): + return self.__deserialize_enum(data, klass) + else: + return self.__deserialize_model(data, klass) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == "multi": + new_params.extend((k, value) for value in v) + else: + if collection_format == "ssv": + delimiter = " " + elif collection_format == "tsv": + delimiter = "\t" + elif collection_format == "pipes": + delimiter = "|" + else: # csv is the default + delimiter = "," + new_params.append((k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def parameters_to_url_query(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: URL query string (e.g. a=Hello%20World&b=123) + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if isinstance(v, bool): + v = str(v).lower() + if isinstance(v, (int, float)): + v = str(v) + if isinstance(v, dict): + v = json.dumps(v) + + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == "multi": + new_params.extend((k, str(value)) for value in v) + else: + if collection_format == "ssv": + delimiter = " " + elif collection_format == "tsv": + delimiter = "\t" + elif collection_format == "pipes": + delimiter = "|" + else: # csv is the default + delimiter = "," + new_params.append( + (k, delimiter.join(quote(str(value)) for value in v)) + ) + else: + new_params.append((k, quote(str(v)))) + + return "&".join(["=".join(map(str, item)) for item in new_params]) + + def files_parameters(self, files: Dict[str, Union[str, bytes]]): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + for k, v in files.items(): + if isinstance(v, str): + with open(v, "rb") as f: + filename = os.path.basename(f.name) + filedata = f.read() + elif isinstance(v, bytes): + filename = k + filedata = v + else: + raise ValueError("Unsupported file value") + mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream" + params.append(tuple([k, tuple([filename, filedata, mimetype])])) + return params + + def select_header_accept(self, accepts: List[str]) -> Optional[str]: + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return None + + for accept in accepts: + if re.search("json", accept, re.IGNORECASE): + return accept + + return accepts[0] + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return None + + for content_type in content_types: + if re.search("json", content_type, re.IGNORECASE): + return content_type + + return content_types[0] + + def update_params_for_auth( + self, + headers, + queries, + auth_settings, + resource_path, + method, + body, + request_auth=None, + ) -> None: + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param request_auth: if set, the provided settings will + override the token in the configuration. + """ + if not auth_settings: + return + + if request_auth: + self._apply_auth_params( + headers, queries, resource_path, method, body, request_auth + ) + else: + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + self._apply_auth_params( + headers, queries, resource_path, method, body, auth_setting + ) + + def _apply_auth_params( + self, headers, queries, resource_path, method, body, auth_setting + ) -> None: + """Updates the request parameters based on a single auth_setting + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param auth_setting: auth settings for the endpoint + """ + if auth_setting["in"] == "cookie": + headers["Cookie"] = auth_setting["value"] + elif auth_setting["in"] == "header": + if auth_setting["type"] != "http-signature": + headers[auth_setting["key"]] = auth_setting["value"] + elif auth_setting["in"] == "query": + queries.append((auth_setting["key"], auth_setting["value"])) + else: + raise ApiValueError("Authentication token must be in `query` or `header`") + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + handle file downloading + save response body into a tmp file and return the instance + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + m = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition) + assert m is not None, "Unexpected 'content-disposition' header value" + filename = m.group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + f.write(response.data) + + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return str(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return an original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, reason="Failed to parse `{0}` as date object".format(string) + ) + + def __deserialize_datetime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason=("Failed to parse `{0}` as datetime object".format(string)), + ) + + def __deserialize_enum(self, data, klass): + """Deserializes primitive type to enum. + + :param data: primitive type. + :param klass: class literal. + :return: enum value. + """ + try: + return klass(data) + except ValueError: + raise rest.ApiException( + status=0, reason=("Failed to parse `{0}` as `{1}`".format(data, klass)) + ) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :param data: dict, list. + :param klass: class literal. + :return: model object. + """ + + return klass.from_dict(data) diff --git a/hatchet_sdk/clients/cloud_rest/api_response.py b/hatchet_sdk/clients/cloud_rest/api_response.py new file mode 100644 index 00000000..ca801da0 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/api_response.py @@ -0,0 +1,22 @@ +"""API response object.""" + +from __future__ import annotations + +from typing import Generic, Mapping, Optional, TypeVar + +from pydantic import BaseModel, Field, StrictBytes, StrictInt + +T = TypeVar("T") + + +class ApiResponse(BaseModel, Generic[T]): + """ + API response object + """ + + status_code: StrictInt = Field(description="HTTP status code") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") + data: T = Field(description="Deserialized data given the data type") + raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") + + model_config = {"arbitrary_types_allowed": True} diff --git a/hatchet_sdk/clients/cloud_rest/configuration.py b/hatchet_sdk/clients/cloud_rest/configuration.py new file mode 100644 index 00000000..1b5b1850 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/configuration.py @@ -0,0 +1,488 @@ +# 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 + + +import copy +import http.client as httplib +import logging +import sys +from logging import FileHandler +from typing import Optional + +import urllib3 + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + "multipleOf", + "maximum", + "exclusiveMaximum", + "minimum", + "exclusiveMinimum", + "maxLength", + "minLength", + "pattern", + "maxItems", + "minItems", +} + + +class Configuration: + """This class contains various settings of the API client. + + :param host: Base url. + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer). + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication. + :param password: Password for HTTP basic authentication. + :param access_token: Access token. + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum + values before. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format. + + :Example: + + API Key Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + cookieAuth: # name for the security scheme + type: apiKey + in: cookie + name: JSESSIONID # cookie name + + You can programmatically set the cookie: + + conf = hatchet_sdk.clients.cloud_rest.Configuration( + api_key={'cookieAuth': 'abc123'} + api_key_prefix={'cookieAuth': 'JSESSIONID'} + ) + + The following cookie will be added to the HTTP request: + Cookie: JSESSIONID abc123 + """ + + _default = 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, + ssl_ca_cert=None, + ) -> None: + """Constructor""" + self._base_path = "http://localhost" if host is None else host + """Default Base url + """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.access_token = access_token + """Access token + """ + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger( + "hatchet_sdk.clients.cloud_rest" + ) + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = "%(asctime)s %(levelname)s %(message)s" + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler: Optional[FileHandler] = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + self.debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = ssl_ca_cert + """Set this to customize the certificate file to verify the peer. + """ + self.cert_file = None + """client certificate file + """ + self.key_file = None + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + self.tls_server_name = None + """SSL/TLS Server Name Indication (SNI) + Set this to the SNI value expected by the server. + """ + + self.connection_pool_maxsize = 100 + """This value is passed to the aiohttp to limit simultaneous connections. + Default values is 100, None means no-limit. + """ + + self.proxy: Optional[str] = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = "" + """Safe chars for path_param + """ + self.retries = None + """Adding retries to override urllib3 default value 3 + """ + # Enable client side validation + self.client_side_validation = True + + self.socket_options = None + """Options to pass down to the underlying urllib3 socket + """ + + self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z" + """datetime format + """ + + self.date_format = "%Y-%m-%d" + """date format + """ + + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ("logger", "logger_file_handler"): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name, value): + object.__setattr__(self, name, value) + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = default + + @classmethod + def get_default_copy(cls): + """Deprecated. Please use `get_default` instead. + + Deprecated. Please use `get_default` instead. + + :return: The configuration object. + """ + return cls.get_default() + + @classmethod + def get_default(cls): + """Return the default configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration. + + :return: The configuration object. + """ + if cls._default is None: + cls._default = Configuration() + return cls._default + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on httplib debug + httplib.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off httplib debug + httplib.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier, alias=None): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get( + identifier, self.api_key.get(alias) if alias is not None else None + ) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers(basic_auth=username + ":" + password).get( + "authorization" + ) + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} + if self.access_token is not None: + auth["bearerAuth"] = { + "type": "bearer", + "in": "header", + "key": "Authorization", + "value": "Bearer " + self.access_token, + } + if "cookieAuth" in self.api_key: + auth["cookieAuth"] = { + "type": "api_key", + "in": "cookie", + "key": "hatchet", + "value": self.get_api_key_with_prefix( + "cookieAuth", + ), + } + return auth + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return ( + "Python SDK Debug Report:\n" + "OS: {env}\n" + "Python Version: {pyversion}\n" + "Version of the API: 1.0.0\n" + "SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version) + ) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + "url": "", + "description": "No description provided", + } + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """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 + :param servers: an array of host settings or None + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers)) + ) + + url = server["url"] + + # go through variables and replace placeholders + for variable_name, variable in server.get("variables", {}).items(): + used_value = variables.get(variable_name, variable["default_value"]) + + if "enum_values" in variable and used_value not in variable["enum_values"]: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], variable["enum_values"] + ) + ) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self): + """Return generated host.""" + return self.get_host_from_settings( + self.server_index, variables=self.server_variables + ) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/hatchet_sdk/clients/cloud_rest/exceptions.py b/hatchet_sdk/clients/cloud_rest/exceptions.py new file mode 100644 index 00000000..b41ac1d2 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/exceptions.py @@ -0,0 +1,200 @@ +# 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 typing import Any, Optional + +from typing_extensions import Self + + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__( + self, msg, path_to_item=None, valid_classes=None, key_type=None + ) -> None: + """Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + + if http_resp: + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode("utf-8") + except Exception: + pass + self.headers = http_resp.getheaders() + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format(self.headers) + + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) + + return error_message + + +class BadRequestException(ApiException): + pass + + +class NotFoundException(ApiException): + pass + + +class UnauthorizedException(ApiException): + pass + + +class ForbiddenException(ApiException): + pass + + +class ServiceException(ApiException): + pass + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/hatchet_sdk/clients/cloud_rest/models/__init__.py b/hatchet_sdk/clients/cloud_rest/models/__init__.py new file mode 100644 index 00000000..6228df77 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/__init__.py @@ -0,0 +1,157 @@ +# coding: utf-8 + +# flake8: noqa +""" + 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 + + +# import models into model package +from hatchet_sdk.clients.cloud_rest.models.billing_portal_link_get200_response import ( + BillingPortalLinkGet200Response, +) +from hatchet_sdk.clients.cloud_rest.models.build_get200_response import ( + BuildGet200Response, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_branches200_response_inner import ( + GithubAppListBranches200ResponseInner, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response import ( + GithubAppListInstallations200Response, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response_pagination import ( + GithubAppListInstallations200ResponsePagination, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response_rows_inner import ( + GithubAppListInstallations200ResponseRowsInner, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response_rows_inner_metadata import ( + GithubAppListInstallations200ResponseRowsInnerMetadata, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_repos200_response_inner import ( + GithubAppListRepos200ResponseInner, +) +from hatchet_sdk.clients.cloud_rest.models.infra_as_code_create_request import ( + InfraAsCodeCreateRequest, +) +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner import ( + LogCreateRequestInner, +) +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner_event import ( + LogCreateRequestInnerEvent, +) +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner_fly import ( + LogCreateRequestInnerFly, +) +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner_fly_app import ( + LogCreateRequestInnerFlyApp, +) +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner_log import ( + LogCreateRequestInnerLog, +) +from hatchet_sdk.clients.cloud_rest.models.log_list200_response import ( + LogList200Response, +) +from hatchet_sdk.clients.cloud_rest.models.log_list200_response_rows_inner import ( + LogList200ResponseRowsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request import ( + ManagedWorkerCreateRequest, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_build_config import ( + ManagedWorkerCreateRequestBuildConfig, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_build_config_steps_inner import ( + ManagedWorkerCreateRequestBuildConfigStepsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_runtime_config import ( + ManagedWorkerCreateRequestRuntimeConfig, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_events_list200_response import ( + ManagedWorkerEventsList200Response, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_events_list200_response_rows_inner import ( + ManagedWorkerEventsList200ResponseRowsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_instances_list200_response import ( + ManagedWorkerInstancesList200Response, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_instances_list200_response_rows_inner import ( + ManagedWorkerInstancesList200ResponseRowsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response import ( + ManagedWorkerList200Response, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner import ( + ManagedWorkerList200ResponseRowsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner_build_config import ( + ManagedWorkerList200ResponseRowsInnerBuildConfig, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner_build_config_steps_inner import ( + ManagedWorkerList200ResponseRowsInnerBuildConfigStepsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner_runtime_configs_inner import ( + ManagedWorkerList200ResponseRowsInnerRuntimeConfigsInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_update_request import ( + ManagedWorkerUpdateRequest, +) +from hatchet_sdk.clients.cloud_rest.models.metadata_get200_response import ( + MetadataGet200Response, +) +from hatchet_sdk.clients.cloud_rest.models.metadata_get400_response import ( + MetadataGet400Response, +) +from hatchet_sdk.clients.cloud_rest.models.metadata_get400_response_errors_inner import ( + MetadataGet400ResponseErrorsInner, +) +from hatchet_sdk.clients.cloud_rest.models.metrics_cpu_get200_response_inner import ( + MetricsCpuGet200ResponseInner, +) +from hatchet_sdk.clients.cloud_rest.models.metrics_cpu_get200_response_inner_histograms_inner import ( + MetricsCpuGet200ResponseInnerHistogramsInner, +) +from hatchet_sdk.clients.cloud_rest.models.metrics_cpu_get200_response_inner_histograms_inner_histogram import ( + MetricsCpuGet200ResponseInnerHistogramsInnerHistogram, +) +from hatchet_sdk.clients.cloud_rest.models.metrics_cpu_get200_response_inner_histograms_inner_histogram_buckets_inner import ( + MetricsCpuGet200ResponseInnerHistogramsInnerHistogramBucketsInner, +) +from hatchet_sdk.clients.cloud_rest.models.runtime_config_list_actions200_response import ( + RuntimeConfigListActions200Response, +) +from hatchet_sdk.clients.cloud_rest.models.subscription_upsert200_response import ( + SubscriptionUpsert200Response, +) +from hatchet_sdk.clients.cloud_rest.models.subscription_upsert_request import ( + SubscriptionUpsertRequest, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response import ( + TenantBillingStateGet200Response, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response_coupons_inner import ( + TenantBillingStateGet200ResponseCouponsInner, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response_payment_methods_inner import ( + TenantBillingStateGet200ResponsePaymentMethodsInner, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response_plans_inner import ( + TenantBillingStateGet200ResponsePlansInner, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response_subscription import ( + TenantBillingStateGet200ResponseSubscription, +) +from hatchet_sdk.clients.cloud_rest.models.workflow_run_events_get_metrics200_response import ( + WorkflowRunEventsGetMetrics200Response, +) +from hatchet_sdk.clients.cloud_rest.models.workflow_run_events_get_metrics200_response_results_inner import ( + WorkflowRunEventsGetMetrics200ResponseResultsInner, +) diff --git a/hatchet_sdk/clients/cloud_rest/models/billing_portal_link_get200_response.py b/hatchet_sdk/clients/cloud_rest/models/billing_portal_link_get200_response.py new file mode 100644 index 00000000..00f4a044 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/billing_portal_link_get200_response.py @@ -0,0 +1,85 @@ +# 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 BillingPortalLinkGet200Response(BaseModel): + """ + BillingPortalLinkGet200Response + """ # noqa: E501 + + url: Optional[StrictStr] = Field( + default=None, description="The url to the billing portal" + ) + __properties: ClassVar[List[str]] = ["url"] + + 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 BillingPortalLinkGet200Response 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 BillingPortalLinkGet200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"url": obj.get("url")}) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/build_get200_response.py b/hatchet_sdk/clients/cloud_rest/models/build_get200_response.py new file mode 100644 index 00000000..f9ef142e --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/build_get200_response.py @@ -0,0 +1,121 @@ +# 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 +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response_rows_inner_metadata import ( + GithubAppListInstallations200ResponseRowsInnerMetadata, +) + + +class BuildGet200Response(BaseModel): + """ + BuildGet200Response + """ # noqa: E501 + + metadata: Optional[GithubAppListInstallations200ResponseRowsInnerMetadata] = None + status: StrictStr + status_detail: Optional[StrictStr] = Field(default=None, alias="statusDetail") + create_time: datetime = Field(alias="createTime") + start_time: Optional[datetime] = Field(default=None, alias="startTime") + finish_time: Optional[datetime] = Field(default=None, alias="finishTime") + build_config_id: StrictStr = Field(alias="buildConfigId") + __properties: ClassVar[List[str]] = [ + "metadata", + "status", + "statusDetail", + "createTime", + "startTime", + "finishTime", + "buildConfigId", + ] + + 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 BuildGet200Response 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 BuildGet200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "metadata": ( + GithubAppListInstallations200ResponseRowsInnerMetadata.from_dict( + obj["metadata"] + ) + if obj.get("metadata") is not None + else None + ), + "status": obj.get("status"), + "statusDetail": obj.get("statusDetail"), + "createTime": obj.get("createTime"), + "startTime": obj.get("startTime"), + "finishTime": obj.get("finishTime"), + "buildConfigId": obj.get("buildConfigId"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/github_app_list_branches200_response_inner.py b/hatchet_sdk/clients/cloud_rest/models/github_app_list_branches200_response_inner.py new file mode 100644 index 00000000..36454872 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/github_app_list_branches200_response_inner.py @@ -0,0 +1,86 @@ +# 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, StrictBool, StrictStr +from typing_extensions import Self + + +class GithubAppListBranches200ResponseInner(BaseModel): + """ + GithubAppListBranches200ResponseInner + """ # noqa: E501 + + branch_name: StrictStr + is_default: StrictBool + __properties: ClassVar[List[str]] = ["branch_name", "is_default"] + + 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 GithubAppListBranches200ResponseInner 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 GithubAppListBranches200ResponseInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + {"branch_name": obj.get("branch_name"), "is_default": obj.get("is_default")} + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response.py b/hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response.py new file mode 100644 index 00000000..a56fb429 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response.py @@ -0,0 +1,119 @@ +# 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.cloud_rest.models.github_app_list_installations200_response_pagination import ( + GithubAppListInstallations200ResponsePagination, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response_rows_inner import ( + GithubAppListInstallations200ResponseRowsInner, +) + + +class GithubAppListInstallations200Response(BaseModel): + """ + GithubAppListInstallations200Response + """ # noqa: E501 + + pagination: GithubAppListInstallations200ResponsePagination + rows: List[GithubAppListInstallations200ResponseRowsInner] + __properties: ClassVar[List[str]] = ["pagination", "rows"] + + 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 GithubAppListInstallations200Response 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 pagination + if self.pagination: + _dict["pagination"] = self.pagination.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in rows (list) + _items = [] + if self.rows: + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) + _dict["rows"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GithubAppListInstallations200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "pagination": ( + GithubAppListInstallations200ResponsePagination.from_dict( + obj["pagination"] + ) + if obj.get("pagination") is not None + else None + ), + "rows": ( + [ + GithubAppListInstallations200ResponseRowsInner.from_dict(_item) + for _item in obj["rows"] + ] + if obj.get("rows") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_pagination.py b/hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_pagination.py new file mode 100644 index 00000000..d47ef6ac --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_pagination.py @@ -0,0 +1,95 @@ +# 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, StrictInt +from typing_extensions import Self + + +class GithubAppListInstallations200ResponsePagination(BaseModel): + """ + GithubAppListInstallations200ResponsePagination + """ # noqa: E501 + + current_page: Optional[StrictInt] = Field( + default=None, description="the current page" + ) + next_page: Optional[StrictInt] = Field(default=None, description="the next page") + num_pages: Optional[StrictInt] = Field( + default=None, description="the total number of pages for listing" + ) + __properties: ClassVar[List[str]] = ["current_page", "next_page", "num_pages"] + + 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 GithubAppListInstallations200ResponsePagination 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 GithubAppListInstallations200ResponsePagination from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "current_page": obj.get("current_page"), + "next_page": obj.get("next_page"), + "num_pages": obj.get("num_pages"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_rows_inner.py b/hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_rows_inner.py new file mode 100644 index 00000000..e2561ee5 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_rows_inner.py @@ -0,0 +1,111 @@ +# 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, StrictStr +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response_rows_inner_metadata import ( + GithubAppListInstallations200ResponseRowsInnerMetadata, +) + + +class GithubAppListInstallations200ResponseRowsInner(BaseModel): + """ + GithubAppListInstallations200ResponseRowsInner + """ # noqa: E501 + + metadata: GithubAppListInstallations200ResponseRowsInnerMetadata + installation_settings_url: StrictStr + account_name: StrictStr + account_avatar_url: StrictStr + __properties: ClassVar[List[str]] = [ + "metadata", + "installation_settings_url", + "account_name", + "account_avatar_url", + ] + + 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 GithubAppListInstallations200ResponseRowsInner 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 GithubAppListInstallations200ResponseRowsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "metadata": ( + GithubAppListInstallations200ResponseRowsInnerMetadata.from_dict( + obj["metadata"] + ) + if obj.get("metadata") is not None + else None + ), + "installation_settings_url": obj.get("installation_settings_url"), + "account_name": obj.get("account_name"), + "account_avatar_url": obj.get("account_avatar_url"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_rows_inner_metadata.py b/hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_rows_inner_metadata.py new file mode 100644 index 00000000..e1852c71 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_rows_inner_metadata.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 datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field +from typing_extensions import Annotated, Self + + +class GithubAppListInstallations200ResponseRowsInnerMetadata(BaseModel): + """ + GithubAppListInstallations200ResponseRowsInnerMetadata + """ # noqa: E501 + + id: Annotated[str, Field(min_length=36, strict=True, max_length=36)] = Field( + description="the id of this resource, in UUID format" + ) + created_at: datetime = Field( + description="the time that this resource was created", alias="createdAt" + ) + updated_at: datetime = Field( + description="the time that this resource was last updated", alias="updatedAt" + ) + __properties: ClassVar[List[str]] = ["id", "createdAt", "updatedAt"] + + 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 GithubAppListInstallations200ResponseRowsInnerMetadata 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 GithubAppListInstallations200ResponseRowsInnerMetadata from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "id": obj.get("id"), + "createdAt": obj.get("createdAt"), + "updatedAt": obj.get("updatedAt"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/github_app_list_repos200_response_inner.py b/hatchet_sdk/clients/cloud_rest/models/github_app_list_repos200_response_inner.py new file mode 100644 index 00000000..193ba06f --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/github_app_list_repos200_response_inner.py @@ -0,0 +1,86 @@ +# 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, StrictStr +from typing_extensions import Self + + +class GithubAppListRepos200ResponseInner(BaseModel): + """ + GithubAppListRepos200ResponseInner + """ # noqa: E501 + + repo_owner: StrictStr + repo_name: StrictStr + __properties: ClassVar[List[str]] = ["repo_owner", "repo_name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GithubAppListRepos200ResponseInner 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 GithubAppListRepos200ResponseInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + {"repo_owner": obj.get("repo_owner"), "repo_name": obj.get("repo_name")} + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/infra_as_code_create_request.py b/hatchet_sdk/clients/cloud_rest/models/infra_as_code_create_request.py new file mode 100644 index 00000000..551f6cfd --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/infra_as_code_create_request.py @@ -0,0 +1,107 @@ +# 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 +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_runtime_config import ( + ManagedWorkerCreateRequestRuntimeConfig, +) + + +class InfraAsCodeCreateRequest(BaseModel): + """ + InfraAsCodeCreateRequest + """ # noqa: E501 + + runtime_configs: List[ManagedWorkerCreateRequestRuntimeConfig] = Field( + alias="runtimeConfigs" + ) + __properties: ClassVar[List[str]] = ["runtimeConfigs"] + + 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 InfraAsCodeCreateRequest 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 runtime_configs (list) + _items = [] + if self.runtime_configs: + for _item in self.runtime_configs: + if _item: + _items.append(_item.to_dict()) + _dict["runtimeConfigs"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of InfraAsCodeCreateRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "runtimeConfigs": ( + [ + ManagedWorkerCreateRequestRuntimeConfig.from_dict(_item) + for _item in obj["runtimeConfigs"] + ] + if obj.get("runtimeConfigs") is not None + else None + ) + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner.py b/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner.py new file mode 100644 index 00000000..dffc7605 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner.py @@ -0,0 +1,136 @@ +# 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, StrictStr +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner_event import ( + LogCreateRequestInnerEvent, +) +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner_fly import ( + LogCreateRequestInnerFly, +) +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner_log import ( + LogCreateRequestInnerLog, +) + + +class LogCreateRequestInner(BaseModel): + """ + LogCreateRequestInner + """ # noqa: E501 + + event: Optional[LogCreateRequestInnerEvent] = None + fly: Optional[LogCreateRequestInnerFly] = None + host: Optional[StrictStr] = None + log: Optional[LogCreateRequestInnerLog] = None + message: Optional[StrictStr] = None + timestamp: Optional[datetime] = None + __properties: ClassVar[List[str]] = [ + "event", + "fly", + "host", + "log", + "message", + "timestamp", + ] + + 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 LogCreateRequestInner 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 event + if self.event: + _dict["event"] = self.event.to_dict() + # override the default output from pydantic by calling `to_dict()` of fly + if self.fly: + _dict["fly"] = self.fly.to_dict() + # override the default output from pydantic by calling `to_dict()` of log + if self.log: + _dict["log"] = self.log.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of LogCreateRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "event": ( + LogCreateRequestInnerEvent.from_dict(obj["event"]) + if obj.get("event") is not None + else None + ), + "fly": ( + LogCreateRequestInnerFly.from_dict(obj["fly"]) + if obj.get("fly") is not None + else None + ), + "host": obj.get("host"), + "log": ( + LogCreateRequestInnerLog.from_dict(obj["log"]) + if obj.get("log") is not None + else None + ), + "message": obj.get("message"), + "timestamp": obj.get("timestamp"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_event.py b/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_event.py new file mode 100644 index 00000000..bd426bb6 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_event.py @@ -0,0 +1,83 @@ +# 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, StrictStr +from typing_extensions import Self + + +class LogCreateRequestInnerEvent(BaseModel): + """ + LogCreateRequestInnerEvent + """ # noqa: E501 + + provider: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["provider"] + + 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 LogCreateRequestInnerEvent 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 LogCreateRequestInnerEvent from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"provider": obj.get("provider")}) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_fly.py b/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_fly.py new file mode 100644 index 00000000..646600e0 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_fly.py @@ -0,0 +1,100 @@ +# 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, StrictStr +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.log_create_request_inner_fly_app import ( + LogCreateRequestInnerFlyApp, +) + + +class LogCreateRequestInnerFly(BaseModel): + """ + LogCreateRequestInnerFly + """ # noqa: E501 + + app: Optional[LogCreateRequestInnerFlyApp] = None + region: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["app", "region"] + + 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 LogCreateRequestInnerFly 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 app + if self.app: + _dict["app"] = self.app.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of LogCreateRequestInnerFly from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "app": ( + LogCreateRequestInnerFlyApp.from_dict(obj["app"]) + if obj.get("app") is not None + else None + ), + "region": obj.get("region"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_fly_app.py b/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_fly_app.py new file mode 100644 index 00000000..0a21524e --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_fly_app.py @@ -0,0 +1,86 @@ +# 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, StrictStr +from typing_extensions import Self + + +class LogCreateRequestInnerFlyApp(BaseModel): + """ + LogCreateRequestInnerFlyApp + """ # noqa: E501 + + instance: Optional[StrictStr] = None + name: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["instance", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of LogCreateRequestInnerFlyApp 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 LogCreateRequestInnerFlyApp from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + {"instance": obj.get("instance"), "name": obj.get("name")} + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_log.py b/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_log.py new file mode 100644 index 00000000..409b1a8f --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_log.py @@ -0,0 +1,83 @@ +# 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, StrictStr +from typing_extensions import Self + + +class LogCreateRequestInnerLog(BaseModel): + """ + LogCreateRequestInnerLog + """ # noqa: E501 + + level: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["level"] + + 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 LogCreateRequestInnerLog 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 LogCreateRequestInnerLog from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"level": obj.get("level")}) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/log_list200_response.py b/hatchet_sdk/clients/cloud_rest/models/log_list200_response.py new file mode 100644 index 00000000..816078dc --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/log_list200_response.py @@ -0,0 +1,119 @@ +# 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.cloud_rest.models.github_app_list_installations200_response_pagination import ( + GithubAppListInstallations200ResponsePagination, +) +from hatchet_sdk.clients.cloud_rest.models.log_list200_response_rows_inner import ( + LogList200ResponseRowsInner, +) + + +class LogList200Response(BaseModel): + """ + LogList200Response + """ # noqa: E501 + + rows: Optional[List[LogList200ResponseRowsInner]] = None + pagination: Optional[GithubAppListInstallations200ResponsePagination] = 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 LogList200Response 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 in self.rows: + if _item: + _items.append(_item.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 LogList200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "rows": ( + [ + LogList200ResponseRowsInner.from_dict(_item) + for _item in obj["rows"] + ] + if obj.get("rows") is not None + else None + ), + "pagination": ( + GithubAppListInstallations200ResponsePagination.from_dict( + obj["pagination"] + ) + if obj.get("pagination") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/log_list200_response_rows_inner.py b/hatchet_sdk/clients/cloud_rest/models/log_list200_response_rows_inner.py new file mode 100644 index 00000000..18bfdb64 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/log_list200_response_rows_inner.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, StrictStr +from typing_extensions import Self + + +class LogList200ResponseRowsInner(BaseModel): + """ + LogList200ResponseRowsInner + """ # noqa: E501 + + timestamp: datetime + instance: StrictStr + line: StrictStr + __properties: ClassVar[List[str]] = ["timestamp", "instance", "line"] + + 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 LogList200ResponseRowsInner 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 LogList200ResponseRowsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "timestamp": obj.get("timestamp"), + "instance": obj.get("instance"), + "line": obj.get("line"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request.py new file mode 100644 index 00000000..1b42a571 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request.py @@ -0,0 +1,128 @@ +# 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 +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_build_config import ( + ManagedWorkerCreateRequestBuildConfig, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_runtime_config import ( + ManagedWorkerCreateRequestRuntimeConfig, +) + + +class ManagedWorkerCreateRequest(BaseModel): + """ + ManagedWorkerCreateRequest + """ # noqa: E501 + + name: StrictStr + build_config: ManagedWorkerCreateRequestBuildConfig = Field(alias="buildConfig") + env_vars: Dict[str, StrictStr] = Field( + description="A map of environment variables to set for the worker", + alias="envVars", + ) + is_iac: StrictBool = Field(alias="isIac") + runtime_config: Optional[ManagedWorkerCreateRequestRuntimeConfig] = Field( + default=None, alias="runtimeConfig" + ) + __properties: ClassVar[List[str]] = [ + "name", + "buildConfig", + "envVars", + "isIac", + "runtimeConfig", + ] + + 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 ManagedWorkerCreateRequest 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 build_config + if self.build_config: + _dict["buildConfig"] = self.build_config.to_dict() + # override the default output from pydantic by calling `to_dict()` of runtime_config + if self.runtime_config: + _dict["runtimeConfig"] = self.runtime_config.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ManagedWorkerCreateRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "name": obj.get("name"), + "buildConfig": ( + ManagedWorkerCreateRequestBuildConfig.from_dict(obj["buildConfig"]) + if obj.get("buildConfig") is not None + else None + ), + "isIac": obj.get("isIac"), + "runtimeConfig": ( + ManagedWorkerCreateRequestRuntimeConfig.from_dict( + obj["runtimeConfig"] + ) + if obj.get("runtimeConfig") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_build_config.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_build_config.py new file mode 100644 index 00000000..0b5e59bd --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_build_config.py @@ -0,0 +1,121 @@ +# 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 Annotated, Self + +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_build_config_steps_inner import ( + ManagedWorkerCreateRequestBuildConfigStepsInner, +) + + +class ManagedWorkerCreateRequestBuildConfig(BaseModel): + """ + ManagedWorkerCreateRequestBuildConfig + """ # noqa: E501 + + github_installation_id: Annotated[ + str, Field(min_length=36, strict=True, max_length=36) + ] = Field(alias="githubInstallationId") + github_repository_owner: StrictStr = Field(alias="githubRepositoryOwner") + github_repository_name: StrictStr = Field(alias="githubRepositoryName") + github_repository_branch: StrictStr = Field(alias="githubRepositoryBranch") + steps: List[ManagedWorkerCreateRequestBuildConfigStepsInner] + __properties: ClassVar[List[str]] = [ + "githubInstallationId", + "githubRepositoryOwner", + "githubRepositoryName", + "githubRepositoryBranch", + "steps", + ] + + 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 ManagedWorkerCreateRequestBuildConfig 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 steps (list) + _items = [] + if self.steps: + for _item in self.steps: + if _item: + _items.append(_item.to_dict()) + _dict["steps"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ManagedWorkerCreateRequestBuildConfig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "githubInstallationId": obj.get("githubInstallationId"), + "githubRepositoryOwner": obj.get("githubRepositoryOwner"), + "githubRepositoryName": obj.get("githubRepositoryName"), + "githubRepositoryBranch": obj.get("githubRepositoryBranch"), + "steps": ( + [ + ManagedWorkerCreateRequestBuildConfigStepsInner.from_dict(_item) + for _item in obj["steps"] + ] + if obj.get("steps") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_build_config_steps_inner.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_build_config_steps_inner.py new file mode 100644 index 00000000..9914524e --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_build_config_steps_inner.py @@ -0,0 +1,94 @@ +# 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 ManagedWorkerCreateRequestBuildConfigStepsInner(BaseModel): + """ + ManagedWorkerCreateRequestBuildConfigStepsInner + """ # noqa: E501 + + build_dir: StrictStr = Field( + description="The relative path to the build directory", alias="buildDir" + ) + dockerfile_path: StrictStr = Field( + description="The relative path from the build dir to the Dockerfile", + alias="dockerfilePath", + ) + __properties: ClassVar[List[str]] = ["buildDir", "dockerfilePath"] + + 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 ManagedWorkerCreateRequestBuildConfigStepsInner 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 ManagedWorkerCreateRequestBuildConfigStepsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "buildDir": obj.get("buildDir"), + "dockerfilePath": obj.get("dockerfilePath"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_runtime_config.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_runtime_config.py new file mode 100644 index 00000000..7dff4205 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_runtime_config.py @@ -0,0 +1,166 @@ +# 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, field_validator +from typing_extensions import Annotated, Self + + +class ManagedWorkerCreateRequestRuntimeConfig(BaseModel): + """ + ManagedWorkerCreateRequestRuntimeConfig + """ # noqa: E501 + + num_replicas: Annotated[int, Field(le=1000, strict=True, ge=0)] = Field( + alias="numReplicas" + ) + regions: Optional[List[StrictStr]] = Field( + default=None, description="The region to deploy the worker to" + ) + cpu_kind: StrictStr = Field( + description="The kind of CPU to use for the worker", alias="cpuKind" + ) + cpus: Annotated[int, Field(le=64, strict=True, ge=1)] = Field( + description="The number of CPUs to use for the worker" + ) + memory_mb: Annotated[int, Field(le=65536, strict=True, ge=1024)] = Field( + description="The amount of memory in MB to use for the worker", alias="memoryMb" + ) + actions: Optional[List[StrictStr]] = None + slots: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = None + __properties: ClassVar[List[str]] = [ + "numReplicas", + "regions", + "cpuKind", + "cpus", + "memoryMb", + "actions", + "slots", + ] + + @field_validator("regions") + def regions_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + for i in value: + if i not in set( + [ + "ams", + "arn", + "atl", + "bog", + "bos", + "cdg", + "den", + "dfw", + "ewr", + "eze", + "gdl", + "gig", + "gru", + "hkg", + "iad", + "jnb", + "lax", + "lhr", + "mad", + "mia", + "nrt", + "ord", + "otp", + "phx", + "qro", + "scl", + "sea", + "sin", + "sjc", + "syd", + "waw", + "yul", + "yyz", + ] + ): + raise ValueError( + "each list item must be one of ('ams', 'arn', 'atl', 'bog', 'bos', 'cdg', 'den', 'dfw', 'ewr', 'eze', 'gdl', 'gig', 'gru', 'hkg', 'iad', 'jnb', 'lax', 'lhr', 'mad', 'mia', 'nrt', 'ord', 'otp', 'phx', 'qro', 'scl', 'sea', 'sin', 'sjc', 'syd', 'waw', 'yul', 'yyz')" + ) + 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 ManagedWorkerCreateRequestRuntimeConfig 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 ManagedWorkerCreateRequestRuntimeConfig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "numReplicas": obj.get("numReplicas"), + "regions": obj.get("regions"), + "cpuKind": obj.get("cpuKind"), + "cpus": obj.get("cpus"), + "memoryMb": obj.get("memoryMb"), + "actions": obj.get("actions"), + "slots": obj.get("slots"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_events_list200_response.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_events_list200_response.py new file mode 100644 index 00000000..3928468e --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_events_list200_response.py @@ -0,0 +1,119 @@ +# 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.cloud_rest.models.github_app_list_installations200_response_pagination import ( + GithubAppListInstallations200ResponsePagination, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_events_list200_response_rows_inner import ( + ManagedWorkerEventsList200ResponseRowsInner, +) + + +class ManagedWorkerEventsList200Response(BaseModel): + """ + ManagedWorkerEventsList200Response + """ # noqa: E501 + + pagination: Optional[GithubAppListInstallations200ResponsePagination] = None + rows: Optional[List[ManagedWorkerEventsList200ResponseRowsInner]] = None + __properties: ClassVar[List[str]] = ["pagination", "rows"] + + 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 ManagedWorkerEventsList200Response 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 pagination + if self.pagination: + _dict["pagination"] = self.pagination.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in rows (list) + _items = [] + if self.rows: + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) + _dict["rows"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ManagedWorkerEventsList200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "pagination": ( + GithubAppListInstallations200ResponsePagination.from_dict( + obj["pagination"] + ) + if obj.get("pagination") is not None + else None + ), + "rows": ( + [ + ManagedWorkerEventsList200ResponseRowsInner.from_dict(_item) + for _item in obj["rows"] + ] + if obj.get("rows") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_events_list200_response_rows_inner.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_events_list200_response_rows_inner.py new file mode 100644 index 00000000..7dc23777 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_events_list200_response_rows_inner.py @@ -0,0 +1,117 @@ +# 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, StrictInt, StrictStr, field_validator +from typing_extensions import Self + + +class ManagedWorkerEventsList200ResponseRowsInner(BaseModel): + """ + ManagedWorkerEventsList200ResponseRowsInner + """ # noqa: E501 + + id: StrictInt + time_first_seen: datetime = Field(alias="timeFirstSeen") + time_last_seen: datetime = Field(alias="timeLastSeen") + managed_worker_id: StrictStr = Field(alias="managedWorkerId") + status: StrictStr + message: StrictStr + data: Dict[str, Any] + __properties: ClassVar[List[str]] = [ + "id", + "timeFirstSeen", + "timeLastSeen", + "managedWorkerId", + "status", + "message", + "data", + ] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["IN_PROGRESS", "SUCCEEDED", "FAILED", "CANCELLED"]): + raise ValueError( + "must be one of enum values ('IN_PROGRESS', 'SUCCEEDED', 'FAILED', 'CANCELLED')" + ) + 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 ManagedWorkerEventsList200ResponseRowsInner 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 ManagedWorkerEventsList200ResponseRowsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "id": obj.get("id"), + "timeFirstSeen": obj.get("timeFirstSeen"), + "timeLastSeen": obj.get("timeLastSeen"), + "managedWorkerId": obj.get("managedWorkerId"), + "status": obj.get("status"), + "message": obj.get("message"), + "data": obj.get("data"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_instances_list200_response.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_instances_list200_response.py new file mode 100644 index 00000000..bbe6375d --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_instances_list200_response.py @@ -0,0 +1,119 @@ +# 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.cloud_rest.models.github_app_list_installations200_response_pagination import ( + GithubAppListInstallations200ResponsePagination, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_instances_list200_response_rows_inner import ( + ManagedWorkerInstancesList200ResponseRowsInner, +) + + +class ManagedWorkerInstancesList200Response(BaseModel): + """ + ManagedWorkerInstancesList200Response + """ # noqa: E501 + + pagination: Optional[GithubAppListInstallations200ResponsePagination] = None + rows: Optional[List[ManagedWorkerInstancesList200ResponseRowsInner]] = None + __properties: ClassVar[List[str]] = ["pagination", "rows"] + + 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 ManagedWorkerInstancesList200Response 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 pagination + if self.pagination: + _dict["pagination"] = self.pagination.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in rows (list) + _items = [] + if self.rows: + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) + _dict["rows"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ManagedWorkerInstancesList200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "pagination": ( + GithubAppListInstallations200ResponsePagination.from_dict( + obj["pagination"] + ) + if obj.get("pagination") is not None + else None + ), + "rows": ( + [ + ManagedWorkerInstancesList200ResponseRowsInner.from_dict(_item) + for _item in obj["rows"] + ] + if obj.get("rows") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_instances_list200_response_rows_inner.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_instances_list200_response_rows_inner.py new file mode 100644 index 00000000..d288a1d1 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_instances_list200_response_rows_inner.py @@ -0,0 +1,113 @@ +# 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, StrictInt, StrictStr +from typing_extensions import Self + + +class ManagedWorkerInstancesList200ResponseRowsInner(BaseModel): + """ + ManagedWorkerInstancesList200ResponseRowsInner + """ # noqa: E501 + + instance_id: StrictStr = Field(alias="instanceId") + name: StrictStr + region: StrictStr + state: StrictStr + cpu_kind: StrictStr = Field(alias="cpuKind") + cpus: StrictInt + memory_mb: StrictInt = Field(alias="memoryMb") + disk_gb: StrictInt = Field(alias="diskGb") + commit_sha: StrictStr = Field(alias="commitSha") + __properties: ClassVar[List[str]] = [ + "instanceId", + "name", + "region", + "state", + "cpuKind", + "cpus", + "memoryMb", + "diskGb", + "commitSha", + ] + + 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 ManagedWorkerInstancesList200ResponseRowsInner 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 ManagedWorkerInstancesList200ResponseRowsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "instanceId": obj.get("instanceId"), + "name": obj.get("name"), + "region": obj.get("region"), + "state": obj.get("state"), + "cpuKind": obj.get("cpuKind"), + "cpus": obj.get("cpus"), + "memoryMb": obj.get("memoryMb"), + "diskGb": obj.get("diskGb"), + "commitSha": obj.get("commitSha"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response.py new file mode 100644 index 00000000..30f96ecc --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response.py @@ -0,0 +1,119 @@ +# 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.cloud_rest.models.github_app_list_installations200_response_pagination import ( + GithubAppListInstallations200ResponsePagination, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner import ( + ManagedWorkerList200ResponseRowsInner, +) + + +class ManagedWorkerList200Response(BaseModel): + """ + ManagedWorkerList200Response + """ # noqa: E501 + + rows: Optional[List[ManagedWorkerList200ResponseRowsInner]] = None + pagination: Optional[GithubAppListInstallations200ResponsePagination] = 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 ManagedWorkerList200Response 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 in self.rows: + if _item: + _items.append(_item.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 ManagedWorkerList200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "rows": ( + [ + ManagedWorkerList200ResponseRowsInner.from_dict(_item) + for _item in obj["rows"] + ] + if obj.get("rows") is not None + else None + ), + "pagination": ( + GithubAppListInstallations200ResponsePagination.from_dict( + obj["pagination"] + ) + if obj.get("pagination") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner.py new file mode 100644 index 00000000..765a37ab --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner.py @@ -0,0 +1,154 @@ +# 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 +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response_rows_inner_metadata import ( + GithubAppListInstallations200ResponseRowsInnerMetadata, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner_build_config import ( + ManagedWorkerList200ResponseRowsInnerBuildConfig, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner_runtime_configs_inner import ( + ManagedWorkerList200ResponseRowsInnerRuntimeConfigsInner, +) + + +class ManagedWorkerList200ResponseRowsInner(BaseModel): + """ + ManagedWorkerList200ResponseRowsInner + """ # noqa: E501 + + metadata: GithubAppListInstallations200ResponseRowsInnerMetadata + name: StrictStr + build_config: ManagedWorkerList200ResponseRowsInnerBuildConfig = Field( + alias="buildConfig" + ) + is_iac: StrictBool = Field(alias="isIac") + env_vars: Dict[str, StrictStr] = Field( + description="A map of environment variables to set for the worker", + alias="envVars", + ) + runtime_configs: Optional[ + List[ManagedWorkerList200ResponseRowsInnerRuntimeConfigsInner] + ] = Field(default=None, alias="runtimeConfigs") + __properties: ClassVar[List[str]] = [ + "metadata", + "name", + "buildConfig", + "isIac", + "envVars", + "runtimeConfigs", + ] + + 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 ManagedWorkerList200ResponseRowsInner 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() + # override the default output from pydantic by calling `to_dict()` of build_config + if self.build_config: + _dict["buildConfig"] = self.build_config.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in runtime_configs (list) + _items = [] + if self.runtime_configs: + for _item in self.runtime_configs: + if _item: + _items.append(_item.to_dict()) + _dict["runtimeConfigs"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ManagedWorkerList200ResponseRowsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "metadata": ( + GithubAppListInstallations200ResponseRowsInnerMetadata.from_dict( + obj["metadata"] + ) + if obj.get("metadata") is not None + else None + ), + "name": obj.get("name"), + "buildConfig": ( + ManagedWorkerList200ResponseRowsInnerBuildConfig.from_dict( + obj["buildConfig"] + ) + if obj.get("buildConfig") is not None + else None + ), + "isIac": obj.get("isIac"), + "runtimeConfigs": ( + [ + ManagedWorkerList200ResponseRowsInnerRuntimeConfigsInner.from_dict( + _item + ) + for _item in obj["runtimeConfigs"] + ] + if obj.get("runtimeConfigs") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_build_config.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_build_config.py new file mode 100644 index 00000000..9e80c9be --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_build_config.py @@ -0,0 +1,151 @@ +# 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 Annotated, Self + +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response_rows_inner_metadata import ( + GithubAppListInstallations200ResponseRowsInnerMetadata, +) +from hatchet_sdk.clients.cloud_rest.models.github_app_list_repos200_response_inner import ( + GithubAppListRepos200ResponseInner, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_list200_response_rows_inner_build_config_steps_inner import ( + ManagedWorkerList200ResponseRowsInnerBuildConfigStepsInner, +) + + +class ManagedWorkerList200ResponseRowsInnerBuildConfig(BaseModel): + """ + ManagedWorkerList200ResponseRowsInnerBuildConfig + """ # noqa: E501 + + metadata: GithubAppListInstallations200ResponseRowsInnerMetadata + github_installation_id: Annotated[ + str, Field(min_length=36, strict=True, max_length=36) + ] = Field(alias="githubInstallationId") + github_repository: GithubAppListRepos200ResponseInner = Field( + alias="githubRepository" + ) + github_repository_branch: StrictStr = Field(alias="githubRepositoryBranch") + steps: Optional[ + List[ManagedWorkerList200ResponseRowsInnerBuildConfigStepsInner] + ] = None + __properties: ClassVar[List[str]] = [ + "metadata", + "githubInstallationId", + "githubRepository", + "githubRepositoryBranch", + "steps", + ] + + 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 ManagedWorkerList200ResponseRowsInnerBuildConfig 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() + # override the default output from pydantic by calling `to_dict()` of github_repository + if self.github_repository: + _dict["githubRepository"] = self.github_repository.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in steps (list) + _items = [] + if self.steps: + for _item in self.steps: + if _item: + _items.append(_item.to_dict()) + _dict["steps"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ManagedWorkerList200ResponseRowsInnerBuildConfig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "metadata": ( + GithubAppListInstallations200ResponseRowsInnerMetadata.from_dict( + obj["metadata"] + ) + if obj.get("metadata") is not None + else None + ), + "githubInstallationId": obj.get("githubInstallationId"), + "githubRepository": ( + GithubAppListRepos200ResponseInner.from_dict( + obj["githubRepository"] + ) + if obj.get("githubRepository") is not None + else None + ), + "githubRepositoryBranch": obj.get("githubRepositoryBranch"), + "steps": ( + [ + ManagedWorkerList200ResponseRowsInnerBuildConfigStepsInner.from_dict( + _item + ) + for _item in obj["steps"] + ] + if obj.get("steps") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_build_config_steps_inner.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_build_config_steps_inner.py new file mode 100644 index 00000000..6581f902 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_build_config_steps_inner.py @@ -0,0 +1,109 @@ +# 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.cloud_rest.models.github_app_list_installations200_response_rows_inner_metadata import ( + GithubAppListInstallations200ResponseRowsInnerMetadata, +) + + +class ManagedWorkerList200ResponseRowsInnerBuildConfigStepsInner(BaseModel): + """ + ManagedWorkerList200ResponseRowsInnerBuildConfigStepsInner + """ # noqa: E501 + + metadata: GithubAppListInstallations200ResponseRowsInnerMetadata + build_dir: StrictStr = Field( + description="The relative path to the build directory", alias="buildDir" + ) + dockerfile_path: StrictStr = Field( + description="The relative path from the build dir to the Dockerfile", + alias="dockerfilePath", + ) + __properties: ClassVar[List[str]] = ["metadata", "buildDir", "dockerfilePath"] + + 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 ManagedWorkerList200ResponseRowsInnerBuildConfigStepsInner 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 ManagedWorkerList200ResponseRowsInnerBuildConfigStepsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "metadata": ( + GithubAppListInstallations200ResponseRowsInnerMetadata.from_dict( + obj["metadata"] + ) + if obj.get("metadata") is not None + else None + ), + "buildDir": obj.get("buildDir"), + "dockerfilePath": obj.get("dockerfilePath"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_runtime_configs_inner.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_runtime_configs_inner.py new file mode 100644 index 00000000..945aa793 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_runtime_configs_inner.py @@ -0,0 +1,171 @@ +# 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, StrictInt, StrictStr, field_validator +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.github_app_list_installations200_response_rows_inner_metadata import ( + GithubAppListInstallations200ResponseRowsInnerMetadata, +) + + +class ManagedWorkerList200ResponseRowsInnerRuntimeConfigsInner(BaseModel): + """ + ManagedWorkerList200ResponseRowsInnerRuntimeConfigsInner + """ # noqa: E501 + + metadata: GithubAppListInstallations200ResponseRowsInnerMetadata + num_replicas: StrictInt = Field(alias="numReplicas") + cpu_kind: StrictStr = Field( + description="The kind of CPU to use for the worker", alias="cpuKind" + ) + cpus: StrictInt = Field(description="The number of CPUs to use for the worker") + memory_mb: StrictInt = Field( + description="The amount of memory in MB to use for the worker", alias="memoryMb" + ) + region: StrictStr = Field(description="The region that the worker is deployed to") + actions: Optional[List[StrictStr]] = Field( + default=None, description="A list of actions this runtime config corresponds to" + ) + __properties: ClassVar[List[str]] = [ + "metadata", + "numReplicas", + "cpuKind", + "cpus", + "memoryMb", + "region", + "actions", + ] + + @field_validator("region") + def region_validate_enum(cls, value): + """Validates the enum""" + if value not in set( + [ + "ams", + "arn", + "atl", + "bog", + "bos", + "cdg", + "den", + "dfw", + "ewr", + "eze", + "gdl", + "gig", + "gru", + "hkg", + "iad", + "jnb", + "lax", + "lhr", + "mad", + "mia", + "nrt", + "ord", + "otp", + "phx", + "qro", + "scl", + "sea", + "sin", + "sjc", + "syd", + "waw", + "yul", + "yyz", + ] + ): + raise ValueError( + "must be one of enum values ('ams', 'arn', 'atl', 'bog', 'bos', 'cdg', 'den', 'dfw', 'ewr', 'eze', 'gdl', 'gig', 'gru', 'hkg', 'iad', 'jnb', 'lax', 'lhr', 'mad', 'mia', 'nrt', 'ord', 'otp', 'phx', 'qro', 'scl', 'sea', 'sin', 'sjc', 'syd', 'waw', 'yul', 'yyz')" + ) + 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 ManagedWorkerList200ResponseRowsInnerRuntimeConfigsInner 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 ManagedWorkerList200ResponseRowsInnerRuntimeConfigsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "metadata": ( + GithubAppListInstallations200ResponseRowsInnerMetadata.from_dict( + obj["metadata"] + ) + if obj.get("metadata") is not None + else None + ), + "numReplicas": obj.get("numReplicas"), + "cpuKind": obj.get("cpuKind"), + "cpus": obj.get("cpus"), + "memoryMb": obj.get("memoryMb"), + "region": obj.get("region"), + "actions": obj.get("actions"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/managed_worker_update_request.py b/hatchet_sdk/clients/cloud_rest/models/managed_worker_update_request.py new file mode 100644 index 00000000..283c1795 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/managed_worker_update_request.py @@ -0,0 +1,131 @@ +# 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 +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_build_config import ( + ManagedWorkerCreateRequestBuildConfig, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_runtime_config import ( + ManagedWorkerCreateRequestRuntimeConfig, +) + + +class ManagedWorkerUpdateRequest(BaseModel): + """ + ManagedWorkerUpdateRequest + """ # noqa: E501 + + name: Optional[StrictStr] = None + build_config: Optional[ManagedWorkerCreateRequestBuildConfig] = Field( + default=None, alias="buildConfig" + ) + env_vars: Optional[Dict[str, StrictStr]] = Field( + default=None, + description="A map of environment variables to set for the worker", + alias="envVars", + ) + is_iac: Optional[StrictBool] = Field(default=None, alias="isIac") + runtime_config: Optional[ManagedWorkerCreateRequestRuntimeConfig] = Field( + default=None, alias="runtimeConfig" + ) + __properties: ClassVar[List[str]] = [ + "name", + "buildConfig", + "envVars", + "isIac", + "runtimeConfig", + ] + + 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 ManagedWorkerUpdateRequest 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 build_config + if self.build_config: + _dict["buildConfig"] = self.build_config.to_dict() + # override the default output from pydantic by calling `to_dict()` of runtime_config + if self.runtime_config: + _dict["runtimeConfig"] = self.runtime_config.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ManagedWorkerUpdateRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "name": obj.get("name"), + "buildConfig": ( + ManagedWorkerCreateRequestBuildConfig.from_dict(obj["buildConfig"]) + if obj.get("buildConfig") is not None + else None + ), + "isIac": obj.get("isIac"), + "runtimeConfig": ( + ManagedWorkerCreateRequestRuntimeConfig.from_dict( + obj["runtimeConfig"] + ) + if obj.get("runtimeConfig") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/metadata_get200_response.py b/hatchet_sdk/clients/cloud_rest/models/metadata_get200_response.py new file mode 100644 index 00000000..f714f598 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/metadata_get200_response.py @@ -0,0 +1,101 @@ +# 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 +from typing_extensions import Self + + +class MetadataGet200Response(BaseModel): + """ + MetadataGet200Response + """ # noqa: E501 + + can_bill: Optional[StrictBool] = Field( + default=None, description="whether the tenant can be billed", alias="canBill" + ) + can_link_github: Optional[StrictBool] = Field( + default=None, + description="whether the tenant can link to GitHub", + alias="canLinkGithub", + ) + metrics_enabled: Optional[StrictBool] = Field( + default=None, + description="whether metrics are enabled for the tenant", + alias="metricsEnabled", + ) + __properties: ClassVar[List[str]] = ["canBill", "canLinkGithub", "metricsEnabled"] + + 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 MetadataGet200Response 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 MetadataGet200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "canBill": obj.get("canBill"), + "canLinkGithub": obj.get("canLinkGithub"), + "metricsEnabled": obj.get("metricsEnabled"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/metadata_get400_response.py b/hatchet_sdk/clients/cloud_rest/models/metadata_get400_response.py new file mode 100644 index 00000000..a456a027 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/metadata_get400_response.py @@ -0,0 +1,105 @@ +# 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.cloud_rest.models.metadata_get400_response_errors_inner import ( + MetadataGet400ResponseErrorsInner, +) + + +class MetadataGet400Response(BaseModel): + """ + MetadataGet400Response + """ # noqa: E501 + + errors: List[MetadataGet400ResponseErrorsInner] + __properties: ClassVar[List[str]] = ["errors"] + + 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 MetadataGet400Response 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 errors (list) + _items = [] + if self.errors: + for _item in self.errors: + if _item: + _items.append(_item.to_dict()) + _dict["errors"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of MetadataGet400Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "errors": ( + [ + MetadataGet400ResponseErrorsInner.from_dict(_item) + for _item in obj["errors"] + ] + if obj.get("errors") is not None + else None + ) + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/metadata_get400_response_errors_inner.py b/hatchet_sdk/clients/cloud_rest/models/metadata_get400_response_errors_inner.py new file mode 100644 index 00000000..8d2808d5 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/metadata_get400_response_errors_inner.py @@ -0,0 +1,102 @@ +# 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, StrictInt, StrictStr +from typing_extensions import Self + + +class MetadataGet400ResponseErrorsInner(BaseModel): + """ + MetadataGet400ResponseErrorsInner + """ # noqa: E501 + + code: Optional[StrictInt] = Field( + default=None, description="a custom Hatchet error code" + ) + var_field: Optional[StrictStr] = Field( + default=None, + description="the field that this error is associated with, if applicable", + alias="field", + ) + description: StrictStr = Field(description="a description for this error") + docs_link: Optional[StrictStr] = Field( + default=None, + description="a link to the documentation for this error, if it exists", + ) + __properties: ClassVar[List[str]] = ["code", "field", "description", "docs_link"] + + 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 MetadataGet400ResponseErrorsInner 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 MetadataGet400ResponseErrorsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "code": obj.get("code"), + "field": obj.get("field"), + "description": obj.get("description"), + "docs_link": obj.get("docs_link"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner.py b/hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner.py new file mode 100644 index 00000000..67bff649 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner.py @@ -0,0 +1,108 @@ +# 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, StrictStr +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.metrics_cpu_get200_response_inner_histograms_inner import ( + MetricsCpuGet200ResponseInnerHistogramsInner, +) + + +class MetricsCpuGet200ResponseInner(BaseModel): + """ + MetricsCpuGet200ResponseInner + """ # noqa: E501 + + metric: Optional[Dict[str, StrictStr]] = None + values: Optional[List[List[StrictStr]]] = None + histograms: Optional[List[MetricsCpuGet200ResponseInnerHistogramsInner]] = None + __properties: ClassVar[List[str]] = ["metric", "values", "histograms"] + + 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 MetricsCpuGet200ResponseInner 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 histograms (list) + _items = [] + if self.histograms: + for _item in self.histograms: + if _item: + _items.append(_item.to_dict()) + _dict["histograms"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of MetricsCpuGet200ResponseInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "values": obj.get("values"), + "histograms": ( + [ + MetricsCpuGet200ResponseInnerHistogramsInner.from_dict(_item) + for _item in obj["histograms"] + ] + if obj.get("histograms") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner.py b/hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner.py new file mode 100644 index 00000000..bddc25c0 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner.py @@ -0,0 +1,102 @@ +# 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, StrictInt +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.metrics_cpu_get200_response_inner_histograms_inner_histogram import ( + MetricsCpuGet200ResponseInnerHistogramsInnerHistogram, +) + + +class MetricsCpuGet200ResponseInnerHistogramsInner(BaseModel): + """ + MetricsCpuGet200ResponseInnerHistogramsInner + """ # noqa: E501 + + timestamp: Optional[StrictInt] = None + histogram: Optional[MetricsCpuGet200ResponseInnerHistogramsInnerHistogram] = None + __properties: ClassVar[List[str]] = ["timestamp", "histogram"] + + 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 MetricsCpuGet200ResponseInnerHistogramsInner 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 histogram + if self.histogram: + _dict["histogram"] = self.histogram.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of MetricsCpuGet200ResponseInnerHistogramsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "timestamp": obj.get("timestamp"), + "histogram": ( + MetricsCpuGet200ResponseInnerHistogramsInnerHistogram.from_dict( + obj["histogram"] + ) + if obj.get("histogram") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner_histogram.py b/hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner_histogram.py new file mode 100644 index 00000000..4ea774f4 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner_histogram.py @@ -0,0 +1,113 @@ +# 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, Union + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.metrics_cpu_get200_response_inner_histograms_inner_histogram_buckets_inner import ( + MetricsCpuGet200ResponseInnerHistogramsInnerHistogramBucketsInner, +) + + +class MetricsCpuGet200ResponseInnerHistogramsInnerHistogram(BaseModel): + """ + MetricsCpuGet200ResponseInnerHistogramsInnerHistogram + """ # noqa: E501 + + count: Optional[Union[StrictFloat, StrictInt]] = None + sum: Optional[Union[StrictFloat, StrictInt]] = None + buckets: Optional[ + List[MetricsCpuGet200ResponseInnerHistogramsInnerHistogramBucketsInner] + ] = None + __properties: ClassVar[List[str]] = ["count", "sum", "buckets"] + + 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 MetricsCpuGet200ResponseInnerHistogramsInnerHistogram 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 buckets (list) + _items = [] + if self.buckets: + for _item in self.buckets: + if _item: + _items.append(_item.to_dict()) + _dict["buckets"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of MetricsCpuGet200ResponseInnerHistogramsInnerHistogram from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "count": obj.get("count"), + "sum": obj.get("sum"), + "buckets": ( + [ + MetricsCpuGet200ResponseInnerHistogramsInnerHistogramBucketsInner.from_dict( + _item + ) + for _item in obj["buckets"] + ] + if obj.get("buckets") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner_histogram_buckets_inner.py b/hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner_histogram_buckets_inner.py new file mode 100644 index 00000000..18a3ae3b --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner_histogram_buckets_inner.py @@ -0,0 +1,93 @@ +# 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, Union + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing_extensions import Self + + +class MetricsCpuGet200ResponseInnerHistogramsInnerHistogramBucketsInner(BaseModel): + """ + MetricsCpuGet200ResponseInnerHistogramsInnerHistogramBucketsInner + """ # noqa: E501 + + boundaries: Optional[StrictInt] = None + lower: Optional[Union[StrictFloat, StrictInt]] = None + upper: Optional[Union[StrictFloat, StrictInt]] = None + count: Optional[Union[StrictFloat, StrictInt]] = None + __properties: ClassVar[List[str]] = ["boundaries", "lower", "upper", "count"] + + 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 MetricsCpuGet200ResponseInnerHistogramsInnerHistogramBucketsInner 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 MetricsCpuGet200ResponseInnerHistogramsInnerHistogramBucketsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "boundaries": obj.get("boundaries"), + "lower": obj.get("lower"), + "upper": obj.get("upper"), + "count": obj.get("count"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/runtime_config_list_actions200_response.py b/hatchet_sdk/clients/cloud_rest/models/runtime_config_list_actions200_response.py new file mode 100644 index 00000000..257b3a58 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/runtime_config_list_actions200_response.py @@ -0,0 +1,83 @@ +# 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, StrictStr +from typing_extensions import Self + + +class RuntimeConfigListActions200Response(BaseModel): + """ + RuntimeConfigListActions200Response + """ # noqa: E501 + + actions: List[StrictStr] + __properties: ClassVar[List[str]] = ["actions"] + + 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 RuntimeConfigListActions200Response 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 RuntimeConfigListActions200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"actions": obj.get("actions")}) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/subscription_upsert200_response.py b/hatchet_sdk/clients/cloud_rest/models/subscription_upsert200_response.py new file mode 100644 index 00000000..42b4cf18 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/subscription_upsert200_response.py @@ -0,0 +1,114 @@ +# 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, field_validator +from typing_extensions import Self + + +class SubscriptionUpsert200Response(BaseModel): + """ + SubscriptionUpsert200Response + """ # noqa: E501 + + plan: Optional[StrictStr] = Field( + default=None, + description="The plan code associated with the tenant subscription.", + ) + period: Optional[StrictStr] = Field( + default=None, description="The period associated with the tenant subscription." + ) + status: Optional[StrictStr] = Field( + default=None, description="The status of the tenant subscription." + ) + note: Optional[StrictStr] = Field( + default=None, description="A note associated with the tenant subscription." + ) + __properties: ClassVar[List[str]] = ["plan", "period", "status", "note"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["active", "pending", "terminated", "canceled"]): + raise ValueError( + "must be one of enum values ('active', 'pending', 'terminated', 'canceled')" + ) + 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 SubscriptionUpsert200Response 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 SubscriptionUpsert200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "plan": obj.get("plan"), + "period": obj.get("period"), + "status": obj.get("status"), + "note": obj.get("note"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/subscription_upsert_request.py b/hatchet_sdk/clients/cloud_rest/models/subscription_upsert_request.py new file mode 100644 index 00000000..0750aced --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/subscription_upsert_request.py @@ -0,0 +1,88 @@ +# 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 SubscriptionUpsertRequest(BaseModel): + """ + SubscriptionUpsertRequest + """ # noqa: E501 + + plan: Optional[StrictStr] = Field(default=None, description="The code of the plan.") + period: Optional[StrictStr] = Field( + default=None, description="The period of the plan." + ) + __properties: ClassVar[List[str]] = ["plan", "period"] + + 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 SubscriptionUpsertRequest 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 SubscriptionUpsertRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + {"plan": obj.get("plan"), "period": obj.get("period")} + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response.py b/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response.py new file mode 100644 index 00000000..93ae32dd --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response.py @@ -0,0 +1,170 @@ +# 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 +from typing_extensions import Self + +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response_coupons_inner import ( + TenantBillingStateGet200ResponseCouponsInner, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response_payment_methods_inner import ( + TenantBillingStateGet200ResponsePaymentMethodsInner, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response_plans_inner import ( + TenantBillingStateGet200ResponsePlansInner, +) +from hatchet_sdk.clients.cloud_rest.models.tenant_billing_state_get200_response_subscription import ( + TenantBillingStateGet200ResponseSubscription, +) + + +class TenantBillingStateGet200Response(BaseModel): + """ + TenantBillingStateGet200Response + """ # noqa: E501 + + payment_methods: Optional[ + List[TenantBillingStateGet200ResponsePaymentMethodsInner] + ] = Field(default=None, alias="paymentMethods") + subscription: TenantBillingStateGet200ResponseSubscription + plans: Optional[List[TenantBillingStateGet200ResponsePlansInner]] = Field( + default=None, description="A list of plans available for the tenant." + ) + coupons: Optional[List[TenantBillingStateGet200ResponseCouponsInner]] = Field( + default=None, description="A list of coupons applied to the tenant." + ) + __properties: ClassVar[List[str]] = [ + "paymentMethods", + "subscription", + "plans", + "coupons", + ] + + 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 TenantBillingStateGet200Response 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 payment_methods (list) + _items = [] + if self.payment_methods: + for _item in self.payment_methods: + if _item: + _items.append(_item.to_dict()) + _dict["paymentMethods"] = _items + # override the default output from pydantic by calling `to_dict()` of subscription + if self.subscription: + _dict["subscription"] = self.subscription.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in plans (list) + _items = [] + if self.plans: + for _item in self.plans: + if _item: + _items.append(_item.to_dict()) + _dict["plans"] = _items + # override the default output from pydantic by calling `to_dict()` of each item in coupons (list) + _items = [] + if self.coupons: + for _item in self.coupons: + if _item: + _items.append(_item.to_dict()) + _dict["coupons"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of TenantBillingStateGet200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "paymentMethods": ( + [ + TenantBillingStateGet200ResponsePaymentMethodsInner.from_dict( + _item + ) + for _item in obj["paymentMethods"] + ] + if obj.get("paymentMethods") is not None + else None + ), + "subscription": ( + TenantBillingStateGet200ResponseSubscription.from_dict( + obj["subscription"] + ) + if obj.get("subscription") is not None + else None + ), + "plans": ( + [ + TenantBillingStateGet200ResponsePlansInner.from_dict(_item) + for _item in obj["plans"] + ] + if obj.get("plans") is not None + else None + ), + "coupons": ( + [ + TenantBillingStateGet200ResponseCouponsInner.from_dict(_item) + for _item in obj["coupons"] + ] + if obj.get("coupons") is not None + else None + ), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_coupons_inner.py b/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_coupons_inner.py new file mode 100644 index 00000000..288654e0 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_coupons_inner.py @@ -0,0 +1,137 @@ +# 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, Union + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictFloat, + StrictInt, + StrictStr, + field_validator, +) +from typing_extensions import Self + + +class TenantBillingStateGet200ResponseCouponsInner(BaseModel): + """ + TenantBillingStateGet200ResponseCouponsInner + """ # noqa: E501 + + name: StrictStr = Field(description="The name of the coupon.") + amount_cents: Optional[StrictInt] = Field( + default=None, description="The amount off of the coupon." + ) + amount_cents_remaining: Optional[StrictInt] = Field( + default=None, description="The amount remaining on the coupon." + ) + amount_currency: Optional[StrictStr] = Field( + default=None, description="The currency of the coupon." + ) + frequency: StrictStr = Field(description="The frequency of the coupon.") + frequency_duration: Optional[StrictInt] = Field( + default=None, description="The frequency duration of the coupon." + ) + frequency_duration_remaining: Optional[StrictInt] = Field( + default=None, description="The frequency duration remaining of the coupon." + ) + percent: Optional[Union[StrictFloat, StrictInt]] = Field( + default=None, description="The percentage off of the coupon." + ) + __properties: ClassVar[List[str]] = [ + "name", + "amount_cents", + "amount_cents_remaining", + "amount_currency", + "frequency", + "frequency_duration", + "frequency_duration_remaining", + "percent", + ] + + @field_validator("frequency") + def frequency_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["once", "recurring"]): + raise ValueError("must be one of enum values ('once', 'recurring')") + 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 TenantBillingStateGet200ResponseCouponsInner 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 TenantBillingStateGet200ResponseCouponsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "name": obj.get("name"), + "amount_cents": obj.get("amount_cents"), + "amount_cents_remaining": obj.get("amount_cents_remaining"), + "amount_currency": obj.get("amount_currency"), + "frequency": obj.get("frequency"), + "frequency_duration": obj.get("frequency_duration"), + "frequency_duration_remaining": obj.get("frequency_duration_remaining"), + "percent": obj.get("percent"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_payment_methods_inner.py b/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_payment_methods_inner.py new file mode 100644 index 00000000..d654f4e8 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_payment_methods_inner.py @@ -0,0 +1,99 @@ +# 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 TenantBillingStateGet200ResponsePaymentMethodsInner(BaseModel): + """ + TenantBillingStateGet200ResponsePaymentMethodsInner + """ # noqa: E501 + + brand: StrictStr = Field(description="The brand of the payment method.") + last4: Optional[StrictStr] = Field( + default=None, description="The last 4 digits of the card." + ) + expiration: Optional[StrictStr] = Field( + default=None, description="The expiration date of the card." + ) + description: Optional[StrictStr] = Field( + default=None, description="The description of the payment method." + ) + __properties: ClassVar[List[str]] = ["brand", "last4", "expiration", "description"] + + 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 TenantBillingStateGet200ResponsePaymentMethodsInner 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 TenantBillingStateGet200ResponsePaymentMethodsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "brand": obj.get("brand"), + "last4": obj.get("last4"), + "expiration": obj.get("expiration"), + "description": obj.get("description"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_plans_inner.py b/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_plans_inner.py new file mode 100644 index 00000000..f98c70da --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_plans_inner.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, StrictInt, StrictStr +from typing_extensions import Self + + +class TenantBillingStateGet200ResponsePlansInner(BaseModel): + """ + TenantBillingStateGet200ResponsePlansInner + """ # noqa: E501 + + plan_code: StrictStr = Field(description="The code of the plan.") + name: StrictStr = Field(description="The name of the plan.") + description: StrictStr = Field(description="The description of the plan.") + amount_cents: StrictInt = Field(description="The price of the plan.") + period: Optional[StrictStr] = Field( + default=None, description="The period of the plan." + ) + __properties: ClassVar[List[str]] = [ + "plan_code", + "name", + "description", + "amount_cents", + "period", + ] + + 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 TenantBillingStateGet200ResponsePlansInner 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 TenantBillingStateGet200ResponsePlansInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "plan_code": obj.get("plan_code"), + "name": obj.get("name"), + "description": obj.get("description"), + "amount_cents": obj.get("amount_cents"), + "period": obj.get("period"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_subscription.py b/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_subscription.py new file mode 100644 index 00000000..a92d16d0 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_subscription.py @@ -0,0 +1,114 @@ +# 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, field_validator +from typing_extensions import Self + + +class TenantBillingStateGet200ResponseSubscription(BaseModel): + """ + The subscription associated with this policy. + """ # noqa: E501 + + plan: Optional[StrictStr] = Field( + default=None, + description="The plan code associated with the tenant subscription.", + ) + period: Optional[StrictStr] = Field( + default=None, description="The period associated with the tenant subscription." + ) + status: Optional[StrictStr] = Field( + default=None, description="The status of the tenant subscription." + ) + note: Optional[StrictStr] = Field( + default=None, description="A note associated with the tenant subscription." + ) + __properties: ClassVar[List[str]] = ["plan", "period", "status", "note"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["active", "pending", "terminated", "canceled"]): + raise ValueError( + "must be one of enum values ('active', 'pending', 'terminated', 'canceled')" + ) + 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 TenantBillingStateGet200ResponseSubscription 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 TenantBillingStateGet200ResponseSubscription from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "plan": obj.get("plan"), + "period": obj.get("period"), + "status": obj.get("status"), + "note": obj.get("note"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/workflow_run_events_get_metrics200_response.py b/hatchet_sdk/clients/cloud_rest/models/workflow_run_events_get_metrics200_response.py new file mode 100644 index 00000000..ae8c9758 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/workflow_run_events_get_metrics200_response.py @@ -0,0 +1,107 @@ +# 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.cloud_rest.models.workflow_run_events_get_metrics200_response_results_inner import ( + WorkflowRunEventsGetMetrics200ResponseResultsInner, +) + + +class WorkflowRunEventsGetMetrics200Response(BaseModel): + """ + WorkflowRunEventsGetMetrics200Response + """ # noqa: E501 + + results: Optional[List[WorkflowRunEventsGetMetrics200ResponseResultsInner]] = None + __properties: ClassVar[List[str]] = ["results"] + + 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 WorkflowRunEventsGetMetrics200Response 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 results (list) + _items = [] + if self.results: + for _item in self.results: + if _item: + _items.append(_item.to_dict()) + _dict["results"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WorkflowRunEventsGetMetrics200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "results": ( + [ + WorkflowRunEventsGetMetrics200ResponseResultsInner.from_dict( + _item + ) + for _item in obj["results"] + ] + if obj.get("results") is not None + else None + ) + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/models/workflow_run_events_get_metrics200_response_results_inner.py b/hatchet_sdk/clients/cloud_rest/models/workflow_run_events_get_metrics200_response_results_inner.py new file mode 100644 index 00000000..93ded820 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/models/workflow_run_events_get_metrics200_response_results_inner.py @@ -0,0 +1,105 @@ +# 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, StrictInt +from typing_extensions import Self + + +class WorkflowRunEventsGetMetrics200ResponseResultsInner(BaseModel): + """ + WorkflowRunEventsGetMetrics200ResponseResultsInner + """ # noqa: E501 + + time: datetime + pending: StrictInt = Field(alias="PENDING") + running: StrictInt = Field(alias="RUNNING") + succeeded: StrictInt = Field(alias="SUCCEEDED") + failed: StrictInt = Field(alias="FAILED") + queued: StrictInt = Field(alias="QUEUED") + __properties: ClassVar[List[str]] = [ + "time", + "PENDING", + "RUNNING", + "SUCCEEDED", + "FAILED", + "QUEUED", + ] + + 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 WorkflowRunEventsGetMetrics200ResponseResultsInner 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 WorkflowRunEventsGetMetrics200ResponseResultsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "time": obj.get("time"), + "PENDING": obj.get("PENDING"), + "RUNNING": obj.get("RUNNING"), + "SUCCEEDED": obj.get("SUCCEEDED"), + "FAILED": obj.get("FAILED"), + "QUEUED": obj.get("QUEUED"), + } + ) + return _obj diff --git a/hatchet_sdk/clients/cloud_rest/rest.py b/hatchet_sdk/clients/cloud_rest/rest.py new file mode 100644 index 00000000..f7188ae4 --- /dev/null +++ b/hatchet_sdk/clients/cloud_rest/rest.py @@ -0,0 +1,182 @@ +# 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 + + +import io +import json +import re +import ssl +from typing import Optional, Union + +import aiohttp +import aiohttp_retry + +from hatchet_sdk.clients.cloud_rest.exceptions import ApiException, ApiValueError + +RESTResponseType = aiohttp.ClientResponse + +ALLOW_RETRY_METHODS = frozenset({"DELETE", "GET", "HEAD", "OPTIONS", "PUT", "TRACE"}) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp) -> None: + self.response = resp + self.status = resp.status + self.reason = resp.reason + self.data = None + + async def read(self): + if self.data is None: + self.data = await self.response.read() + return self.data + + def getheaders(self): + """Returns a CIMultiDictProxy of the response headers.""" + return self.response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.response.headers.get(name, default) + + +class RESTClientObject: + + def __init__(self, configuration) -> None: + + # maxsize is number of requests to host that are allowed in parallel + maxsize = configuration.connection_pool_maxsize + + ssl_context = ssl.create_default_context(cafile=configuration.ssl_ca_cert) + if configuration.cert_file: + ssl_context.load_cert_chain( + configuration.cert_file, keyfile=configuration.key_file + ) + + if not configuration.verify_ssl: + ssl_context.check_hostname = False + ssl_context.verify_mode = ssl.CERT_NONE + + connector = aiohttp.TCPConnector(limit=maxsize, ssl=ssl_context) + + self.proxy = configuration.proxy + self.proxy_headers = configuration.proxy_headers + + # https pool manager + self.pool_manager = aiohttp.ClientSession(connector=connector, trust_env=True) + + retries = configuration.retries + self.retry_client: Optional[aiohttp_retry.RetryClient] + if retries is not None: + self.retry_client = aiohttp_retry.RetryClient( + client_session=self.pool_manager, + retry_options=aiohttp_retry.ExponentialRetry( + attempts=retries, factor=0.0, start_timeout=0.0, max_timeout=120.0 + ), + ) + else: + self.retry_client = None + + async def close(self): + await self.pool_manager.close() + if self.retry_client is not None: + await self.retry_client.close() + + async def request( + self, + method, + url, + headers=None, + body=None, + post_params=None, + _request_timeout=None, + ): + """Execute request + + :param method: http request method + :param url: http request url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _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. + """ + method = method.upper() + assert method in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"] + + if post_params and body: + raise ApiValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + # url already contains the URL query string + timeout = _request_timeout or 5 * 60 + + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" + + args = {"method": method, "url": url, "timeout": timeout, "headers": headers} + + if self.proxy: + args["proxy"] = self.proxy + if self.proxy_headers: + args["proxy_headers"] = self.proxy_headers + + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: + if re.search("json", headers["Content-Type"], re.IGNORECASE): + if body is not None: + body = json.dumps(body) + args["data"] = body + elif headers["Content-Type"] == "application/x-www-form-urlencoded": + args["data"] = aiohttp.FormData(post_params) + elif headers["Content-Type"] == "multipart/form-data": + # must del headers['Content-Type'], or the correct + # Content-Type which generated by aiohttp + del headers["Content-Type"] + data = aiohttp.FormData() + for param in post_params: + k, v = param + if isinstance(v, tuple) and len(v) == 3: + data.add_field(k, value=v[1], filename=v[0], content_type=v[2]) + else: + data.add_field(k, v) + args["data"] = data + + # Pass a `bytes` parameter directly in the body to support + # other content types than Json when `body` argument is provided + # in serialized form + elif isinstance(body, bytes): + args["data"] = body + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + + pool_manager: Union[aiohttp.ClientSession, aiohttp_retry.RetryClient] + if self.retry_client is not None and method in ALLOW_RETRY_METHODS: + pool_manager = self.retry_client + else: + pool_manager = self.pool_manager + + r = await pool_manager.request(**args) + + return RESTResponse(r) diff --git a/hatchet_sdk/clients/rest/api/api_token_api.py b/hatchet_sdk/clients/rest/api/api_token_api.py index 054ccc6b..b207b46d 100644 --- a/hatchet_sdk/clients/rest/api/api_token_api.py +++ b/hatchet_sdk/clients/rest/api/api_token_api.py @@ -298,10 +298,9 @@ def _api_token_create_serialize( _body_params = create_api_token_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -571,10 +570,9 @@ def _api_token_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -834,10 +832,9 @@ def _api_token_update_revoke_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] diff --git a/hatchet_sdk/clients/rest/api/default_api.py b/hatchet_sdk/clients/rest/api/default_api.py index 27b77ab7..e5728965 100644 --- a/hatchet_sdk/clients/rest/api/default_api.py +++ b/hatchet_sdk/clients/rest/api/default_api.py @@ -324,10 +324,9 @@ def _tenant_invite_delete_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -644,10 +643,9 @@ def _tenant_invite_update_serialize( _body_params = update_tenant_invite_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -935,10 +933,9 @@ def _webhook_create_serialize( _body_params = webhook_worker_create_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1211,10 +1208,9 @@ def _webhook_delete_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1477,10 +1473,9 @@ def _webhook_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1743,10 +1738,9 @@ def _webhook_requests_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] diff --git a/hatchet_sdk/clients/rest/api/event_api.py b/hatchet_sdk/clients/rest/api/event_api.py index bb1500d6..266899fc 100644 --- a/hatchet_sdk/clients/rest/api/event_api.py +++ b/hatchet_sdk/clients/rest/api/event_api.py @@ -319,10 +319,9 @@ def _event_create_serialize( _body_params = create_event_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -616,10 +615,9 @@ def _event_create_bulk_serialize( _body_params = bulk_create_event_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -889,10 +887,9 @@ def _event_data_get_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1152,10 +1149,9 @@ def _event_get_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1415,10 +1411,9 @@ def _event_key_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1932,10 +1927,9 @@ def _event_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -2219,10 +2213,9 @@ def _event_update_cancel_serialize( _body_params = cancel_event_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2516,10 +2509,9 @@ def _event_update_replay_serialize( _body_params = replay_event_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/hatchet_sdk/clients/rest/api/github_api.py b/hatchet_sdk/clients/rest/api/github_api.py index 23c1b269..76be9ea2 100644 --- a/hatchet_sdk/clients/rest/api/github_api.py +++ b/hatchet_sdk/clients/rest/api/github_api.py @@ -307,10 +307,9 @@ def _sns_update_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = [] diff --git a/hatchet_sdk/clients/rest/api/log_api.py b/hatchet_sdk/clients/rest/api/log_api.py index eaf16677..c4f9c747 100644 --- a/hatchet_sdk/clients/rest/api/log_api.py +++ b/hatchet_sdk/clients/rest/api/log_api.py @@ -423,10 +423,9 @@ def _log_line_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] diff --git a/hatchet_sdk/clients/rest/api/metadata_api.py b/hatchet_sdk/clients/rest/api/metadata_api.py index 61659069..1043884e 100644 --- a/hatchet_sdk/clients/rest/api/metadata_api.py +++ b/hatchet_sdk/clients/rest/api/metadata_api.py @@ -244,10 +244,9 @@ def _cloud_metadata_get_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = [] @@ -474,10 +473,9 @@ def _metadata_get_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = [] @@ -704,10 +702,9 @@ def _metadata_list_integrations_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] diff --git a/hatchet_sdk/clients/rest/api/rate_limits_api.py b/hatchet_sdk/clients/rest/api/rate_limits_api.py index c5e7e4ee..3445856c 100644 --- a/hatchet_sdk/clients/rest/api/rate_limits_api.py +++ b/hatchet_sdk/clients/rest/api/rate_limits_api.py @@ -365,9 +365,7 @@ def _rate_limit_list_serialize( _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]]] - ] = {} + _files: Dict[str, Union[str, bytes]] = {} _body_params: Optional[bytes] = None # process the path parameters @@ -399,10 +397,9 @@ def _rate_limit_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] diff --git a/hatchet_sdk/clients/rest/api/slack_api.py b/hatchet_sdk/clients/rest/api/slack_api.py index 9b0e637d..c72e1e36 100644 --- a/hatchet_sdk/clients/rest/api/slack_api.py +++ b/hatchet_sdk/clients/rest/api/slack_api.py @@ -287,10 +287,9 @@ def _slack_webhook_delete_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -553,10 +552,9 @@ def _slack_webhook_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] diff --git a/hatchet_sdk/clients/rest/api/sns_api.py b/hatchet_sdk/clients/rest/api/sns_api.py index bb020ceb..5b928689 100644 --- a/hatchet_sdk/clients/rest/api/sns_api.py +++ b/hatchet_sdk/clients/rest/api/sns_api.py @@ -297,10 +297,9 @@ def _sns_create_serialize( _body_params = create_sns_integration_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -582,10 +581,9 @@ def _sns_delete_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -848,10 +846,9 @@ def _sns_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] diff --git a/hatchet_sdk/clients/rest/api/step_run_api.py b/hatchet_sdk/clients/rest/api/step_run_api.py index 851ed174..3a10fa42 100644 --- a/hatchet_sdk/clients/rest/api/step_run_api.py +++ b/hatchet_sdk/clients/rest/api/step_run_api.py @@ -311,10 +311,9 @@ def _step_run_get_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -607,10 +606,9 @@ def _step_run_get_schema_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -919,10 +917,9 @@ def _step_run_list_archives_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1231,10 +1228,9 @@ def _step_run_list_events_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1524,10 +1520,9 @@ def _step_run_update_cancel_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1838,10 +1833,9 @@ def _step_run_update_rerun_serialize( _body_params = rerun_step_run_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2176,10 +2170,9 @@ def _workflow_run_list_step_run_events_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] diff --git a/hatchet_sdk/clients/rest/api/tenant_api.py b/hatchet_sdk/clients/rest/api/tenant_api.py index cd5e4f07..69de9ddd 100644 --- a/hatchet_sdk/clients/rest/api/tenant_api.py +++ b/hatchet_sdk/clients/rest/api/tenant_api.py @@ -329,10 +329,9 @@ def _alert_email_group_create_serialize( _body_params = create_tenant_alert_email_group_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -611,10 +610,9 @@ def _alert_email_group_delete_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -874,10 +872,9 @@ def _alert_email_group_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1170,10 +1167,9 @@ def _alert_email_group_update_serialize( _body_params = update_tenant_alert_email_group_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1443,10 +1439,9 @@ def _tenant_alerting_settings_get_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1697,10 +1692,9 @@ def _tenant_create_serialize( _body_params = create_tenant_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1959,9 +1953,7 @@ def _tenant_get_step_run_queue_metrics_serialize( _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]]] - ] = {} + _files: Dict[str, Union[str, bytes]] = {} _body_params: Optional[bytes] = None # process the path parameters @@ -1973,10 +1965,9 @@ def _tenant_get_step_run_queue_metrics_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -2221,10 +2212,9 @@ def _tenant_invite_accept_serialize( _body_params = accept_invite_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2515,10 +2505,9 @@ def _tenant_invite_create_serialize( _body_params = create_tenant_invite_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2788,10 +2777,9 @@ def _tenant_invite_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -3036,10 +3024,9 @@ def _tenant_invite_reject_serialize( _body_params = reject_invite_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -3351,10 +3338,9 @@ def _tenant_member_delete_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -3614,10 +3600,9 @@ def _tenant_member_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -3877,10 +3862,9 @@ def _tenant_resource_policy_get_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -4161,10 +4145,9 @@ def _tenant_update_serialize( _body_params = update_tenant_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -4404,10 +4387,9 @@ def _user_list_tenant_invites_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth"] diff --git a/hatchet_sdk/clients/rest/api/user_api.py b/hatchet_sdk/clients/rest/api/user_api.py index a9e7a35f..e9fe8b42 100644 --- a/hatchet_sdk/clients/rest/api/user_api.py +++ b/hatchet_sdk/clients/rest/api/user_api.py @@ -253,10 +253,9 @@ def _tenant_memberships_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth"] @@ -504,10 +503,9 @@ def _user_create_serialize( _body_params = user_register_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -750,10 +748,9 @@ def _user_get_current_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth"] @@ -1885,10 +1882,9 @@ def _user_update_login_serialize( _body_params = user_login_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2131,10 +2127,9 @@ def _user_update_logout_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth"] @@ -2382,10 +2377,9 @@ def _user_update_password_serialize( _body_params = user_change_password_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/hatchet_sdk/clients/rest/api/worker_api.py b/hatchet_sdk/clients/rest/api/worker_api.py index f1be3e82..63127fb6 100644 --- a/hatchet_sdk/clients/rest/api/worker_api.py +++ b/hatchet_sdk/clients/rest/api/worker_api.py @@ -277,10 +277,9 @@ def _worker_get_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -540,10 +539,9 @@ def _worker_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -824,10 +822,9 @@ def _worker_update_serialize( _body_params = update_worker_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/hatchet_sdk/clients/rest/api/workflow_api.py b/hatchet_sdk/clients/rest/api/workflow_api.py index 87532339..1efe0652 100644 --- a/hatchet_sdk/clients/rest/api/workflow_api.py +++ b/hatchet_sdk/clients/rest/api/workflow_api.py @@ -354,10 +354,9 @@ def _tenant_get_queue_metrics_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -620,10 +619,9 @@ def _workflow_delete_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -886,10 +884,9 @@ def _workflow_get_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1201,10 +1198,9 @@ def _workflow_get_metrics_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1494,10 +1490,9 @@ def _workflow_get_workers_count_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1757,10 +1752,9 @@ def _workflow_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -2059,10 +2053,9 @@ def _workflow_run_get_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -2520,10 +2513,9 @@ def _workflow_run_get_metrics_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -2822,10 +2814,9 @@ def _workflow_run_get_shape_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -3502,10 +3493,9 @@ def _workflow_run_list_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -3770,9 +3760,7 @@ def _workflow_update_serialize( _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]]] - ] = {} + _files: Dict[str, Union[str, bytes]] = {} _body_params: Optional[bytes] = None # process the path parameters @@ -3786,10 +3774,9 @@ def _workflow_update_serialize( _body_params = workflow_update_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -4094,10 +4081,9 @@ def _workflow_version_get_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] diff --git a/hatchet_sdk/clients/rest/api/workflow_run_api.py b/hatchet_sdk/clients/rest/api/workflow_run_api.py index d0e1aeb4..b999aed9 100644 --- a/hatchet_sdk/clients/rest/api/workflow_run_api.py +++ b/hatchet_sdk/clients/rest/api/workflow_run_api.py @@ -314,10 +314,9 @@ def _workflow_run_cancel_serialize( _body_params = workflow_runs_cancel_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -649,10 +648,9 @@ def _workflow_run_create_serialize( _body_params = trigger_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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: @@ -964,10 +962,9 @@ def _workflow_run_get_input_serialize( # 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"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # authentication setting _auth_settings: List[str] = ["cookieAuth", "bearerAuth"] @@ -1254,10 +1251,9 @@ def _workflow_run_update_replay_serialize( _body_params = replay_workflow_runs_request # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/hatchet_sdk/clients/rest/api_client.py b/hatchet_sdk/clients/rest/api_client.py index 76446dda..02af4d06 100644 --- a/hatchet_sdk/clients/rest/api_client.py +++ b/hatchet_sdk/clients/rest/api_client.py @@ -13,7 +13,6 @@ import datetime -import decimal import json import mimetypes import os @@ -69,7 +68,6 @@ class ApiClient: "bool": bool, "date": datetime.date, "datetime": datetime.datetime, - "decimal": decimal.Decimal, "object": object, } _pool = None @@ -222,7 +220,7 @@ def param_serialize( body = self.sanitize_for_serialization(body) # request url - if _host is None or self.configuration.ignore_operation_servers: + if _host is None: url = self.configuration.host + resource_path else: # use server/host defined in path or operation instead @@ -313,9 +311,12 @@ def response_deserialize( match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) encoding = match.group(1) if match else "utf-8" response_text = response_data.data.decode(encoding) - return_data = self.deserialize( - response_text, response_type, content_type - ) + if response_type in ["bytearray", "str"]: + return_data = self.__deserialize_primitive( + response_text, response_type + ) + else: + return_data = self.deserialize(response_text, response_type) finally: if not 200 <= response_data.status <= 299: raise ApiException.from_response( @@ -339,7 +340,6 @@ def sanitize_for_serialization(self, obj): If obj is str, int, long, float, bool, return directly. If obj is datetime.datetime, datetime.date convert to string in iso8601 format. - If obj is decimal.Decimal return string representation. If obj is list, sanitize each element in the list. If obj is dict, return the dict. If obj is OpenAPI model, return the properties dict. @@ -361,8 +361,6 @@ def sanitize_for_serialization(self, obj): return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) elif isinstance(obj, (datetime.datetime, datetime.date)): return obj.isoformat() - elif isinstance(obj, decimal.Decimal): - return str(obj) elif isinstance(obj, dict): obj_dict = obj @@ -381,40 +379,21 @@ def sanitize_for_serialization(self, obj): key: self.sanitize_for_serialization(val) for key, val in obj_dict.items() } - def deserialize( - self, response_text: str, response_type: str, content_type: Optional[str] - ): + def deserialize(self, response_text, response_type): """Deserializes response into an object. :param response: RESTResponse object to be deserialized. :param response_type: class literal for deserialized object, or string of class name. - :param content_type: content type of response. :return: deserialized object. """ # fetch data from response object - if content_type is None: - try: - data = json.loads(response_text) - except ValueError: - data = response_text - elif re.match( - r"^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)", - content_type, - re.IGNORECASE, - ): - if response_text == "": - data = "" - else: - data = json.loads(response_text) - elif re.match(r"^text\/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE): + try: + data = json.loads(response_text) + except ValueError: data = response_text - else: - raise ApiException( - status=0, reason="Unsupported content type: {0}".format(content_type) - ) return self.__deserialize(data, response_type) @@ -456,8 +435,6 @@ def __deserialize(self, data, klass): return self.__deserialize_date(data) elif klass == datetime.datetime: return self.__deserialize_datetime(data) - elif klass == decimal.Decimal: - return decimal.Decimal(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/hatchet_sdk/clients/rest/configuration.py b/hatchet_sdk/clients/rest/configuration.py index 03743d0b..e33efa68 100644 --- a/hatchet_sdk/clients/rest/configuration.py +++ b/hatchet_sdk/clients/rest/configuration.py @@ -39,9 +39,6 @@ class Configuration: """This class contains various settings of the API client. :param host: Base url. - :param ignore_operation_servers - Boolean to ignore operation servers for the API client. - Config will use `host` as the base url regardless of the operation servers. :param api_key: Dict to store API key(s). Each entry in the dict specifies an API key. The dict key is the name of the security scheme in the OAS specification. @@ -64,7 +61,6 @@ class Configuration: values before. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. - :param retries: Number of retries for API requests. :Example: @@ -102,11 +98,7 @@ def __init__( server_variables=None, server_operation_index=None, server_operation_variables=None, - ignore_operation_servers=False, ssl_ca_cert=None, - retries=None, - *, - debug: Optional[bool] = None ) -> None: """Constructor""" self._base_path = "http://localhost" if host is None else host @@ -120,9 +112,6 @@ def __init__( self.server_operation_variables = server_operation_variables or {} """Default server variables """ - self.ignore_operation_servers = ignore_operation_servers - """Ignore operation servers - """ self.temp_folder_path = None """Temp file folder for downloading files """ @@ -166,10 +155,7 @@ def __init__( self.logger_file = None """Debug file location """ - if debug is not None: - self.debug = debug - else: - self.__debug = False + self.debug = False """Debug switch """ @@ -209,7 +195,7 @@ def __init__( self.safe_chars_for_path_param = "" """Safe chars for path_param """ - self.retries = retries + self.retries = None """Adding retries to override urllib3 default value 3 """ # Enable client side validation diff --git a/hatchet_sdk/clients/rest/models/api_errors.py b/hatchet_sdk/clients/rest/models/api_errors.py index e4dfed11..e41cf5fc 100644 --- a/hatchet_sdk/clients/rest/models/api_errors.py +++ b/hatchet_sdk/clients/rest/models/api_errors.py @@ -73,9 +73,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in errors (list) _items = [] if self.errors: - for _item_errors in self.errors: - if _item_errors: - _items.append(_item_errors.to_dict()) + for _item in self.errors: + if _item: + _items.append(_item.to_dict()) _dict["errors"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/bulk_create_event_request.py b/hatchet_sdk/clients/rest/models/bulk_create_event_request.py index 8d08d394..2c053ee1 100644 --- a/hatchet_sdk/clients/rest/models/bulk_create_event_request.py +++ b/hatchet_sdk/clients/rest/models/bulk_create_event_request.py @@ -73,9 +73,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in events (list) _items = [] if self.events: - for _item_events in self.events: - if _item_events: - _items.append(_item_events.to_dict()) + for _item in self.events: + if _item: + _items.append(_item.to_dict()) _dict["events"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/bulk_create_event_response.py b/hatchet_sdk/clients/rest/models/bulk_create_event_response.py index 768c5c90..5fd1f3a1 100644 --- a/hatchet_sdk/clients/rest/models/bulk_create_event_response.py +++ b/hatchet_sdk/clients/rest/models/bulk_create_event_response.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in events (list) _items = [] if self.events: - for _item_events in self.events: - if _item_events: - _items.append(_item_events.to_dict()) + for _item in self.events: + if _item: + _items.append(_item.to_dict()) _dict["events"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/event_list.py b/hatchet_sdk/clients/rest/models/event_list.py index 5c928005..e12aa656 100644 --- a/hatchet_sdk/clients/rest/models/event_list.py +++ b/hatchet_sdk/clients/rest/models/event_list.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/get_step_run_diff_response.py b/hatchet_sdk/clients/rest/models/get_step_run_diff_response.py index b9dbc435..c01018b6 100644 --- a/hatchet_sdk/clients/rest/models/get_step_run_diff_response.py +++ b/hatchet_sdk/clients/rest/models/get_step_run_diff_response.py @@ -73,9 +73,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in diffs (list) _items = [] if self.diffs: - for _item_diffs in self.diffs: - if _item_diffs: - _items.append(_item_diffs.to_dict()) + for _item in self.diffs: + if _item: + _items.append(_item.to_dict()) _dict["diffs"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/job.py b/hatchet_sdk/clients/rest/models/job.py index c412ef68..aceaf6f4 100644 --- a/hatchet_sdk/clients/rest/models/job.py +++ b/hatchet_sdk/clients/rest/models/job.py @@ -95,9 +95,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in steps (list) _items = [] if self.steps: - for _item_steps in self.steps: - if _item_steps: - _items.append(_item_steps.to_dict()) + for _item in self.steps: + if _item: + _items.append(_item.to_dict()) _dict["steps"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/job_run.py b/hatchet_sdk/clients/rest/models/job_run.py index 3a7ec051..a9b0da3b 100644 --- a/hatchet_sdk/clients/rest/models/job_run.py +++ b/hatchet_sdk/clients/rest/models/job_run.py @@ -117,9 +117,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in step_runs (list) _items = [] if self.step_runs: - for _item_step_runs in self.step_runs: - if _item_step_runs: - _items.append(_item_step_runs.to_dict()) + for _item in self.step_runs: + if _item: + _items.append(_item.to_dict()) _dict["stepRuns"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/list_api_tokens_response.py b/hatchet_sdk/clients/rest/models/list_api_tokens_response.py index b3590ab3..df9b60ac 100644 --- a/hatchet_sdk/clients/rest/models/list_api_tokens_response.py +++ b/hatchet_sdk/clients/rest/models/list_api_tokens_response.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/list_pull_requests_response.py b/hatchet_sdk/clients/rest/models/list_pull_requests_response.py index 589d4c45..6cfd61bb 100644 --- a/hatchet_sdk/clients/rest/models/list_pull_requests_response.py +++ b/hatchet_sdk/clients/rest/models/list_pull_requests_response.py @@ -73,9 +73,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in pull_requests (list) _items = [] if self.pull_requests: - for _item_pull_requests in self.pull_requests: - if _item_pull_requests: - _items.append(_item_pull_requests.to_dict()) + for _item in self.pull_requests: + if _item: + _items.append(_item.to_dict()) _dict["pullRequests"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/list_slack_webhooks.py b/hatchet_sdk/clients/rest/models/list_slack_webhooks.py index e86956d3..647bc276 100644 --- a/hatchet_sdk/clients/rest/models/list_slack_webhooks.py +++ b/hatchet_sdk/clients/rest/models/list_slack_webhooks.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/list_sns_integrations.py b/hatchet_sdk/clients/rest/models/list_sns_integrations.py index 130e9127..ecf67484 100644 --- a/hatchet_sdk/clients/rest/models/list_sns_integrations.py +++ b/hatchet_sdk/clients/rest/models/list_sns_integrations.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/log_line_list.py b/hatchet_sdk/clients/rest/models/log_line_list.py index e05d186a..306ee2c7 100644 --- a/hatchet_sdk/clients/rest/models/log_line_list.py +++ b/hatchet_sdk/clients/rest/models/log_line_list.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/rate_limit_list.py b/hatchet_sdk/clients/rest/models/rate_limit_list.py index e9f2847d..24df2f3a 100644 --- a/hatchet_sdk/clients/rest/models/rate_limit_list.py +++ b/hatchet_sdk/clients/rest/models/rate_limit_list.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/replay_workflow_runs_response.py b/hatchet_sdk/clients/rest/models/replay_workflow_runs_response.py index d8a9609d..6f0f780f 100644 --- a/hatchet_sdk/clients/rest/models/replay_workflow_runs_response.py +++ b/hatchet_sdk/clients/rest/models/replay_workflow_runs_response.py @@ -73,9 +73,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in workflow_runs (list) _items = [] if self.workflow_runs: - for _item_workflow_runs in self.workflow_runs: - if _item_workflow_runs: - _items.append(_item_workflow_runs.to_dict()) + for _item in self.workflow_runs: + if _item: + _items.append(_item.to_dict()) _dict["workflowRuns"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/step_run_archive_list.py b/hatchet_sdk/clients/rest/models/step_run_archive_list.py index eb4bcef2..fcc1419c 100644 --- a/hatchet_sdk/clients/rest/models/step_run_archive_list.py +++ b/hatchet_sdk/clients/rest/models/step_run_archive_list.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/step_run_event_list.py b/hatchet_sdk/clients/rest/models/step_run_event_list.py index f146eb8e..a46f2089 100644 --- a/hatchet_sdk/clients/rest/models/step_run_event_list.py +++ b/hatchet_sdk/clients/rest/models/step_run_event_list.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/tenant_alert_email_group_list.py b/hatchet_sdk/clients/rest/models/tenant_alert_email_group_list.py index 73d67df4..9e1a4fc1 100644 --- a/hatchet_sdk/clients/rest/models/tenant_alert_email_group_list.py +++ b/hatchet_sdk/clients/rest/models/tenant_alert_email_group_list.py @@ -80,9 +80,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/tenant_invite_list.py b/hatchet_sdk/clients/rest/models/tenant_invite_list.py index 0ed078ef..95e4ba4d 100644 --- a/hatchet_sdk/clients/rest/models/tenant_invite_list.py +++ b/hatchet_sdk/clients/rest/models/tenant_invite_list.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/tenant_list.py b/hatchet_sdk/clients/rest/models/tenant_list.py index 2dbb320e..623d6206 100644 --- a/hatchet_sdk/clients/rest/models/tenant_list.py +++ b/hatchet_sdk/clients/rest/models/tenant_list.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/tenant_member_list.py b/hatchet_sdk/clients/rest/models/tenant_member_list.py index 5aabdcd1..6627c281 100644 --- a/hatchet_sdk/clients/rest/models/tenant_member_list.py +++ b/hatchet_sdk/clients/rest/models/tenant_member_list.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/tenant_queue_metrics.py b/hatchet_sdk/clients/rest/models/tenant_queue_metrics.py index 4043d47f..02807090 100644 --- a/hatchet_sdk/clients/rest/models/tenant_queue_metrics.py +++ b/hatchet_sdk/clients/rest/models/tenant_queue_metrics.py @@ -77,13 +77,6 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of total if self.total: _dict["total"] = self.total.to_dict() - # override the default output from pydantic by calling `to_dict()` of each value in workflow (dict) - _field_dict = {} - if self.workflow: - for _key_workflow in self.workflow: - if self.workflow[_key_workflow]: - _field_dict[_key_workflow] = self.workflow[_key_workflow].to_dict() - _dict["workflow"] = _field_dict return _dict @classmethod @@ -102,15 +95,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("total") is not None else None ), - "workflow": ( - dict( - (_k, QueueMetrics.from_dict(_v)) - for _k, _v in obj["workflow"].items() - ) - if obj.get("workflow") is not None - else None - ), - "queues": obj.get("queues"), } ) return _obj diff --git a/hatchet_sdk/clients/rest/models/tenant_resource_policy.py b/hatchet_sdk/clients/rest/models/tenant_resource_policy.py index b9e5181f..c8f10af0 100644 --- a/hatchet_sdk/clients/rest/models/tenant_resource_policy.py +++ b/hatchet_sdk/clients/rest/models/tenant_resource_policy.py @@ -75,9 +75,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in limits (list) _items = [] if self.limits: - for _item_limits in self.limits: - if _item_limits: - _items.append(_item_limits.to_dict()) + for _item in self.limits: + if _item: + _items.append(_item.to_dict()) _dict["limits"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/tenant_step_run_queue_metrics.py b/hatchet_sdk/clients/rest/models/tenant_step_run_queue_metrics.py index 4b9bfc81..90f85ae6 100644 --- a/hatchet_sdk/clients/rest/models/tenant_step_run_queue_metrics.py +++ b/hatchet_sdk/clients/rest/models/tenant_step_run_queue_metrics.py @@ -79,5 +79,5 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({"queues": obj.get("queues")}) + _obj = cls.model_validate({}) return _obj diff --git a/hatchet_sdk/clients/rest/models/user_tenant_memberships_list.py b/hatchet_sdk/clients/rest/models/user_tenant_memberships_list.py index 98b8041b..1f45b260 100644 --- a/hatchet_sdk/clients/rest/models/user_tenant_memberships_list.py +++ b/hatchet_sdk/clients/rest/models/user_tenant_memberships_list.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/webhook_worker_list_response.py b/hatchet_sdk/clients/rest/models/webhook_worker_list_response.py index a221e182..2d9e08c7 100644 --- a/hatchet_sdk/clients/rest/models/webhook_worker_list_response.py +++ b/hatchet_sdk/clients/rest/models/webhook_worker_list_response.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/webhook_worker_request_list_response.py b/hatchet_sdk/clients/rest/models/webhook_worker_request_list_response.py index ec813a38..30915cd0 100644 --- a/hatchet_sdk/clients/rest/models/webhook_worker_request_list_response.py +++ b/hatchet_sdk/clients/rest/models/webhook_worker_request_list_response.py @@ -75,9 +75,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in requests (list) _items = [] if self.requests: - for _item_requests in self.requests: - if _item_requests: - _items.append(_item_requests.to_dict()) + for _item in self.requests: + if _item: + _items.append(_item.to_dict()) _dict["requests"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/worker.py b/hatchet_sdk/clients/rest/models/worker.py index 0d89492a..48e6eda8 100644 --- a/hatchet_sdk/clients/rest/models/worker.py +++ b/hatchet_sdk/clients/rest/models/worker.py @@ -169,23 +169,23 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in slots (list) _items = [] if self.slots: - for _item_slots in self.slots: - if _item_slots: - _items.append(_item_slots.to_dict()) + for _item in self.slots: + if _item: + _items.append(_item.to_dict()) _dict["slots"] = _items # override the default output from pydantic by calling `to_dict()` of each item in recent_step_runs (list) _items = [] if self.recent_step_runs: - for _item_recent_step_runs in self.recent_step_runs: - if _item_recent_step_runs: - _items.append(_item_recent_step_runs.to_dict()) + for _item in self.recent_step_runs: + if _item: + _items.append(_item.to_dict()) _dict["recentStepRuns"] = _items # override the default output from pydantic by calling `to_dict()` of each item in labels (list) _items = [] if self.labels: - for _item_labels in self.labels: - if _item_labels: - _items.append(_item_labels.to_dict()) + for _item in self.labels: + if _item: + _items.append(_item.to_dict()) _dict["labels"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/worker_list.py b/hatchet_sdk/clients/rest/models/worker_list.py index bb02d792..3ffa4349 100644 --- a/hatchet_sdk/clients/rest/models/worker_list.py +++ b/hatchet_sdk/clients/rest/models/worker_list.py @@ -78,9 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/workflow.py b/hatchet_sdk/clients/rest/models/workflow.py index f3107144..42fd94dd 100644 --- a/hatchet_sdk/clients/rest/models/workflow.py +++ b/hatchet_sdk/clients/rest/models/workflow.py @@ -100,23 +100,23 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in versions (list) _items = [] if self.versions: - for _item_versions in self.versions: - if _item_versions: - _items.append(_item_versions.to_dict()) + for _item in self.versions: + if _item: + _items.append(_item.to_dict()) _dict["versions"] = _items # override the default output from pydantic by calling `to_dict()` of each item in tags (list) _items = [] if self.tags: - for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + for _item in self.tags: + if _item: + _items.append(_item.to_dict()) _dict["tags"] = _items # override the default output from pydantic by calling `to_dict()` of each item in jobs (list) _items = [] if self.jobs: - for _item_jobs in self.jobs: - if _item_jobs: - _items.append(_item_jobs.to_dict()) + for _item in self.jobs: + if _item: + _items.append(_item.to_dict()) _dict["jobs"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/workflow_list.py b/hatchet_sdk/clients/rest/models/workflow_list.py index 9eb14aee..72f9fb90 100644 --- a/hatchet_sdk/clients/rest/models/workflow_list.py +++ b/hatchet_sdk/clients/rest/models/workflow_list.py @@ -80,9 +80,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items # override the default output from pydantic by calling `to_dict()` of pagination if self.pagination: diff --git a/hatchet_sdk/clients/rest/models/workflow_run.py b/hatchet_sdk/clients/rest/models/workflow_run.py index 903da30f..3362b830 100644 --- a/hatchet_sdk/clients/rest/models/workflow_run.py +++ b/hatchet_sdk/clients/rest/models/workflow_run.py @@ -125,9 +125,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in job_runs (list) _items = [] if self.job_runs: - for _item_job_runs in self.job_runs: - if _item_job_runs: - _items.append(_item_job_runs.to_dict()) + for _item in self.job_runs: + if _item: + _items.append(_item.to_dict()) _dict["jobRuns"] = _items # override the default output from pydantic by calling `to_dict()` of triggered_by if self.triggered_by: diff --git a/hatchet_sdk/clients/rest/models/workflow_run_list.py b/hatchet_sdk/clients/rest/models/workflow_run_list.py index a56d3feb..e57a14f4 100644 --- a/hatchet_sdk/clients/rest/models/workflow_run_list.py +++ b/hatchet_sdk/clients/rest/models/workflow_run_list.py @@ -75,9 +75,9 @@ def to_dict(self) -> Dict[str, Any]: # 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()) + for _item in self.rows: + if _item: + _items.append(_item.to_dict()) _dict["rows"] = _items # override the default output from pydantic by calling `to_dict()` of pagination if self.pagination: diff --git a/hatchet_sdk/clients/rest/models/workflow_run_shape.py b/hatchet_sdk/clients/rest/models/workflow_run_shape.py index 426e7ef9..dec6a4fd 100644 --- a/hatchet_sdk/clients/rest/models/workflow_run_shape.py +++ b/hatchet_sdk/clients/rest/models/workflow_run_shape.py @@ -128,9 +128,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in job_runs (list) _items = [] if self.job_runs: - for _item_job_runs in self.job_runs: - if _item_job_runs: - _items.append(_item_job_runs.to_dict()) + for _item in self.job_runs: + if _item: + _items.append(_item.to_dict()) _dict["jobRuns"] = _items # override the default output from pydantic by calling `to_dict()` of triggered_by if self.triggered_by: diff --git a/hatchet_sdk/clients/rest/models/workflow_triggers.py b/hatchet_sdk/clients/rest/models/workflow_triggers.py index fd2f07ef..d3fff3f1 100644 --- a/hatchet_sdk/clients/rest/models/workflow_triggers.py +++ b/hatchet_sdk/clients/rest/models/workflow_triggers.py @@ -92,16 +92,16 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in events (list) _items = [] if self.events: - for _item_events in self.events: - if _item_events: - _items.append(_item_events.to_dict()) + for _item in self.events: + if _item: + _items.append(_item.to_dict()) _dict["events"] = _items # override the default output from pydantic by calling `to_dict()` of each item in crons (list) _items = [] if self.crons: - for _item_crons in self.crons: - if _item_crons: - _items.append(_item_crons.to_dict()) + for _item in self.crons: + if _item: + _items.append(_item.to_dict()) _dict["crons"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/models/workflow_version.py b/hatchet_sdk/clients/rest/models/workflow_version.py index 47554e56..87d0cb29 100644 --- a/hatchet_sdk/clients/rest/models/workflow_version.py +++ b/hatchet_sdk/clients/rest/models/workflow_version.py @@ -117,9 +117,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in jobs (list) _items = [] if self.jobs: - for _item_jobs in self.jobs: - if _item_jobs: - _items.append(_item_jobs.to_dict()) + for _item in self.jobs: + if _item: + _items.append(_item.to_dict()) _dict["jobs"] = _items return _dict diff --git a/hatchet_sdk/clients/rest/rest.py b/hatchet_sdk/clients/rest/rest.py index 56286e14..bb45d53a 100644 --- a/hatchet_sdk/clients/rest/rest.py +++ b/hatchet_sdk/clients/rest/rest.py @@ -81,7 +81,7 @@ def __init__(self, configuration) -> None: self.retry_client = aiohttp_retry.RetryClient( client_session=self.pool_manager, retry_options=aiohttp_retry.ExponentialRetry( - attempts=retries, factor=2.0, start_timeout=0.1, max_timeout=120.0 + attempts=retries, factor=0.0, start_timeout=0.0, max_timeout=120.0 ), ) else: @@ -164,10 +164,10 @@ async def request( data.add_field(k, v) args["data"] = data - # Pass a `bytes` or `str` parameter directly in the body to support + # Pass a `bytes` parameter directly in the body to support # other content types than Json when `body` argument is provided # in serialized form - elif isinstance(body, str) or isinstance(body, bytes): + elif isinstance(body, bytes): args["data"] = body else: # Cannot generate the request from given parameters diff --git a/hatchet_sdk/clients/rest_client.py b/hatchet_sdk/clients/rest_client.py index b3d502e0..d62ce221 100644 --- a/hatchet_sdk/clients/rest_client.py +++ b/hatchet_sdk/clients/rest_client.py @@ -3,6 +3,11 @@ import threading from typing import Any +from hatchet_sdk.clients.cloud_rest.api.managed_worker_api import ManagedWorkerApi +from hatchet_sdk.clients.cloud_rest.api_client import ApiClient as CloudApiClient +from hatchet_sdk.clients.cloud_rest.configuration import ( + Configuration as CloudConfiguration, +) from hatchet_sdk.clients.rest.api.event_api import EventApi from hatchet_sdk.clients.rest.api.log_api import LogApi from hatchet_sdk.clients.rest.api.step_run_api import StepRunApi @@ -60,7 +65,15 @@ def __init__(self, host: str, api_key: str, tenant_id: str): access_token=api_key, ) + self.cloud_config = CloudConfiguration( + host=host, + access_token=api_key, + ) + self._api_client = None + self._cloud_api_client = None + self._managed_worker_api = None + self._workflow_api = None self._workflow_run_api = None self._step_run_api = None @@ -71,8 +84,15 @@ def __init__(self, host: str, api_key: str, tenant_id: str): def api_client(self): if self._api_client is None: self._api_client = ApiClient(configuration=self.config) + self._cloud_api_client = CloudApiClient(configuration=self.cloud_config) return self._api_client + @property + def managed_worker_api(self): + if self._managed_worker_api is None: + self._managed_worker_api = ManagedWorkerApi(self.api_client) + return self._managed_worker_api + @property def workflow_api(self): if self._workflow_api is None: diff --git a/hatchet_sdk/compute/__init__.py b/hatchet_sdk/compute/__init__.py new file mode 100644 index 00000000..aaf6d8f4 --- /dev/null +++ b/hatchet_sdk/compute/__init__.py @@ -0,0 +1,3 @@ +from hatchet_sdk.compute.configs import Compute + +__all__ = ["Compute"] diff --git a/hatchet_sdk/compute/configs.py b/hatchet_sdk/compute/configs.py new file mode 100644 index 00000000..89c465f6 --- /dev/null +++ b/hatchet_sdk/compute/configs.py @@ -0,0 +1,34 @@ +import hashlib +from typing import Annotated, Optional + +from pydantic import BaseModel, Field, StrictStr + + +class Compute(BaseModel): + pool: Optional[str] = Field( + default="default", + description="The name of the compute pool to use", + ) + num_replicas: Annotated[int, Field(le=1000, strict=True, ge=0)] = Field( + default=1, alias="num_replicas" + ) + # TODO: change to ManagedWorkerRegion + regions: Optional[list[str]] = Field( + default=None, description="The regions to deploy the worker to" + ) + cpu_kind: StrictStr = Field( + description="The kind of CPU to use for the worker", alias="cpu_kind" + ) + cpus: Annotated[int, Field(le=64, strict=True, ge=1)] = Field( + description="The number of CPUs to use for the worker" + ) + memory_mb: Annotated[int, Field(le=65536, strict=True, ge=1024)] = Field( + description="The amount of memory in MB to use for the worker", + alias="memory_mb", + ) + + def __json__(self): + return self.model_dump_json() + + def hash(self): + return hashlib.sha256(self.__json__().encode()).hexdigest() diff --git a/hatchet_sdk/compute/managed_compute.py b/hatchet_sdk/compute/managed_compute.py new file mode 100644 index 00000000..4c2c0a25 --- /dev/null +++ b/hatchet_sdk/compute/managed_compute.py @@ -0,0 +1,111 @@ +import os +import sys +from typing import Any, Callable, Dict, List + +from hatchet_sdk.client import Client +from hatchet_sdk.clients.cloud_rest.models.infra_as_code_create_request import ( + InfraAsCodeCreateRequest, +) +from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_runtime_config import ( + ManagedWorkerCreateRequestRuntimeConfig, +) +from hatchet_sdk.compute.configs import Compute +from hatchet_sdk.logger import logger + +# TODO why is this not generating +# from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request import ManagedWorkerRegion + + +class ManagedCompute: + def __init__( + self, actions: Dict[str, Callable[..., Any]], client: Client, max_runs: int = 1 + ): + self.actions = actions + self.client = client + self.max_runs = max_runs + self.configs = self.get_compute_configs(self.actions) + self.cloud_register_enabled = os.environ.get("HATCHET_CLOUD_REGISTER_ID") + + if len(self.configs) == 0: + logger.debug( + "no compute configs found, skipping cloud registration and running all actions locally." + ) + return + + if self.cloud_register_enabled is None: + logger.warning("managed cloud compute plan:") + for compute in self.configs: + logger.warning(f" ----------------------------") + logger.warning(f" actions: {', '.join(compute.actions)}") + logger.warning(f" num replicas: {compute.num_replicas}") + logger.warning(f" cpu kind: {compute.cpu_kind}") + logger.warning(f" cpus: {compute.cpus}") + logger.warning(f" memory mb: {compute.memory_mb}") + logger.warning(f" regions: {compute.regions}") + + logger.warning( + "NOTICE: local mode detected, skipping cloud registration and running all actions locally." + ) + + def get_compute_configs( + self, actions: Dict[str, Callable[..., Any]] + ) -> List[ManagedWorkerCreateRequestRuntimeConfig]: + """ + Builds a map of compute hashes to compute configs and lists of actions that correspond to each compute hash. + """ + map: Dict[str, ManagedWorkerCreateRequestRuntimeConfig] = {} + + try: + for action, func in actions.items(): + compute = func._step_compute + + if compute is None: + continue + + key = compute.hash() + if key not in map: + map[key] = ManagedWorkerCreateRequestRuntimeConfig( + actions=[], + num_replicas=compute.num_replicas, + cpu_kind=compute.cpu_kind, + cpus=compute.cpus, + memory_mb=compute.memory_mb, + regions=compute.regions, + slots=self.max_runs, + ) + map[key].actions.append(action) + + return list(map.values()) + except Exception as e: + logger.error(f"Error getting compute configs: {e}") + return [] + + async def cloud_register(self): + + # if the environment variable HATCHET_CLOUD_REGISTER_ID is set, use it and exit + if self.cloud_register_enabled is not None: + logger.info( + f"Registering cloud compute plan with ID: {self.cloud_register_enabled}" + ) + + try: + if len(self.configs) == 0: + logger.warning( + "No actions to register, skipping cloud registration." + ) + return + + req = InfraAsCodeCreateRequest(runtime_configs=self.configs) + + res = ( + await self.client.rest.aio.managed_worker_api.infra_as_code_create( + infra_as_code_request=self.cloud_register_enabled, + infra_as_code_create_request=req, + _request_timeout=10, + ) + ) + + sys.exit(0) + except Exception as e: + print("ERROR", e) + sys.exit(1) diff --git a/hatchet_sdk/hatchet.py b/hatchet_sdk/hatchet.py index 54ffbfbe..37baabdc 100644 --- a/hatchet_sdk/hatchet.py +++ b/hatchet_sdk/hatchet.py @@ -5,6 +5,7 @@ from typing_extensions import deprecated from hatchet_sdk.clients.rest_client import RestApi +from hatchet_sdk.compute.configs import Compute from hatchet_sdk.contracts.workflows_pb2 import ( ConcurrencyLimitStrategy, CreateStepRateLimit, @@ -32,6 +33,23 @@ def workflow( default_priority: int | None = None, concurrency: ConcurrencyExpression | None = None, ): + """ + Decorator to mark a class as a workflow. + + Args: + name (str, optional): The name of the workflow. Defaults to an empty string. + on_events (list, optional): A list of events that trigger the workflow. Defaults to None. + on_crons (list, optional): A list of cron expressions that trigger the workflow. Defaults to None. + version (str, optional): The version of the workflow. Defaults to an empty string. + timeout (str, optional): The timeout for the workflow. Defaults to "60m". + schedule_timeout (str, optional): The schedule timeout for the workflow. Defaults to "5m". + sticky (StickyStrategy, optional): The sticky strategy for the workflow. Defaults to None. + default_priority (int, optional): The default priority for the workflow. Defaults to None. + concurrency (ConcurrencyExpression, optional): The concurrency expression for the workflow. Defaults to None. + + Returns: + function: The decorated class with workflow metadata. + """ on_events = on_events or [] on_crons = on_crons or [] @@ -59,7 +77,23 @@ def step( retries: int = 0, rate_limits: List[RateLimit] | None = None, desired_worker_labels: dict[str:DesiredWorkerLabel] = {}, + compute: Compute | None = None, ): + """ + Decorator to mark a function as a step in a workflow. + + Args: + name (str, optional): The name of the step. Defaults to the function name. + timeout (str, optional): The timeout for the step. Defaults to an empty string. + parents (List[str], optional): A list of parent step names. Defaults to an empty list. + retries (int, optional): The number of retries for the step. Defaults to 0. + rate_limits (List[RateLimit], optional): A list of rate limits for the step. Defaults to None. + desired_worker_labels (dict[str:DesiredWorkerLabel], optional): A dictionary of desired worker labels. Defaults to an empty dictionary. + compute (Compute, optional): The compute configuration for the step. Hatchet Cloud only. Defaults to None. + + Returns: + function: The decorated function with step metadata. + """ parents = parents or [] def inner(func): @@ -75,6 +109,7 @@ def inner(func): func._step_timeout = timeout func._step_retries = retries func._step_rate_limits = limits + func._step_compute = compute func._step_desired_worker_labels = {} diff --git a/hatchet_sdk/loader.py b/hatchet_sdk/loader.py index 831c10d7..5220dcd8 100644 --- a/hatchet_sdk/loader.py +++ b/hatchet_sdk/loader.py @@ -38,6 +38,9 @@ def __init__( logger: Logger = None, grpc_max_recv_message_length: int = 4 * 1024 * 1024, # 4MB grpc_max_send_message_length: int = 4 * 1024 * 1024, # 4MB + runnable_actions: list[ + str + ] = None, # list of action names that are runnable, defaults to all actions ): self.tenant_id = tenant_id self.tls_config = tls_config @@ -62,6 +65,12 @@ def __init__( self.listener_v2_timeout = listener_v2_timeout + self.runnable_actions: list[str] | None = ( + [self.namespace + action for action in runnable_actions] + if runnable_actions + else None + ) + class ConfigLoader: def __init__(self, directory: str): @@ -127,6 +136,13 @@ def get_config_value(key, env_var): tls_config = self._load_tls_config(config_data["tls"], host_port) + raw_runnable_actions = get_config_value( + "runnable_actions", "HATCHET_CLOUD_ACTIONS" + ) + runnable_actions = ( + raw_runnable_actions.split(",") if raw_runnable_actions else None + ) + return ClientConfig( tenant_id=tenant_id, tls_config=tls_config, @@ -138,6 +154,7 @@ def get_config_value(key, env_var): logger=defaults.logInterceptor, grpc_max_recv_message_length=grpc_max_recv_message_length, grpc_max_send_message_length=grpc_max_send_message_length, + runnable_actions=runnable_actions, ) def _load_tls_config(self, tls_data: Dict, host_port) -> ClientTLSConfig: diff --git a/hatchet_sdk/worker/worker.py b/hatchet_sdk/worker/worker.py index db944511..7b8f51cb 100644 --- a/hatchet_sdk/worker/worker.py +++ b/hatchet_sdk/worker/worker.py @@ -9,6 +9,7 @@ from typing import Any, Callable, Dict, Optional from hatchet_sdk.client import Client, new_client_raw +from hatchet_sdk.compute.managed_compute import ManagedCompute from hatchet_sdk.context import Context from hatchet_sdk.contracts.workflows_pb2 import CreateWorkflowVersionOpts from hatchet_sdk.loader import ClientConfig @@ -99,7 +100,17 @@ def action_function(context): return action_function for action_name, action_func in workflow.get_actions(namespace): - self.action_registry[action_name] = create_action_function(action_func) + if ( + self.client.config.runnable_actions + and action_name not in self.client.config.runnable_actions + ): + logger.debug(f"skipping action: {action_name} not in runnable actions") + continue + + fn = create_action_function(action_func) + # copy the compute from the action func to the action function + fn._step_compute = action_func._step_compute + self.action_registry[action_name] = fn def status(self) -> WorkerStatus: return self._status @@ -154,6 +165,11 @@ async def async_start( if not _from_start: self.setup_loop(options.loop) + managed_compute = ManagedCompute( + self.action_registry, self.client, self.max_runs + ) + await managed_compute.cloud_register() + self.action_listener_process = self._start_listener() self.action_runner = self._run_action_runner() self.action_listener_health_check = self.loop.create_task( diff --git a/pyproject.toml b/pyproject.toml index 03647c97..b4adea2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "hatchet-sdk" -version = "0.39.0a1" +version = "0.40.0a9" description = "" authors = ["Alexander Belanger "] readme = "README.md" @@ -64,6 +64,7 @@ on_failure = "examples.on_failure.worker:main" programatic_replay = "examples.programatic_replay.worker:main" rate_limit = "examples.rate_limit.worker:main" simple = "examples.simple.worker:main" +managed = "examples.managed.worker:main" timeout = "examples.timeout.worker:main" blocked = "examples.blocked_async.worker:main" existing_loop = "examples.worker_existing_loop.worker:main"