use super::*;
use chrono::{DateTime, Utc};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WorkFlow {
pub id: WorkflowId,
pub node_id: String,
pub name: String,
pub path: String,
pub state: String,
pub created_at: chrono::DateTime<chrono::Utc>,
pub updated_at: chrono::DateTime<chrono::Utc>,
pub url: Url,
pub html_url: Url,
pub badge_url: Url,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Run {
pub id: RunId,
pub workflow_id: WorkflowId,
pub node_id: String,
pub name: String,
pub head_branch: String,
pub head_sha: String,
pub run_number: i64,
pub event: String,
pub status: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub conclusion: Option<String>,
pub created_at: chrono::DateTime<chrono::Utc>,
pub updated_at: chrono::DateTime<chrono::Utc>,
pub url: Url,
pub html_url: Url,
pub jobs_url: Url,
pub logs_url: Url,
pub check_suite_url: Url,
pub artifacts_url: Url,
pub cancel_url: Url,
pub rerun_url: Url,
pub workflow_url: Url,
pub head_commit: HeadCommit,
pub repository: Repository,
#[serde(skip_serializing_if = "Option::is_none")]
pub head_repository: Option<Repository>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct HeadCommit {
pub id: String,
pub tree_id: String,
pub message: String,
pub timestamp: chrono::DateTime<chrono::Utc>,
pub author: super::repos::CommitAuthor,
pub committer: super::repos::CommitAuthor,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Job {
pub id: JobId,
pub run_id: RunId,
pub workflow_name: String,
pub head_branch: String,
pub run_url: Url,
pub run_attempt: u32,
pub node_id: String,
pub head_sha: String,
pub url: Url,
pub html_url: Url,
pub status: Status,
#[serde(skip_serializing_if = "Option::is_none")]
pub conclusion: Option<Conclusion>,
pub created_at: DateTime<Utc>,
pub started_at: DateTime<Utc>,
#[serde(skip_serializing_if = "Option::is_none")]
pub completed_at: Option<DateTime<Utc>>,
pub name: String,
pub steps: Vec<Step>,
pub check_run_url: String,
pub labels: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub runner_id: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub runner_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub runner_group_id: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub runner_group_name: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum Conclusion {
ActionRequired,
Cancelled,
Failure,
Neutral,
Skipped,
Success,
TimedOut,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum Status {
Pending,
Queued,
InProgress,
Completed,
Failed,
Waiting,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Step {
pub name: String,
pub status: Status,
#[serde(skip_serializing_if = "Option::is_none")]
pub conclusion: Option<Conclusion>,
pub number: i64,
pub started_at: Option<chrono::DateTime<chrono::Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub completed_at: Option<chrono::DateTime<chrono::Utc>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WorkflowListArtifact {
pub id: crate::models::ArtifactId,
pub node_id: String,
pub name: String,
pub size_in_bytes: usize,
pub url: Url,
pub archive_download_url: Url,
pub expired: bool,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub expires_at: DateTime<Utc>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub workflow_run: Option<ArtifactWorkflowRun>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ArtifactWorkflowRun {
pub id: crate::models::RunId,
pub repository_id: crate::models::RepositoryId,
pub head_repository_id: crate::models::RepositoryId,
pub head_branch: String,
pub head_sha: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
#[non_exhaustive]
pub struct WorkflowDispatch {
pub r#ref: String,
#[serde(skip_serializing_if = "serde_json::Value::is_null")]
pub inputs: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WorkflowUsage {
pub billable: WorkflowBillable,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WorkflowBillable {
#[serde(default, rename = "UBUNTU")]
pub ubuntu: Option<WorkflowPlatformUsage>,
#[serde(default, rename = "MACOS")]
pub macos: Option<WorkflowPlatformUsage>,
#[serde(default, rename = "WINDOWS")]
pub windows: Option<WorkflowPlatformUsage>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WorkflowPlatformUsage {
#[serde(default)]
pub total_ms: u64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WorkflowRunUsage {
pub billable: WorkflowRunBillable,
#[serde(default)]
pub run_duration_ms: Option<u64>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WorkflowRunBillable {
#[serde(default, rename = "UBUNTU")]
pub ubuntu: Option<WorkflowRunPlatformUsage>,
#[serde(default, rename = "MACOS")]
pub macos: Option<WorkflowRunPlatformUsage>,
#[serde(default, rename = "WINDOWS")]
pub windows: Option<WorkflowRunPlatformUsage>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WorkflowRunPlatformUsage {
#[serde(default)]
pub total_ms: u64,
#[serde(default)]
pub jobs: u64,
#[serde(default)]
pub job_runs: Vec<WorkflowRunJobRun>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WorkflowRunJobRun {
pub job_id: u64,
pub duration_ms: u64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WorkflowRunApproval {
#[serde(default)]
pub environments: Vec<PendingDeploymentEnvironment>,
pub user: super::Author,
pub state: String,
pub comment: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PendingDeployment {
pub environment: PendingDeploymentEnvironment,
#[serde(default)]
pub wait_timer: u64,
pub wait_timer_started_at: Option<DateTime<Utc>>,
#[serde(default)]
pub current_user_can_approve: bool,
#[serde(default)]
pub reviewers: Vec<PendingDeploymentReviewer>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PendingDeploymentEnvironment {
pub id: u64,
pub node_id: String,
pub name: String,
pub url: String,
pub html_url: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PendingDeploymentReviewer {
#[serde(rename = "type")]
pub reviewer_type: String,
pub reviewer: serde_json::Value,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum ReviewDeploymentState {
Approved,
Rejected,
}