#![allow(clippy::all)]
#![allow(missing_docs)]
#![allow(unused_imports)]
#![allow(unused_mut)]
use reqwest::Method;
use serde::Serialize;
use crate::error::{ApiError, Result};
use crate::http::HttpInner;
use crate::models;
#[derive(Debug, Clone)]
pub struct GitSettingsClient {
inner: HttpInner,
}
impl GitSettingsClient {
pub fn new(inner: HttpInner) -> Self {
Self { inner }
}
pub async fn delete_branch_protection(
&self,
repo: String,
id: String,
) -> Result<serde_json::Value> {
let path = format!("/{}/-/settings/branch-protections/{}", repo, id);
let mut url = self.inner.url(&path)?;
self.inner
.execute::<serde_json::Value>(Method::DELETE, url)
.await
}
pub async fn get_branch_protection(
&self,
repo: String,
id: String,
) -> Result<crate::models::BranchProtection> {
let path = format!("/{}/-/settings/branch-protections/{}", repo, id);
let mut url = self.inner.url(&path)?;
self.inner
.execute::<crate::models::BranchProtection>(Method::GET, url)
.await
}
pub async fn get_pipeline_settings(
&self,
repo: String,
) -> Result<crate::models::PipelineSettings> {
let path = format!("/{}/-/settings/cloud-native-build", repo);
let mut url = self.inner.url(&path)?;
self.inner
.execute::<crate::models::PipelineSettings>(Method::GET, url)
.await
}
pub async fn get_pull_request_settings(
&self,
repo: String,
) -> Result<crate::models::PullRequestSettings> {
let path = format!("/{}/-/settings/pull-request", repo);
let mut url = self.inner.url(&path)?;
self.inner
.execute::<crate::models::PullRequestSettings>(Method::GET, url)
.await
}
pub async fn get_push_limit_settings(
&self,
repo: String,
) -> Result<crate::models::PushLimitSettings> {
let path = format!("/{}/-/settings/push-limit", repo);
let mut url = self.inner.url(&path)?;
self.inner
.execute::<crate::models::PushLimitSettings>(Method::GET, url)
.await
}
pub async fn list_branch_protections(
&self,
repo: String,
) -> Result<Vec<crate::models::BranchProtection>> {
let path = format!("/{}/-/settings/branch-protections", repo);
let mut url = self.inner.url(&path)?;
self.inner
.execute::<Vec<crate::models::BranchProtection>>(Method::GET, url)
.await
}
pub async fn patch_branch_protection(
&self,
repo: String,
id: String,
body: &crate::models::BranchProtection,
) -> Result<serde_json::Value> {
let path = format!("/{}/-/settings/branch-protections/{}", repo, id);
let mut url = self.inner.url(&path)?;
self.inner
.execute_with_body::<serde_json::Value, _>(Method::PATCH, url, body)
.await
}
pub async fn post_branch_protection(
&self,
repo: String,
body: &crate::models::BranchProtection,
) -> Result<serde_json::Value> {
let path = format!("/{}/-/settings/branch-protections", repo);
let mut url = self.inner.url(&path)?;
self.inner
.execute_with_body::<serde_json::Value, _>(Method::POST, url, body)
.await
}
pub async fn put_pipeline_settings(
&self,
repo: String,
body: &crate::models::PipelineSettings,
) -> Result<serde_json::Value> {
let path = format!("/{}/-/settings/cloud-native-build", repo);
let mut url = self.inner.url(&path)?;
self.inner
.execute_with_body::<serde_json::Value, _>(Method::PUT, url, body)
.await
}
pub async fn put_pull_request_settings(
&self,
repo: String,
body: &crate::models::PullRequestSettings,
) -> Result<serde_json::Value> {
let path = format!("/{}/-/settings/pull-request", repo);
let mut url = self.inner.url(&path)?;
self.inner
.execute_with_body::<serde_json::Value, _>(Method::PUT, url, body)
.await
}
pub async fn put_push_limit_settings(
&self,
repo: String,
body: &crate::models::PushLimitSettings,
) -> Result<serde_json::Value> {
let path = format!("/{}/-/settings/push-limit", repo);
let mut url = self.inner.url(&path)?;
self.inner
.execute_with_body::<serde_json::Value, _>(Method::PUT, url, body)
.await
}
}