openapi_github/models/repos_update_branch_protection_request.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 ReposUpdateBranchProtectionRequest {
16 #[serde(rename = "required_status_checks", deserialize_with = "Option::deserialize")]
17 pub required_status_checks: Option<Box<models::ReposUpdateBranchProtectionRequestRequiredStatusChecks>>,
18 /// Enforce all configured restrictions for administrators. Set to `true` to enforce required status checks for repository administrators. Set to `null` to disable.
19 #[serde(rename = "enforce_admins", deserialize_with = "Option::deserialize")]
20 pub enforce_admins: Option<bool>,
21 #[serde(rename = "required_pull_request_reviews", deserialize_with = "Option::deserialize")]
22 pub required_pull_request_reviews: Option<Box<models::ReposUpdateBranchProtectionRequestRequiredPullRequestReviews>>,
23 #[serde(rename = "restrictions", deserialize_with = "Option::deserialize")]
24 pub restrictions: Option<Box<models::ReposUpdateBranchProtectionRequestRestrictions>>,
25 /// Enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch. Set to `true` to enforce a linear commit history. Set to `false` to disable a linear commit Git history. Your repository must allow squash merging or rebase merging before you can enable a linear commit history. Default: `false`. For more information, see \"[Requiring a linear commit history](https://docs.github.com/github/administering-a-repository/requiring-a-linear-commit-history)\" in the GitHub Help documentation.
26 #[serde(rename = "required_linear_history", skip_serializing_if = "Option::is_none")]
27 pub required_linear_history: Option<bool>,
28 /// Permits force pushes to the protected branch by anyone with write access to the repository. Set to `true` to allow force pushes. Set to `false` or `null` to block force pushes. Default: `false`. For more information, see \"[Enabling force pushes to a protected branch](https://docs.github.com/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)\" in the GitHub Help documentation.\"
29 #[serde(rename = "allow_force_pushes", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
30 pub allow_force_pushes: Option<Option<bool>>,
31 /// Allows deletion of the protected branch by anyone with write access to the repository. Set to `false` to prevent deletion of the protected branch. Default: `false`. For more information, see \"[Enabling force pushes to a protected branch](https://docs.github.com/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)\" in the GitHub Help documentation.
32 #[serde(rename = "allow_deletions", skip_serializing_if = "Option::is_none")]
33 pub allow_deletions: Option<bool>,
34 /// If set to `true`, the `restrictions` branch protection settings which limits who can push will also block pushes which create new branches, unless the push is initiated by a user, team, or app which has the ability to push. Set to `true` to restrict new branch creation. Default: `false`.
35 #[serde(rename = "block_creations", skip_serializing_if = "Option::is_none")]
36 pub block_creations: Option<bool>,
37 /// Requires all conversations on code to be resolved before a pull request can be merged into a branch that matches this rule. Set to `false` to disable. Default: `false`.
38 #[serde(rename = "required_conversation_resolution", skip_serializing_if = "Option::is_none")]
39 pub required_conversation_resolution: Option<bool>,
40 /// Whether to set the branch as read-only. If this is true, users will not be able to push to the branch. Default: `false`.
41 #[serde(rename = "lock_branch", skip_serializing_if = "Option::is_none")]
42 pub lock_branch: Option<bool>,
43 /// Whether users can pull changes from upstream when the branch is locked. Set to `true` to allow fork syncing. Set to `false` to prevent fork syncing. Default: `false`.
44 #[serde(rename = "allow_fork_syncing", skip_serializing_if = "Option::is_none")]
45 pub allow_fork_syncing: Option<bool>,
46}
47
48impl ReposUpdateBranchProtectionRequest {
49 pub fn new(required_status_checks: Option<models::ReposUpdateBranchProtectionRequestRequiredStatusChecks>, enforce_admins: Option<bool>, required_pull_request_reviews: Option<models::ReposUpdateBranchProtectionRequestRequiredPullRequestReviews>, restrictions: Option<models::ReposUpdateBranchProtectionRequestRestrictions>) -> ReposUpdateBranchProtectionRequest {
50 ReposUpdateBranchProtectionRequest {
51 required_status_checks: required_status_checks.map(Box::new),
52 enforce_admins,
53 required_pull_request_reviews: required_pull_request_reviews.map(Box::new),
54 restrictions: restrictions.map(Box::new),
55 required_linear_history: None,
56 allow_force_pushes: None,
57 allow_deletions: None,
58 block_creations: None,
59 required_conversation_resolution: None,
60 lock_branch: None,
61 allow_fork_syncing: None,
62 }
63 }
64}
65