326 lines
9.2 KiB
Rust
326 lines
9.2 KiB
Rust
use remora_domain::{AttemptState, JobLifecycle, JobPhase, OpaqueId};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::{
|
|
AttemptAuthorityDto, CursorDto, DateTimeDto, HuggingFaceRepositoryTypeDto,
|
|
HuggingFaceSelectionDto, JobFailureDto, NullableDto, ObjectIdentityDto, PositiveIntegerDto,
|
|
ProgressDto, ResultDescriptorDto, SafeIntegerDto, TargetDto,
|
|
};
|
|
|
|
#[derive(Clone, Deserialize, PartialEq, Serialize)]
|
|
#[serde(tag = "kind", rename_all = "snake_case")]
|
|
pub enum SourceProjectionDto {
|
|
Http(HttpSourceProjectionDto),
|
|
ObjectStore(ObjectStoreSourceProjectionDto),
|
|
HuggingFace(HuggingFaceSourceProjectionDto),
|
|
}
|
|
|
|
#[derive(Clone, Deserialize, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct HttpSourceProjectionDto {
|
|
pub display_url: String,
|
|
pub result_path: String,
|
|
#[serde(
|
|
default,
|
|
deserialize_with = "crate::dto::optional_non_null",
|
|
skip_serializing_if = "Option::is_none"
|
|
)]
|
|
pub credential_id: Option<OpaqueId>,
|
|
}
|
|
|
|
#[derive(Clone, Deserialize, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct ObjectStoreSourceProjectionDto {
|
|
pub store: String,
|
|
pub bucket: String,
|
|
pub key: String,
|
|
#[serde(
|
|
default,
|
|
deserialize_with = "crate::dto::optional_non_null",
|
|
skip_serializing_if = "Option::is_none"
|
|
)]
|
|
pub version_id: Option<String>,
|
|
pub result_path: String,
|
|
#[serde(
|
|
default,
|
|
deserialize_with = "crate::dto::optional_non_null",
|
|
skip_serializing_if = "Option::is_none"
|
|
)]
|
|
pub credential_id: Option<OpaqueId>,
|
|
}
|
|
|
|
#[derive(Clone, Deserialize, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct HuggingFaceSourceProjectionDto {
|
|
pub repository_type: HuggingFaceRepositoryTypeDto,
|
|
pub repository_id: String,
|
|
pub revision: String,
|
|
#[serde(
|
|
default,
|
|
deserialize_with = "crate::dto::optional_non_null",
|
|
skip_serializing_if = "Option::is_none"
|
|
)]
|
|
pub selection: Option<HuggingFaceSelectionDto>,
|
|
#[serde(
|
|
default,
|
|
deserialize_with = "crate::dto::optional_non_null",
|
|
skip_serializing_if = "Option::is_none"
|
|
)]
|
|
pub credential_id: Option<OpaqueId>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct LeaseProjectionDto {
|
|
pub expires_at: DateTimeDto,
|
|
pub renew_after: DateTimeDto,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct ProgressValueDto {
|
|
pub completed_bytes: SafeIntegerDto,
|
|
pub total_bytes: Option<SafeIntegerDto>,
|
|
pub completed_members: SafeIntegerDto,
|
|
pub total_members: Option<SafeIntegerDto>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct CheckpointProjectionDto {
|
|
pub reusable: bool,
|
|
pub validated_bytes: SafeIntegerDto,
|
|
pub validated_members: SafeIntegerDto,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum DurableDescriptorKindDto {
|
|
ResolvedSource,
|
|
Checkpoint,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct DurableDescriptorRefDto {
|
|
pub id: OpaqueId,
|
|
pub kind: DurableDescriptorKindDto,
|
|
pub schema_version: PositiveIntegerDto,
|
|
pub byte_length: SafeIntegerDto,
|
|
#[serde(
|
|
default,
|
|
deserialize_with = "crate::dto::optional_non_null",
|
|
skip_serializing_if = "Option::is_none"
|
|
)]
|
|
pub item_count: Option<SafeIntegerDto>,
|
|
pub checksum: String,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct ResultMemberDto {
|
|
pub id: OpaqueId,
|
|
pub path: String,
|
|
pub size: SafeIntegerDto,
|
|
pub object: ObjectIdentityDto,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct ResultMemberPageDto {
|
|
pub items: Vec<ResultMemberDto>,
|
|
pub next_cursor: NullableDto<String>,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum JobKindDto {
|
|
Job,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum TombstoneKindDto {
|
|
Tombstone,
|
|
}
|
|
|
|
#[derive(Clone, Deserialize, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct JobDto {
|
|
pub resource_kind: JobKindDto,
|
|
pub id: OpaqueId,
|
|
pub owner: OpaqueId,
|
|
pub label: NullableDto<String>,
|
|
pub revision: PositiveIntegerDto,
|
|
pub phase: JobPhase,
|
|
pub lifecycle: JobLifecycle,
|
|
pub source: SourceProjectionDto,
|
|
pub target: TargetDto,
|
|
pub authoritative_attempt: NullableDto<AttemptAuthorityDto>,
|
|
pub progress: NullableDto<ProgressDto>,
|
|
pub checkpoint: NullableDto<CheckpointProjectionDto>,
|
|
pub result: NullableDto<ResultDescriptorDto>,
|
|
pub failure: NullableDto<JobFailureDto>,
|
|
pub created_at: DateTimeDto,
|
|
pub updated_at: DateTimeDto,
|
|
pub event_cursor: CursorDto,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
pub enum TerminalJobPhaseDto {
|
|
Succeeded,
|
|
Failed,
|
|
Cancelled,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct JobTombstoneDto {
|
|
pub resource_kind: TombstoneKindDto,
|
|
pub id: OpaqueId,
|
|
pub owner: OpaqueId,
|
|
pub target: TargetDto,
|
|
pub terminal_phase: TerminalJobPhaseDto,
|
|
pub deletion_operation_id: OpaqueId,
|
|
pub created_at: DateTimeDto,
|
|
pub hard_delete_started_at: DateTimeDto,
|
|
pub updated_at: DateTimeDto,
|
|
pub event_cursor: CursorDto,
|
|
}
|
|
|
|
#[derive(Clone, Deserialize, PartialEq, Serialize)]
|
|
#[serde(untagged)]
|
|
pub enum JobResourceDto {
|
|
Job(Box<JobDto>),
|
|
Tombstone(Box<JobTombstoneDto>),
|
|
}
|
|
|
|
#[derive(Clone, Deserialize, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct JobPageDto {
|
|
pub items: Vec<JobResourceDto>,
|
|
pub next_cursor: NullableDto<String>,
|
|
pub event_cursor: CursorDto,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
pub enum AttemptRecordStateDto {
|
|
AttemptAuthorized,
|
|
AttemptExecuting,
|
|
AttemptStopped,
|
|
AttemptCommitted,
|
|
}
|
|
|
|
impl From<AttemptRecordStateDto> for AttemptState {
|
|
fn from(value: AttemptRecordStateDto) -> Self {
|
|
match value {
|
|
AttemptRecordStateDto::AttemptAuthorized => Self::AttemptAuthorized,
|
|
AttemptRecordStateDto::AttemptExecuting => Self::AttemptExecuting,
|
|
AttemptRecordStateDto::AttemptStopped => Self::AttemptStopped,
|
|
AttemptRecordStateDto::AttemptCommitted => Self::AttemptCommitted,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct AttemptRecordDto {
|
|
pub id: OpaqueId,
|
|
pub fence: PositiveIntegerDto,
|
|
pub worker_incarnation: OpaqueId,
|
|
pub state: AttemptRecordStateDto,
|
|
pub progress: NullableDto<ProgressDto>,
|
|
pub result: NullableDto<ResultDescriptorDto>,
|
|
pub failure: NullableDto<JobFailureDto>,
|
|
pub created_at: DateTimeDto,
|
|
pub updated_at: DateTimeDto,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct AttemptPageDto {
|
|
pub items: Vec<AttemptRecordDto>,
|
|
pub next_cursor: NullableDto<String>,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum DeletionProblemClassDto {
|
|
Authorization,
|
|
TargetUnavailable,
|
|
Configuration,
|
|
Internal,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct DeletionProblemDto {
|
|
pub class: DeletionProblemClassDto,
|
|
pub message: String,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum DeletionStateDto {
|
|
Queued,
|
|
Running,
|
|
RetryWait,
|
|
Blocked,
|
|
Completed,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct DeletionOperationDto {
|
|
pub id: OpaqueId,
|
|
pub job_id: OpaqueId,
|
|
pub state: DeletionStateDto,
|
|
pub problem: NullableDto<DeletionProblemDto>,
|
|
pub created_at: DateTimeDto,
|
|
pub updated_at: DateTimeDto,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ApiErrorCodeDto {
|
|
InvalidRequest,
|
|
Unauthenticated,
|
|
Forbidden,
|
|
NotFound,
|
|
IdempotencyConflict,
|
|
PreconditionFailed,
|
|
CursorInvalid,
|
|
CursorExpired,
|
|
RateLimited,
|
|
Unavailable,
|
|
Internal,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct ApiErrorFieldDto {
|
|
pub pointer: String,
|
|
pub code: String,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct ApiErrorDto {
|
|
pub code: ApiErrorCodeDto,
|
|
pub message: String,
|
|
pub request_id: OpaqueId,
|
|
#[serde(
|
|
default,
|
|
deserialize_with = "crate::dto::optional_non_null",
|
|
skip_serializing_if = "Option::is_none"
|
|
)]
|
|
pub fields: Option<Vec<ApiErrorFieldDto>>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct StagingTargetDto {
|
|
pub store: String,
|
|
pub bucket: String,
|
|
pub prefix: String,
|
|
}
|