hatchet-sdk 0.0.0 → 0.1.0.pre.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -2
- data/CLAUDE.md +61 -4
- data/INTEGRATION_TESTING.md +176 -0
- data/LICENSE.txt +1 -1
- data/REST_API_GENERATION.md +257 -0
- data/Rakefile +9 -0
- data/Rakefile.rest +133 -0
- data/config/openapi_generator_config.json +31 -0
- data/lib/hatchet/clients/rest/.gitignore +39 -0
- data/lib/hatchet/clients/rest/.gitlab-ci.yml +26 -0
- data/lib/hatchet/clients/rest/.openapi-generator/FILES +420 -0
- data/lib/hatchet/clients/rest/.openapi-generator/VERSION +1 -0
- data/lib/hatchet/clients/rest/.openapi-generator-ignore +23 -0
- data/lib/hatchet/clients/rest/.rspec +2 -0
- data/lib/hatchet/clients/rest/.rubocop.yml +148 -0
- data/lib/hatchet/clients/rest/.travis.yml +11 -0
- data/lib/hatchet/clients/rest/Gemfile +9 -0
- data/lib/hatchet/clients/rest/README.md +420 -0
- data/lib/hatchet/clients/rest/Rakefile +10 -0
- data/lib/hatchet/clients/rest/docs/APIError.md +24 -0
- data/lib/hatchet/clients/rest/docs/APIErrors.md +18 -0
- data/lib/hatchet/clients/rest/docs/APIMeta.md +30 -0
- data/lib/hatchet/clients/rest/docs/APIMetaAuth.md +18 -0
- data/lib/hatchet/clients/rest/docs/APIMetaIntegration.md +20 -0
- data/lib/hatchet/clients/rest/docs/APIMetaPosthog.md +20 -0
- data/lib/hatchet/clients/rest/docs/APIResourceMeta.md +22 -0
- data/lib/hatchet/clients/rest/docs/APIToken.md +22 -0
- data/lib/hatchet/clients/rest/docs/APITokenApi.md +235 -0
- data/lib/hatchet/clients/rest/docs/AcceptInviteRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/BulkCreateEventRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/CancelEventRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/ConcurrencyLimitStrategy.md +15 -0
- data/lib/hatchet/clients/rest/docs/CreateAPITokenRequest.md +20 -0
- data/lib/hatchet/clients/rest/docs/CreateAPITokenResponse.md +18 -0
- data/lib/hatchet/clients/rest/docs/CreateCronWorkflowTriggerRequest.md +26 -0
- data/lib/hatchet/clients/rest/docs/CreateEventRequest.md +26 -0
- data/lib/hatchet/clients/rest/docs/CreatePullRequestFromStepRun.md +18 -0
- data/lib/hatchet/clients/rest/docs/CreateSNSIntegrationRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/CreateTenantAlertEmailGroupRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/CreateTenantInviteRequest.md +20 -0
- data/lib/hatchet/clients/rest/docs/CreateTenantRequest.md +24 -0
- data/lib/hatchet/clients/rest/docs/CronWorkflows.md +40 -0
- data/lib/hatchet/clients/rest/docs/CronWorkflowsList.md +20 -0
- data/lib/hatchet/clients/rest/docs/CronWorkflowsMethod.md +15 -0
- data/lib/hatchet/clients/rest/docs/CronWorkflowsOrderByField.md +15 -0
- data/lib/hatchet/clients/rest/docs/DefaultApi.md +602 -0
- data/lib/hatchet/clients/rest/docs/Event.md +28 -0
- data/lib/hatchet/clients/rest/docs/EventApi.md +809 -0
- data/lib/hatchet/clients/rest/docs/EventData.md +18 -0
- data/lib/hatchet/clients/rest/docs/EventKeyList.md +20 -0
- data/lib/hatchet/clients/rest/docs/EventList.md +20 -0
- data/lib/hatchet/clients/rest/docs/EventOrderByDirection.md +15 -0
- data/lib/hatchet/clients/rest/docs/EventOrderByField.md +15 -0
- data/lib/hatchet/clients/rest/docs/EventUpdateCancel200Response.md +18 -0
- data/lib/hatchet/clients/rest/docs/EventWorkflowRunSummary.md +28 -0
- data/lib/hatchet/clients/rest/docs/Events.md +20 -0
- data/lib/hatchet/clients/rest/docs/FilterApi.md +402 -0
- data/lib/hatchet/clients/rest/docs/GetStepRunDiffResponse.md +18 -0
- data/lib/hatchet/clients/rest/docs/GithubApi.md +73 -0
- data/lib/hatchet/clients/rest/docs/HealthcheckApi.md +129 -0
- data/lib/hatchet/clients/rest/docs/InfoGetVersion200Response.md +18 -0
- data/lib/hatchet/clients/rest/docs/Job.md +30 -0
- data/lib/hatchet/clients/rest/docs/JobRun.md +48 -0
- data/lib/hatchet/clients/rest/docs/JobRunStatus.md +15 -0
- data/lib/hatchet/clients/rest/docs/ListAPITokensResponse.md +20 -0
- data/lib/hatchet/clients/rest/docs/ListPullRequestsResponse.md +18 -0
- data/lib/hatchet/clients/rest/docs/ListSNSIntegrations.md +20 -0
- data/lib/hatchet/clients/rest/docs/ListSlackWebhooks.md +20 -0
- data/lib/hatchet/clients/rest/docs/LogApi.md +171 -0
- data/lib/hatchet/clients/rest/docs/LogLine.md +22 -0
- data/lib/hatchet/clients/rest/docs/LogLineLevel.md +15 -0
- data/lib/hatchet/clients/rest/docs/LogLineList.md +20 -0
- data/lib/hatchet/clients/rest/docs/LogLineOrderByDirection.md +15 -0
- data/lib/hatchet/clients/rest/docs/LogLineOrderByField.md +15 -0
- data/lib/hatchet/clients/rest/docs/MetadataApi.md +203 -0
- data/lib/hatchet/clients/rest/docs/PaginationResponse.md +22 -0
- data/lib/hatchet/clients/rest/docs/PullRequest.md +32 -0
- data/lib/hatchet/clients/rest/docs/PullRequestState.md +15 -0
- data/lib/hatchet/clients/rest/docs/QueueMetrics.md +22 -0
- data/lib/hatchet/clients/rest/docs/RateLimit.md +28 -0
- data/lib/hatchet/clients/rest/docs/RateLimitList.md +20 -0
- data/lib/hatchet/clients/rest/docs/RateLimitOrderByDirection.md +15 -0
- data/lib/hatchet/clients/rest/docs/RateLimitOrderByField.md +15 -0
- data/lib/hatchet/clients/rest/docs/RateLimitsApi.md +94 -0
- data/lib/hatchet/clients/rest/docs/RecentStepRuns.md +30 -0
- data/lib/hatchet/clients/rest/docs/RejectInviteRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/ReplayEventRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/ReplayWorkflowRunsRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/ReplayWorkflowRunsResponse.md +18 -0
- data/lib/hatchet/clients/rest/docs/RerunStepRunRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/SNSApi.md +235 -0
- data/lib/hatchet/clients/rest/docs/SNSIntegration.md +24 -0
- data/lib/hatchet/clients/rest/docs/ScheduleWorkflowRunRequest.md +24 -0
- data/lib/hatchet/clients/rest/docs/ScheduledRunStatus.md +15 -0
- data/lib/hatchet/clients/rest/docs/ScheduledWorkflows.md +44 -0
- data/lib/hatchet/clients/rest/docs/ScheduledWorkflowsList.md +20 -0
- data/lib/hatchet/clients/rest/docs/ScheduledWorkflowsMethod.md +15 -0
- data/lib/hatchet/clients/rest/docs/ScheduledWorkflowsOrderByField.md +15 -0
- data/lib/hatchet/clients/rest/docs/SemaphoreSlots.md +28 -0
- data/lib/hatchet/clients/rest/docs/SlackApi.md +156 -0
- data/lib/hatchet/clients/rest/docs/SlackWebhook.md +28 -0
- data/lib/hatchet/clients/rest/docs/Step.md +32 -0
- data/lib/hatchet/clients/rest/docs/StepRun.md +68 -0
- data/lib/hatchet/clients/rest/docs/StepRunApi.md +560 -0
- data/lib/hatchet/clients/rest/docs/StepRunArchive.md +50 -0
- data/lib/hatchet/clients/rest/docs/StepRunArchiveList.md +20 -0
- data/lib/hatchet/clients/rest/docs/StepRunDiff.md +22 -0
- data/lib/hatchet/clients/rest/docs/StepRunEvent.md +36 -0
- data/lib/hatchet/clients/rest/docs/StepRunEventList.md +20 -0
- data/lib/hatchet/clients/rest/docs/StepRunEventReason.md +15 -0
- data/lib/hatchet/clients/rest/docs/StepRunEventSeverity.md +15 -0
- data/lib/hatchet/clients/rest/docs/StepRunStatus.md +15 -0
- data/lib/hatchet/clients/rest/docs/TaskApi.md +566 -0
- data/lib/hatchet/clients/rest/docs/Tenant.md +30 -0
- data/lib/hatchet/clients/rest/docs/TenantAlertEmailGroup.md +20 -0
- data/lib/hatchet/clients/rest/docs/TenantAlertEmailGroupList.md +20 -0
- data/lib/hatchet/clients/rest/docs/TenantAlertingSettings.md +30 -0
- data/lib/hatchet/clients/rest/docs/TenantApi.md +1362 -0
- data/lib/hatchet/clients/rest/docs/TenantInvite.md +28 -0
- data/lib/hatchet/clients/rest/docs/TenantInviteList.md +20 -0
- data/lib/hatchet/clients/rest/docs/TenantList.md +20 -0
- data/lib/hatchet/clients/rest/docs/TenantMember.md +24 -0
- data/lib/hatchet/clients/rest/docs/TenantMemberList.md +20 -0
- data/lib/hatchet/clients/rest/docs/TenantMemberRole.md +15 -0
- data/lib/hatchet/clients/rest/docs/TenantQueueMetrics.md +22 -0
- data/lib/hatchet/clients/rest/docs/TenantResource.md +15 -0
- data/lib/hatchet/clients/rest/docs/TenantResourceLimit.md +30 -0
- data/lib/hatchet/clients/rest/docs/TenantResourcePolicy.md +18 -0
- data/lib/hatchet/clients/rest/docs/TenantStepRunQueueMetrics.md +18 -0
- data/lib/hatchet/clients/rest/docs/TenantUIVersion.md +15 -0
- data/lib/hatchet/clients/rest/docs/TenantVersion.md +15 -0
- data/lib/hatchet/clients/rest/docs/TriggerWorkflowRunRequest.md +20 -0
- data/lib/hatchet/clients/rest/docs/UpdateTenantAlertEmailGroupRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/UpdateTenantInviteRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/UpdateTenantRequest.md +34 -0
- data/lib/hatchet/clients/rest/docs/UpdateWorkerRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/User.md +28 -0
- data/lib/hatchet/clients/rest/docs/UserApi.md +805 -0
- data/lib/hatchet/clients/rest/docs/UserChangePasswordRequest.md +20 -0
- data/lib/hatchet/clients/rest/docs/UserLoginRequest.md +20 -0
- data/lib/hatchet/clients/rest/docs/UserRegisterRequest.md +22 -0
- data/lib/hatchet/clients/rest/docs/UserTenantMembershipsList.md +20 -0
- data/lib/hatchet/clients/rest/docs/UserTenantPublic.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1CancelTaskRequest.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1CancelledTasks.md +18 -0
- data/lib/hatchet/clients/rest/docs/V1CreateFilterRequest.md +24 -0
- data/lib/hatchet/clients/rest/docs/V1DagChildren.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1Event.md +36 -0
- data/lib/hatchet/clients/rest/docs/V1EventList.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1EventTriggeredRun.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1EventWorkflowRunSummary.md +26 -0
- data/lib/hatchet/clients/rest/docs/V1Filter.md +28 -0
- data/lib/hatchet/clients/rest/docs/V1FilterList.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1LogLine.md +28 -0
- data/lib/hatchet/clients/rest/docs/V1LogLineLevel.md +15 -0
- data/lib/hatchet/clients/rest/docs/V1LogLineList.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1ReplayTaskRequest.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1ReplayedTasks.md +18 -0
- data/lib/hatchet/clients/rest/docs/V1TaskEvent.md +38 -0
- data/lib/hatchet/clients/rest/docs/V1TaskEventList.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1TaskEventType.md +15 -0
- data/lib/hatchet/clients/rest/docs/V1TaskFilter.md +26 -0
- data/lib/hatchet/clients/rest/docs/V1TaskPointMetric.md +22 -0
- data/lib/hatchet/clients/rest/docs/V1TaskPointMetrics.md +18 -0
- data/lib/hatchet/clients/rest/docs/V1TaskRunMetric.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1TaskRunStatus.md +15 -0
- data/lib/hatchet/clients/rest/docs/V1TaskStatus.md +15 -0
- data/lib/hatchet/clients/rest/docs/V1TaskSummary.md +72 -0
- data/lib/hatchet/clients/rest/docs/V1TaskSummaryList.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1TaskTiming.md +46 -0
- data/lib/hatchet/clients/rest/docs/V1TaskTimingList.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1TriggerWorkflowRunRequest.md +24 -0
- data/lib/hatchet/clients/rest/docs/V1UpdateFilterRequest.md +22 -0
- data/lib/hatchet/clients/rest/docs/V1WorkflowRun.md +46 -0
- data/lib/hatchet/clients/rest/docs/V1WorkflowRunDetails.md +26 -0
- data/lib/hatchet/clients/rest/docs/V1WorkflowRunDisplayName.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1WorkflowRunDisplayNameList.md +20 -0
- data/lib/hatchet/clients/rest/docs/V1WorkflowType.md +15 -0
- data/lib/hatchet/clients/rest/docs/WebhookWorker.md +22 -0
- data/lib/hatchet/clients/rest/docs/WebhookWorkerCreateRequest.md +22 -0
- data/lib/hatchet/clients/rest/docs/WebhookWorkerCreateResponse.md +18 -0
- data/lib/hatchet/clients/rest/docs/WebhookWorkerCreated.md +24 -0
- data/lib/hatchet/clients/rest/docs/WebhookWorkerListResponse.md +20 -0
- data/lib/hatchet/clients/rest/docs/WebhookWorkerRequest.md +22 -0
- data/lib/hatchet/clients/rest/docs/WebhookWorkerRequestListResponse.md +18 -0
- data/lib/hatchet/clients/rest/docs/WebhookWorkerRequestMethod.md +15 -0
- data/lib/hatchet/clients/rest/docs/Worker.md +48 -0
- data/lib/hatchet/clients/rest/docs/WorkerApi.md +234 -0
- data/lib/hatchet/clients/rest/docs/WorkerLabel.md +22 -0
- data/lib/hatchet/clients/rest/docs/WorkerList.md +20 -0
- data/lib/hatchet/clients/rest/docs/WorkerRuntimeInfo.md +26 -0
- data/lib/hatchet/clients/rest/docs/WorkerRuntimeSDKs.md +15 -0
- data/lib/hatchet/clients/rest/docs/WorkerType.md +15 -0
- data/lib/hatchet/clients/rest/docs/Workflow.md +32 -0
- data/lib/hatchet/clients/rest/docs/WorkflowApi.md +1480 -0
- data/lib/hatchet/clients/rest/docs/WorkflowConcurrency.md +22 -0
- data/lib/hatchet/clients/rest/docs/WorkflowKind.md +15 -0
- data/lib/hatchet/clients/rest/docs/WorkflowList.md +22 -0
- data/lib/hatchet/clients/rest/docs/WorkflowMetrics.md +20 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRun.md +48 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRunApi.md +477 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRunList.md +20 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRunOrderByDirection.md +15 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRunOrderByField.md +15 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRunShape.md +50 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRunShapeItemForWorkflowRunDetails.md +24 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRunStatus.md +15 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRunTriggeredBy.md +26 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRunsApi.md +572 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRunsCancelRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRunsMetrics.md +18 -0
- data/lib/hatchet/clients/rest/docs/WorkflowRunsMetricsCounts.md +28 -0
- data/lib/hatchet/clients/rest/docs/WorkflowTag.md +20 -0
- data/lib/hatchet/clients/rest/docs/WorkflowTriggerCronRef.md +20 -0
- data/lib/hatchet/clients/rest/docs/WorkflowTriggerEventRef.md +20 -0
- data/lib/hatchet/clients/rest/docs/WorkflowTriggers.md +26 -0
- data/lib/hatchet/clients/rest/docs/WorkflowUpdateRequest.md +18 -0
- data/lib/hatchet/clients/rest/docs/WorkflowVersion.md +40 -0
- data/lib/hatchet/clients/rest/docs/WorkflowVersionDefinition.md +18 -0
- data/lib/hatchet/clients/rest/docs/WorkflowVersionMeta.md +26 -0
- data/lib/hatchet/clients/rest/docs/WorkflowWorkersCount.md +22 -0
- data/lib/hatchet/clients/rest/git_push.sh +57 -0
- data/lib/hatchet/clients/rest/hatchet-sdk-rest.gemspec +41 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/api_token_api.rb +242 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/default_api.rb +622 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/event_api.rb +836 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/filter_api.rb +449 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/github_api.rb +107 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/healthcheck_api.rb +132 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/log_api.rb +182 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/metadata_api.rb +193 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/rate_limits_api.rb +108 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/slack_api.rb +164 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/sns_api.rb +242 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/step_run_api.rb +615 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/task_api.rb +599 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/tenant_api.rb +1327 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/user_api.rb +729 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/worker_api.rb +246 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/workflow_api.rb +1654 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/workflow_run_api.rb +540 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/workflow_runs_api.rb +614 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api_client.rb +437 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api_error.rb +58 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/configuration.rb +399 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/accept_invite_request.rb +255 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/api_error.rb +268 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/api_errors.rb +239 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/api_meta.rb +279 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/api_meta_auth.rb +223 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/api_meta_integration.rb +265 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/api_meta_posthog.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/api_resource_meta.rb +310 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/api_token.rb +300 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/bulk_create_event_request.rb +239 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/cancel_event_request.rb +239 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/concurrency_limit_strategy.rb +42 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/create_api_token_request.rb +257 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/create_api_token_response.rb +238 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/create_cron_workflow_trigger_request.rb +352 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/create_event_request.rb +295 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/create_pull_request_from_step_run.rb +237 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/create_sns_integration_request.rb +238 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/create_tenant_alert_email_group_request.rb +240 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/create_tenant_invite_request.rb +287 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/create_tenant_request.rb +307 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/cron_workflows.rb +509 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/cron_workflows_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/cron_workflows_method.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/cron_workflows_order_by_field.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/event.rb +321 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/event_data.rb +238 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/event_key_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/event_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/event_order_by_direction.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/event_order_by_field.rb +39 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/event_update_cancel200_response.rb +222 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/event_workflow_run_summary.rb +271 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/events.rb +266 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/get_step_run_diff_response.rb +239 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/info_get_version200_response.rb +237 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/job.rb +363 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/job_run.rb +464 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/job_run_status.rb +44 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/list_api_tokens_response.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/list_pull_requests_response.rb +239 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/list_slack_webhooks.rb +265 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/list_sns_integrations.rb +265 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/log_line.rb +292 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/log_line_level.rb +42 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/log_line_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/log_line_order_by_direction.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/log_line_order_by_field.rb +39 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/pagination_response.rb +241 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/pull_request.rb +441 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/pull_request_state.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/queue_metrics.rb +292 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/rate_limit.rb +373 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/rate_limit_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/rate_limit_order_by_direction.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/rate_limit_order_by_field.rb +41 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/recent_step_runs.rb +365 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/reject_invite_request.rb +255 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/replay_event_request.rb +239 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/replay_workflow_runs_request.rb +239 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/replay_workflow_runs_response.rb +239 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/rerun_step_run_request.rb +237 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/schedule_workflow_run_request.rb +326 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/scheduled_run_status.rb +45 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/scheduled_workflows.rb +538 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/scheduled_workflows_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/scheduled_workflows_method.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/scheduled_workflows_order_by_field.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/semaphore_slots.rb +343 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/slack_webhook.rb +372 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/sns_integration.rb +301 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/step.rb +374 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/step_run.rb +556 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/step_run_archive.rb +432 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/step_run_archive_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/step_run_diff.rb +289 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/step_run_event.rb +442 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/step_run_event_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/step_run_event_reason.rb +55 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/step_run_event_severity.rb +41 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/step_run_status.rb +47 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant.rb +370 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_alert_email_group.rb +266 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_alert_email_group_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_alerting_settings.rb +314 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_invite.rb +377 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_invite_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_member.rb +323 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_member_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_member_role.rb +41 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_queue_metrics.rb +243 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_resource.rb +45 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_resource_limit.rb +370 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_resource_policy.rb +240 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_step_run_queue_metrics.rb +220 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_ui_version.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_version.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/trigger_workflow_run_request.rb +246 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/update_tenant_alert_email_group_request.rb +240 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/update_tenant_invite_request.rb +260 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/update_tenant_request.rb +323 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/update_worker_request.rb +221 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/user.rb +321 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/user_change_password_request.rb +265 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/user_login_request.rb +265 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/user_register_request.rb +292 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/user_tenant_memberships_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/user_tenant_public.rb +248 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_cancel_task_request.rb +232 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_cancelled_tasks.rb +223 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_create_filter_request.rb +320 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_dag_children.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_event.rb +380 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_event_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_event_triggered_run.rb +266 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_event_workflow_run_summary.rb +346 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_filter.rb +390 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_filter_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_log_line.rb +344 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_log_line_level.rb +42 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_log_line_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_replay_task_request.rb +232 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_replayed_tasks.rb +223 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_event.rb +419 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_event_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_event_type.rb +58 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_filter.rb +279 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_point_metric.rb +289 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_point_metrics.rb +222 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_run_metric.rb +285 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_run_status.rb +43 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_status.rb +43 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_summary.rb +812 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_summary_list.rb +266 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_timing.rb +581 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_timing_list.rb +266 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_trigger_workflow_run_request.rb +283 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_update_filter_request.rb +241 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_workflow_run.rb +544 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_workflow_run_details.rb +331 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_workflow_run_display_name.rb +263 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_workflow_run_display_name_list.rb +266 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_workflow_type.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/webhook_worker.rb +291 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/webhook_worker_create_request.rb +294 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/webhook_worker_create_response.rb +220 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/webhook_worker_created.rb +318 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/webhook_worker_list_response.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/webhook_worker_request.rb +314 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/webhook_worker_request_list_response.rb +223 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/webhook_worker_request_method.rb +41 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/worker.rb +489 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/worker_label.rb +274 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/worker_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/worker_runtime_info.rb +278 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/worker_runtime_sdks.rb +41 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/worker_type.rb +41 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow.rb +346 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_concurrency.rb +314 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_kind.rb +41 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_list.rb +240 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_metrics.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_run.rb +524 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_run_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_run_order_by_direction.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_run_order_by_field.rb +42 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_run_shape.rb +533 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_run_shape_item_for_workflow_run_details.rb +353 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_run_status.rb +45 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_run_triggered_by.rb +273 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_runs_cancel_request.rb +239 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_runs_metrics.rb +220 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_runs_metrics_counts.rb +265 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_tag.rb +265 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_trigger_cron_ref.rb +229 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_trigger_event_ref.rb +229 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_triggers.rb +260 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_update_request.rb +221 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_version.rb +392 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_version_definition.rb +238 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_version_meta.rb +325 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_workers_count.rb +238 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/version.rb +15 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest.rb +241 -0
- data/lib/hatchet/clients/rest/spec/spec_helper.rb +111 -0
- data/lib/hatchet/clients/rest.rb +126 -0
- data/lib/hatchet/clients.rb +71 -0
- data/lib/hatchet/config.rb +482 -0
- data/lib/hatchet/features/events.rb +265 -0
- data/lib/hatchet/features/runs.rb +423 -0
- data/lib/hatchet/version.rb +1 -1
- data/lib/hatchet-sdk.rb +74 -3
- data/scripts/generate.sh +167 -0
- data/scripts/generate_api.rb +174 -0
- data/sig/hatchet-sdk.rbs +525 -1
- metadata +491 -1
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'time'
|
|
4
|
+
|
|
5
|
+
module Hatchet
|
|
6
|
+
module Features
|
|
7
|
+
# Events client for interacting with Hatchet event management API
|
|
8
|
+
#
|
|
9
|
+
# This class provides a high-level interface for creating and managing events
|
|
10
|
+
# in the Hatchet system. It wraps the generated REST API client with a more
|
|
11
|
+
# convenient Ruby interface.
|
|
12
|
+
#
|
|
13
|
+
# @example Creating an event
|
|
14
|
+
# response = events.push(
|
|
15
|
+
# key: "user-login",
|
|
16
|
+
# data: { user_id: 123, action: "login" },
|
|
17
|
+
# additional_metadata: { ip_address: "192.168.1.1" }
|
|
18
|
+
# )
|
|
19
|
+
#
|
|
20
|
+
# @since 0.1.0
|
|
21
|
+
class Events
|
|
22
|
+
# Re-export commonly used event classes for convenience
|
|
23
|
+
CreateEventRequest = ::HatchetSdkRest::CreateEventRequest
|
|
24
|
+
BulkCreateEventRequest = ::HatchetSdkRest::BulkCreateEventRequest
|
|
25
|
+
EventList = ::HatchetSdkRest::V1EventList
|
|
26
|
+
|
|
27
|
+
# Initializes a new Events client instance
|
|
28
|
+
#
|
|
29
|
+
# @param rest_client [Object] The configured REST client for API communication
|
|
30
|
+
# @param config [Hatchet::Config] The Hatchet configuration containing tenant_id and other settings
|
|
31
|
+
# @return [void]
|
|
32
|
+
# @since 0.1.0
|
|
33
|
+
def initialize(rest_client, config)
|
|
34
|
+
@rest_client = rest_client
|
|
35
|
+
@config = config
|
|
36
|
+
@event_api = HatchetSdkRest::EventApi.new(rest_client)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Creates a new event in the Hatchet system
|
|
40
|
+
#
|
|
41
|
+
# This method sends an event creation request to the Hatchet API using the
|
|
42
|
+
# configured tenant ID. The event will be processed and made available for
|
|
43
|
+
# workflow triggers and event-driven automation.
|
|
44
|
+
#
|
|
45
|
+
# @param key [String] The event key/name
|
|
46
|
+
# @param data [Hash] The event payload data
|
|
47
|
+
# @param additional_metadata [Hash, nil] Additional metadata for the event
|
|
48
|
+
# @param priority [Integer, nil] Event priority
|
|
49
|
+
# @param scope [String, nil] The scope for event filtering
|
|
50
|
+
# @param namespace [String, nil] Override namespace for this event
|
|
51
|
+
# @return [Object] The API response containing the created event details
|
|
52
|
+
# @raise [ArgumentError] If required parameters are missing
|
|
53
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
54
|
+
# @example Creating a simple event
|
|
55
|
+
# response = events.create(
|
|
56
|
+
# key: "user-login",
|
|
57
|
+
# data: { user_id: 123, action: "login" },
|
|
58
|
+
# additional_metadata: { ip_address: "192.168.1.1" }
|
|
59
|
+
# )
|
|
60
|
+
# @since 0.1.0
|
|
61
|
+
def create(key:, data:, additional_metadata: nil, priority: nil, scope: nil, namespace: nil)
|
|
62
|
+
event_key = apply_namespace(key, namespace)
|
|
63
|
+
|
|
64
|
+
event_request = HatchetSdkRest::CreateEventRequest.new(
|
|
65
|
+
key: event_key,
|
|
66
|
+
data: data,
|
|
67
|
+
additional_metadata: additional_metadata,
|
|
68
|
+
priority: priority,
|
|
69
|
+
scope: scope
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
@event_api.event_create(@config.tenant_id, event_request)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Push a single event to Hatchet
|
|
76
|
+
#
|
|
77
|
+
# @param event_key [String] The event key/name
|
|
78
|
+
# @param payload [Hash] The event payload data
|
|
79
|
+
# @param additional_metadata [Hash, nil] Additional metadata for the event
|
|
80
|
+
# @param namespace [String, nil] Override namespace for this event
|
|
81
|
+
# @param priority [Integer, nil] Event priority
|
|
82
|
+
# @return [Object] The API response containing the created event details
|
|
83
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
84
|
+
# @example Push a simple event
|
|
85
|
+
# response = events.push(
|
|
86
|
+
# "user-signup",
|
|
87
|
+
# { user_id: 456, email: "user@example.com" },
|
|
88
|
+
# additional_metadata: { source: "web" }
|
|
89
|
+
# )
|
|
90
|
+
def push(event_key, payload, additional_metadata: nil, namespace: nil, priority: nil)
|
|
91
|
+
create(
|
|
92
|
+
key: event_key,
|
|
93
|
+
data: payload,
|
|
94
|
+
additional_metadata: additional_metadata,
|
|
95
|
+
priority: priority,
|
|
96
|
+
namespace: namespace
|
|
97
|
+
)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Create events in bulk
|
|
101
|
+
#
|
|
102
|
+
# @param events [Array<Hash>] Array of event hashes, each containing :key, :data, and optionally :additional_metadata and :priority
|
|
103
|
+
# @param namespace [String, nil] Override namespace for all events
|
|
104
|
+
# @return [Object] The API response containing the created events
|
|
105
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
106
|
+
# @example Bulk create events
|
|
107
|
+
# events_data = [
|
|
108
|
+
# { key: "user-signup", data: { user_id: 1 } },
|
|
109
|
+
# { key: "user-login", data: { user_id: 1 }, priority: 1 }
|
|
110
|
+
# ]
|
|
111
|
+
# response = events.bulk_push(events_data)
|
|
112
|
+
def bulk_push(events, namespace: nil)
|
|
113
|
+
events_requests = events.map do |event|
|
|
114
|
+
event_key = apply_namespace(event[:key], namespace)
|
|
115
|
+
|
|
116
|
+
HatchetSdkRest::CreateEventRequest.new(
|
|
117
|
+
key: event_key,
|
|
118
|
+
data: event[:data] || {},
|
|
119
|
+
additional_metadata: event[:additional_metadata],
|
|
120
|
+
priority: event[:priority]
|
|
121
|
+
)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
bulk_request = HatchetSdkRest::BulkCreateEventRequest.new(
|
|
125
|
+
events: events_requests
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
@event_api.event_create_bulk(@config.tenant_id, bulk_request)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# List events with filtering options
|
|
132
|
+
#
|
|
133
|
+
# @param offset [Integer, nil] Pagination offset
|
|
134
|
+
# @param limit [Integer, nil] Maximum number of events to return
|
|
135
|
+
# @param keys [Array<String>, nil] Filter by event keys
|
|
136
|
+
# @param since [Time, nil] Filter events after this time
|
|
137
|
+
# @param until_time [Time, nil] Filter events before this time
|
|
138
|
+
# @param workflow_ids [Array<String>, nil] Filter by workflow IDs
|
|
139
|
+
# @param workflow_run_statuses [Array<String>, nil] Filter by workflow run statuses
|
|
140
|
+
# @param event_ids [Array<String>, nil] Filter by specific event IDs
|
|
141
|
+
# @param additional_metadata [Hash<String, String>, nil] Filter by additional metadata
|
|
142
|
+
# @param scopes [Array<String>, nil] Filter by event scopes
|
|
143
|
+
# @return [HatchetSdkRest::V1EventList] List of events matching the filters
|
|
144
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
145
|
+
# @example List recent events
|
|
146
|
+
# events = events_client.list(
|
|
147
|
+
# limit: 10,
|
|
148
|
+
# since: Time.now - 24 * 60 * 60,
|
|
149
|
+
# keys: ["user-signup", "user-login"]
|
|
150
|
+
# )
|
|
151
|
+
def list(
|
|
152
|
+
offset: nil,
|
|
153
|
+
limit: nil,
|
|
154
|
+
keys: nil,
|
|
155
|
+
since: nil,
|
|
156
|
+
until_time: nil,
|
|
157
|
+
workflow_ids: nil,
|
|
158
|
+
workflow_run_statuses: nil,
|
|
159
|
+
event_ids: nil,
|
|
160
|
+
additional_metadata: nil,
|
|
161
|
+
scopes: nil
|
|
162
|
+
)
|
|
163
|
+
@event_api.v1_event_list(
|
|
164
|
+
@config.tenant_id,
|
|
165
|
+
{
|
|
166
|
+
offset: offset,
|
|
167
|
+
limit: limit,
|
|
168
|
+
keys: keys,
|
|
169
|
+
since: since&.utc&.iso8601,
|
|
170
|
+
until: until_time&.utc&.iso8601,
|
|
171
|
+
workflow_ids: workflow_ids,
|
|
172
|
+
workflow_run_statuses: workflow_run_statuses,
|
|
173
|
+
event_ids: event_ids,
|
|
174
|
+
additional_metadata: maybe_additional_metadata_to_kv(additional_metadata),
|
|
175
|
+
scopes: scopes
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Get a specific event by ID
|
|
181
|
+
#
|
|
182
|
+
# @param event_id [String] The event ID
|
|
183
|
+
# @return [Object] The event details
|
|
184
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
185
|
+
def get(event_id)
|
|
186
|
+
@event_api.event_get(event_id)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Get event data for a specific event
|
|
190
|
+
#
|
|
191
|
+
# @param event_id [String] The event ID
|
|
192
|
+
# @return [Object] The event data
|
|
193
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
194
|
+
def get_data(event_id)
|
|
195
|
+
@event_api.event_data_get(event_id)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# List available event keys for the tenant
|
|
199
|
+
#
|
|
200
|
+
# @return [Object] List of available event keys
|
|
201
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
202
|
+
def list_keys
|
|
203
|
+
@event_api.v1_event_key_list(@config.tenant_id)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Cancel events matching the given criteria
|
|
207
|
+
#
|
|
208
|
+
# @param event_ids [Array<String>, nil] Specific event IDs to cancel
|
|
209
|
+
# @param keys [Array<String>, nil] Event keys to cancel
|
|
210
|
+
# @param since [Time, nil] Cancel events after this time
|
|
211
|
+
# @param until_time [Time, nil] Cancel events before this time
|
|
212
|
+
# @return [Object] The cancellation response
|
|
213
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
214
|
+
def cancel(event_ids: nil, keys: nil, since: nil, until_time: nil)
|
|
215
|
+
cancel_request = HatchetSdkRest::CancelEventRequest.new(
|
|
216
|
+
event_ids: event_ids,
|
|
217
|
+
keys: keys,
|
|
218
|
+
since: since&.utc&.iso8601,
|
|
219
|
+
until: until_time&.utc&.iso8601
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
@event_api.event_update_cancel(@config.tenant_id, cancel_request)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Replay events matching the given criteria
|
|
226
|
+
#
|
|
227
|
+
# @param event_ids [Array<String>, nil] Specific event IDs to replay
|
|
228
|
+
# @param keys [Array<String>, nil] Event keys to replay
|
|
229
|
+
# @param since [Time, nil] Replay events after this time
|
|
230
|
+
# @param until_time [Time, nil] Replay events before this time
|
|
231
|
+
# @return [Object] The replay response
|
|
232
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
233
|
+
def replay(event_ids: nil, keys: nil, since: nil, until_time: nil)
|
|
234
|
+
replay_request = HatchetSdkRest::ReplayEventRequest.new(
|
|
235
|
+
event_ids: event_ids,
|
|
236
|
+
keys: keys,
|
|
237
|
+
since: since&.utc&.iso8601,
|
|
238
|
+
until: until_time&.utc&.iso8601
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
@event_api.event_update_replay(@config.tenant_id, replay_request)
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
private
|
|
245
|
+
|
|
246
|
+
# Apply namespace to event key
|
|
247
|
+
#
|
|
248
|
+
# @param event_key [String] The original event key
|
|
249
|
+
# @param namespace_override [String, nil] Optional namespace override
|
|
250
|
+
# @return [String] The namespaced event key
|
|
251
|
+
def apply_namespace(event_key, namespace_override = nil)
|
|
252
|
+
@config.apply_namespace(event_key, namespace_override: namespace_override)
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# Convert additional metadata hash to key-value array format expected by API
|
|
256
|
+
#
|
|
257
|
+
# @param metadata [Hash<String, String>, nil] Metadata hash
|
|
258
|
+
# @return [Array<Hash>, nil] Array of {key: string, value: string} objects
|
|
259
|
+
def maybe_additional_metadata_to_kv(metadata)
|
|
260
|
+
return nil unless metadata
|
|
261
|
+
metadata.map { |k, v| { key: k.to_s, value: v.to_s } }
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'time'
|
|
4
|
+
require 'timeout'
|
|
5
|
+
|
|
6
|
+
module Hatchet
|
|
7
|
+
module Features
|
|
8
|
+
# Filter options for listing task runs
|
|
9
|
+
class RunFilter
|
|
10
|
+
attr_accessor :since, :until_time, :statuses, :workflow_ids, :additional_metadata
|
|
11
|
+
|
|
12
|
+
def initialize(since:, until_time: nil, statuses: nil, workflow_ids: nil, additional_metadata: nil)
|
|
13
|
+
@since = since
|
|
14
|
+
@until_time = until_time
|
|
15
|
+
@statuses = statuses
|
|
16
|
+
@workflow_ids = workflow_ids
|
|
17
|
+
@additional_metadata = additional_metadata
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Options for bulk cancel and replay operations
|
|
22
|
+
class BulkCancelReplayOpts
|
|
23
|
+
attr_accessor :ids, :filters
|
|
24
|
+
|
|
25
|
+
def initialize(ids: nil, filters: nil)
|
|
26
|
+
raise ArgumentError, "ids or filters must be set" if !ids && !filters
|
|
27
|
+
raise ArgumentError, "ids and filters cannot both be set" if ids && filters
|
|
28
|
+
|
|
29
|
+
@ids = ids
|
|
30
|
+
@filters = filters
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def v1_task_filter
|
|
34
|
+
return nil unless @filters
|
|
35
|
+
|
|
36
|
+
HatchetSdkRest::V1TaskFilter.new(
|
|
37
|
+
since: @filters.since,
|
|
38
|
+
until: @filters.until_time,
|
|
39
|
+
statuses: @filters.statuses,
|
|
40
|
+
workflow_ids: @filters.workflow_ids,
|
|
41
|
+
additional_metadata: maybe_additional_metadata_to_kv(@filters.additional_metadata)
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def to_cancel_request
|
|
46
|
+
HatchetSdkRest::V1CancelTaskRequest.new(
|
|
47
|
+
external_ids: @ids,
|
|
48
|
+
filter: v1_task_filter
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def to_replay_request
|
|
53
|
+
HatchetSdkRest::V1ReplayTaskRequest.new(
|
|
54
|
+
external_ids: @ids,
|
|
55
|
+
filter: v1_task_filter
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
|
|
61
|
+
def maybe_additional_metadata_to_kv(metadata)
|
|
62
|
+
return nil unless metadata
|
|
63
|
+
metadata.map { |k, v| { key: k.to_s, value: v.to_s } }
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Runs client for interacting with Hatchet workflow run management API
|
|
68
|
+
#
|
|
69
|
+
# This class provides a high-level interface for creating and managing workflow runs
|
|
70
|
+
# in the Hatchet system. It wraps the generated REST API client with a more
|
|
71
|
+
# convenient Ruby interface.
|
|
72
|
+
#
|
|
73
|
+
# @example Creating a workflow run
|
|
74
|
+
# runs = Features::Runs.new(rest_client, config)
|
|
75
|
+
# response = runs.create(
|
|
76
|
+
# name: "my-workflow",
|
|
77
|
+
# input: { key: "value" },
|
|
78
|
+
# additional_metadata: { source: "api" }
|
|
79
|
+
# )
|
|
80
|
+
#
|
|
81
|
+
# @since 0.1.0
|
|
82
|
+
class Runs
|
|
83
|
+
# Re-export commonly used workflow run classes for convenience
|
|
84
|
+
TriggerWorkflowRunRequest = ::HatchetSdkRest::V1TriggerWorkflowRunRequest
|
|
85
|
+
WorkflowRunDetails = ::HatchetSdkRest::V1WorkflowRunDetails
|
|
86
|
+
TaskSummary = ::HatchetSdkRest::V1TaskSummary
|
|
87
|
+
TaskSummaryList = ::HatchetSdkRest::V1TaskSummaryList
|
|
88
|
+
TaskStatus = ::HatchetSdkRest::V1TaskStatus
|
|
89
|
+
|
|
90
|
+
DEFAULT_SINCE_DAYS = 1
|
|
91
|
+
LARGE_DATE_RANGE_WARNING_DAYS = 7
|
|
92
|
+
|
|
93
|
+
# Initializes a new Runs client instance
|
|
94
|
+
#
|
|
95
|
+
# @param rest_client [Object] The configured REST client for API communication
|
|
96
|
+
# @param config [Hatchet::Config] The Hatchet configuration containing tenant_id and other settings
|
|
97
|
+
# @return [void]
|
|
98
|
+
# @since 0.1.0
|
|
99
|
+
def initialize(rest_client, config)
|
|
100
|
+
@rest_client = rest_client
|
|
101
|
+
@config = config
|
|
102
|
+
@workflow_runs_api = HatchetSdkRest::WorkflowRunsApi.new(rest_client)
|
|
103
|
+
@task_api = HatchetSdkRest::TaskApi.new(rest_client)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Get task run details for a given task run ID
|
|
107
|
+
#
|
|
108
|
+
# @param task_run_id [String] The ID of the task run to retrieve details for
|
|
109
|
+
# @return [HatchetSdkRest::V1TaskSummary] Task run details for the specified task run ID
|
|
110
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
111
|
+
def get_task_run(task_run_id)
|
|
112
|
+
@task_api.v1_task_get(task_run_id)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Get workflow run details for a given workflow run ID
|
|
116
|
+
#
|
|
117
|
+
# @param workflow_run_id [String] The ID of the workflow run to retrieve details for
|
|
118
|
+
# @return [HatchetSdkRest::V1WorkflowRunDetails] Workflow run details for the specified workflow run ID
|
|
119
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
120
|
+
def get(workflow_run_id)
|
|
121
|
+
@workflow_runs_api.v1_workflow_run_get(workflow_run_id.to_s)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Get workflow run status for a given workflow run ID
|
|
125
|
+
#
|
|
126
|
+
# @param workflow_run_id [String] The ID of the workflow run to retrieve status for
|
|
127
|
+
# @return [HatchetSdkRest::V1TaskStatus] The task status
|
|
128
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
129
|
+
def get_status(workflow_run_id)
|
|
130
|
+
@workflow_runs_api.v1_workflow_run_get_status(workflow_run_id)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# List task runs according to a set of filters, paginating through days
|
|
134
|
+
#
|
|
135
|
+
# @param since [Time, nil] The start time for filtering task runs
|
|
136
|
+
# @param only_tasks [Boolean] Whether to only list task runs
|
|
137
|
+
# @param offset [Integer, nil] The offset for pagination
|
|
138
|
+
# @param limit [Integer, nil] The maximum number of task runs to return
|
|
139
|
+
# @param statuses [Array<HatchetSdkRest::V1TaskStatus>, nil] The statuses to filter task runs by
|
|
140
|
+
# @param until_time [Time, nil] The end time for filtering task runs
|
|
141
|
+
# @param additional_metadata [Hash<String, String>, nil] Additional metadata to filter task runs by
|
|
142
|
+
# @param workflow_ids [Array<String>, nil] The workflow IDs to filter task runs by
|
|
143
|
+
# @param worker_id [String, nil] The worker ID to filter task runs by
|
|
144
|
+
# @param parent_task_external_id [String, nil] The parent task external ID to filter task runs by
|
|
145
|
+
# @param triggering_event_external_id [String, nil] The event id that triggered the task run
|
|
146
|
+
# @return [Array<HatchetSdkRest::V1TaskSummary>] A list of task runs matching the specified filters
|
|
147
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
148
|
+
def list_with_pagination(
|
|
149
|
+
since: nil,
|
|
150
|
+
only_tasks: false,
|
|
151
|
+
offset: nil,
|
|
152
|
+
limit: nil,
|
|
153
|
+
statuses: nil,
|
|
154
|
+
until_time: nil,
|
|
155
|
+
additional_metadata: nil,
|
|
156
|
+
workflow_ids: nil,
|
|
157
|
+
worker_id: nil,
|
|
158
|
+
parent_task_external_id: nil,
|
|
159
|
+
triggering_event_external_id: nil
|
|
160
|
+
)
|
|
161
|
+
date_ranges = partition_date_range(
|
|
162
|
+
since: since || (Time.now - DEFAULT_SINCE_DAYS * 24 * 60 * 60),
|
|
163
|
+
until_time: until_time || Time.now
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
responses = date_ranges.map do |start_time, end_time|
|
|
167
|
+
@workflow_runs_api.v1_workflow_run_list(
|
|
168
|
+
@config.tenant_id,
|
|
169
|
+
start_time.utc.iso8601,
|
|
170
|
+
only_tasks,
|
|
171
|
+
{
|
|
172
|
+
offset: offset,
|
|
173
|
+
limit: limit,
|
|
174
|
+
statuses: statuses,
|
|
175
|
+
until: end_time.utc.iso8601,
|
|
176
|
+
additional_metadata: maybe_additional_metadata_to_kv(additional_metadata),
|
|
177
|
+
workflow_ids: workflow_ids,
|
|
178
|
+
worker_id: worker_id,
|
|
179
|
+
parent_task_external_id: parent_task_external_id,
|
|
180
|
+
triggering_event_external_id: triggering_event_external_id
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Hack for uniqueness
|
|
186
|
+
run_id_to_run = {}
|
|
187
|
+
responses.each do |record|
|
|
188
|
+
record.rows.each do |run|
|
|
189
|
+
run_id_to_run[run.metadata.id] = run
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
run_id_to_run.values.sort_by(&:created_at).reverse
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# List task runs according to a set of filters
|
|
197
|
+
#
|
|
198
|
+
# @param since [Time, nil] The start time for filtering task runs
|
|
199
|
+
# @param only_tasks [Boolean] Whether to only list task runs
|
|
200
|
+
# @param offset [Integer, nil] The offset for pagination
|
|
201
|
+
# @param limit [Integer, nil] The maximum number of task runs to return
|
|
202
|
+
# @param statuses [Array<HatchetSdkRest::V1TaskStatus>, nil] The statuses to filter task runs by
|
|
203
|
+
# @param until_time [Time, nil] The end time for filtering task runs
|
|
204
|
+
# @param additional_metadata [Hash<String, String>, nil] Additional metadata to filter task runs by
|
|
205
|
+
# @param workflow_ids [Array<String>, nil] The workflow IDs to filter task runs by
|
|
206
|
+
# @param worker_id [String, nil] The worker ID to filter task runs by
|
|
207
|
+
# @param parent_task_external_id [String, nil] The parent task external ID to filter task runs by
|
|
208
|
+
# @param triggering_event_external_id [String, nil] The event id that triggered the task run
|
|
209
|
+
# @return [HatchetSdkRest::V1TaskSummaryList] A list of task runs matching the specified filters
|
|
210
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
211
|
+
def list(
|
|
212
|
+
since: nil,
|
|
213
|
+
only_tasks: false,
|
|
214
|
+
offset: nil,
|
|
215
|
+
limit: nil,
|
|
216
|
+
statuses: nil,
|
|
217
|
+
until_time: nil,
|
|
218
|
+
additional_metadata: nil,
|
|
219
|
+
workflow_ids: nil,
|
|
220
|
+
worker_id: nil,
|
|
221
|
+
parent_task_external_id: nil,
|
|
222
|
+
triggering_event_external_id: nil
|
|
223
|
+
)
|
|
224
|
+
since = since || (Time.now - DEFAULT_SINCE_DAYS * 24 * 60 * 60)
|
|
225
|
+
until_time = until_time || Time.now
|
|
226
|
+
|
|
227
|
+
if (until_time - since) / (24 * 60 * 60) >= LARGE_DATE_RANGE_WARNING_DAYS
|
|
228
|
+
warn "Listing runs with a date range longer than #{LARGE_DATE_RANGE_WARNING_DAYS} days may result in performance issues. " +
|
|
229
|
+
"Consider using `list_with_pagination` instead."
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
@workflow_runs_api.v1_workflow_run_list(
|
|
233
|
+
@config.tenant_id,
|
|
234
|
+
since.utc.iso8601,
|
|
235
|
+
only_tasks,
|
|
236
|
+
{
|
|
237
|
+
offset: offset,
|
|
238
|
+
limit: limit,
|
|
239
|
+
statuses: statuses,
|
|
240
|
+
until: until_time.utc.iso8601,
|
|
241
|
+
additional_metadata: maybe_additional_metadata_to_kv(additional_metadata),
|
|
242
|
+
workflow_ids: workflow_ids,
|
|
243
|
+
worker_id: worker_id,
|
|
244
|
+
parent_task_external_id: parent_task_external_id,
|
|
245
|
+
triggering_event_external_id: triggering_event_external_id
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Creates a new workflow run in the Hatchet system
|
|
251
|
+
#
|
|
252
|
+
# This method triggers a new workflow or task run for the specified workflow using the
|
|
253
|
+
# provided input data. The workflow run will be queued according to the
|
|
254
|
+
# workflow definition on an available worker.
|
|
255
|
+
#
|
|
256
|
+
# IMPORTANT: It's preferable to use `Workflow.run` (and similar) to trigger workflows if possible.
|
|
257
|
+
# This method is intended to be an escape hatch.
|
|
258
|
+
#
|
|
259
|
+
# @param name [String] The name of the workflow to trigger
|
|
260
|
+
# @param input [Hash] The input data for the workflow run
|
|
261
|
+
# @param additional_metadata [Hash, nil] Additional metadata associated with the workflow run
|
|
262
|
+
# @param priority [Integer, nil] The priority of the workflow run
|
|
263
|
+
# @return [HatchetSdkRest::V1WorkflowRunDetails] The details of the triggered workflow run
|
|
264
|
+
# @raise [ArgumentError] If the workflow_name or input parameters are nil or invalid
|
|
265
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
266
|
+
# @example Creating a workflow run
|
|
267
|
+
# response = runs.create(
|
|
268
|
+
# name: "simple-workflow",
|
|
269
|
+
# input: { user_id: 123, action: "process_data" },
|
|
270
|
+
# additional_metadata: { source: "api", priority: "high" }
|
|
271
|
+
# )
|
|
272
|
+
def create(name:, input:, additional_metadata: nil, priority: nil)
|
|
273
|
+
trigger_request = HatchetSdkRest::V1TriggerWorkflowRunRequest.new(
|
|
274
|
+
workflow_name: @config.apply_namespace(name),
|
|
275
|
+
input: input,
|
|
276
|
+
additional_metadata: additional_metadata,
|
|
277
|
+
priority: priority
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
run = @workflow_runs_api.v1_workflow_run_create(@config.tenant_id, trigger_request)
|
|
281
|
+
run.run
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# Replay a task or workflow run
|
|
285
|
+
#
|
|
286
|
+
# @param run_id [String] The external ID of the task or workflow run to replay
|
|
287
|
+
# @return [void]
|
|
288
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
289
|
+
def replay(run_id)
|
|
290
|
+
bulk_replay(BulkCancelReplayOpts.new(ids: [run_id]))
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# Replay task or workflow runs in bulk, according to a set of filters
|
|
294
|
+
#
|
|
295
|
+
# @param opts [BulkCancelReplayOpts] Options for bulk replay, including filters and IDs
|
|
296
|
+
# @return [void]
|
|
297
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
298
|
+
def bulk_replay(opts)
|
|
299
|
+
@task_api.v1_task_replay(
|
|
300
|
+
@config.tenant_id,
|
|
301
|
+
opts.to_replay_request
|
|
302
|
+
)
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
# Cancel a task or workflow run
|
|
306
|
+
#
|
|
307
|
+
# @param run_id [String] The external ID of the task or workflow run to cancel
|
|
308
|
+
# @return [void]
|
|
309
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
310
|
+
def cancel(run_id)
|
|
311
|
+
bulk_cancel(BulkCancelReplayOpts.new(ids: [run_id]))
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
# Cancel task or workflow runs in bulk, according to a set of filters
|
|
315
|
+
#
|
|
316
|
+
# @param opts [BulkCancelReplayOpts] Options for bulk cancel, including filters and IDs
|
|
317
|
+
# @return [void]
|
|
318
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
319
|
+
def bulk_cancel(opts)
|
|
320
|
+
@task_api.v1_task_cancel(
|
|
321
|
+
@config.tenant_id,
|
|
322
|
+
opts.to_cancel_request
|
|
323
|
+
)
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
# Get the result of a workflow run by its external ID
|
|
327
|
+
#
|
|
328
|
+
# @param run_id [String] The external ID of the workflow run to retrieve the result for
|
|
329
|
+
# @return [Hash] The result of the workflow run
|
|
330
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
331
|
+
def get_result(run_id)
|
|
332
|
+
details = get(run_id)
|
|
333
|
+
details.run.output
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
# Poll for workflow run completion with configurable interval and timeout
|
|
337
|
+
#
|
|
338
|
+
# This method repeatedly calls `get` until the workflow run reaches a terminal state
|
|
339
|
+
# (succeeded, failed, or cancelled) or the timeout is reached.
|
|
340
|
+
#
|
|
341
|
+
# @param workflow_run_id [String] The ID of the workflow run to poll
|
|
342
|
+
# @param interval [Numeric] The polling interval in seconds (default: 1.0)
|
|
343
|
+
# @param timeout [Numeric, nil] The maximum time to poll in seconds (default: no timeout)
|
|
344
|
+
# @return [HatchetSdkRest::V1WorkflowRunDetails] The final workflow run details
|
|
345
|
+
# @raise [Timeout::Error] If the timeout is reached before completion
|
|
346
|
+
# @raise [Hatchet::Error] If the API request fails or returns an error
|
|
347
|
+
# @example Poll with default settings (1s interval, no timeout)
|
|
348
|
+
# result = runs.poll("workflow-run-123")
|
|
349
|
+
# @example Poll with custom interval and timeout
|
|
350
|
+
# result = runs.poll("workflow-run-123", interval: 2.0, timeout: 30.0)
|
|
351
|
+
# @since 0.1.0
|
|
352
|
+
def poll(workflow_run_id, interval: 1.0, timeout: nil)
|
|
353
|
+
start_time = Time.now
|
|
354
|
+
|
|
355
|
+
loop do
|
|
356
|
+
puts "Polling for completion of run #{workflow_run_id}"
|
|
357
|
+
details = get(workflow_run_id)
|
|
358
|
+
status = details.run.status
|
|
359
|
+
|
|
360
|
+
# Check if workflow run has reached a terminal state
|
|
361
|
+
puts "Run status: #{status}"
|
|
362
|
+
if terminal_status?(status)
|
|
363
|
+
return details
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
# Check timeout
|
|
367
|
+
if timeout && (Time.now - start_time) >= timeout
|
|
368
|
+
raise Timeout::Error, "Polling timed out after #{timeout} seconds"
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
sleep(interval)
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
private
|
|
376
|
+
|
|
377
|
+
# Check if a workflow run status is terminal (completed)
|
|
378
|
+
#
|
|
379
|
+
# @param status [String] The workflow run status
|
|
380
|
+
# @return [Boolean] True if the status is terminal (succeeded, failed, or cancelled)
|
|
381
|
+
def terminal_status?(status)
|
|
382
|
+
case status
|
|
383
|
+
when HatchetSdkRest::WorkflowRunStatus::SUCCEEDED,
|
|
384
|
+
HatchetSdkRest::WorkflowRunStatus::FAILED,
|
|
385
|
+
HatchetSdkRest::WorkflowRunStatus::CANCELLED,
|
|
386
|
+
HatchetSdkRest::V1TaskStatus::COMPLETED,
|
|
387
|
+
HatchetSdkRest::V1TaskStatus::CANCELLED,
|
|
388
|
+
HatchetSdkRest::V1TaskStatus::FAILED
|
|
389
|
+
true
|
|
390
|
+
else
|
|
391
|
+
false
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
# Partition a date range into daily chunks to avoid API limits
|
|
396
|
+
#
|
|
397
|
+
# @param since [Time] Start time
|
|
398
|
+
# @param until_time [Time] End time
|
|
399
|
+
# @return [Array<Array<Time, Time>>] Array of [start_time, end_time] pairs
|
|
400
|
+
def partition_date_range(since:, until_time:)
|
|
401
|
+
ranges = []
|
|
402
|
+
current = since
|
|
403
|
+
|
|
404
|
+
while current < until_time
|
|
405
|
+
next_day = [current + 24 * 60 * 60, until_time].min
|
|
406
|
+
ranges << [current, next_day]
|
|
407
|
+
current = next_day
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
ranges
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
# Convert additional metadata hash to key-value array format expected by API
|
|
414
|
+
#
|
|
415
|
+
# @param metadata [Hash<String, String>, nil] Metadata hash
|
|
416
|
+
# @return [Array<Hash>, nil] Array of {key: string, value: string} objects
|
|
417
|
+
def maybe_additional_metadata_to_kv(metadata)
|
|
418
|
+
return nil unless metadata
|
|
419
|
+
metadata.map { |k, v| { key: k.to_s, value: v.to_s } }
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
end
|
data/lib/hatchet/version.rb
CHANGED