openapi_github/models/
job.rs

1/*
2 * GitHub's official OpenAPI spec + Octokit extension
3 *
4 * OpenAPI specs from https://github.com/github/rest-api-description with the 'x-octokit' extension required by the Octokit SDKs
5 *
6 * The version of the OpenAPI document: 16.6.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// Job : Information of a job execution in a workflow run
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Job {
17    /// The id of the job.
18    #[serde(rename = "id")]
19    pub id: i32,
20    /// The id of the associated workflow run.
21    #[serde(rename = "run_id")]
22    pub run_id: i32,
23    #[serde(rename = "run_url")]
24    pub run_url: String,
25    /// Attempt number of the associated workflow run, 1 for first attempt and higher if the workflow was re-run.
26    #[serde(rename = "run_attempt", skip_serializing_if = "Option::is_none")]
27    pub run_attempt: Option<i32>,
28    #[serde(rename = "node_id")]
29    pub node_id: String,
30    /// The SHA of the commit that is being run.
31    #[serde(rename = "head_sha")]
32    pub head_sha: String,
33    #[serde(rename = "url")]
34    pub url: String,
35    #[serde(rename = "html_url", deserialize_with = "Option::deserialize")]
36    pub html_url: Option<String>,
37    /// The phase of the lifecycle that the job is currently in.
38    #[serde(rename = "status")]
39    pub status: Status,
40    /// The outcome of the job.
41    #[serde(rename = "conclusion", deserialize_with = "Option::deserialize")]
42    pub conclusion: Option<Conclusion>,
43    /// The time that the job created, in ISO 8601 format.
44    #[serde(rename = "created_at")]
45    pub created_at: String,
46    /// The time that the job started, in ISO 8601 format.
47    #[serde(rename = "started_at")]
48    pub started_at: String,
49    /// The time that the job finished, in ISO 8601 format.
50    #[serde(rename = "completed_at", deserialize_with = "Option::deserialize")]
51    pub completed_at: Option<String>,
52    /// The name of the job.
53    #[serde(rename = "name")]
54    pub name: String,
55    /// Steps in this job.
56    #[serde(rename = "steps", skip_serializing_if = "Option::is_none")]
57    pub steps: Option<Vec<models::JobStepsInner>>,
58    #[serde(rename = "check_run_url")]
59    pub check_run_url: String,
60    /// Labels for the workflow job. Specified by the \"runs_on\" attribute in the action's workflow file.
61    #[serde(rename = "labels")]
62    pub labels: Vec<String>,
63    /// The ID of the runner to which this job has been assigned. (If a runner hasn't yet been assigned, this will be null.)
64    #[serde(rename = "runner_id", deserialize_with = "Option::deserialize")]
65    pub runner_id: Option<i32>,
66    /// The name of the runner to which this job has been assigned. (If a runner hasn't yet been assigned, this will be null.)
67    #[serde(rename = "runner_name", deserialize_with = "Option::deserialize")]
68    pub runner_name: Option<String>,
69    /// The ID of the runner group to which this job has been assigned. (If a runner hasn't yet been assigned, this will be null.)
70    #[serde(rename = "runner_group_id", deserialize_with = "Option::deserialize")]
71    pub runner_group_id: Option<i32>,
72    /// The name of the runner group to which this job has been assigned. (If a runner hasn't yet been assigned, this will be null.)
73    #[serde(rename = "runner_group_name", deserialize_with = "Option::deserialize")]
74    pub runner_group_name: Option<String>,
75    /// The name of the workflow.
76    #[serde(rename = "workflow_name", deserialize_with = "Option::deserialize")]
77    pub workflow_name: Option<String>,
78    /// The name of the current branch.
79    #[serde(rename = "head_branch", deserialize_with = "Option::deserialize")]
80    pub head_branch: Option<String>,
81}
82
83impl Job {
84    /// Information of a job execution in a workflow run
85    pub fn new(id: i32, run_id: i32, run_url: String, node_id: String, head_sha: String, url: String, html_url: Option<String>, status: Status, conclusion: Option<Conclusion>, created_at: String, started_at: String, completed_at: Option<String>, name: String, check_run_url: String, labels: Vec<String>, runner_id: Option<i32>, runner_name: Option<String>, runner_group_id: Option<i32>, runner_group_name: Option<String>, workflow_name: Option<String>, head_branch: Option<String>) -> Job {
86        Job {
87            id,
88            run_id,
89            run_url,
90            run_attempt: None,
91            node_id,
92            head_sha,
93            url,
94            html_url,
95            status,
96            conclusion,
97            created_at,
98            started_at,
99            completed_at,
100            name,
101            steps: None,
102            check_run_url,
103            labels,
104            runner_id,
105            runner_name,
106            runner_group_id,
107            runner_group_name,
108            workflow_name,
109            head_branch,
110        }
111    }
112}
113/// The phase of the lifecycle that the job is currently in.
114#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
115pub enum Status {
116    #[serde(rename = "queued")]
117    Queued,
118    #[serde(rename = "in_progress")]
119    InProgress,
120    #[serde(rename = "completed")]
121    Completed,
122    #[serde(rename = "waiting")]
123    Waiting,
124    #[serde(rename = "requested")]
125    Requested,
126    #[serde(rename = "pending")]
127    Pending,
128}
129
130impl Default for Status {
131    fn default() -> Status {
132        Self::Queued
133    }
134}
135/// The outcome of the job.
136#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
137pub enum Conclusion {
138    #[serde(rename = "success")]
139    Success,
140    #[serde(rename = "failure")]
141    Failure,
142    #[serde(rename = "neutral")]
143    Neutral,
144    #[serde(rename = "cancelled")]
145    Cancelled,
146    #[serde(rename = "skipped")]
147    Skipped,
148    #[serde(rename = "timed_out")]
149    TimedOut,
150    #[serde(rename = "action_required")]
151    ActionRequired,
152}
153
154impl Default for Conclusion {
155    fn default() -> Conclusion {
156        Self::Success
157    }
158}
159