openapi_github/models/
webhook_push.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#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct WebhookPush {
16    /// The SHA of the most recent commit on `ref` after the push.
17    #[serde(rename = "after")]
18    pub after: String,
19    #[serde(rename = "base_ref", deserialize_with = "Option::deserialize")]
20    pub base_ref: Option<String>,
21    /// The SHA of the most recent commit on `ref` before the push.
22    #[serde(rename = "before")]
23    pub before: String,
24    /// An array of commit objects describing the pushed commits. (Pushed commits are all commits that are included in the `compare` between the `before` commit and the `after` commit.) The array includes a maximum of 2048 commits. If necessary, you can use the [Commits API](https://docs.github.com/rest/commits) to fetch additional commits.
25    #[serde(rename = "commits")]
26    pub commits: Vec<models::Commit>,
27    /// URL that shows the changes in this `ref` update, from the `before` commit to the `after` commit. For a newly created `ref` that is directly based on the default branch, this is the comparison between the head of the default branch and the `after` commit. Otherwise, this shows all commits until the `after` commit.
28    #[serde(rename = "compare")]
29    pub compare: String,
30    /// Whether this push created the `ref`.
31    #[serde(rename = "created")]
32    pub created: bool,
33    /// Whether this push deleted the `ref`.
34    #[serde(rename = "deleted")]
35    pub deleted: bool,
36    #[serde(rename = "enterprise", skip_serializing_if = "Option::is_none")]
37    pub enterprise: Option<Box<models::EnterpriseWebhooks>>,
38    /// Whether this push was a force push of the `ref`.
39    #[serde(rename = "forced")]
40    pub forced: bool,
41    #[serde(rename = "head_commit", deserialize_with = "Option::deserialize")]
42    pub head_commit: Option<Box<models::Commit1>>,
43    #[serde(rename = "installation", skip_serializing_if = "Option::is_none")]
44    pub installation: Option<Box<models::SimpleInstallation>>,
45    #[serde(rename = "organization", skip_serializing_if = "Option::is_none")]
46    pub organization: Option<Box<models::OrganizationSimpleWebhooks>>,
47    #[serde(rename = "pusher")]
48    pub pusher: Box<models::Committer1>,
49    /// The full git ref that was pushed. Example: `refs/heads/main` or `refs/tags/v3.14.1`.
50    #[serde(rename = "ref")]
51    pub r#ref: String,
52    #[serde(rename = "repository")]
53    pub repository: Box<models::Repository2>,
54    #[serde(rename = "sender", skip_serializing_if = "Option::is_none")]
55    pub sender: Option<Box<models::SimpleUserWebhooks>>,
56}
57
58impl WebhookPush {
59    pub fn new(after: String, base_ref: Option<String>, before: String, commits: Vec<models::Commit>, compare: String, created: bool, deleted: bool, forced: bool, head_commit: Option<models::Commit1>, pusher: models::Committer1, r#ref: String, repository: models::Repository2) -> WebhookPush {
60        WebhookPush {
61            after,
62            base_ref,
63            before,
64            commits,
65            compare,
66            created,
67            deleted,
68            enterprise: None,
69            forced,
70            head_commit: head_commit.map(Box::new),
71            installation: None,
72            organization: None,
73            pusher: Box::new(pusher),
74            r#ref,
75            repository: Box::new(repository),
76            sender: None,
77        }
78    }
79}
80