// The external API for managing automations in the Workflows service. edition = "2023"; package workflows.v1; import "buf/validate/validate.proto"; import "google/api/field_behavior.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/timestamp.proto"; import "tilebox/v1/id.proto"; import "workflows/v1/core.proto"; import "workflows/v1/storage_location.proto"; option features.field_presence = IMPLICIT; // AutomationPrototype is a task prototype that can result in many submitted tasks. Task submissions are triggered by // NRT triggers, such as bucket triggers or cron triggers. message AutomationPrototype { option (buf.validate.message).oneof = { fields: [ "storage_event_triggers", "cron_triggers" ] required: true }; // Unique identifier for the trigger tilebox.v1.ID id = 1; // A human-readable name for the trigger string name = 2 [(buf.validate.field).string = { min_bytes: 1 max_bytes: 1024 }]; // The task submission to trigger SingleTaskSubmission prototype = 3; // The storage event triggers that will trigger the task repeated StorageEventTrigger storage_event_triggers = 4 [(buf.validate.field).repeated.max_items = 32]; // The cron triggers that will trigger the task repeated CronTrigger cron_triggers = 5 [(buf.validate.field).repeated.max_items = 32]; // Whether the automation is disabled (paused) or not. // the field is named disabled rather than enabled (with the semantics flipped) to make sure not setting the field at // all results in the automation being enabled by default. bool disabled = 6; } // Automations is a list of automations message Automations { repeated AutomationPrototype automations = 1; } // StorageEventTrigger is a trigger that will trigger a task submission when an object matching the glob pattern is // created in a storage location. message StorageEventTrigger { // Unique identifier for the trigger tilebox.v1.ID id = 1; // The storage location to watch for events StorageLocation storage_location = 2; // Glob pattern matched against object keys within the bucket or container, or paths relative to the local directory root. string glob_pattern = 3 [(buf.validate.field).string.min_len = 1]; } // CronTrigger is a trigger that will trigger a task submission on a schedule. message CronTrigger { // Unique identifier for the trigger tilebox.v1.ID id = 1; // A cron schedule for the trigger, e.g. "0 0 * * *" (every day at midnight) string schedule = 2 [(buf.validate.field).string.min_len = 1]; // The next time the cron schedule occurs, regardless of whether the automation is disabled. google.protobuf.Timestamp next_scheduled_at = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; } // Automation is an actual submitted task that was triggered by a automation prototype. // It contains the trigger arguments of the event that triggered the task, and the custom, user-defined task arguments. message Automation { // Details of the event that triggered the task. This is a serialized protobuf message. The type of the message // depends on the type of the trigger, either StorageEventTriggerEvent or CronTriggerEvent. bytes trigger_event = 1; // Additional, user-defined arguments for the task, to be deserialized by the task itself bytes args = 2; } // TriggeredCronEvent contains the details of a concrete event that triggered a cron trigger. message TriggeredCronEvent { // The time the cron trigger fired google.protobuf.Timestamp trigger_time = 1; } // DeleteAutomationRequest requests the deletion of an automation. message DeleteAutomationRequest { // The ID of the automation to delete. tilebox.v1.ID automation_id = 1 [(buf.validate.field).required = true]; // Whether to cancel all jobs that have been created by this automation. bool cancel_jobs = 2; } // AutomationService is a service for managing automations. Currently, we support two types of triggers for automations: // - Bucket triggers, which triggers tasks when an object is uploaded to a storage bucket that matches a glob pattern // - Cron triggers, which triggers tasks on a schedule service AutomationService { // ListAutomations lists all the automations that are currently registered in a namespace. rpc ListAutomations(google.protobuf.Empty) returns (Automations); // GetAutomation gets an automation by its ID. rpc GetAutomation(tilebox.v1.ID) returns (AutomationPrototype); // CreateAutomation creates a new automation in a namespace. rpc CreateAutomation(AutomationPrototype) returns (AutomationPrototype); // UpdateAutomation updates an automation in a namespace. rpc UpdateAutomation(AutomationPrototype) returns (AutomationPrototype); // DeleteAutomation deletes an automation from a namespace. rpc DeleteAutomation(DeleteAutomationRequest) returns (google.protobuf.Empty); }