spiral-sdk 0.1.10

Rust SDK for Spiral resource and table APIs
Documentation
// Generated by tools/service-contracts/rust.py. Do not edit.
#![doc = "Transport-independent service interface for local and remote calls."]

use async_trait::async_trait;
use spiral_contract::auth::AuthHeader;
use spiral_contract::call::CallError;
use uuid::Uuid;

use crate::api::tasks::objects::*;
/// Service implementations authenticate Authorization headers and enforce resource permissions.
#[async_trait]
pub trait TasksApi: Send + Sync + 'static {
    /// Activate one Worker pool.
    async fn activate_worker_pool(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        worker_pool_id: Uuid,
    ) -> Result<WorkerPoolResponse, CallError<TasksError>>;
    /// Cancel a Task through a Project. Deprecated; use cancel_task, which derives the Project.
    async fn cancel_project_task(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        task_id: Uuid,
    ) -> Result<Task, CallError<TasksError>>;
    /// Request cancellation of a Task. The Task's own Project authorizes the request; a Task the
    /// caller cannot view is not found.
    async fn cancel_task(
        &self,
        auth_header: AuthHeader,
        task_id: Uuid,
    ) -> Result<Task, CallError<TasksError>>;
    /// Claim worker task.
    async fn claim_worker_task(
        &self,
        auth_header: AuthHeader,
        worker_session_id: Uuid,
        task_id: Uuid,
    ) -> Result<PollTaskResponse, CallError<TasksError>>;
    /// Create a Task from a specification ID and JSON input. Deprecated; use submit_task.
    async fn create_task(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        request: CreateTaskRequest,
    ) -> Result<CreateTaskResponse, CallError<TasksError>>;
    /// Create trigger.
    async fn create_trigger(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        request: TriggerDefinition,
    ) -> Result<TaskTrigger, CallError<TasksError>>;
    /// Create worker pool.
    async fn create_worker_pool(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        request: CreateWorkerPoolRequest,
    ) -> Result<WorkerPoolResponse, CallError<TasksError>>;
    /// Delete trigger.
    async fn delete_trigger(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        trigger_id: Uuid,
    ) -> Result<(), CallError<TasksError>>;
    /// Drain worker.
    async fn drain_worker(
        &self,
        auth_header: AuthHeader,
        worker_session_id: Uuid,
    ) -> Result<DrainWorkerResponse, CallError<TasksError>>;
    /// Finish worker attempt.
    async fn finish_worker_attempt(
        &self,
        auth_header: AuthHeader,
        worker_session_id: Uuid,
        attempt_id: Uuid,
        request: FinishAttemptRequest,
    ) -> Result<FinishAttemptResponse, CallError<TasksError>>;
    /// Heartbeat worker.
    async fn heartbeat_worker(
        &self,
        auth_header: AuthHeader,
        worker_session_id: Uuid,
        request: HeartbeatWorkerRequest,
    ) -> Result<HeartbeatWorkerResponse, CallError<TasksError>>;
    /// List task specs.
    async fn list_task_specs(
        &self,
        auth_header: AuthHeader,
        project_id: String,
    ) -> Result<ListTaskSpecsResponse, CallError<TasksError>>;
    /// List Tasks by descending Task ID. Pages default to 100 items with a maximum of 1000.
    /// Continuations expire after one hour and are scoped to the caller, target, operation, filters
    /// and page size. This is a live listing; concurrent updates can change later pages.
    async fn list_tasks(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        request: ListTasksRequest,
    ) -> Result<ListTasksResponse, CallError<TasksError>>;
    /// List invocations by descending submission time and Task ID in fixed pages of 10.
    /// Continuations expire after one hour and are scoped to the caller, target, operation, filters
    /// and page size. This is a live listing; concurrent updates can change later pages.
    async fn list_trigger_invocations(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        trigger_id: Uuid,
        request: InvocationPageRequest,
    ) -> Result<InvocationPage, CallError<TasksError>>;
    /// List triggers by descending trigger ID in fixed pages of 50. Continuations expire after one
    /// hour and are scoped to the caller, target, operation, filters and page size. This is a live
    /// listing; concurrent updates can change later pages.
    async fn list_triggers(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        request: TriggerPageRequest,
    ) -> Result<TriggerPage, CallError<TasksError>>;
    /// List Attempts by descending Attempt ID. Pages default to 100 items with a maximum of 100.
    /// Continuations expire after one hour and are scoped to the caller, target, operation, filters
    /// and page size. This is a live listing; concurrent updates can change later pages.
    async fn list_worker_attempts(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        worker_session_id: Uuid,
        request: ListWorkerAttemptsRequest,
    ) -> Result<ListWorkerAttemptsResponse, CallError<TasksError>>;
    /// List Worker pools and aligned statistics by ascending pool ID. Pages default to 100 items
    /// with a maximum of 1000. Continuations expire after one hour and are scoped to the caller,
    /// target, operation, filters and page size. This is a live listing; concurrent updates can
    /// change later pages.
    async fn list_worker_pools(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        request: ListWorkerPoolsRequest,
    ) -> Result<ListWorkerPoolsResponse, CallError<TasksError>>;
    /// List Worker sessions by descending session ID. Pages default to 100 items with a maximum of
    /// 1000. Continuations expire after one hour and are scoped to the caller, target, operation,
    /// filters and page size. This is a live listing; concurrent updates can change later pages.
    async fn list_worker_sessions(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        request: ListWorkerSessionsRequest,
    ) -> Result<ListWorkerSessionsResponse, CallError<TasksError>>;
    /// Pause one Worker pool.
    async fn pause_worker_pool(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        worker_pool_id: Uuid,
    ) -> Result<WorkerPoolResponse, CallError<TasksError>>;
    /// Poll worker.
    async fn poll_worker(
        &self,
        auth_header: AuthHeader,
        worker_session_id: Uuid,
    ) -> Result<PollTaskResponse, CallError<TasksError>>;
    /// Read a Task through a Project. Deprecated; use read_task, which derives the Project.
    async fn read_project_task(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        task_id: Uuid,
    ) -> Result<TaskDetails, CallError<TasksError>>;
    /// Read resource usage.
    async fn read_resource_usage(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        worker_session_id: Uuid,
        request: ResourceUsageRequest,
    ) -> Result<ResourceUsageHistory, CallError<TasksError>>;
    /// Read a Task with its Attempts and resource references. The Task's own Project authorizes the
    /// read; a Task the caller cannot view is not found.
    async fn read_task(
        &self,
        auth_header: AuthHeader,
        task_id: Uuid,
    ) -> Result<TaskDetails, CallError<TasksError>>;
    /// Read task stats.
    async fn read_task_stats(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        request: TaskStatsRequest,
    ) -> Result<TaskStats, CallError<TasksError>>;
    /// Read trigger.
    async fn read_trigger(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        trigger_id: Uuid,
    ) -> Result<TaskTrigger, CallError<TasksError>>;
    /// Read worker pool.
    async fn read_worker_pool(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        worker_pool_id: Uuid,
    ) -> Result<WorkerPoolDetails, CallError<TasksError>>;
    /// Read worker session.
    async fn read_worker_session(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        worker_session_id: Uuid,
    ) -> Result<WorkerSession, CallError<TasksError>>;
    /// Register worker.
    async fn register_worker(
        &self,
        auth_header: AuthHeader,
        request: RegisterWorkerRequest,
    ) -> Result<RegisterWorkerResponse, CallError<TasksError>>;
    /// Retire one Worker pool.
    async fn retire_worker_pool(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        worker_pool_id: Uuid,
    ) -> Result<WorkerPoolResponse, CallError<TasksError>>;
    /// Run trigger.
    async fn run_trigger(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        trigger_id: Uuid,
        request: RunTriggerRequest,
    ) -> Result<TriggerInvocation, CallError<TasksError>>;
    /// Submit a Task from its definition. The response is accepted with the Task, or skipped when
    /// the definition's overlap policy keeps an equivalent Task already waiting.
    async fn submit_task(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        request: SubmitTaskRequest,
    ) -> Result<CreateTaskResponse, CallError<TasksError>>;
    /// Test trigger.
    async fn test_trigger(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        trigger_id: Uuid,
        request: TestTriggerRequest,
    ) -> Result<TestTriggerResponse, CallError<TasksError>>;
    /// Update trigger.
    async fn update_trigger(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        trigger_id: Uuid,
        request: UpdateTriggerRequest,
    ) -> Result<TaskTrigger, CallError<TasksError>>;
}