diff --git a/generator/src/client.rs b/generator/src/client.rs index 51c33dd4..af0b374e 100644 --- a/generator/src/client.rs +++ b/generator/src/client.rs @@ -138,7 +138,7 @@ impl Client { self.credentials = credentials.into(); } - fn credentials(&self, authentication: crate::auth::AuthenticationConstraint) -> Option<&crate::auth::Credentials> { + fn get_credentials(&self, authentication: crate::auth::AuthenticationConstraint) -> Option<&crate::auth::Credentials> { match (authentication, self.credentials.as_ref()) { (crate::auth::AuthenticationConstraint::Unconstrained, creds) => creds, (crate::auth::AuthenticationConstraint::JWT, creds @ Some(&crate::auth::Credentials::JWT(_))) => creds, @@ -162,7 +162,7 @@ impl Client { ) -> ClientResult<(reqwest::Url, Option)> { let mut parsed_url = uri.parse::()?; - match self.credentials(authentication) { + match self.get_credentials(authentication) { Some(&crate::auth::Credentials::Client(ref id, ref secret)) => { parsed_url.query_pairs_mut() .append_pair("client_id", id) diff --git a/generator/src/main.rs b/generator/src/main.rs index 14adaefd..30782550 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -5,7 +5,7 @@ mod types; mod utils; use std::{ - collections::{BTreeMap, HashSet}, + collections::{BTreeMap, HashMap, HashSet}, ffi::OsStr, fs::{File, OpenOptions}, io::Write, @@ -227,7 +227,7 @@ impl ParameterDataExt for openapiv3::ParameterData { }; if st.pattern.is_some() { - bail!("XXX pattern"); + println!("XXX unsupported pattern detected"); } if !st.enumeration.is_empty() { @@ -303,6 +303,7 @@ impl ParameterDataExt for openapiv3::ParameterData { "uuid" => "&str".to_string(), "hostname" => "&str".to_string(), "time" => "chrono::NaiveTime".to_string(), + "repo.nwo" => "&str".to_string(), f => { bail!("XXX unknown string format {}", f) } @@ -436,7 +437,7 @@ impl ExtractJsonMediaType for openapiv3::Response { bail!("expected binary format string, got {:?}", st.format); } if st.pattern.is_some() { - bail!("XXX pattern"); + println!("XXX unsupported pattern detected"); } if !st.enumeration.is_empty() { bail!("XXX binary enumeration {:?}", st); @@ -734,6 +735,13 @@ impl PartialEq for TypeId { } } +#[derive(Debug, Clone, Default)] +pub struct Constraints { + pub pattern: Option, + pub min_length: Option, + pub max_length: Option, +} + #[derive(Debug, Clone)] pub struct TypeSpace { next_id: u64, @@ -741,10 +749,12 @@ pub struct TypeSpace { * Object types generally have a useful name, which we would like to match * with anywhere that name appears in the definition document. Many other * types, though, do not; e.g., an array of strings is just going to become - * Vec without necesssarily having a useful distinct type name. + * Vec without necessarily having a useful distinct type name. */ name_to_id: BTreeMap, id_to_entry: BTreeMap, + unresolved_refs: HashMap>, + constraints: BTreeMap, } impl TypeSpace { @@ -753,6 +763,8 @@ impl TypeSpace { next_id: 1, name_to_id: BTreeMap::new(), id_to_entry: BTreeMap::new(), + unresolved_refs: HashMap::new(), + constraints: BTreeMap::new(), } } @@ -912,7 +924,26 @@ impl TypeSpace { if let Some(te) = self.id_to_entry.get(tid) { match &te.details { TypeDetails::Basic(t, _) => Ok(t.to_string()), - TypeDetails::NamedType(itid, _) => self.render_type(itid, in_mod), + TypeDetails::NamedType(itid, _) => { + if !self.id_to_entry.contains_key(itid) { + eprintln!( + "[error] {:?} [{:?}] has an unresolvable inner {:?}!", + tid, + te.name.as_deref().unwrap_or("unknown"), + itid + ); + + for (ref_path, ids) in &self.unresolved_refs { + if ids.contains(tid) { + println!(" Referenced as: {}", ref_path); + } + } + + bail!("could not resolve referenced type ID {:?}", itid); + } + + self.render_type(itid, in_mod) + } TypeDetails::Enum(..) => { if let Some(n) = &te.name { let struct_name = struct_name(n); @@ -1109,7 +1140,15 @@ impl TypeSpace { // Let's make some generic details, assign an id and then later in // populate ref we can replace this ID with the real one. let details = TypeDetails::NamedType(self.assign(), Default::default()); - self.add_if_not_exists(Some(ref_), details, "", true) + let id = self.add_if_not_exists(Some(ref_.clone()), details, "", true)?; + + // Keep track of this reference until it is resolved to make troubleshooting references easier + self.unresolved_refs + .entry(ref_) + .or_default() + .push(id.clone()); + + Ok(id) } fn add_if_not_exists( @@ -1270,7 +1309,7 @@ impl TypeSpace { is_reference, ); } else if !name.contains("object") { - // Let's try to append "type" onto the end and see if that helps. + // Let's try to append "object" onto the end and see if that helps. let new_name = format!("{} object", name); return self.add_if_not_exists( Some(clean_name(&new_name)), @@ -1280,7 +1319,34 @@ impl TypeSpace { ); } - // If we don't have anything to append, let's bail. + // Failed to find a unique suffix based on the name. Try + // using unique descriptors from the type's details + let content_suffixes: Vec = match &details { + TypeDetails::Enum(vals, _) => { + // Use enum values as distinguishing suffixes. + vals.iter().map(|v| clean_name(v)).collect() + } + TypeDetails::Object(props, _) => { + // Use property names as distinguishing suffixes. + props.keys().map(|k| clean_name(k)).collect() + } + _ => vec![], + }; + + // Try each content-derived suffix, picking the first one + // that isn't already part of the name. + for suffix in &content_suffixes { + if !name.contains(suffix.as_str()) { + let new_name = format!("{} {}", name, suffix); + return self.add_if_not_exists( + Some(clean_name(&new_name)), + details, + "", + is_reference, + ); + } + } + // WE ARE RUNNING OUT OF NAMES AND WE TRIED. bail!( "we ran out of unique names for this thing {}: {:?}", @@ -1358,7 +1424,23 @@ impl TypeSpace { let details = if let Some(id) = id { TypeDetails::NamedType(id, Default::default()) } else { - TypeDetails::NamedType(self.id_for_name("String"), Default::default()) + let string_id = self.id_for_name("String"); + + // NOTE: + // In the GitHub API a few response types have no content attribute. There is no + // String type defined, resulting in mismatched references. This code is intended to + // ensure that a String TypeId exists and is mapped correctly in both directions. + if !self.id_to_entry.contains_key(&string_id) { + self.id_to_entry.insert( + string_id.clone(), + TypeEntry { + id: string_id.clone(), + name: Some("String".to_string()), + details: TypeDetails::Basic("String".to_string(), Default::default()), + }, + ); + } + TypeDetails::NamedType(string_id, Default::default()) }; // Lets check if we already have this reference added. @@ -1366,7 +1448,7 @@ impl TypeSpace { // was referenced that had not yet been parsed. if let Some(rid) = self.name_to_id.get(&ref_) { // Okay we have the id for the reference. - // Let's update it's named type. + // Let's update its named type. self.id_to_entry.insert( rid.clone(), TypeEntry { @@ -1376,6 +1458,15 @@ impl TypeSpace { }, ); + // If we are defining an unresolved reference clean it up here + if let Some(type_ids) = self.unresolved_refs.remove(&ref_) { + println!( + "Resolved reference '{}' used by {} type IDs", + ref_, + type_ids.len() + ); + } + return Ok(rid.clone()); } @@ -1424,7 +1515,24 @@ impl TypeSpace { let (n, details) = self.get_type_name_and_details(name, s, parent_name, additional_description)?; - self.add_if_not_exists(n, details, parent_name, false) + let id = self.add_if_not_exists(n, details, parent_name, false)?; + + // Extract string-type constraints and associate them with the TypeId. + if let openapiv3::SchemaKind::Type(openapiv3::Type::String(st)) = &s.schema_kind { + let constraints = Constraints { + pattern: st.pattern.clone(), + min_length: st.min_length, + max_length: st.max_length, + }; + if constraints.pattern.is_some() + || constraints.min_length.is_some() + || constraints.max_length.is_some() + { + self.set_constraints(id.clone(), constraints); + } + } + + Ok(id) } fn get_type_name_and_details( @@ -1825,6 +1933,10 @@ impl TypeSpace { s.schema_data.clone(), ), )), + "repo.nwo" => Ok(( + Some(uid.to_string()), + TypeDetails::Basic("String".to_string(), s.schema_data.clone()), + )), f => bail!("XXX unknown string format {}", f), }, } @@ -2134,6 +2246,44 @@ impl TypeSpace { bail!("could not get parameter_data for {:?}: {:?}", name, p); } } + + fn validate_refs(&self) -> Result<()> { + if !self.unresolved_refs.is_empty() { + eprintln!( + "[error]: Found {} unresolved references:", + self.unresolved_refs.len() + ); + + for (reference, ids) in &self.unresolved_refs { + eprintln!(" '{}' referenced by {} types:", reference, ids.len()); + + for id in ids { + if let Some(entry) = self.id_to_entry.get(id) { + let name = entry.name.as_deref().unwrap_or("unnamed"); + eprintln!(" - {:?} [{}]", id, name); + + if let TypeDetails::NamedType(target_id, _) = &entry.details { + eprintln!(" points to {:?}", target_id); + } + } + } + } + bail!( + "parsed API contains {} unresolved references.", + self.unresolved_refs.keys().len() + ) + } + + Ok(()) + } + + fn set_constraints(&mut self, id: TypeId, constraints: Constraints) { + self.constraints.insert(id, constraints); + } + + fn get_constraints(&self, id: &TypeId) -> Option<&Constraints> { + self.constraints.get(id) + } } fn get_parameter_data(param: &openapiv3::Parameter) -> Option<&openapiv3::ParameterData> { @@ -2332,11 +2482,11 @@ fn gen( * Tags are how functions are grouped. */ for tag in api.tags.iter() { - if !tags.contains(&to_snake_case(&clean_name(&tag.name))) - && (proper_name == "Zoom" || proper_name == "DocuSign") - { + if !tags.contains(&to_snake_case(&clean_name(&tag.name))) { + // This specifically fixes Zoom, GitHub and DocuSign where they + // list tags that have no associated functions, but this should be + // safe for all APIs. // Return early do nothing! - // This fixes Zoom and DocuSign where they list tags that have no associated functions. continue; } @@ -2569,11 +2719,11 @@ pub(crate) struct Message { * Tags are how functions are grouped. */ for tag in api.tags.iter() { - if !tags.contains(&to_snake_case(&tag.name)) - && (proper_name == "Zoom" || proper_name == "DocuSign") - { + if !tags.contains(&to_snake_case(&clean_name(&tag.name))) { + // This specifically fixes Zoom, GitHub and DocuSign where they + // list tags that have no associated functions, but this should be + // safe for all APIs. // Return early do nothing! - // This fixes Zoom and DocuSign where they list tags that have no associated functions. continue; } @@ -2990,6 +3140,13 @@ fn main() -> Result<()> { if let Some(components) = &api.components { // Populate a type to describe each entry in the schemas section. for (i, (sn, s)) in components.schemas.iter().enumerate() { + if args.opt_str("proper-name").unwrap() == "GitHub" + && ((sn.starts_with("webhook-") && !sn.starts_with("webhook-config")) + || sn.starts_with("webhooks_")) + { + debug(&format!("Skipping schema: {}", sn)); + continue; + } let name = clean_name(sn); debug(&format!( "SCHEMA {}/{}: {}", @@ -3297,6 +3454,8 @@ fn main() -> Result<()> { } debug(""); + ts.validate_refs()?; + let name = args.opt_str("n").unwrap(); let version = args.opt_str("v").unwrap(); let host = args.opt_str("host").unwrap(); @@ -3516,18 +3675,12 @@ rustdoc-args = ["--cfg", "docsrs"] save(utilsrs, utils.as_str())?; /* - * Create the Rust source types file containing the generated types: - */ - let types = types::generate_types(&mut ts, &proper_name)?; - let mut typesrs = src.clone(); - typesrs.push("types.rs"); - save(typesrs, types.as_str())?; - - /* - * Create the Rust source files for each of the tags functions: + * NOTE: In at least the GitHub API the TypeSpace is changed + * during code generation. If moving type generation to after + * this step breaks other APIs we may need to do it twice. */ - - match functions::generate_files(&api, &proper_name, &mut ts, ¶meters) { + // Create the Rust source files for each of the tags functions: + let result = match functions::generate_files(&api, &proper_name, &mut ts, ¶meters) { Ok(files) => { // We have a map of our files, let's write to them. for (f, output) in files { @@ -3572,7 +3725,17 @@ impl {} {{ println!("generate_files fail: {:?}", e); true } - } + }; + + /* + * Create the Rust source types file containing the generated types: + */ + let types = types::generate_types(&mut ts, &proper_name)?; + let mut typesrs = src.clone(); + typesrs.push("types.rs"); + save(typesrs, types.as_str())?; + + result } Err(e) => { println!("gen fail: {:?}", e); diff --git a/generator/src/template.rs b/generator/src/template.rs index 317290db..5b3b7227 100644 --- a/generator/src/template.rs +++ b/generator/src/template.rs @@ -365,10 +365,10 @@ pub fn generate_docs_github( //! use base64::{{Engine, engine::general_purpose::STANDARD}}; //! //! let app_id_str = env::var("GH_APP_ID").unwrap(); -//! let app_id = app_id_str.parse::().unwrap(); +//! let app_id = app_id_str.parse::().unwrap(); //! //! let app_installation_id_str = env::var("GH_INSTALLATION_ID").unwrap(); -//! let app_installation_id = app_installation_id_str.parse::().unwrap(); +//! let app_installation_id = app_installation_id_str.parse::().unwrap(); //! //! let encoded_private_key = env::var("GH_PRIVATE_KEY").unwrap(); //! let private_key = STANDARD.decode(encoded_private_key).unwrap(); diff --git a/generator/src/types.rs b/generator/src/types.rs index ecee96b9..cae4a5d4 100644 --- a/generator/src/types.rs +++ b/generator/src/types.rs @@ -1,4 +1,4 @@ -use std::collections::BTreeMap; +use std::collections::{BTreeMap, HashSet}; use anyhow::{bail, Result}; use inflector::cases::snakecase::to_snake_case; @@ -21,10 +21,19 @@ pub fn generate_types(ts: &mut TypeSpace, proper_name: &str) -> Result { a(" use serde::{Serialize, Deserialize};"); a(""); + let mut emitted_names: HashSet = HashSet::new(); + for te in ts.clone().id_to_entry.values() { if let Some(sn) = te.name.as_deref() { let sn = struct_name(sn); + // Warn about duplicate type names, but keep going + if emitted_names.contains(&sn) { + eprintln!("[warn] skipping duplicate type name: {}", sn); + continue; + } + emitted_names.insert(sn.clone()); + match &te.details { TypeDetails::Enum(vals, schema_data) => { let mut desc = "".to_string(); @@ -80,7 +89,7 @@ pub fn generate_types(ts: &mut TypeSpace, proper_name: &str) -> Result { || sn == "PagesHttpsCertificate" || sn == "ErrorDetails" || sn == "EnvelopeDefinition" - || (sn == "Event" && proper_name != "Stripe") + || (sn == "Event" && proper_name != "Stripe" && proper_name != "GitHub") || sn == "User" || sn == "Group" || sn == "CalendarResource" @@ -97,7 +106,6 @@ pub fn generate_types(ts: &mut TypeSpace, proper_name: &str) -> Result { || sn == "DescriptionlessJobOptionsDataType" || sn == "SubmitJobOptions" || sn == "SubmitJobOptionsData" - || sn == "MinimalRepository" || sn == "WorkflowRun" || sn == "CheckAnnotation" { @@ -149,6 +157,7 @@ pub fn generate_types(ts: &mut TypeSpace, proper_name: &str) -> Result { || prop == "enum" || prop == "const" || prop == "use" + || prop == "async" { prop = format!("{}_", name); } else if name == "$ref" { @@ -283,6 +292,7 @@ pub fn generate_types(ts: &mut TypeSpace, proper_name: &str) -> Result { || prop == "enum" || prop == "const" || prop == "use" + || prop == "async" { prop = format!("{}_", prop); } diff --git a/github/README.md b/github/README.md index 04431620..c2045508 100644 --- a/github/README.md +++ b/github/README.md @@ -16,7 +16,7 @@ GitHub's v3 REST API. | name | url | |----|----| -| Support | | +| Support | | ### License @@ -121,10 +121,10 @@ use octorust::http_cache::FileBasedCache; use base64::{Engine, engine::general_purpose::STANDARD}; let app_id_str = env::var("GH_APP_ID").unwrap(); -let app_id = app_id_str.parse::().unwrap(); +let app_id = app_id_str.parse::().unwrap(); let app_installation_id_str = env::var("GH_INSTALLATION_ID").unwrap(); -let app_installation_id = app_installation_id_str.parse::().unwrap(); +let app_installation_id = app_installation_id_str.parse::().unwrap(); let encoded_private_key = env::var("GH_PRIVATE_KEY").unwrap(); let private_key = STANDARD.decode(encoded_private_key).unwrap(); diff --git a/github/src/actions.rs b/github/src/actions.rs index ca1626e1..983ebe60 100644 --- a/github/src/actions.rs +++ b/github/src/actions.rs @@ -12,28 +12,29 @@ impl Actions { } /** - * Get GitHub Actions permissions for an organization. + * Get GitHub Actions cache retention limit for an enterprise. * - * This function performs a `GET` to the `/orgs/{org}/actions/permissions` endpoint. + * This function performs a `GET` to the `/enterprises/{enterprise}/actions/cache/retention-limit` endpoint. * - * Gets the GitHub Actions permissions policy for repositories and allowed actions in an organization. + * Gets GitHub Actions cache retention limit for an enterprise. All organizations and repositories under this + * enterprise may not set a higher cache retention limit. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `administration` organization permission to use this API. + * OAuth tokens and personal access tokens (classic) need the `admin:enterprise` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `enterprise: &str` -- The slug version of the enterprise name. */ - pub async fn get_github_actions_permissions_organization( + pub async fn get_actions_cache_retention_limit_for_enterprise( &self, - org: &str, - ) -> ClientResult> { + enterprise: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/permissions", - crate::progenitor_support::encode_path(org), + "/enterprises/{}/actions/cache/retention-limit", + crate::progenitor_support::encode_path(&enterprise.to_string()), ), None, ); @@ -48,31 +49,30 @@ impl Actions { .await } /** - * Set GitHub Actions permissions for an organization. - * - * This function performs a `PUT` to the `/orgs/{org}/actions/permissions` endpoint. + * Set GitHub Actions cache retention limit for an enterprise. * - * Sets the GitHub Actions permissions policy for repositories and allowed actions in an organization. + * This function performs a `PUT` to the `/enterprises/{enterprise}/actions/cache/retention-limit` endpoint. * - * If the organization belongs to an enterprise that has set restrictive permissions at the enterprise level, such as `allowed_actions` to `selected` actions, then you cannot override them for the organization. + * Sets GitHub Actions cache retention limit for an enterprise. All organizations and repositories under this + * enterprise may not set a higher cache retention limit. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `administration` organization permission to use this API. + * OAuth tokens and personal access tokens (classic) need the `admin:enterprise` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `enterprise: &str` -- The slug version of the enterprise name. */ - pub async fn set_github_actions_permissions_organization( + pub async fn set_actions_cache_retention_limit_for_enterprise( &self, - org: &str, - body: &crate::types::ActionsSetGithubPermissionsOrganizationRequest, + enterprise: &str, + body: &crate::types::ActionsCacheRetentionLimitEnterprise, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/permissions", - crate::progenitor_support::encode_path(org), + "/enterprises/{}/actions/cache/retention-limit", + crate::progenitor_support::encode_path(&enterprise.to_string()), ), None, ); @@ -87,45 +87,29 @@ impl Actions { .await } /** - * List selected repositories enabled for GitHub Actions in an organization. + * Get GitHub Actions cache storage limit for an enterprise. * - * This function performs a `GET` to the `/orgs/{org}/actions/permissions/repositories` endpoint. + * This function performs a `GET` to the `/enterprises/{enterprise}/actions/cache/storage-limit` endpoint. * - * Lists the selected repositories that are enabled for GitHub Actions in an organization. To use this endpoint, the organization permission policy for `enabled_repositories` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." + * Gets GitHub Actions cache storage limit for an enterprise. All organizations and repositories under this + * enterprise may not set a higher cache storage limit. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `administration` organization permission to use this API. + * OAuth tokens and personal access tokens (classic) need the `admin:enterprise` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `enterprise: &str` -- The slug version of the enterprise name. */ - pub async fn list_selected_repositories_enabled_github_actions_organization( + pub async fn get_actions_cache_storage_limit_for_enterprise( &self, - org: &str, - per_page: i64, - page: i64, - ) -> ClientResult< - crate::Response< - crate::types::ActionsListSelectedRepositoriesEnabledGithubOrganizationResponse, - >, - > { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + enterprise: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/permissions/repositories?{}", - crate::progenitor_support::encode_path(org), - query_ + "/enterprises/{}/actions/cache/storage-limit", + crate::progenitor_support::encode_path(&enterprise.to_string()), ), None, ); @@ -140,29 +124,30 @@ impl Actions { .await } /** - * Set selected repositories enabled for GitHub Actions in an organization. + * Set GitHub Actions cache storage limit for an enterprise. * - * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/repositories` endpoint. + * This function performs a `PUT` to the `/enterprises/{enterprise}/actions/cache/storage-limit` endpoint. * - * Replaces the list of selected repositories that are enabled for GitHub Actions in an organization. To use this endpoint, the organization permission policy for `enabled_repositories` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." + * Sets GitHub Actions cache storage limit for an enterprise. All organizations and repositories under this + * enterprise may not set a higher cache storage limit. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `administration` organization permission to use this API. + * OAuth tokens and personal access tokens (classic) need the `admin:enterprise` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `enterprise: &str` -- The slug version of the enterprise name. */ - pub async fn set_selected_repositories_enabled_github_actions_organization( + pub async fn set_actions_cache_storage_limit_for_enterprise( &self, - org: &str, - body: &crate::types::ActionsSetRepoAccessSelfHostedRunnerGroupInOrgRequest, + enterprise: &str, + body: &crate::types::ActionsCacheStorageLimitEnterprise, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/permissions/repositories", - crate::progenitor_support::encode_path(org), + "/enterprises/{}/actions/cache/storage-limit", + crate::progenitor_support::encode_path(&enterprise.to_string()), ), None, ); @@ -177,36 +162,34 @@ impl Actions { .await } /** - * Enable a selected repository for GitHub Actions in an organization. + * Get GitHub Actions cache retention limit for an organization. * - * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/repositories/{repository_id}` endpoint. + * This function performs a `GET` to the `/organizations/{org}/actions/cache/retention-limit` endpoint. * - * Adds a repository to the list of selected repositories that are enabled for GitHub Actions in an organization. To use this endpoint, the organization permission policy for `enabled_repositories` must be must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." + * Gets GitHub Actions cache retention limit for an organization. All repositories under this + * organization may not set a higher cache retention limit. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `administration` organization permission to use this API. + * OAuth tokens and personal access tokens (classic) need the `admin:organization` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `repository_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn enable_selected_repository_github_actions_organization( + pub async fn get_actions_cache_retention_limit_for_organization( &self, org: &str, - repository_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/permissions/repositories/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&repository_id.to_string()), + "/organizations/{}/actions/cache/retention-limit", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { body: None, @@ -216,67 +199,67 @@ impl Actions { .await } /** - * Disable a selected repository for GitHub Actions in an organization. + * Set GitHub Actions cache retention limit for an organization. * - * This function performs a `DELETE` to the `/orgs/{org}/actions/permissions/repositories/{repository_id}` endpoint. + * This function performs a `PUT` to the `/organizations/{org}/actions/cache/retention-limit` endpoint. * - * Removes a repository from the list of selected repositories that are enabled for GitHub Actions in an organization. To use this endpoint, the organization permission policy for `enabled_repositories` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." + * Sets GitHub Actions cache retention limit for an organization. All repositories under this + * organization may not set a higher cache retention limit. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `administration` organization permission to use this API. + * OAuth tokens and personal access tokens (classic) need the `admin:organization` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `repository_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn disable_selected_repository_github_actions_organization( + pub async fn set_actions_cache_retention_limit_for_organization( &self, org: &str, - repository_id: i64, + body: &crate::types::ActionsCacheRetentionLimitOrganization, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/permissions/repositories/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&repository_id.to_string()), + "/organizations/{}/actions/cache/retention-limit", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .delete( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Get allowed actions for an organization. + * Get GitHub Actions cache storage limit for an organization. * - * This function performs a `GET` to the `/orgs/{org}/actions/permissions/selected-actions` endpoint. + * This function performs a `GET` to the `/organizations/{org}/actions/cache/storage-limit` endpoint. * - * Gets the selected actions that are allowed in an organization. To use this endpoint, the organization permission policy for `allowed_actions` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)."" + * Gets GitHub Actions cache storage limit for an organization. All repositories under this + * organization may not set a higher cache storage limit. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `administration` organization permission to use this API. + * OAuth tokens and personal access tokens (classic) need the `admin:organization` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn get_allowed_actions_organization( + pub async fn get_actions_cache_storage_limit_for_organization( &self, org: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/permissions/selected-actions", - crate::progenitor_support::encode_path(org), + "/organizations/{}/actions/cache/storage-limit", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -291,33 +274,30 @@ impl Actions { .await } /** - * Set allowed actions for an organization. - * - * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/selected-actions` endpoint. + * Set GitHub Actions cache storage limit for an organization. * - * Sets the actions that are allowed in an organization. To use this endpoint, the organization permission policy for `allowed_actions` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." + * This function performs a `PUT` to the `/organizations/{org}/actions/cache/storage-limit` endpoint. * - * If the organization belongs to an enterprise that has `selected` actions set at the enterprise level, then you cannot override any of the enterprise's allowed actions settings. + * Sets GitHub Actions cache storage limit for an organization. All organizations and repositories under this + * organization may not set a higher cache storage limit. * - * To use the `patterns_allowed` setting for private repositories, the organization must belong to an enterprise. If the organization does not belong to an enterprise, then the `patterns_allowed` setting only applies to public repositories in the organization. + * OAuth tokens and personal access tokens (classic) need the `admin:organization` scope to use this endpoint. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `administration` organization permission to use this API. - * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn set_allowed_actions_organization( + pub async fn set_actions_cache_storage_limit_for_organization( &self, org: &str, - body: &crate::types::SelectedActions, + body: &crate::types::ActionsCacheStorageLimitOrganization, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/permissions/selected-actions", - crate::progenitor_support::encode_path(org), + "/organizations/{}/actions/cache/storage-limit", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -332,31 +312,66 @@ impl Actions { .await } /** - * List self-hosted runner groups for an organization. + * Get GitHub Actions cache usage for an organization. * - * This function performs a `GET` to the `/orgs/{org}/actions/runner-groups` endpoint. + * This function performs a `GET` to the `/orgs/{org}/actions/cache/usage` endpoint. * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." + * Gets the total GitHub Actions cache usage for an organization. + * The data fetched using this API is refreshed approximately every 5 minutes, so values returned from this endpoint may take at least 5 minutes to get updated. * - * Lists all self-hosted runner groups configured in an organization and inherited from an enterprise. + * OAuth tokens and personal access tokens (classic) need the `read:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn get_actions_cache_usage_for_org( + &self, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/cache/usage", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List repositories with GitHub Actions cache usage for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/actions/cache/usage-by-repository` endpoint. + * + * Lists repositories and their GitHub Actions cache usage for an organization. + * The data fetched using this API is refreshed approximately every 5 minutes, so values returned from this endpoint may take at least 5 minutes to get updated. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `read:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_self_hosted_runner_groups_for_org( + pub async fn get_actions_cache_usage_by_repo_for_org( &self, org: &str, per_page: i64, page: i64, - ) -> ClientResult> - { + ) -> ClientResult> { let mut query_args: Vec<(String, String)> = Default::default(); if page > 0 { query_args.push(("page".to_string(), page.to_string())); @@ -367,8 +382,8 @@ impl Actions { let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups?{}", - crate::progenitor_support::encode_path(org), + "/orgs/{}/actions/cache/usage-by-repository?{}", + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -384,118 +399,118 @@ impl Actions { .await } /** - * Create a self-hosted runner group for an organization. - * - * This function performs a `POST` to the `/orgs/{org}/actions/runner-groups` endpoint. + * List GitHub-hosted runners for an organization. * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud and GitHub Enterprise Server. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." + * This function performs a `GET` to the `/orgs/{org}/actions/hosted-runners` endpoint. * - * Creates a new self-hosted runner group for an organization. + * Lists all GitHub-hosted runners configured in an organization. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `manage_runner:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn create_self_hosted_runner_group_for_org( + pub async fn list_hosted_runners_for_org( &self, org: &str, - body: &crate::types::ActionsCreateSelfHostedRunnerGroupOrgRequest, - ) -> ClientResult> { + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups", - crate::progenitor_support::encode_path(org), + "/orgs/{}/actions/hosted-runners?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ ), None, ); self.client - .post( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get a self-hosted runner group for an organization. - * - * This function performs a `GET` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}` endpoint. + * Create a GitHub-hosted runner for an organization. * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." + * This function performs a `POST` to the `/orgs/{org}/actions/hosted-runners` endpoint. * - * Gets a specific self-hosted runner group for an organization. - * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * Creates a GitHub-hosted runner for an organization. + * OAuth tokens and personal access tokens (classic) need the `manage_runners:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn get_self_hosted_runner_group_for_org( + pub async fn create_hosted_runner_for_org( &self, org: &str, - runner_group_id: i64, - ) -> ClientResult> { + body: &crate::types::ActionsCreateHostedRunnerOrgRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_group_id.to_string()), + "/orgs/{}/actions/hosted-runners", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Delete a self-hosted runner group from an organization. - * - * This function performs a `DELETE` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}` endpoint. + * List custom images for an organization. * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." + * This function performs a `GET` to the `/orgs/{org}/actions/hosted-runners/images/custom` endpoint. * - * Deletes a self-hosted runner group for an organization. + * List custom images for an organization. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `manage_runners:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn delete_self_hosted_runner_group_from_org( + pub async fn list_custom_images_for_org( &self, org: &str, - runner_group_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_group_id.to_string()), + "/orgs/{}/actions/hosted-runners/images/custom", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -505,95 +520,75 @@ impl Actions { .await } /** - * Update a self-hosted runner group for an organization. - * - * This function performs a `PATCH` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}` endpoint. + * Get a custom image definition for GitHub Actions Hosted Runners. * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." + * This function performs a `GET` to the `/orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}` endpoint. * - * Updates the `name` and `visibility` of a self-hosted runner group in an organization. + * Get a custom image definition for GitHub Actions Hosted Runners. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `manage_runners:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `image_definition_id: i64` -- Image definition ID of custom image. */ - pub async fn update_self_hosted_runner_group_for_org( + pub async fn get_custom_image_for_org( &self, org: &str, - runner_group_id: i64, - body: &crate::types::ActionsUpdateSelfHostedRunnerGroupOrgRequest, - ) -> ClientResult> { + image_definition_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_group_id.to_string()), + "/orgs/{}/actions/hosted-runners/images/custom/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&image_definition_id.to_string()), ), None, ); self.client - .patch( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * List repository access to a self-hosted runner group in an organization. + * Delete a custom image from the organization. * - * This function performs a `GET` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories` endpoint. - * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud and GitHub Enterprise Server. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." + * This function performs a `DELETE` to the `/orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}` endpoint. * - * Lists the repositories with access to a self-hosted runner group configured in an organization. + * Delete a custom image from the organization. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `manage_runners:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. - * * `page: i64` -- Page number of the results to fetch. - * * `per_page: i64` -- Results per page (max 100). + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `image_definition_id: i64` -- Image definition ID of custom image. */ - pub async fn list_repo_access_to_self_hosted_runner_group_in_org( + pub async fn delete_custom_image_from_org( &self, org: &str, - runner_group_id: i64, - page: i64, - per_page: i64, - ) -> ClientResult< - crate::Response, - > { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + image_definition_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups/{}/repositories?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_group_id.to_string()), - query_ + "/orgs/{}/actions/hosted-runners/images/custom/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&image_definition_id.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -603,85 +598,79 @@ impl Actions { .await } /** - * Set repository access for a self-hosted runner group in an organization. - * - * This function performs a `PUT` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories` endpoint. + * List image versions of a custom image for an organization. * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." + * This function performs a `GET` to the `/orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}/versions` endpoint. * - * Replaces the list of repositories that have access to a self-hosted runner group configured in an organization. + * List image versions of a custom image for an organization. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `manage_runners:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + * * `image_definition_id: i64` -- Image definition ID of custom image. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn set_repo_access_to_self_hosted_runner_group_in_org( + pub async fn list_custom_image_versions_for_org( &self, + image_definition_id: i64, org: &str, - runner_group_id: i64, - body: &crate::types::ActionsSetRepoAccessSelfHostedRunnerGroupInOrgRequest, - ) -> ClientResult> { + ) -> ClientResult> + { let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups/{}/repositories", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_group_id.to_string()), + "/orgs/{}/actions/hosted-runners/images/custom/{}/versions", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&image_definition_id.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Add repository access to a self-hosted runner group in an organization. - * - * This function performs a `PUT` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories/{repository_id}` endpoint. - * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." + * Get an image version of a custom image for GitHub Actions Hosted Runners. * + * This function performs a `GET` to the `/orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}/versions/{version}` endpoint. * - * Adds a repository to the list of selected repositories that can access a self-hosted runner group. The runner group must have `visibility` set to `selected`. For more information, see "[Create a self-hosted runner group for an organization](#create-a-self-hosted-runner-group-for-an-organization)." + * Get an image version of a custom image for GitHub Actions Hosted Runners. * - * You must authenticate using an access token with the `admin:org` - * scope to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `manage_runners:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. - * * `repository_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `image_definition_id: i64` -- Image definition ID of custom image. + * * `version: &str` -- Version of a custom image. */ - pub async fn add_repo_access_to_self_hosted_runner_group_in_org( + pub async fn get_custom_image_version_for_org( &self, org: &str, - runner_group_id: i64, - repository_id: i64, - ) -> ClientResult> { + image_definition_id: i64, + version: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups/{}/repositories/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_group_id.to_string()), - crate::progenitor_support::encode_path(&repository_id.to_string()), + "/orgs/{}/actions/hosted-runners/images/custom/{}/versions/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&image_definition_id.to_string()), + crate::progenitor_support::encode_path(&version.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { body: None, @@ -691,37 +680,34 @@ impl Actions { .await } /** - * Remove repository access to a self-hosted runner group in an organization. - * - * This function performs a `DELETE` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories/{repository_id}` endpoint. + * Delete an image version of custom image from the organization. * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." + * This function performs a `DELETE` to the `/orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}/versions/{version}` endpoint. * + * Delete an image version of custom image from the organization. * - * Removes a repository from the list of selected repositories that can access a self-hosted runner group. The runner group must have `visibility` set to `selected`. For more information, see "[Create a self-hosted runner group for an organization](#create-a-self-hosted-runner-group-for-an-organization)." - * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `manage_runners:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. - * * `repository_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `image_definition_id: i64` -- Image definition ID of custom image. + * * `version: &str` -- Version of a custom image. */ - pub async fn remove_repo_access_to_self_hosted_runner_group_in_org( + pub async fn delete_custom_image_version_from_org( &self, org: &str, - runner_group_id: i64, - repository_id: i64, + image_definition_id: i64, + version: &str, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups/{}/repositories/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_group_id.to_string()), - crate::progenitor_support::encode_path(&repository_id.to_string()), + "/orgs/{}/actions/hosted-runners/images/custom/{}/versions/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&image_definition_id.to_string()), + crate::progenitor_support::encode_path(&version.to_string()), ), None, ); @@ -736,47 +722,27 @@ impl Actions { .await } /** - * List self-hosted runners in a group for an organization. - * - * This function performs a `GET` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/runners` endpoint. - * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." + * Get GitHub-owned images for GitHub-hosted runners in an organization. * - * Lists self-hosted runners that are in a specific organization group. + * This function performs a `GET` to the `/orgs/{org}/actions/hosted-runners/images/github-owned` endpoint. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * Get the list of GitHub-owned images available for GitHub-hosted runners for an organization. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn list_self_hosted_runners_in_group_for_org( + pub async fn get_hosted_runners_github_owned_images_for_org( &self, org: &str, - runner_group_id: i64, - per_page: i64, - page: i64, - ) -> ClientResult> + ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups/{}/runners?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_group_id.to_string()), - query_ + "/orgs/{}/actions/hosted-runners/images/github-owned", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -791,85 +757,66 @@ impl Actions { .await } /** - * Set self-hosted runners in a group for an organization. - * - * This function performs a `PUT` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/runners` endpoint. - * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." + * Get partner images for GitHub-hosted runners in an organization. * - * Replaces the list of self-hosted runners that are part of an organization runner group. + * This function performs a `GET` to the `/orgs/{org}/actions/hosted-runners/images/partner` endpoint. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * Get the list of partner images available for GitHub-hosted runners for an organization. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn set_self_hosted_runners_in_group_for_org( + pub async fn get_hosted_runners_partner_images_for_org( &self, org: &str, - runner_group_id: i64, - body: &crate::types::ActionsSetSelfHostedRunnersInGroupOrgRequest, - ) -> ClientResult> { + ) -> ClientResult> + { let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups/{}/runners", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_group_id.to_string()), + "/orgs/{}/actions/hosted-runners/images/partner", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Add a self-hosted runner to a group for an organization. - * - * This function performs a `PUT` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/runners/{runner_id}` endpoint. - * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." - * + * Get limits on GitHub-hosted runners for an organization. * - * Adds a self-hosted runner to a runner group configured in an organization. + * This function performs a `GET` to the `/orgs/{org}/actions/hosted-runners/limits` endpoint. * - * You must authenticate using an access token with the `admin:org` - * scope to use this endpoint. + * Get the GitHub-hosted runners limits for an organization. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. - * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn add_self_hosted_runner_to_group_for_org( + pub async fn get_hosted_runners_limits_for_org( &self, org: &str, - runner_group_id: i64, - runner_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups/{}/runners/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_group_id.to_string()), - crate::progenitor_support::encode_path(&runner_id.to_string()), + "/orgs/{}/actions/hosted-runners/limits", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { body: None, @@ -879,42 +826,32 @@ impl Actions { .await } /** - * Remove a self-hosted runner from a group for an organization. - * - * This function performs a `DELETE` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/runners/{runner_id}` endpoint. - * - * The self-hosted runner groups REST API is available with GitHub Enterprise Cloud. For more information, see "[GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)." + * Get GitHub-hosted runners machine specs for an organization. * + * This function performs a `GET` to the `/orgs/{org}/actions/hosted-runners/machine-sizes` endpoint. * - * Removes a self-hosted runner from a group configured in an organization. The runner is then returned to the default group. - * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * Get the list of machine specs available for GitHub-hosted runners for an organization. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. - * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn remove_self_hosted_runner_from_group_for_org( + pub async fn get_hosted_runners_machine_specs_for_org( &self, org: &str, - runner_group_id: i64, - runner_id: i64, - ) -> ClientResult> { + ) -> ClientResult> + { let url = self.client.url( &format!( - "/orgs/{}/actions/runner-groups/{}/runners/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_group_id.to_string()), - crate::progenitor_support::encode_path(&runner_id.to_string()), + "/orgs/{}/actions/hosted-runners/machine-sizes", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -924,41 +861,27 @@ impl Actions { .await } /** - * List self-hosted runners for an organization. - * - * This function performs a `GET` to the `/orgs/{org}/actions/runners` endpoint. + * Get platforms for GitHub-hosted runners in an organization. * - * Lists all self-hosted runners configured in an organization. + * This function performs a `GET` to the `/orgs/{org}/actions/hosted-runners/platforms` endpoint. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * Get the list of platforms available for GitHub-hosted runners for an organization. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn list_self_hosted_runners_for_org( + pub async fn get_hosted_runners_platforms_for_org( &self, org: &str, - per_page: i64, - page: i64, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult> + { let url = self.client.url( &format!( - "/orgs/{}/actions/runners?{}", - crate::progenitor_support::encode_path(org), - query_ + "/orgs/{}/actions/hosted-runners/platforms", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -973,28 +896,31 @@ impl Actions { .await } /** - * List runner applications for an organization. + * Get a GitHub-hosted runner for an organization. * - * This function performs a `GET` to the `/orgs/{org}/actions/runners/downloads` endpoint. + * This function performs a `GET` to the `/orgs/{org}/actions/hosted-runners/{hosted_runner_id}` endpoint. * - * Lists binaries for the runner application that you can download and run. + * Gets a GitHub-hosted runner configured in an organization. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `manage_runners:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `hosted_runner_id: i64` -- Unique identifier of the GitHub-hosted runner. */ - pub async fn list_runner_applications_for_org( + pub async fn get_hosted_runner_for_org( &self, org: &str, - ) -> ClientResult>> { + hosted_runner_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runners/downloads", - crate::progenitor_support::encode_path(org), + "/orgs/{}/actions/hosted-runners/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hosted_runner_id.to_string()), ), None, ); @@ -1009,31 +935,34 @@ impl Actions { .await } /** - * List runner applications for an organization. + * Delete a GitHub-hosted runner for an organization. * - * This function performs a `GET` to the `/orgs/{org}/actions/runners/downloads` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/actions/hosted-runners/{hosted_runner_id}` endpoint. * - * As opposed to `list_runner_applications_for_org`, this function returns all the pages of the request at once. + * Deletes a GitHub-hosted runner for an organization. * - * Lists binaries for the runner application that you can download and run. + * FROM: * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * **Parameters:** * - * FROM: + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `hosted_runner_id: i64` -- Unique identifier of the GitHub-hosted runner. */ - pub async fn list_all_runner_applications_for_org( + pub async fn delete_hosted_runner_for_org( &self, org: &str, - ) -> ClientResult>> { + hosted_runner_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runners/downloads", - crate::progenitor_support::encode_path(org), + "/orgs/{}/actions/hosted-runners/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hosted_runner_id.to_string()), ), None, ); self.client - .get_all_pages( + .delete( &url, crate::Message { body: None, @@ -1043,41 +972,72 @@ impl Actions { .await } /** - * Create a registration token for an organization. + * Update a GitHub-hosted runner for an organization. * - * This function performs a `POST` to the `/orgs/{org}/actions/runners/registration-token` endpoint. + * This function performs a `PATCH` to the `/orgs/{org}/actions/hosted-runners/{hosted_runner_id}` endpoint. * - * Returns a token that you can pass to the `config` script. The token expires after one hour. + * Updates a GitHub-hosted runner for an organization. + * OAuth app tokens and personal access tokens (classic) need the `manage_runners:org` scope to use this endpoint. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `hosted_runner_id: i64` -- Unique identifier of the GitHub-hosted runner. + */ + pub async fn update_hosted_runner_for_org( + &self, + org: &str, + hosted_runner_id: i64, + body: &crate::types::ActionsUpdateHostedRunnerOrgRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/hosted-runners/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hosted_runner_id.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get GitHub Actions permissions for an organization. * - * #### Example using registration token + * This function performs a `GET` to the `/orgs/{org}/actions/permissions` endpoint. * - * Configure your self-hosted runner, replacing `TOKEN` with the registration token provided by this endpoint. + * Gets the GitHub Actions permissions policy for repositories and allowed actions and reusable workflows in an organization. * - * ``` - * ./config.sh --url https://github.com/octo-org --token TOKEN - * ``` + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn create_registration_token_for_org( + pub async fn get_github_actions_permissions_organization( &self, org: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runners/registration-token", - crate::progenitor_support::encode_path(org), + "/orgs/{}/actions/permissions", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .post( + .get( &url, crate::Message { body: None, @@ -1087,76 +1047,65 @@ impl Actions { .await } /** - * Create a remove token for an organization. - * - * This function performs a `POST` to the `/orgs/{org}/actions/runners/remove-token` endpoint. - * - * Returns a token that you can pass to the `config` script to remove a self-hosted runner from an organization. The token expires after one hour. - * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * Set GitHub Actions permissions for an organization. * - * #### Example using remove token + * This function performs a `PUT` to the `/orgs/{org}/actions/permissions` endpoint. * - * To remove your self-hosted runner from an organization, replace `TOKEN` with the remove token provided by this - * endpoint. + * Sets the GitHub Actions permissions policy for repositories and allowed actions and reusable workflows in an organization. * - * ``` - * ./config.sh remove --token TOKEN - * ``` + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn create_remove_token_for_org( + pub async fn set_github_actions_permissions_organization( &self, org: &str, - ) -> ClientResult> { + body: &crate::types::ActionsSetGithubPermissionsOrganizationRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runners/remove-token", - crate::progenitor_support::encode_path(org), + "/orgs/{}/actions/permissions", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .post( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Get a self-hosted runner for an organization. + * Get artifact and log retention settings for an organization. * - * This function performs a `GET` to the `/orgs/{org}/actions/runners/{runner_id}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/actions/permissions/artifact-and-log-retention` endpoint. * - * Gets a specific self-hosted runner configured in an organization. + * Gets artifact and log retention settings for an organization. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope or the "Actions policies" fine-grained permission to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn get_self_hosted_runner_for_org( + pub async fn get_artifact_and_log_retention_settings_organization( &self, org: &str, - runner_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runners/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_id.to_string()), + "/orgs/{}/actions/permissions/artifact-and-log-retention", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -1171,78 +1120,65 @@ impl Actions { .await } /** - * Delete a self-hosted runner from an organization. + * Set artifact and log retention settings for an organization. * - * This function performs a `DELETE` to the `/orgs/{org}/actions/runners/{runner_id}` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/artifact-and-log-retention` endpoint. * - * Forces the removal of a self-hosted runner from an organization. You can use this endpoint to completely remove the runner when the machine you were using no longer exists. + * Sets artifact and log retention settings for an organization. * - * You must authenticate using an access token with the `admin:org` scope to use this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope or the "Actions policies" fine-grained permission to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn delete_self_hosted_runner_from_org( + pub async fn set_artifact_and_log_retention_settings_organization( &self, org: &str, - runner_id: i64, + body: &crate::types::ActionsArtifactLogRetention, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/runners/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&runner_id.to_string()), + "/orgs/{}/actions/permissions/artifact-and-log-retention", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .delete( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List organization secrets. + * Get fork PR contributor approval permissions for an organization. * - * This function performs a `GET` to the `/orgs/{org}/actions/secrets` endpoint. + * This function performs a `GET` to the `/orgs/{org}/actions/permissions/fork-pr-contributor-approval` endpoint. * - * Lists all secrets available in an organization without revealing their encrypted values. You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `secrets` organization permission to use this endpoint. + * Gets the fork PR contributor approval policy for an organization. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope or the "Actions policies" fine-grained permission to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn list_org_secrets( + pub async fn get_fork_pr_contributor_approval_permissions_organization( &self, org: &str, - per_page: i64, - page: i64, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/secrets?{}", - crate::progenitor_support::encode_path(org), - query_ + "/orgs/{}/actions/permissions/fork-pr-contributor-approval", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -1257,63 +1193,63 @@ impl Actions { .await } /** - * Get an organization public key. + * Set fork PR contributor approval permissions for an organization. * - * This function performs a `GET` to the `/orgs/{org}/actions/secrets/public-key` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/fork-pr-contributor-approval` endpoint. + * + * Sets the fork PR contributor approval policy for an organization. * - * Gets your public key, which you need to encrypt secrets. You need to encrypt a secret before you can create or update secrets. You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `secrets` organization permission to use this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn get_org_public_key( + pub async fn set_fork_pr_contributor_approval_permissions_organization( &self, org: &str, - ) -> ClientResult> { + body: &crate::types::ActionsForkPrContributorApproval, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/secrets/public-key", - crate::progenitor_support::encode_path(org), + "/orgs/{}/actions/permissions/fork-pr-contributor-approval", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Get an organization secret. + * Get private repo fork PR workflow settings for an organization. * - * This function performs a `GET` to the `/orgs/{org}/actions/secrets/{secret_name}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/actions/permissions/fork-pr-workflows-private-repos` endpoint. * - * Gets a single organization secret without revealing its encrypted value. You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `secrets` organization permission to use this endpoint. + * Gets the settings for whether workflows from fork pull requests can run on private repositories in an organization. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `secret_name: &str` -- secret_name parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn get_org_secret( + pub async fn get_private_repo_fork_pr_workflows_settings_organization( &self, org: &str, - secret_name: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/secrets/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(secret_name), + "/orgs/{}/actions/permissions/fork-pr-workflows-private-repos", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -1328,104 +1264,157 @@ impl Actions { .await } /** - * Create or update an organization secret. + * Set private repo fork PR workflow settings for an organization. * - * This function performs a `PUT` to the `/orgs/{org}/actions/secrets/{secret_name}` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/fork-pr-workflows-private-repos` endpoint. * - * Creates or updates an organization secret with an encrypted value. Encrypt your secret using - * [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). You must authenticate using an access - * token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `secrets` organization permission to - * use this endpoint. + * Sets the settings for whether workflows from fork pull requests can run on private repositories in an organization. * - * #### Example encrypting a secret using Node.js + * FROM: * - * Encrypt your secret using the [tweetsodium](https://github.com/github/tweetsodium) library. + * **Parameters:** * - * ``` - * const sodium = require('tweetsodium'); + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn set_private_repo_fork_pr_workflows_settings_organization( + &self, + org: &str, + body: &crate::types::ActionsForkPrWorkflowsPrivateReposRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/permissions/fork-pr-workflows-private-repos", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List selected repositories enabled for GitHub Actions in an organization. * - * const key = "base64-encoded-public-key"; - * const value = "plain-text-secret"; + * This function performs a `GET` to the `/orgs/{org}/actions/permissions/repositories` endpoint. * - * // Convert the message and key to Uint8Array's (Buffer implements that interface) - * const messageBytes = Buffer.from(value); - * const keyBytes = Buffer.from(key, 'base64'); + * Lists the selected repositories that are enabled for GitHub Actions in an organization. To use this endpoint, the organization permission policy for `enabled_repositories` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." * - * // Encrypt using LibSodium. - * const encryptedBytes = sodium.seal(messageBytes, keyBytes); + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * // Base64 the encrypted secret - * const encrypted = Buffer.from(encryptedBytes).toString('base64'); + * FROM: * - * console.log(encrypted); - * ``` + * **Parameters:** * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_selected_repositories_enabled_github_actions_organization( + &self, + org: &str, + per_page: i64, + page: i64, + ) -> ClientResult< + crate::Response< + crate::types::ActionsListSelectedRepositoriesEnabledGithubOrganizationResponse, + >, + > { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/actions/permissions/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set selected repositories enabled for GitHub Actions in an organization. * - * #### Example encrypting a secret using Python - * - * Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/stable/public/#nacl-public-sealedbox) with Python 3. - * - * ``` - * from base64 import b64encode - * from nacl import encoding, public - * - * def encrypt(public_key: str, secret_value: str) -> str: - * """Encrypt a Unicode string using the public key.""" - * public_key = public.PublicKey(public_key.encode("utf-8"), encoding.Base64Encoder()) - * sealed_box = public.SealedBox(public_key) - * encrypted = sealed_box.encrypt(secret_value.encode("utf-8")) - * return b64encode(encrypted).decode("utf-8") - * ``` - * - * #### Example encrypting a secret using C# - * - * Encrypt your secret using the [Sodium.Core](https://www.nuget.org/packages/Sodium.Core/) package. + * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/repositories` endpoint. * - * ``` - * var secretValue = System.Text.Encoding.UTF8.GetBytes("mySecret"); - * var publicKey = Convert.FromBase64String("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvvcCU="); + * Replaces the list of selected repositories that are enabled for GitHub Actions in an organization. To use this endpoint, the organization permission policy for `enabled_repositories` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." * - * var sealedPublicKeyBox = Sodium.SealedPublicKeyBox.Create(secretValue, publicKey); * - * Console.WriteLine(Convert.ToBase64String(sealedPublicKeyBox)); - * ``` + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * #### Example encrypting a secret using Ruby + * FROM: * - * Encrypt your secret using the [rbnacl](https://github.com/RubyCrypto/rbnacl) gem. + * **Parameters:** * - * ```ruby - * require "rbnacl" - * require "base64" + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn set_selected_repositories_enabled_github_actions_organization( + &self, + org: &str, + body: &crate::types::CodespacesSetRepositoriesSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/permissions/repositories", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Enable a selected repository for GitHub Actions in an organization. * - * key = Base64.decode64("+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0=") - * public_key = RbNaCl::PublicKey.new(key) + * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/repositories/{repository_id}` endpoint. * - * box = RbNaCl::Boxes::Sealed.from_public_key(public_key) - * encrypted_secret = box.encrypt("my_secret") + * Adds a repository to the list of selected repositories that are enabled for GitHub Actions in an organization. To use this endpoint, the organization permission policy for `enabled_repositories` must be must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." * - * # Print the base64 encoded secret - * puts Base64.strict_encode64(encrypted_secret) - * ``` + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `secret_name: &str` -- secret_name parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `repository_id: i64` -- The unique identifier of the repository. */ - pub async fn create_or_update_org_secret( + pub async fn enable_selected_repository_github_actions_organization( &self, org: &str, - secret_name: &str, - body: &crate::types::ActionsCreateUpdateOrgSecretRequest, + repository_id: i64, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/secrets/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(secret_name), + "/orgs/{}/actions/permissions/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), ), None, ); @@ -1433,36 +1422,38 @@ impl Actions { .put( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Delete an organization secret. + * Disable a selected repository for GitHub Actions in an organization. * - * This function performs a `DELETE` to the `/orgs/{org}/actions/secrets/{secret_name}` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/actions/permissions/repositories/{repository_id}` endpoint. + * + * Removes a repository from the list of selected repositories that are enabled for GitHub Actions in an organization. To use this endpoint, the organization permission policy for `enabled_repositories` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." * - * Deletes a secret in an organization using the secret name. You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `secrets` organization permission to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `secret_name: &str` -- secret_name parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `repository_id: i64` -- The unique identifier of the repository. */ - pub async fn delete_org_secret( + pub async fn disable_selected_repository_github_actions_organization( &self, org: &str, - secret_name: &str, + repository_id: i64, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/secrets/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(secret_name), + "/orgs/{}/actions/permissions/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), ), None, ); @@ -1477,43 +1468,28 @@ impl Actions { .await } /** - * List selected repositories for an organization secret. + * Get allowed actions and reusable workflows for an organization. * - * This function performs a `GET` to the `/orgs/{org}/actions/secrets/{secret_name}/repositories` endpoint. + * This function performs a `GET` to the `/orgs/{org}/actions/permissions/selected-actions` endpoint. + * + * Gets the selected actions and reusable workflows that are allowed in an organization. To use this endpoint, the organization permission policy for `allowed_actions` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." * - * Lists all repositories that have been selected when the `visibility` for repository access to a secret is set to `selected`. You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `secrets` organization permission to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `secret_name: &str` -- secret_name parameter. - * * `page: i64` -- Page number of the results to fetch. - * * `per_page: i64` -- Results per page (max 100). + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn list_selected_repos_for_org_secret( + pub async fn get_allowed_actions_organization( &self, org: &str, - secret_name: &str, - page: i64, - per_page: i64, - ) -> ClientResult> - { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/secrets/{}/repositories?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(secret_name), - query_ + "/orgs/{}/actions/permissions/selected-actions", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -1528,30 +1504,29 @@ impl Actions { .await } /** - * Set selected repositories for an organization secret. + * Set allowed actions and reusable workflows for an organization. * - * This function performs a `PUT` to the `/orgs/{org}/actions/secrets/{secret_name}/repositories` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/selected-actions` endpoint. + * + * Sets the actions and reusable workflows that are allowed in an organization. To use this endpoint, the organization permission policy for `allowed_actions` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." * - * Replaces all repositories for an organization secret when the `visibility` for repository access is set to `selected`. The visibility is set when you [Create or update an organization secret](https://docs.github.com/rest/reference/actions#create-or-update-an-organization-secret). You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `secrets` organization permission to use this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `secret_name: &str` -- secret_name parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn set_selected_repos_for_org_secret( + pub async fn set_allowed_actions_organization( &self, org: &str, - secret_name: &str, - body: &crate::types::ActionsSetSelectedReposOrgSecretRequest, + body: &crate::types::SelectedActions, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/secrets/{}/repositories", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(secret_name), + "/orgs/{}/actions/permissions/selected-actions", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -1566,37 +1541,33 @@ impl Actions { .await } /** - * Add selected repository to an organization secret. + * Get self-hosted runners settings for an organization. * - * This function performs a `PUT` to the `/orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/actions/permissions/self-hosted-runners` endpoint. * - * Adds a repository to an organization secret when the `visibility` for repository access is set to `selected`. The visibility is set when you [Create or update an organization secret](https://docs.github.com/rest/reference/actions#create-or-update-an-organization-secret). You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `secrets` organization permission to use this endpoint. + * Gets the settings for self-hosted runners for an organization. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope or the "Actions policies" fine-grained permission to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `secret_name: &str` -- secret_name parameter. - * * `repository_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn add_selected_repo_to_org_secret( + pub async fn get_self_hosted_runners_permissions_organization( &self, org: &str, - secret_name: &str, - repository_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/secrets/{}/repositories/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(secret_name), - crate::progenitor_support::encode_path(&repository_id.to_string()), + "/orgs/{}/actions/permissions/self-hosted-runners", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { body: None, @@ -1606,68 +1577,69 @@ impl Actions { .await } /** - * Remove selected repository from an organization secret. + * Set self-hosted runners settings for an organization. * - * This function performs a `DELETE` to the `/orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/self-hosted-runners` endpoint. * - * Removes a repository from an organization secret when the `visibility` for repository access is set to `selected`. The visibility is set when you [Create or update an organization secret](https://docs.github.com/rest/reference/actions#create-or-update-an-organization-secret). You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `secrets` organization permission to use this endpoint. + * Sets the settings for self-hosted runners for an organization. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope or the "Actions policies" fine-grained permission to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `secret_name: &str` -- secret_name parameter. - * * `repository_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn remove_selected_repo_from_org_secret( + pub async fn set_self_hosted_runners_permissions_organization( &self, org: &str, - secret_name: &str, - repository_id: i64, + body: &crate::types::ActionsSetSelfHostedRunnersPermissionsOrganizationRequest, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/actions/secrets/{}/repositories/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(secret_name), - crate::progenitor_support::encode_path(&repository_id.to_string()), + "/orgs/{}/actions/permissions/self-hosted-runners", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .delete( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List artifacts for a repository. + * List repositories allowed to use self-hosted runners in an organization. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/artifacts` endpoint. + * This function performs a `GET` to the `/orgs/{org}/actions/permissions/self-hosted-runners/repositories` endpoint. + * + * Lists repositories that are allowed to use self-hosted runners in an organization. * - * Lists all artifacts for a repository. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope or the "Actions policies" fine-grained permission to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_artifacts_for_repo( + pub async fn list_selected_repositories_self_hosted_runners_organization( &self, - owner: &str, - repo: &str, + org: &str, per_page: i64, page: i64, - ) -> ClientResult> { + ) -> ClientResult< + crate::Response< + crate::types::ActionsListSelectedRepositoriesSelfHostedRunnersOrganizationResponse, + >, + > { let mut query_args: Vec<(String, String)> = Default::default(); if page > 0 { query_args.push(("page".to_string(), page.to_string())); @@ -1678,9 +1650,8 @@ impl Actions { let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/actions/artifacts?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/orgs/{}/actions/permissions/self-hosted-runners/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -1696,77 +1667,73 @@ impl Actions { .await } /** - * Get an artifact. + * Set repositories allowed to use self-hosted runners in an organization. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/artifacts/{artifact_id}` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/self-hosted-runners/repositories` endpoint. * - * Gets a specific artifact for a workflow run. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * Sets repositories that are allowed to use self-hosted runners in an organization. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope or the "Actions policies" fine-grained permission to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `artifact_id: i64` -- artifact_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn get_artifact( + pub async fn set_selected_repositories_self_hosted_runners_organization( &self, - owner: &str, - repo: &str, - artifact_id: i64, - ) -> ClientResult> { + org: &str, + body: &crate::types::CodespacesSetRepositoriesSecretRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/artifacts/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&artifact_id.to_string()), + "/orgs/{}/actions/permissions/self-hosted-runners/repositories", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Delete an artifact. + * Add a repository to the list of repositories allowed to use self-hosted runners in an organization. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/artifacts/{artifact_id}` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/self-hosted-runners/repositories/{repository_id}` endpoint. * - * Deletes an artifact for a workflow run. You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `actions:write` permission to use this endpoint. + * Adds a repository to the list of repositories that are allowed to use self-hosted runners in an organization. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope or the "Actions policies" fine-grained permission to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `artifact_id: i64` -- artifact_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `repository_id: i64` -- The unique identifier of the repository. */ - pub async fn delete_artifact( + pub async fn enable_selected_repository_self_hosted_runners_organization( &self, - owner: &str, - repo: &str, - artifact_id: i64, + org: &str, + repository_id: i64, ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/artifacts/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&artifact_id.to_string()), + "/orgs/{}/actions/permissions/self-hosted-runners/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), ), None, ); self.client - .delete( + .put( &url, crate::Message { body: None, @@ -1776,43 +1743,36 @@ impl Actions { .await } /** - * Download an artifact. + * Remove a repository from the list of repositories allowed to use self-hosted runners in an organization. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/actions/permissions/self-hosted-runners/repositories/{repository_id}` endpoint. * - * Gets a redirect URL to download an archive for a repository. This URL expires after 1 minute. Look for `Location:` in - * the response header to find the URL for the download. The `:archive_format` must be `zip`. Anyone with read access to - * the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. - * GitHub Apps must have the `actions:read` permission to use this endpoint. + * Removes a repository from the list of repositories that are allowed to use self-hosted runners in an organization. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope or the "Actions policies" fine-grained permission to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `artifact_id: i64` -- artifact_id parameter. - * * `archive_format: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `repository_id: i64` -- The unique identifier of the repository. */ - pub async fn download_artifact( + pub async fn disable_selected_repository_self_hosted_runners_organization( &self, - owner: &str, - repo: &str, - artifact_id: i64, - archive_format: &str, + org: &str, + repository_id: i64, ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/artifacts/{}/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&artifact_id.to_string()), - crate::progenitor_support::encode_path(archive_format), + "/orgs/{}/actions/permissions/self-hosted-runners/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -1822,32 +1782,30 @@ impl Actions { .await } /** - * Get a job for a workflow run. + * Get default workflow permissions for an organization. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/jobs/{job_id}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/actions/permissions/workflow` endpoint. + * + * Gets the default workflow permissions granted to the `GITHUB_TOKEN` when running workflows in an organization, + * as well as whether GitHub Actions can submit approving pull request reviews. For more information, see + * "[Setting the permissions of the GITHUB_TOKEN for your organization](https://docs.github.com/organizations/managing-organization-settings/disabling-or-limiting-github-actions-for-your-organization#setting-the-permissions-of-the-github_token-for-your-organization)." * - * Gets a specific job in a workflow run. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `job_id: i64` -- job_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn get_job_for_workflow_run( + pub async fn get_github_actions_default_workflow_permissions_organization( &self, - owner: &str, - repo: &str, - job_id: i64, - ) -> ClientResult> { + org: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/jobs/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&job_id.to_string()), + "/orgs/{}/actions/permissions/workflow", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -1862,80 +1820,3826 @@ impl Actions { .await } /** - * Download job logs for a workflow run. + * Set default workflow permissions for an organization. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/jobs/{job_id}/logs` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/actions/permissions/workflow` endpoint. * - * Gets a redirect URL to download a plain text file of logs for a workflow job. This link expires after 1 minute. Look - * for `Location:` in the response header to find the URL for the download. Anyone with read access to the repository can - * use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must - * have the `actions:read` permission to use this endpoint. + * Sets the default workflow permissions granted to the `GITHUB_TOKEN` when running workflows in an organization, and sets if GitHub Actions + * can submit approving pull request reviews. For more information, see + * "[Setting the permissions of the GITHUB_TOKEN for your organization](https://docs.github.com/organizations/managing-organization-settings/disabling-or-limiting-github-actions-for-your-organization#setting-the-permissions-of-the-github_token-for-your-organization)." + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `job_id: i64` -- job_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn download_job_logs_for_workflow_run( + pub async fn set_github_actions_default_workflow_permissions_organization( &self, - owner: &str, - repo: &str, - job_id: i64, + org: &str, + body: &crate::types::ActionsSetDefaultWorkflowPermissions, ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/jobs/{}/logs", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&job_id.to_string()), + "/orgs/{}/actions/permissions/workflow", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Get GitHub Actions permissions for a repository. + * List self-hosted runner groups for an organization. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/permissions` endpoint. + * This function performs a `GET` to the `/orgs/{org}/actions/runner-groups` endpoint. * - * Gets the GitHub Actions permissions policy for a repository, including whether GitHub Actions is enabled and the actions allowed to run in the repository. + * Lists all self-hosted runner groups configured in an organization and inherited from an enterprise. * - * You must authenticate using an access token with the `repo` scope to use this - * endpoint. GitHub Apps must have the `administration` repository permission to use this API. + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `visible_to_repository: &str` -- Only return runner groups that are allowed to be used by this repository. */ - pub async fn get_github_actions_permissions_repository( + pub async fn list_self_hosted_runner_groups_for_org( + &self, + org: &str, + per_page: i64, + page: i64, + visible_to_repository: &str, + ) -> ClientResult> + { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !visible_to_repository.is_empty() { + query_args.push(( + "visible_to_repository".to_string(), + visible_to_repository.to_string(), + )); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a self-hosted runner group for an organization. + * + * This function performs a `POST` to the `/orgs/{org}/actions/runner-groups` endpoint. + * + * Creates a new self-hosted runner group for an organization. + * + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_self_hosted_runner_group_for_org( + &self, + org: &str, + body: &crate::types::ActionsCreateSelfHostedRunnerGroupOrgRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a self-hosted runner group for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}` endpoint. + * + * Gets a specific self-hosted runner group for an organization. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + */ + pub async fn get_self_hosted_runner_group_for_org( + &self, + org: &str, + runner_group_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_group_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a self-hosted runner group from an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}` endpoint. + * + * Deletes a self-hosted runner group for an organization. + * + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + */ + pub async fn delete_self_hosted_runner_group_from_org( + &self, + org: &str, + runner_group_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_group_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a self-hosted runner group for an organization. + * + * This function performs a `PATCH` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}` endpoint. + * + * Updates the `name` and `visibility` of a self-hosted runner group in an organization. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + */ + pub async fn update_self_hosted_runner_group_for_org( + &self, + org: &str, + runner_group_id: i64, + body: &crate::types::ActionsUpdateSelfHostedRunnerGroupOrgRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_group_id.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List GitHub-hosted runners in a group for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/hosted-runners` endpoint. + * + * Lists the GitHub-hosted runners in an organization group. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_github_hosted_runners_in_group_for_org( + &self, + org: &str, + runner_group_id: i64, + per_page: i64, + page: i64, + ) -> ClientResult> + { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups/{}/hosted-runners?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_group_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List repository access to a self-hosted runner group in an organization. + * + * This function performs a `GET` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories` endpoint. + * + * Lists the repositories with access to a self-hosted runner group configured in an organization. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_repo_access_to_self_hosted_runner_group_in_org( + &self, + org: &str, + runner_group_id: i64, + page: i64, + per_page: i64, + ) -> ClientResult< + crate::Response, + > { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups/{}/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_group_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set repository access for a self-hosted runner group in an organization. + * + * This function performs a `PUT` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories` endpoint. + * + * Replaces the list of repositories that have access to a self-hosted runner group configured in an organization. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + */ + pub async fn set_repo_access_to_self_hosted_runner_group_in_org( + &self, + org: &str, + runner_group_id: i64, + body: &crate::types::CodespacesSetRepositoriesSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups/{}/repositories", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_group_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Add repository access to a self-hosted runner group in an organization. + * + * This function performs a `PUT` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories/{repository_id}` endpoint. + * + * Adds a repository to the list of repositories that can access a self-hosted runner group. The runner group must have `visibility` set to `selected`. For more information, see "[Create a self-hosted runner group for an organization](#create-a-self-hosted-runner-group-for-an-organization)." + * + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + * * `repository_id: i64` -- The unique identifier of the repository. + */ + pub async fn add_repo_access_to_self_hosted_runner_group_in_org( + &self, + org: &str, + runner_group_id: i64, + repository_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups/{}/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_group_id.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove repository access to a self-hosted runner group in an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories/{repository_id}` endpoint. + * + * Removes a repository from the list of selected repositories that can access a self-hosted runner group. The runner group must have `visibility` set to `selected`. For more information, see "[Create a self-hosted runner group for an organization](#create-a-self-hosted-runner-group-for-an-organization)." + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + * * `repository_id: i64` -- The unique identifier of the repository. + */ + pub async fn remove_repo_access_to_self_hosted_runner_group_in_org( + &self, + org: &str, + runner_group_id: i64, + repository_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups/{}/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_group_id.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List self-hosted runners in a group for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/runners` endpoint. + * + * Lists self-hosted runners that are in a specific organization group. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_self_hosted_runners_in_group_for_org( + &self, + org: &str, + runner_group_id: i64, + per_page: i64, + page: i64, + ) -> ClientResult> + { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups/{}/runners?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_group_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set self-hosted runners in a group for an organization. + * + * This function performs a `PUT` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/runners` endpoint. + * + * Replaces the list of self-hosted runners that are part of an organization runner group. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + */ + pub async fn set_self_hosted_runners_in_group_for_org( + &self, + org: &str, + runner_group_id: i64, + body: &crate::types::ActionsSetSelfHostedRunnersInGroupOrgRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups/{}/runners", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_group_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Add a self-hosted runner to a group for an organization. + * + * This function performs a `PUT` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/runners/{runner_id}` endpoint. + * + * Adds a self-hosted runner to a runner group configured in an organization. + * + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + */ + pub async fn add_self_hosted_runner_to_group_for_org( + &self, + org: &str, + runner_group_id: i64, + runner_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups/{}/runners/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_group_id.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove a self-hosted runner from a group for an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/actions/runner-groups/{runner_group_id}/runners/{runner_id}` endpoint. + * + * Removes a self-hosted runner from a group configured in an organization. The runner is then returned to the default group. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_group_id: i64` -- Unique identifier of the self-hosted runner group. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + */ + pub async fn remove_self_hosted_runner_from_group_for_org( + &self, + org: &str, + runner_group_id: i64, + runner_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runner-groups/{}/runners/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_group_id.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List self-hosted runners for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/actions/runners` endpoint. + * + * Lists all self-hosted runners configured in an organization. + * + * Authenticated users must have admin access to the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `name: &str` -- The name of a self-hosted runner. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_self_hosted_runners_for_org( + &self, + name: &str, + org: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !name.is_empty() { + query_args.push(("name".to_string(), name.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List runner applications for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/actions/runners/downloads` endpoint. + * + * Lists binaries for the runner application that you can download and run. + * + * Authenticated users must have admin access to the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn list_runner_applications_for_org( + &self, + org: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners/downloads", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List runner applications for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/actions/runners/downloads` endpoint. + * + * As opposed to `list_runner_applications_for_org`, this function returns all the pages of the request at once. + * + * Lists binaries for the runner application that you can download and run. + * + * Authenticated users must have admin access to the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + */ + pub async fn list_all_runner_applications_for_org( + &self, + org: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners/downloads", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create configuration for a just-in-time runner for an organization. + * + * This function performs a `POST` to the `/orgs/{org}/actions/runners/generate-jitconfig` endpoint. + * + * Generates a configuration that can be passed to the runner application at startup. + * + * The authenticated user must have admin access to the organization. + * + * OAuth tokens and personal access tokens (classic) need the`admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn generate_runner_jitconfig_for_org( + &self, + org: &str, + body: &crate::types::ActionsGenerateRunnerJitconfigOrgRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners/generate-jitconfig", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Create a registration token for an organization. + * + * This function performs a `POST` to the `/orgs/{org}/actions/runners/registration-token` endpoint. + * + * Returns a token that you can pass to the `config` script. The token expires after one hour. + * + * For example, you can replace `TOKEN` in the following example with the registration token provided by this endpoint to configure your self-hosted runner: + * + * ``` + * ./config.sh --url https://github.com/octo-org --token TOKEN + * ``` + * + * Authenticated users must have admin access to the organization to use this endpoint. + * + * OAuth tokens and personal access tokens (classic) need the`admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_registration_token_for_org( + &self, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners/registration-token", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a remove token for an organization. + * + * This function performs a `POST` to the `/orgs/{org}/actions/runners/remove-token` endpoint. + * + * Returns a token that you can pass to the `config` script to remove a self-hosted runner from an organization. The token expires after one hour. + * + * For example, you can replace `TOKEN` in the following example with the registration token provided by this endpoint to remove your self-hosted runner from an organization: + * + * ``` + * ./config.sh remove --token TOKEN + * ``` + * + * Authenticated users must have admin access to the organization to use this endpoint. + * + * OAuth tokens and personal access tokens (classic) need the`admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_remove_token_for_org( + &self, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners/remove-token", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a self-hosted runner for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/actions/runners/{runner_id}` endpoint. + * + * Gets a specific self-hosted runner configured in an organization. + * + * Authenticated users must have admin access to the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + */ + pub async fn get_self_hosted_runner_for_org( + &self, + org: &str, + runner_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a self-hosted runner from an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/actions/runners/{runner_id}` endpoint. + * + * Forces the removal of a self-hosted runner from an organization. You can use this endpoint to completely remove the runner when the machine you were using no longer exists. + * + * Authenticated users must have admin access to the organization to use this endpoint. + * + * OAuth tokens and personal access tokens (classic) need the`admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + */ + pub async fn delete_self_hosted_runner_from_org( + &self, + org: &str, + runner_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List labels for a self-hosted runner for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/actions/runners/{runner_id}/labels` endpoint. + * + * Lists all labels for a self-hosted runner configured in an organization. + * + * Authenticated users must have admin access to the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + */ + pub async fn list_labels_for_self_hosted_runner_for_org( + &self, + org: &str, + runner_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners/{}/labels", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set custom labels for a self-hosted runner for an organization. + * + * This function performs a `PUT` to the `/orgs/{org}/actions/runners/{runner_id}/labels` endpoint. + * + * Remove all previous custom labels and set the new custom labels for a specific + * self-hosted runner configured in an organization. + * + * Authenticated users must have admin access to the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + */ + pub async fn set_custom_labels_for_self_hosted_runner_for_org( + &self, + org: &str, + runner_id: i64, + body: &crate::types::IssuesAddLabelsRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners/{}/labels", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Add custom labels to a self-hosted runner for an organization. + * + * This function performs a `POST` to the `/orgs/{org}/actions/runners/{runner_id}/labels` endpoint. + * + * Adds custom labels to a self-hosted runner configured in an organization. + * + * Authenticated users must have admin access to the organization to use this endpoint. + * + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + */ + pub async fn add_custom_labels_to_self_hosted_runner_for_org( + &self, + org: &str, + runner_id: i64, + body: &crate::types::IssuesAddLabelsRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners/{}/labels", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Remove all custom labels from a self-hosted runner for an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/actions/runners/{runner_id}/labels` endpoint. + * + * Remove all custom labels from a self-hosted runner configured in an + * organization. Returns the remaining read-only labels from the runner. + * + * Authenticated users must have admin access to the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + */ + pub async fn remove_all_custom_labels_from_self_hosted_runner_for_org( + &self, + org: &str, + runner_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners/{}/labels", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove a custom label from a self-hosted runner for an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/actions/runners/{runner_id}/labels/{name}` endpoint. + * + * Remove a custom label from a self-hosted runner configured + * in an organization. Returns the remaining labels from the runner. + * + * This endpoint returns a `404 Not Found` status if the custom label is not + * present on the runner. + * + * Authenticated users must have admin access to the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + * * `name: &str` -- The name of a self-hosted runner's custom label. + */ + pub async fn remove_custom_label_from_self_hosted_runner_for_org( + &self, + org: &str, + runner_id: i64, + name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/runners/{}/labels/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List organization secrets. + * + * This function performs a `GET` to the `/orgs/{org}/actions/secrets` endpoint. + * + * Lists all secrets available in an organization without revealing their + * encrypted values. + * + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_org_secrets( + &self, + org: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/actions/secrets?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get an organization public key. + * + * This function performs a `GET` to the `/orgs/{org}/actions/secrets/public-key` endpoint. + * + * Gets your public key, which you need to encrypt secrets. You need to + * encrypt a secret before you can create or update secrets. + * + * The authenticated user must have collaborator access to a repository to create, update, or read secrets. + * + * OAuth tokens and personal access tokens (classic) need the`admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn get_org_public_key( + &self, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/secrets/public-key", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get an organization secret. + * + * This function performs a `GET` to the `/orgs/{org}/actions/secrets/{secret_name}` endpoint. + * + * Gets a single organization secret without revealing its encrypted value. + * + * The authenticated user must have collaborator access to a repository to create, update, or read secrets + * + * OAuth tokens and personal access tokens (classic) need the`admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn get_org_secret( + &self, + org: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/secrets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create or update an organization secret. + * + * This function performs a `PUT` to the `/orgs/{org}/actions/secrets/{secret_name}` endpoint. + * + * Creates or updates an organization secret with an encrypted value. Encrypt your secret using + * [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api)." + * + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. + * + * OAuth tokens and personal access tokens (classic) need the`admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn create_or_update_org_secret( + &self, + org: &str, + secret_name: &str, + body: &crate::types::ActionsCreateUpdateOrgSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/secrets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete an organization secret. + * + * This function performs a `DELETE` to the `/orgs/{org}/actions/secrets/{secret_name}` endpoint. + * + * Deletes a secret in an organization using the secret name. + * + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. + * + * OAuth tokens and personal access tokens (classic) need the`admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn delete_org_secret( + &self, + org: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/secrets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List selected repositories for an organization secret. + * + * This function performs a `GET` to the `/orgs/{org}/actions/secrets/{secret_name}/repositories` endpoint. + * + * Lists all repositories that have been selected when the `visibility` + * for repository access to a secret is set to `selected`. + * + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_selected_repos_for_org_secret( + &self, + org: &str, + secret_name: &str, + page: i64, + per_page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/actions/secrets/{}/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set selected repositories for an organization secret. + * + * This function performs a `PUT` to the `/orgs/{org}/actions/secrets/{secret_name}/repositories` endpoint. + * + * Replaces all repositories for an organization secret when the `visibility` + * for repository access is set to `selected`. The visibility is set when you [Create + * or update an organization secret](https://docs.github.com/rest/actions/secrets#create-or-update-an-organization-secret). + * + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn set_selected_repos_for_org_secret( + &self, + org: &str, + secret_name: &str, + body: &crate::types::CodespacesSetRepositoriesSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/secrets/{}/repositories", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Add selected repository to an organization secret. + * + * This function performs a `PUT` to the `/orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}` endpoint. + * + * Adds a repository to an organization secret when the `visibility` for + * repository access is set to `selected`. For more information about setting the visibility, see [Create or + * update an organization secret](https://docs.github.com/rest/actions/secrets#create-or-update-an-organization-secret). + * + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. + * + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + * * `repository_id: i64` + */ + pub async fn add_selected_repo_to_org_secret( + &self, + org: &str, + secret_name: &str, + repository_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/secrets/{}/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove selected repository from an organization secret. + * + * This function performs a `DELETE` to the `/orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}` endpoint. + * + * Removes a repository from an organization secret when the `visibility` + * for repository access is set to `selected`. The visibility is set when you [Create + * or update an organization secret](https://docs.github.com/rest/actions/secrets#create-or-update-an-organization-secret). + * + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + * * `repository_id: i64` + */ + pub async fn remove_selected_repo_from_org_secret( + &self, + org: &str, + secret_name: &str, + repository_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/secrets/{}/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List organization variables. + * + * This function performs a `GET` to the `/orgs/{org}/actions/variables` endpoint. + * + * Lists all organization variables. + * + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 30). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_org_variables( + &self, + org: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/actions/variables?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create an organization variable. + * + * This function performs a `POST` to the `/orgs/{org}/actions/variables` endpoint. + * + * Creates an organization variable that you can reference in a GitHub Actions workflow. + * + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth tokens and personal access tokens (classic) need the`admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_org_variable( + &self, + org: &str, + body: &crate::types::ActionsCreateOrgVariableRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/variables", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get an organization variable. + * + * This function performs a `GET` to the `/orgs/{org}/actions/variables/{name}` endpoint. + * + * Gets a specific variable in an organization. + * + * The authenticated user must have collaborator access to a repository to create, update, or read variables. + * + * OAuth tokens and personal access tokens (classic) need the`admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `name: &str` -- The name of the variable. + */ + pub async fn get_org_variable( + &self, + org: &str, + name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/variables/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete an organization variable. + * + * This function performs a `DELETE` to the `/orgs/{org}/actions/variables/{name}` endpoint. + * + * Deletes an organization variable using the variable name. + * + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth tokens and personal access tokens (classic) need the`admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `name: &str` -- The name of the variable. + */ + pub async fn delete_org_variable( + &self, + org: &str, + name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/variables/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update an organization variable. + * + * This function performs a `PATCH` to the `/orgs/{org}/actions/variables/{name}` endpoint. + * + * Updates an organization variable that you can reference in a GitHub Actions workflow. + * + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `name: &str` -- The name of the variable. + */ + pub async fn update_org_variable( + &self, + org: &str, + name: &str, + body: &crate::types::ActionsUpdateOrgVariableRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/variables/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List selected repositories for an organization variable. + * + * This function performs a `GET` to the `/orgs/{org}/actions/variables/{name}/repositories` endpoint. + * + * Lists all repositories that can access an organization variable + * that is available to selected repositories. + * + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `name: &str` -- The name of the variable. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_selected_repos_for_org_variable( + &self, + org: &str, + name: &str, + page: i64, + per_page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/actions/variables/{}/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set selected repositories for an organization variable. + * + * This function performs a `PUT` to the `/orgs/{org}/actions/variables/{name}/repositories` endpoint. + * + * Replaces all repositories for an organization variable that is available + * to selected repositories. Organization variables that are available to selected + * repositories have their `visibility` field set to `selected`. + * + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `name: &str` -- The name of the variable. + */ + pub async fn set_selected_repos_for_org_variable( + &self, + org: &str, + name: &str, + body: &crate::types::CodespacesSetRepositoriesSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/variables/{}/repositories", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Add selected repository to an organization variable. + * + * This function performs a `PUT` to the `/orgs/{org}/actions/variables/{name}/repositories/{repository_id}` endpoint. + * + * Adds a repository to an organization variable that is available to selected repositories. + * Organization variables that are available to selected repositories have their `visibility` field set to `selected`. + * + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. + * + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `name: &str` -- The name of the variable. + * * `repository_id: i64` + */ + pub async fn add_selected_repo_to_org_variable( + &self, + org: &str, + name: &str, + repository_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/variables/{}/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove selected repository from an organization variable. + * + * This function performs a `DELETE` to the `/orgs/{org}/actions/variables/{name}/repositories/{repository_id}` endpoint. + * + * Removes a repository from an organization variable that is + * available to selected repositories. Organization variables that are available to + * selected repositories have their `visibility` field set to `selected`. + * + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `name: &str` -- The name of the variable. + * * `repository_id: i64` + */ + pub async fn remove_selected_repo_from_org_variable( + &self, + org: &str, + name: &str, + repository_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/variables/{}/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List artifacts for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/artifacts` endpoint. + * + * Lists all artifacts for a repository. + * + * Anyone with read access to the repository can use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `name: &str` -- The name field of an artifact. When specified, only artifacts with this name will be returned. + */ + pub async fn list_artifacts_for_repo( + &self, + owner: &str, + repo: &str, + per_page: i64, + page: i64, + name: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !name.is_empty() { + query_args.push(("name".to_string(), name.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/artifacts?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get an artifact. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/artifacts/{artifact_id}` endpoint. + * + * Gets a specific artifact for a workflow run. + * + * Anyone with read access to the repository can use this endpoint. + * + * If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `artifact_id: i64` -- The unique identifier of the artifact. + */ + pub async fn get_artifact( + &self, + owner: &str, + repo: &str, + artifact_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/artifacts/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&artifact_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete an artifact. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/artifacts/{artifact_id}` endpoint. + * + * Deletes an artifact for a workflow run. + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `artifact_id: i64` -- The unique identifier of the artifact. + */ + pub async fn delete_artifact( + &self, + owner: &str, + repo: &str, + artifact_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/artifacts/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&artifact_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Download an artifact. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}` endpoint. + * + * Gets a redirect URL to download an archive for a repository. This URL expires after 1 minute. Look for `Location:` in + * the response header to find the URL for the download. The `:archive_format` must be `zip`. + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `artifact_id: i64` -- The unique identifier of the artifact. + * * `archive_format: &str` + */ + pub async fn download_artifact( + &self, + owner: &str, + repo: &str, + artifact_id: i64, + archive_format: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/artifacts/{}/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&artifact_id.to_string()), + crate::progenitor_support::encode_path(&archive_format.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get GitHub Actions cache retention limit for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/cache/retention-limit` endpoint. + * + * Gets GitHub Actions cache retention limit for a repository. This determines how long caches will be retained for, if + * not manually removed or evicted due to size constraints. + * + * OAuth tokens and personal access tokens (classic) need the `admin:repository` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_actions_cache_retention_limit_for_repository( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/cache/retention-limit", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set GitHub Actions cache retention limit for a repository. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/cache/retention-limit` endpoint. + * + * Sets GitHub Actions cache retention limit for a repository. This determines how long caches will be retained for, if + * not manually removed or evicted due to size constraints. + * + * OAuth tokens and personal access tokens (classic) need the `admin:repository` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn set_actions_cache_retention_limit_for_repository( + &self, + owner: &str, + repo: &str, + body: &crate::types::ActionsCacheRetentionLimitRepository, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/cache/retention-limit", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get GitHub Actions cache storage limit for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/cache/storage-limit` endpoint. + * + * Gets GitHub Actions cache storage limit for a repository. This determines the maximum size of caches that can be + * stored before eviction occurs. + * + * OAuth tokens and personal access tokens (classic) need the `admin:repository` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_actions_cache_storage_limit_for_repository( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/cache/storage-limit", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set GitHub Actions cache storage limit for a repository. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/cache/storage-limit` endpoint. + * + * Sets GitHub Actions cache storage limit for a repository. This determines the maximum size of caches that can be + * stored before eviction occurs. + * + * OAuth tokens and personal access tokens (classic) need the `admin:repository` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn set_actions_cache_storage_limit_for_repository( + &self, + owner: &str, + repo: &str, + body: &crate::types::ActionsCacheStorageLimitRepository, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/cache/storage-limit", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get GitHub Actions cache usage for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/cache/usage` endpoint. + * + * Gets GitHub Actions cache usage for a repository. + * The data fetched using this API is refreshed approximately every 5 minutes, so values returned from this endpoint may take at least 5 minutes to get updated. + * + * Anyone with read access to the repository can use this endpoint. + * + * If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_actions_cache_usage( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/cache/usage", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List GitHub Actions caches for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/caches` endpoint. + * + * Lists the GitHub Actions caches for a repository. + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `ref_: &str` -- The full Git reference for narrowing down the cache. The `ref` for a branch should be formatted as `refs/heads/`. To reference a pull request use `refs/pull//merge`. + * * `key: &str` -- An explicit key or prefix for identifying the cache. + * * `sort: crate::types::ActionsCacheListSort` -- The property to sort the results by. `created_at` means when the cache was created. `last_accessed_at` means when the cache was last accessed. `size_in_bytes` is the size of the cache in bytes. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + */ + pub async fn get_actions_cache_list( + &self, + owner: &str, + repo: &str, + per_page: i64, + page: i64, + ref_: &str, + key: &str, + sort: crate::types::ActionsCacheListSort, + direction: crate::types::Order, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !key.is_empty() { + query_args.push(("key".to_string(), key.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/caches?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete GitHub Actions caches for a repository (using a cache key). + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/caches` endpoint. + * + * Deletes one or more GitHub Actions caches for a repository, using a complete cache key. By default, all caches that match the provided key are deleted, but you can optionally provide a Git ref to restrict deletions to caches that match both the provided key and the Git ref. + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `key: &str` -- A key for identifying the cache. + * * `ref_: &str` -- The full Git reference for narrowing down the cache. The `ref` for a branch should be formatted as `refs/heads/`. To reference a pull request use `refs/pull//merge`. + */ + pub async fn delete_actions_cache_by_key( + &self, + owner: &str, + repo: &str, + key: &str, + ref_: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !key.is_empty() { + query_args.push(("key".to_string(), key.to_string())); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/caches?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a GitHub Actions cache for a repository (using a cache ID). + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/caches/{cache_id}` endpoint. + * + * Deletes a GitHub Actions cache for a repository, using a cache ID. + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `cache_id: i64` -- The unique identifier of the GitHub Actions cache. + */ + pub async fn delete_actions_cache_by_id( + &self, + owner: &str, + repo: &str, + cache_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/caches/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&cache_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a job for a workflow run. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/jobs/{job_id}` endpoint. + * + * Gets a specific job in a workflow run. + * + * Anyone with read access to the repository can use this endpoint. + * + * If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `job_id: i64` -- The unique identifier of the job. + */ + pub async fn get_job_for_workflow_run( + &self, + owner: &str, + repo: &str, + job_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/jobs/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&job_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Download job logs for a workflow run. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/jobs/{job_id}/logs` endpoint. + * + * Gets a redirect URL to download a plain text file of logs for a workflow job. This link expires after 1 minute. Look + * for `Location:` in the response header to find the URL for the download. + * + * Anyone with read access to the repository can use this endpoint. + * + * If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `job_id: i64` -- The unique identifier of the job. + */ + pub async fn download_job_logs_for_workflow_run( + &self, + owner: &str, + repo: &str, + job_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/jobs/{}/logs", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&job_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Re-run a job from a workflow run. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/jobs/{job_id}/rerun` endpoint. + * + * Re-run a job and its dependent jobs in a workflow run. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `job_id: i64` -- The unique identifier of the job. + */ + pub async fn re_run_job_for_workflow_run( + &self, + owner: &str, + repo: &str, + job_id: i64, + body: &crate::types::ActionsReRunWorkflowRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/jobs/{}/rerun", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&job_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get the customization template for an OIDC subject claim for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/oidc/customization/sub` endpoint. + * + * Gets the customization template for an OpenID Connect (OIDC) subject claim. + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_custom_oidc_sub_claim_for_repo( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/oidc/customization/sub", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set the customization template for an OIDC subject claim for a repository. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/oidc/customization/sub` endpoint. + * + * Sets the customization template and `opt-in` or `opt-out` flag for an OpenID Connect (OIDC) subject claim for a repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn set_custom_oidc_sub_claim_for_repo( + &self, + owner: &str, + repo: &str, + body: &crate::types::OidcCustomSubRepo, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/oidc/customization/sub", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List repository organization secrets. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/organization-secrets` endpoint. + * + * Lists all organization secrets shared with a repository without revealing their encrypted + * values. + * + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_repo_organization_secrets( + &self, + owner: &str, + repo: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/organization-secrets?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List repository organization variables. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/organization-variables` endpoint. + * + * Lists all organization variables shared with a repository. + * + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 30). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_repo_organization_variables( + &self, + owner: &str, + repo: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/organization-variables?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get GitHub Actions permissions for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/permissions` endpoint. + * + * Gets the GitHub Actions permissions policy for a repository, including whether GitHub Actions is enabled and the actions and reusable workflows allowed to run in the repository. + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_github_actions_permissions_repository( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set GitHub Actions permissions for a repository. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/permissions` endpoint. + * + * Sets the GitHub Actions permissions policy for enabling GitHub Actions and allowed actions and reusable workflows in the repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn set_github_actions_permissions_repository( + &self, + owner: &str, + repo: &str, + body: &crate::types::ActionsSetGithubPermissionsRepositoryRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get the level of access for workflows outside of the repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/permissions/access` endpoint. + * + * Gets the level of access that workflows outside of the repository have to actions and reusable workflows in the repository. + * This endpoint only applies to private repositories. + * For more information, see "[Allowing access to components in a private repository](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#allowing-access-to-components-in-a-private-repository)." + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_workflow_access_to_repository( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions/access", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set the level of access for workflows outside of the repository. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/permissions/access` endpoint. + * + * Sets the level of access that workflows outside of the repository have to actions and reusable workflows in the repository. + * This endpoint only applies to private repositories. + * For more information, see "[Allowing access to components in a private repository](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#allowing-access-to-components-in-a-private-repository)". + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn set_workflow_access_to_repository( + &self, + owner: &str, + repo: &str, + body: &crate::types::ActionsWorkflowAccessRepository, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions/access", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get artifact and log retention settings for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/permissions/artifact-and-log-retention` endpoint. + * + * Gets artifact and log retention settings for a repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_artifact_and_log_retention_settings_repository( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions/artifact-and-log-retention", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set artifact and log retention settings for a repository. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/permissions/artifact-and-log-retention` endpoint. + * + * Sets artifact and log retention settings for a repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn set_artifact_and_log_retention_settings_repository( + &self, + owner: &str, + repo: &str, + body: &crate::types::ActionsArtifactLogRetention, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions/artifact-and-log-retention", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get fork PR contributor approval permissions for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/permissions/fork-pr-contributor-approval` endpoint. + * + * Gets the fork PR contributor approval policy for a repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_fork_pr_contributor_approval_permissions_repository( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions/fork-pr-contributor-approval", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set fork PR contributor approval permissions for a repository. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/permissions/fork-pr-contributor-approval` endpoint. + * + * Sets the fork PR contributor approval policy for a repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn set_fork_pr_contributor_approval_permissions_repository( + &self, + owner: &str, + repo: &str, + body: &crate::types::ActionsForkPrContributorApproval, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions/fork-pr-contributor-approval", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get private repo fork PR workflow settings for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/permissions/fork-pr-workflows-private-repos` endpoint. + * + * Gets the settings for whether workflows from fork pull requests can run on a private repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_private_repo_fork_pr_workflows_settings_repository( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions/fork-pr-workflows-private-repos", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set private repo fork PR workflow settings for a repository. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/permissions/fork-pr-workflows-private-repos` endpoint. + * + * Sets the settings for whether workflows from fork pull requests can run on a private repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn set_private_repo_fork_pr_workflows_settings_repository( + &self, + owner: &str, + repo: &str, + body: &crate::types::ActionsForkPrWorkflowsPrivateReposRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions/fork-pr-workflows-private-repos", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get allowed actions and reusable workflows for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/permissions/selected-actions` endpoint. + * + * Gets the settings for selected actions and reusable workflows that are allowed in a repository. To use this endpoint, the repository policy for `allowed_actions` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for a repository](#set-github-actions-permissions-for-a-repository)." + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_allowed_actions_repository( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions/selected-actions", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set allowed actions and reusable workflows for a repository. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/permissions/selected-actions` endpoint. + * + * Sets the actions and reusable workflows that are allowed in a repository. To use this endpoint, the repository permission policy for `allowed_actions` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for a repository](#set-github-actions-permissions-for-a-repository)." + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn set_allowed_actions_repository( + &self, + owner: &str, + repo: &str, + body: &crate::types::SelectedActions, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions/selected-actions", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get default workflow permissions for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/permissions/workflow` endpoint. + * + * Gets the default workflow permissions granted to the `GITHUB_TOKEN` when running workflows in a repository, + * as well as if GitHub Actions can submit approving pull request reviews. + * For more information, see "[Setting the permissions of the GITHUB_TOKEN for your repository](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository)." + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_github_actions_default_workflow_permissions_repository( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions/workflow", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set default workflow permissions for a repository. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/permissions/workflow` endpoint. + * + * Sets the default workflow permissions granted to the `GITHUB_TOKEN` when running workflows in a repository, and sets if GitHub Actions + * can submit approving pull request reviews. + * For more information, see "[Setting the permissions of the GITHUB_TOKEN for your repository](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository)." + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn set_github_actions_default_workflow_permissions_repository( + &self, + owner: &str, + repo: &str, + body: &crate::types::ActionsSetDefaultWorkflowPermissions, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/permissions/workflow", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List self-hosted runners for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runners` endpoint. + * + * Lists all self-hosted runners configured in a repository. + * + * Authenticated users must have admin access to the repository to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `name: &str` -- The name of a self-hosted runner. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_self_hosted_runners_for_repo( + &self, + name: &str, + owner: &str, + repo: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !name.is_empty() { + query_args.push(("name".to_string(), name.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/runners?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List runner applications for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runners/downloads` endpoint. + * + * Lists binaries for the runner application that you can download and run. + * + * Authenticated users must have admin access to the repository to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn list_runner_applications_for_repo( + &self, + owner: &str, + repo: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/runners/downloads", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List runner applications for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runners/downloads` endpoint. + * + * As opposed to `list_runner_applications_for_repo`, this function returns all the pages of the request at once. + * + * Lists binaries for the runner application that you can download and run. + * + * Authenticated users must have admin access to the repository to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + */ + pub async fn list_all_runner_applications_for_repo( + &self, + owner: &str, + repo: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/runners/downloads", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create configuration for a just-in-time runner for a repository. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runners/generate-jitconfig` endpoint. + * + * Generates a configuration that can be passed to the runner application at startup. + * + * The authenticated user must have admin access to the repository. + * + * OAuth tokens and personal access tokens (classic) need the`repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn generate_runner_jitconfig_for_repo( + &self, + owner: &str, + repo: &str, + body: &crate::types::ActionsGenerateRunnerJitconfigOrgRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/runners/generate-jitconfig", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Create a registration token for a repository. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runners/registration-token` endpoint. + * + * Returns a token that you can pass to the `config` script. The token expires after one hour. + * + * For example, you can replace `TOKEN` in the following example with the registration token provided by this endpoint to configure your self-hosted runner: + * + * ``` + * ./config.sh --url https://github.com/octo-org --token TOKEN + * ``` + * + * Authenticated users must have admin access to the repository to use this endpoint. + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_registration_token_for_repo( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/runners/registration-token", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a remove token for a repository. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runners/remove-token` endpoint. + * + * Returns a token that you can pass to the `config` script to remove a self-hosted runner from an repository. The token expires after one hour. + * + * For example, you can replace `TOKEN` in the following example with the registration token provided by this endpoint to remove your self-hosted runner from an organization: + * + * ``` + * ./config.sh remove --token TOKEN + * ``` + * + * Authenticated users must have admin access to the repository to use this endpoint. + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_remove_token_for_repo( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/runners/remove-token", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a self-hosted runner for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runners/{runner_id}` endpoint. + * + * Gets a specific self-hosted runner configured in a repository. + * + * Authenticated users must have admin access to the repository to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + */ + pub async fn get_self_hosted_runner_for_repo( + &self, + owner: &str, + repo: &str, + runner_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/runners/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a self-hosted runner from a repository. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/runners/{runner_id}` endpoint. + * + * Forces the removal of a self-hosted runner from a repository. You can use this endpoint to completely remove the runner when the machine you were using no longer exists. + * + * Authenticated users must have admin access to the repository to use this endpoint. + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + */ + pub async fn delete_self_hosted_runner_from_repo( &self, owner: &str, repo: &str, - ) -> ClientResult> { + runner_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/permissions", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runners/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -1945,122 +5649,132 @@ impl Actions { .await } /** - * Set GitHub Actions permissions for a repository. + * List labels for a self-hosted runner for a repository. * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/permissions` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runners/{runner_id}/labels` endpoint. * - * Sets the GitHub Actions permissions policy for enabling GitHub Actions and allowed actions in the repository. + * Lists all labels for a self-hosted runner configured in a repository. * - * If the repository belongs to an organization or enterprise that has set restrictive permissions at the organization or enterprise levels, such as `allowed_actions` to `selected` actions, then you cannot override them for the repository. + * Authenticated users must have admin access to the repository to use this endpoint. * - * You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `administration` repository permission to use this API. + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. */ - pub async fn set_github_actions_permissions_repository( + pub async fn list_labels_for_self_hosted_runner_for_repo( &self, owner: &str, repo: &str, - body: &crate::types::ActionsSetGithubPermissionsRepositoryRequest, - ) -> ClientResult> { + runner_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/permissions", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runners/{}/labels", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get allowed actions for a repository. + * Set custom labels for a self-hosted runner for a repository. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/permissions/selected-actions` endpoint. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/runners/{runner_id}/labels` endpoint. * - * Gets the settings for selected actions that are allowed in a repository. To use this endpoint, the repository policy for `allowed_actions` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for a repository](#set-github-actions-permissions-for-a-repository)." + * Remove all previous custom labels and set the new custom labels for a specific + * self-hosted runner configured in a repository. * - * You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `administration` repository permission to use this API. + * Authenticated users must have admin access to the repository to use this endpoint. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. */ - pub async fn get_allowed_actions_repository( + pub async fn set_custom_labels_for_self_hosted_runner_for_repo( &self, owner: &str, repo: &str, - ) -> ClientResult> { + runner_id: i64, + body: &crate::types::IssuesAddLabelsRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/permissions/selected-actions", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runners/{}/labels", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Set allowed actions for a repository. - * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/permissions/selected-actions` endpoint. + * Add custom labels to a self-hosted runner for a repository. * - * Sets the actions that are allowed in a repository. To use this endpoint, the repository permission policy for `allowed_actions` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for a repository](#set-github-actions-permissions-for-a-repository)." + * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runners/{runner_id}/labels` endpoint. * - * If the repository belongs to an organization or enterprise that has `selected` actions set at the organization or enterprise levels, then you cannot override any of the allowed actions settings. + * Adds custom labels to a self-hosted runner configured in a repository. * - * To use the `patterns_allowed` setting for private repositories, the repository must belong to an enterprise. If the repository does not belong to an enterprise, then the `patterns_allowed` setting only applies to public repositories. + * Authenticated users must have admin access to the organization to use this endpoint. * - * You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `administration` repository permission to use this API. + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. */ - pub async fn set_allowed_actions_repository( + pub async fn add_custom_labels_to_self_hosted_runner_for_repo( &self, owner: &str, repo: &str, - body: &crate::types::SelectedActions, - ) -> ClientResult> { + runner_id: i64, + body: &crate::types::IssuesAddLabelsRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/permissions/selected-actions", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runners/{}/labels", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), ), None, ); self.client - .put( + .post( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -2070,47 +5784,42 @@ impl Actions { .await } /** - * List self-hosted runners for a repository. + * Remove all custom labels from a self-hosted runner for a repository. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runners` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/runners/{runner_id}/labels` endpoint. * - * Lists all self-hosted runners configured in a repository. You must authenticate using an access token with the `repo` scope to use this endpoint. + * Remove all custom labels from a self-hosted runner configured in a + * repository. Returns the remaining read-only labels from the runner. * - * FROM: + * Authenticated users must have admin access to the repository to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. */ - pub async fn list_self_hosted_runners_for_repo( + pub async fn remove_all_custom_labels_from_self_hosted_runner_for_repo( &self, owner: &str, repo: &str, - per_page: i64, - page: i64, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + runner_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/runners?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/actions/runners/{}/labels", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -2120,36 +5829,48 @@ impl Actions { .await } /** - * List runner applications for a repository. + * Remove a custom label from a self-hosted runner for a repository. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runners/downloads` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/runners/{runner_id}/labels/{name}` endpoint. * - * Lists binaries for the runner application that you can download and run. + * Remove a custom label from a self-hosted runner configured + * in a repository. Returns the remaining labels from the runner. * - * You must authenticate using an access token with the `repo` scope to use this endpoint. + * This endpoint returns a `404 Not Found` status if the custom label is not + * present on the runner. * - * FROM: + * Authenticated users must have admin access to the repository to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + * * `name: &str` -- The name of a self-hosted runner's custom label. */ - pub async fn list_runner_applications_for_repo( + pub async fn remove_custom_label_from_self_hosted_runner_for_repo( &self, owner: &str, repo: &str, - ) -> ClientResult>> { + runner_id: i64, + name: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/runners/downloads", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runners/{}/labels/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&runner_id.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -2159,33 +5880,96 @@ impl Actions { .await } /** - * List runner applications for a repository. + * List workflow runs for a repository. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runners/downloads` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs` endpoint. * - * As opposed to `list_runner_applications_for_repo`, this function returns all the pages of the request at once. + * Lists all workflow runs for a repository. You can use parameters to narrow the list of results. For more information about using parameters, see [Parameters](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#parameters). * - * Lists binaries for the runner application that you can download and run. + * Anyone with read access to the repository can use this endpoint. * - * You must authenticate using an access token with the `repo` scope to use this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. * - * FROM: + * This endpoint will return up to 1,000 results for each search when using the following parameters: `actor`, `branch`, `check_suite_id`, `created`, `event`, `head_sha`, `status`. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `actor: &str` -- Returns someone's workflow runs. Use the login for the user who created the `push` associated with the check suite or workflow run. + * * `branch: &str` -- Returns workflow runs associated with a branch. Use the name of the branch of the `push`. + * * `event: &str` -- Returns workflow run triggered by the event you specify. For example, `push`, `pull_request` or `issue`. For more information, see "[Events that trigger workflows](https://docs.github.com/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows).". + * * `status: crate::types::WorkflowRunStatus` -- Returns workflow runs with the check run `status` or `conclusion` that you specify. For example, a conclusion can be `success` or a status can be `in_progress`. Only GitHub Actions can set a status of `waiting`, `pending`, or `requested`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `created: chrono::DateTime` -- Returns workflow runs created within the given date-time range. For more information on the syntax, see "[Understanding the search syntax](https://docs.github.com/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates).". + * * `exclude_pull_requests: bool` -- If `true` pull requests are omitted from the response (empty array). + * * `check_suite_id: i64` -- Returns workflow runs with the `check_suite_id` that you specify. + * * `head_sha: &str` -- Only returns workflow runs that are associated with the specified `head_sha`. */ - pub async fn list_all_runner_applications_for_repo( + pub async fn list_workflow_runs_for_repo( &self, owner: &str, repo: &str, - ) -> ClientResult>> { + actor: &str, + branch: &str, + event: &str, + status: crate::types::WorkflowRunStatus, + per_page: i64, + page: i64, + created: Option>, + exclude_pull_requests: bool, + check_suite_id: i64, + head_sha: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !actor.is_empty() { + query_args.push(("actor".to_string(), actor.to_string())); + } + if !branch.is_empty() { + query_args.push(("branch".to_string(), branch.to_string())); + } + if check_suite_id > 0 { + query_args.push(("check_suite_id".to_string(), check_suite_id.to_string())); + } + if let Some(date) = created { + query_args.push(("created".to_string(), date.to_rfc3339())); + } + if !event.is_empty() { + query_args.push(("event".to_string(), event.to_string())); + } + if exclude_pull_requests { + query_args.push(( + "exclude_pull_requests".to_string(), + exclude_pull_requests.to_string(), + )); + } + if !head_sha.is_empty() { + query_args.push(("head_sha".to_string(), head_sha.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !status.to_string().is_empty() { + query_args.push(("status".to_string(), status.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/actions/runners/downloads", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runs?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -2195,43 +5979,52 @@ impl Actions { .await } /** - * Create a registration token for a repository. + * Get a workflow run. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runners/registration-token` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}` endpoint. * - * Returns a token that you can pass to the `config` script. The token expires after one hour. You must authenticate - * using an access token with the `repo` scope to use this endpoint. + * Gets a specific workflow run. * - * #### Example using registration token - * - * Configure your self-hosted runner, replacing `TOKEN` with the registration token provided by this endpoint. + * Anyone with read access to the repository can use this endpoint. * - * ``` - * ./config.sh --url https://github.com/octo-org/octo-repo-artifacts --token TOKEN - * ``` + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. + * * `exclude_pull_requests: bool` -- If `true` pull requests are omitted from the response (empty array). */ - pub async fn create_registration_token_for_repo( + pub async fn get_workflow_run( &self, owner: &str, repo: &str, - ) -> ClientResult> { + run_id: i64, + exclude_pull_requests: bool, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if exclude_pull_requests { + query_args.push(( + "exclude_pull_requests".to_string(), + exclude_pull_requests.to_string(), + )); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/actions/runners/registration-token", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runs/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&run_id.to_string()), + query_ ), None, ); self.client - .post( + .get( &url, crate::Message { body: None, @@ -2241,43 +6034,41 @@ impl Actions { .await } /** - * Create a remove token for a repository. + * Delete a workflow run. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runners/remove-token` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/runs/{run_id}` endpoint. * - * Returns a token that you can pass to remove a self-hosted runner from a repository. The token expires after one hour. - * You must authenticate using an access token with the `repo` scope to use this endpoint. + * Deletes a specific workflow run. * - * #### Example using remove token - * - * To remove your self-hosted runner from a repository, replace TOKEN with the remove token provided by this endpoint. + * Anyone with write access to the repository can use this endpoint. * - * ``` - * ./config.sh remove --token TOKEN - * ``` + * If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ - pub async fn create_remove_token_for_repo( + pub async fn delete_workflow_run( &self, owner: &str, repo: &str, - ) -> ClientResult> { + run_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/runners/remove-token", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runs/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&run_id.to_string()), ), None, ); self.client - .post( + .delete( &url, crate::Message { body: None, @@ -2287,35 +6078,34 @@ impl Actions { .await } /** - * Get a self-hosted runner for a repository. + * Get the review history for a workflow run. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runners/{runner_id}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/approvals` endpoint. * - * Gets a specific self-hosted runner configured in a repository. + * Anyone with read access to the repository can use this endpoint. * - * You must authenticate using an access token with the `repo` scope to use this - * endpoint. + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ - pub async fn get_self_hosted_runner_for_repo( + pub async fn get_reviews_for_run( &self, owner: &str, repo: &str, - runner_id: i64, - ) -> ClientResult> { + run_id: i64, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/runners/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&runner_id.to_string()), + "/repos/{}/{}/actions/runs/{}/approvals", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&run_id.to_string()), ), None, ); @@ -2330,40 +6120,35 @@ impl Actions { .await } /** - * Delete a self-hosted runner from a repository. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/runners/{runner_id}` endpoint. + * Get the review history for a workflow run. * - * Forces the removal of a self-hosted runner from a repository. You can use this endpoint to completely remove the runner when the machine you were using no longer exists. + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/approvals` endpoint. * - * You must authenticate using an access token with the `repo` - * scope to use this endpoint. + * As opposed to `get_reviews_for_run`, this function returns all the pages of the request at once. * - * FROM: + * Anyone with read access to the repository can use this endpoint. * - * **Parameters:** + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. * - * * `owner: &str` - * * `repo: &str` - * * `runner_id: i64` -- Unique identifier of the self-hosted runner. + * FROM: */ - pub async fn delete_self_hosted_runner_from_repo( + pub async fn get_all_reviews_for_run( &self, owner: &str, repo: &str, - runner_id: i64, - ) -> ClientResult> { + run_id: i64, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/runners/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&runner_id.to_string()), + "/repos/{}/{}/actions/runs/{}/approvals", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&run_id.to_string()), ), None, ); self.client - .delete( + .get_all_pages( &url, crate::Message { body: None, @@ -2373,74 +6158,39 @@ impl Actions { .await } /** - * List workflow runs for a repository. + * Approve a workflow run for a fork pull request. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/approve` endpoint. * - * Lists all workflow runs for a repository. You can use parameters to narrow the list of results. For more information about using parameters, see [Parameters](https://docs.github.com/rest/overview/resources-in-the-rest-api#parameters). + * Approves a workflow run for a pull request from a public fork of a first time contributor. For more information, see ["Approving workflow runs from public forks](https://docs.github.com/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks)." * - * Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `actor: &str` -- Returns someone's workflow runs. Use the login for the user who created the `push` associated with the check suite or workflow run. - * * `branch: &str` -- Returns workflow runs associated with a branch. Use the name of the branch of the `push`. - * * `event: &str` -- Returns workflow run triggered by the event you specify. For example, `push`, `pull_request` or `issue`. For more information, see "[Events that trigger workflows](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows).". - * * `status: crate::types::WorkflowRunStatus` -- Returns workflow runs with the check run `status` or `conclusion` that you specify. For example, a conclusion can be `success` or a status can be `in_progress`. Only GitHub can set a status of `waiting` or `requested`. For a list of the possible `status` and `conclusion` options, see "[Create a check run](https://docs.github.com/rest/reference/checks#create-a-check-run).". - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - * * `created: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ - pub async fn list_workflow_runs_for_repo( + pub async fn approve_workflow_run( &self, owner: &str, repo: &str, - actor: &str, - branch: &str, - event: &str, - status: crate::types::WorkflowRunStatus, - per_page: i64, - page: i64, - created: &str, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !actor.is_empty() { - query_args.push(("actor".to_string(), actor.to_string())); - } - if !branch.is_empty() { - query_args.push(("branch".to_string(), branch.to_string())); - } - if !created.is_empty() { - query_args.push(("created".to_string(), created.to_string())); - } - if !event.is_empty() { - query_args.push(("event".to_string(), event.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - if !status.to_string().is_empty() { - query_args.push(("status".to_string(), status.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + run_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/runs?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/actions/runs/{}/approve", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&run_id.to_string()), ), None, ); self.client - .get( + .post( &url, crate::Message { body: None, @@ -2450,32 +6200,54 @@ impl Actions { .await } /** - * Get a workflow run. + * List workflow run artifacts. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/artifacts` endpoint. + * + * Lists artifacts for a workflow run. * - * Gets a specific workflow run. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * Anyone with read access to the repository can use this endpoint. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `name: &str` -- The name field of an artifact. When specified, only artifacts with this name will be returned. */ - pub async fn get_workflow_run( + pub async fn list_workflow_run_artifacts( &self, owner: &str, repo: &str, run_id: i64, - ) -> ClientResult> { + per_page: i64, + page: i64, + name: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !name.is_empty() { + query_args.push(("name".to_string(), name.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/actions/runs/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runs/{}/artifacts?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), + query_ ), None, ); @@ -2490,39 +6262,55 @@ impl Actions { .await } /** - * Delete a workflow run. + * Get a workflow run attempt. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/runs/{run_id}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}` endpoint. + * + * Gets a specific workflow run attempt. + * + * Anyone with read access to the repository can use this endpoint. * - * Delete a specific workflow run. Anyone with write access to the repository can use this endpoint. If the repository is - * private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:write` permission to use - * this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. + * * `attempt_number: i64` -- The attempt number of the workflow run. + * * `exclude_pull_requests: bool` -- If `true` pull requests are omitted from the response (empty array). */ - pub async fn delete_workflow_run( + pub async fn get_workflow_run_attempt( &self, owner: &str, repo: &str, run_id: i64, - ) -> ClientResult> { + attempt_number: i64, + exclude_pull_requests: bool, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if exclude_pull_requests { + query_args.push(( + "exclude_pull_requests".to_string(), + exclude_pull_requests.to_string(), + )); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/actions/runs/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runs/{}/attempts/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), + crate::progenitor_support::encode_path(&attempt_number.to_string()), + query_ ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -2532,32 +6320,53 @@ impl Actions { .await } /** - * Get the review history for a workflow run. + * List jobs for a workflow run attempt. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/approvals` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs` endpoint. + * + * Lists jobs for a specific workflow run attempt. You can use parameters to narrow the list of results. For more information + * about using parameters, see [Parameters](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#parameters). * - * Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * Anyone with read access to the repository can use this endpoint. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. + * * `attempt_number: i64` -- The attempt number of the workflow run. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn get_reviews_for_run( + pub async fn list_jobs_for_workflow_run_attempt( &self, owner: &str, repo: &str, run_id: i64, - ) -> ClientResult>> { + attempt_number: i64, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/actions/runs/{}/approvals", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runs/{}/attempts/{}/jobs?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), + crate::progenitor_support::encode_path(&attempt_number.to_string()), + query_ ), None, ); @@ -2572,33 +6381,45 @@ impl Actions { .await } /** - * Get the review history for a workflow run. + * Download workflow run attempt logs. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/approvals` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/logs` endpoint. * - * As opposed to `get_reviews_for_run`, this function returns all the pages of the request at once. + * Gets a redirect URL to download an archive of log files for a specific workflow run attempt. This link expires after + * 1 minute. Look for `Location:` in the response header to find the URL for the download. + * + * Anyone with read access to the repository can use this endpoint. * - * Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. + * * `attempt_number: i64` -- The attempt number of the workflow run. */ - pub async fn get_all_reviews_for_run( + pub async fn download_workflow_run_attempt_logs( &self, owner: &str, repo: &str, run_id: i64, - ) -> ClientResult>> { + attempt_number: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/runs/{}/approvals", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runs/{}/attempts/{}/logs", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), + crate::progenitor_support::encode_path(&attempt_number.to_string()), ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -2608,33 +6429,33 @@ impl Actions { .await } /** - * Approve a workflow run for a fork pull request. + * Cancel a workflow run. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/approve` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/cancel` endpoint. * - * Approves a workflow run for a pull request from a public fork of a first time contributor. For more information, see ["Approving workflow runs from public forks](https://docs.github.com/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks)." + * Cancels a workflow run using its `id`. * - * You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `actions:write` permission to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ - pub async fn approve_workflow_run( + pub async fn cancel_workflow_run( &self, owner: &str, repo: &str, run_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/runs/{}/approve", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runs/{}/cancel", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), ), None, @@ -2650,84 +6471,80 @@ impl Actions { .await } /** - * List workflow run artifacts. + * Review custom deployment protection rules for a workflow run. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/artifacts` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/deployment_protection_rule` endpoint. + * + * Approve or reject custom deployment protection rules provided by a GitHub App for a workflow run. For more information, see "[Using environments for deployment](https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment)." * - * Lists artifacts for a workflow run. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * > [!NOTE] + * > GitHub Apps can only review their own custom deployment protection rules. To approve or reject pending deployments that are waiting for review from a specific person or team, see [`POST /repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments`](/rest/actions/workflow-runs#review-pending-deployments-for-a-workflow-run). * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ - pub async fn list_workflow_run_artifacts( + pub async fn review_custom_gates_for_run( &self, owner: &str, repo: &str, run_id: i64, - per_page: i64, - page: i64, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + body: &crate::types::ActionsReviewCustomGatesRunRequestAnyOf, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/runs/{}/artifacts?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runs/{}/deployment_protection_rule", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), - query_ ), None, ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Cancel a workflow run. + * Force cancel a workflow run. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/cancel` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/force-cancel` endpoint. * - * Cancels a workflow run using its `id`. You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `actions:write` permission to use this endpoint. + * Cancels a workflow run and bypasses conditions that would otherwise cause a workflow execution to continue, such as an `always()` condition on a job. + * You should only use this endpoint to cancel a workflow run when the workflow run is not responding to [`POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel`](/rest/actions/workflow-runs#cancel-a-workflow-run). * - * FROM: + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ - pub async fn cancel_workflow_run( + pub async fn force_cancel_workflow_run( &self, owner: &str, repo: &str, run_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/runs/{}/cancel", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/actions/runs/{}/force-cancel", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), ), None, @@ -2747,20 +6564,23 @@ impl Actions { * * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/jobs` endpoint. * - * Lists jobs for a workflow run. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. You can use parameters to narrow the list of results. For more information about using parameters, see [Parameters](https://docs.github.com/rest/overview/resources-in-the-rest-api#parameters). + * Lists jobs for a workflow run. You can use parameters to narrow the list of results. For more information + * about using parameters, see [Parameters](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#parameters). + * + * Anyone with read access to the repository can use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. - * * `filter: crate::types::ActionsListJobsWorkflowRunFilter` -- Filters jobs by their `completed_at` timestamp. Can be one of: - * \\* `latest`: Returns jobs from the most recent execution of the workflow run. - * \\* `all`: Returns all jobs for a workflow run, including from old executions of the workflow run. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. + * * `filter: crate::types::ActionsListJobsWorkflowRunFilter` -- Filters jobs by their `completed_at` timestamp. `latest` returns jobs from the most recent execution of the workflow run. `all` returns all jobs for a workflow run, including from old executions of the workflow run. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_jobs_for_workflow_run( &self, @@ -2785,8 +6605,8 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/runs/{}/jobs?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), query_ ), @@ -2808,17 +6628,19 @@ impl Actions { * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/logs` endpoint. * * Gets a redirect URL to download an archive of log files for a workflow run. This link expires after 1 minute. Look for - * `Location:` in the response header to find the URL for the download. Anyone with read access to the repository can use - * this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have - * the `actions:read` permission to use this endpoint. + * `Location:` in the response header to find the URL for the download. * - * FROM: + * Anyone with read access to the repository can use this endpoint. + * + * If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ pub async fn download_workflow_run_logs( &self, @@ -2829,8 +6651,8 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/runs/{}/logs", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), ), None, @@ -2850,15 +6672,17 @@ impl Actions { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/logs` endpoint. * - * Deletes all logs for a workflow run. You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `actions:write` permission to use this endpoint. + * Deletes all logs for a workflow run. * - * FROM: + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ pub async fn delete_workflow_run_logs( &self, @@ -2869,8 +6693,8 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/runs/{}/logs", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), ), None, @@ -2892,15 +6716,17 @@ impl Actions { * * Get all deployment environments for a workflow run that are waiting for protection rules to pass. * - * Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * Anyone with read access to the repository can use this endpoint. + * + * If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ pub async fn get_pending_deployments_for_run( &self, @@ -2911,8 +6737,8 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/runs/{}/pending_deployments", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), ), None, @@ -2936,9 +6762,11 @@ impl Actions { * * Get all deployment environments for a workflow run that are waiting for protection rules to pass. * - * Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * Anyone with read access to the repository can use this endpoint. * - * FROM: + * If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: */ pub async fn get_all_pending_deployments_for_run( &self, @@ -2949,8 +6777,8 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/runs/{}/pending_deployments", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), ), None, @@ -2972,15 +6800,17 @@ impl Actions { * * Approve or reject pending deployments that are waiting on approval by a required reviewer. * - * Anyone with read access to the repository contents and deployments can use this endpoint. + * Required reviewers with read access to the repository contents and deployments can use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ pub async fn review_pending_deployments_for_run( &self, @@ -2992,8 +6822,8 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/runs/{}/pending_deployments", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), ), None, @@ -3013,27 +6843,30 @@ impl Actions { * * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/rerun` endpoint. * - * Re-runs your workflow run using its `id`. You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `actions:write` permission to use this endpoint. + * Re-runs your workflow run using its `id`. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ pub async fn re_run_workflow( &self, owner: &str, repo: &str, run_id: i64, - ) -> ClientResult> { + body: &crate::types::ActionsReRunWorkflowRequest, + ) -> ClientResult> { let url = self.client.url( &format!( "/repos/{}/{}/actions/runs/{}/rerun", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), ), None, @@ -3042,8 +6875,8 @@ impl Actions { .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await @@ -3053,27 +6886,30 @@ impl Actions { * * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/rerun-failed-jobs` endpoint. * - * Re-run all of the failed jobs and their dependent jobs in a workflow run using the `id` of the workflow run. You must authenticate using an access token with the `repo` scope to use this endpoint. + * Re-run all of the failed jobs and their dependent jobs in a workflow run using the `id` of the workflow run. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ pub async fn re_run_workflow_failed_jobs( &self, owner: &str, repo: &str, run_id: i64, - ) -> ClientResult> { + body: &crate::types::ActionsReRunWorkflowRequest, + ) -> ClientResult> { let url = self.client.url( &format!( "/repos/{}/{}/actions/runs/{}/rerun-failed-jobs", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), ), None, @@ -3082,8 +6918,8 @@ impl Actions { .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await @@ -3093,17 +6929,22 @@ impl Actions { * * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/runs/{run_id}/timing` endpoint. * - * Gets the number of billable minutes and total run time for a specific workflow run. Billable minutes only apply to workflows in private repositories that use GitHub-hosted runners. Usage is listed for each GitHub-hosted runner operating system in milliseconds. Any job re-runs are also included in the usage. The usage does not include the multiplier for macOS and Windows runners and is not rounded up to the nearest whole minute. For more information, see "[Managing billing for GitHub Actions](https://help.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-actions)". + * > [!WARNING] + * > This endpoint is in the process of closing down. Refer to "[Actions Get workflow usage and Get workflow run usage endpoints closing down](https://github.blog/changelog/2025-02-02-actions-get-workflow-usage-and-get-workflow-run-usage-endpoints-closing-down/)" for more information. + * + * Gets the number of billable minutes and total run time for a specific workflow run. Billable minutes only apply to workflows in private repositories that use GitHub-hosted runners. Usage is listed for each GitHub-hosted runner operating system in milliseconds. Any job re-runs are also included in the usage. The usage does not include the multiplier for macOS and Windows runners and is not rounded up to the nearest whole minute. For more information, see "[Managing billing for GitHub Actions](https://docs.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-actions)". + * + * Anyone with read access to the repository can use this endpoint. * - * Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `run_id: i64` -- The id of the workflow run. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `run_id: i64` -- The unique identifier of the workflow run. */ pub async fn get_workflow_run_usage( &self, @@ -3114,8 +6955,8 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/runs/{}/timing", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&run_id.to_string()), ), None, @@ -3135,16 +6976,21 @@ impl Actions { * * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/secrets` endpoint. * - * Lists all secrets available in a repository without revealing their encrypted values. You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `secrets` repository permission to use this endpoint. + * Lists all secrets available in a repository without revealing their encrypted + * values. * - * FROM: + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_repo_secrets( &self, @@ -3164,8 +7010,8 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/secrets?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -3185,14 +7031,19 @@ impl Actions { * * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/secrets/public-key` endpoint. * - * Gets your public key, which you need to encrypt secrets. You need to encrypt a secret before you can create or update secrets. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `secrets` repository permission to use this endpoint. + * Gets your public key, which you need to encrypt secrets. You need to + * encrypt a secret before you can create or update secrets. + * + * Anyone with read access to the repository can use this endpoint. + * + * If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_repo_public_key( &self, @@ -3202,8 +7053,8 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/secrets/public-key", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -3222,15 +7073,19 @@ impl Actions { * * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/secrets/{secret_name}` endpoint. * - * Gets a single repository secret without revealing its encrypted value. You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `secrets` repository permission to use this endpoint. + * Gets a single repository secret without revealing its encrypted value. * - * FROM: + * The authenticated user must have collaborator access to the repository to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `secret_name: &str` -- secret_name parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. */ pub async fn get_repo_secret( &self, @@ -3241,9 +7096,9 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/secrets/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(secret_name), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), ), None, ); @@ -3263,151 +7118,315 @@ impl Actions { * This function performs a `PUT` to the `/repos/{owner}/{repo}/actions/secrets/{secret_name}` endpoint. * * Creates or updates a repository secret with an encrypted value. Encrypt your secret using - * [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). You must authenticate using an access - * token with the `repo` scope to use this endpoint. GitHub Apps must have the `secrets` repository permission to use - * this endpoint. + * [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api)." * - * #### Example encrypting a secret using Node.js + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. * - * Encrypt your secret using the [tweetsodium](https://github.com/github/tweetsodium) library. + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * ``` - * const sodium = require('tweetsodium'); + * FROM: * - * const key = "base64-encoded-public-key"; - * const value = "plain-text-secret"; + * **Parameters:** * - * // Convert the message and key to Uint8Array's (Buffer implements that interface) - * const messageBytes = Buffer.from(value); - * const keyBytes = Buffer.from(key, 'base64'); + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn create_or_update_repo_secret( + &self, + owner: &str, + repo: &str, + secret_name: &str, + body: &crate::types::ActionsCreateUpdateRepoSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/secrets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete a repository secret. * - * // Encrypt using LibSodium. - * const encryptedBytes = sodium.seal(messageBytes, keyBytes); + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/secrets/{secret_name}` endpoint. * - * // Base64 the encrypted secret - * const encrypted = Buffer.from(encryptedBytes).toString('base64'); + * Deletes a secret in a repository using the secret name. * - * console.log(encrypted); - * ``` + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * #### Example encrypting a secret using Python + * FROM: * - * Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/stable/public/#nacl-public-sealedbox) with Python 3. + * **Parameters:** * - * ``` - * from base64 import b64encode - * from nacl import encoding, public - * - * def encrypt(public_key: str, secret_value: str) -> str: - * """Encrypt a Unicode string using the public key.""" - * public_key = public.PublicKey(public_key.encode("utf-8"), encoding.Base64Encoder()) - * sealed_box = public.SealedBox(public_key) - * encrypted = sealed_box.encrypt(secret_value.encode("utf-8")) - * return b64encode(encrypted).decode("utf-8") - * ``` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn delete_repo_secret( + &self, + owner: &str, + repo: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/secrets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List repository variables. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/variables` endpoint. + * + * Lists all repository variables. + * + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 30). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_repo_variables( + &self, + owner: &str, + repo: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/variables?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a repository variable. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/actions/variables` endpoint. + * + * Creates a repository variable that you can reference in a GitHub Actions workflow. + * + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_repo_variable( + &self, + owner: &str, + repo: &str, + body: &crate::types::ActionsCreateRepoVariableRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/variables", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a repository variable. * - * #### Example encrypting a secret using C# + * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/variables/{name}` endpoint. * - * Encrypt your secret using the [Sodium.Core](https://www.nuget.org/packages/Sodium.Core/) package. + * Gets a specific variable in a repository. * - * ``` - * var secretValue = System.Text.Encoding.UTF8.GetBytes("mySecret"); - * var publicKey = Convert.FromBase64String("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvvcCU="); + * The authenticated user must have collaborator access to the repository to use this endpoint. * - * var sealedPublicKeyBox = Sodium.SealedPublicKeyBox.Create(secretValue, publicKey); + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * Console.WriteLine(Convert.ToBase64String(sealedPublicKeyBox)); - * ``` + * FROM: * - * #### Example encrypting a secret using Ruby + * **Parameters:** * - * Encrypt your secret using the [rbnacl](https://github.com/RubyCrypto/rbnacl) gem. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `name: &str` -- The name of the variable. + */ + pub async fn get_repo_variable( + &self, + owner: &str, + repo: &str, + name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/actions/variables/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a repository variable. * - * ```ruby - * require "rbnacl" - * require "base64" + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/variables/{name}` endpoint. * - * key = Base64.decode64("+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0=") - * public_key = RbNaCl::PublicKey.new(key) + * Deletes a repository variable using the variable name. * - * box = RbNaCl::Boxes::Sealed.from_public_key(public_key) - * encrypted_secret = box.encrypt("my_secret") + * Authenticated users must have collaborator access to a repository to create, update, or read variables. * - * # Print the base64 encoded secret - * puts Base64.strict_encode64(encrypted_secret) - * ``` + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `secret_name: &str` -- secret_name parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `name: &str` -- The name of the variable. */ - pub async fn create_or_update_repo_secret( + pub async fn delete_repo_variable( &self, owner: &str, repo: &str, - secret_name: &str, - body: &crate::types::ActionsCreateUpdateRepoSecretRequest, + name: &str, ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/secrets/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(secret_name), + "/repos/{}/{}/actions/variables/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), ), None, ); self.client - .put( + .delete( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Delete a repository secret. + * Update a repository variable. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/actions/secrets/{secret_name}` endpoint. + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/actions/variables/{name}` endpoint. + * + * Updates a repository variable that you can reference in a GitHub Actions workflow. * - * Deletes a secret in a repository using the secret name. You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `secrets` repository permission to use this endpoint. + * Authenticated users must have collaborator access to a repository to create, update, or read variables. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `secret_name: &str` -- secret_name parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `name: &str` -- The name of the variable. */ - pub async fn delete_repo_secret( + pub async fn update_repo_variable( &self, owner: &str, repo: &str, - secret_name: &str, + name: &str, + body: &crate::types::ActionsUpdateRepoVariableRequest, ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/actions/secrets/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(secret_name), + "/repos/{}/{}/actions/variables/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), ), None, ); self.client - .delete( + .patch( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await @@ -3417,16 +7436,20 @@ impl Actions { * * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/workflows` endpoint. * - * Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * Lists the workflows in a repository. * - * FROM: + * Anyone with read access to the repository can use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_repo_workflows( &self, @@ -3446,8 +7469,8 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/workflows?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -3467,14 +7490,19 @@ impl Actions { * * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/workflows/{workflow_id}` endpoint. * - * Gets a specific workflow. You can replace `workflow_id` with the workflow file name. For example, you could use `main.yaml`. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * Gets a specific workflow. You can replace `workflow_id` with the workflow + * file name. For example, you could use `main.yaml`. + * + * Anyone with read access to the repository can use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `workflow_id: &str` -- The ID of the workflow. You can also pass the workflow file name as a string. */ pub async fn get_workflow( @@ -3486,9 +7514,9 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/workflows/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(workflow_id), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&workflow_id.to_string()), ), None, ); @@ -3509,14 +7537,14 @@ impl Actions { * * Disables a workflow and sets the `state` of the workflow to `disabled_manually`. You can replace `workflow_id` with the workflow file name. For example, you could use `main.yaml`. * - * You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `actions:write` permission to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `workflow_id: &str` -- The ID of the workflow. You can also pass the workflow file name as a string. */ pub async fn disable_workflow( @@ -3528,9 +7556,9 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/workflows/{}/disable", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(workflow_id), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&workflow_id.to_string()), ), None, ); @@ -3553,14 +7581,14 @@ impl Actions { * * You must configure your GitHub Actions workflow to run when the [`workflow_dispatch` webhook](/developers/webhooks-and-events/webhook-events-and-payloads#workflow_dispatch) event occurs. The `inputs` are configured in the workflow file. For more information about how to configure the `workflow_dispatch` event in the workflow file, see "[Events that trigger workflows](/actions/reference/events-that-trigger-workflows#workflow_dispatch)." * - * You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `actions:write` permission to use this endpoint. For more information, see "[Creating a personal access token for the command line](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line)." + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `workflow_id: &str` -- The ID of the workflow. You can also pass the workflow file name as a string. */ pub async fn create_workflow_dispatch( @@ -3573,9 +7601,9 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/workflows/{}/dispatches", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(workflow_id), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&workflow_id.to_string()), ), None, ); @@ -3596,14 +7624,14 @@ impl Actions { * * Enables a workflow and sets the `state` of the workflow to `active`. You can replace `workflow_id` with the workflow file name. For example, you could use `main.yaml`. * - * You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `actions:write` permission to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `workflow_id: &str` -- The ID of the workflow. You can also pass the workflow file name as a string. */ pub async fn enable_workflow( @@ -3615,9 +7643,9 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/workflows/{}/enable", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(workflow_id), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&workflow_id.to_string()), ), None, ); @@ -3632,28 +7660,35 @@ impl Actions { .await } /** - * List workflow runs. + * List workflow runs for a workflow. * * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs` endpoint. * - * List all workflow runs for a workflow. You can replace `workflow_id` with the workflow file name. For example, you could use `main.yaml`. You can use parameters to narrow the list of results. For more information about using parameters, see [Parameters](https://docs.github.com/rest/overview/resources-in-the-rest-api#parameters). + * List all workflow runs for a workflow. You can replace `workflow_id` with the workflow file name. For example, you could use `main.yaml`. You can use parameters to narrow the list of results. For more information about using parameters, see [Parameters](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#parameters). * - * Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. + * Anyone with read access to the repository can use this endpoint * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * This endpoint will return up to 1,000 results for each search when using the following parameters: `actor`, `branch`, `check_suite_id`, `created`, `event`, `head_sha`, `status`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `workflow_id: &str` -- The ID of the workflow. You can also pass the workflow file name as a string. * * `actor: &str` -- Returns someone's workflow runs. Use the login for the user who created the `push` associated with the check suite or workflow run. * * `branch: &str` -- Returns workflow runs associated with a branch. Use the name of the branch of the `push`. - * * `event: &str` -- Returns workflow run triggered by the event you specify. For example, `push`, `pull_request` or `issue`. For more information, see "[Events that trigger workflows](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows).". - * * `status: crate::types::WorkflowRunStatus` -- Returns workflow runs with the check run `status` or `conclusion` that you specify. For example, a conclusion can be `success` or a status can be `in_progress`. Only GitHub can set a status of `waiting` or `requested`. For a list of the possible `status` and `conclusion` options, see "[Create a check run](https://docs.github.com/rest/reference/checks#create-a-check-run).". - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - * * `created: &str` + * * `event: &str` -- Returns workflow run triggered by the event you specify. For example, `push`, `pull_request` or `issue`. For more information, see "[Events that trigger workflows](https://docs.github.com/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows).". + * * `status: crate::types::WorkflowRunStatus` -- Returns workflow runs with the check run `status` or `conclusion` that you specify. For example, a conclusion can be `success` or a status can be `in_progress`. Only GitHub Actions can set a status of `waiting`, `pending`, or `requested`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `created: chrono::DateTime` -- Returns workflow runs created within the given date-time range. For more information on the syntax, see "[Understanding the search syntax](https://docs.github.com/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates).". + * * `exclude_pull_requests: bool` -- If `true` pull requests are omitted from the response (empty array). + * * `check_suite_id: i64` -- Returns workflow runs with the `check_suite_id` that you specify. + * * `head_sha: &str` -- Only returns workflow runs that are associated with the specified `head_sha`. */ pub async fn list_workflow_runs( &self, @@ -3666,7 +7701,10 @@ impl Actions { status: crate::types::WorkflowRunStatus, per_page: i64, page: i64, - created: &str, + created: Option>, + exclude_pull_requests: bool, + check_suite_id: i64, + head_sha: &str, ) -> ClientResult> { let mut query_args: Vec<(String, String)> = Default::default(); if !actor.is_empty() { @@ -3675,12 +7713,24 @@ impl Actions { if !branch.is_empty() { query_args.push(("branch".to_string(), branch.to_string())); } - if !created.is_empty() { - query_args.push(("created".to_string(), created.to_string())); + if check_suite_id > 0 { + query_args.push(("check_suite_id".to_string(), check_suite_id.to_string())); + } + if let Some(date) = created { + query_args.push(("created".to_string(), date.to_rfc3339())); } if !event.is_empty() { query_args.push(("event".to_string(), event.to_string())); } + if exclude_pull_requests { + query_args.push(( + "exclude_pull_requests".to_string(), + exclude_pull_requests.to_string(), + )); + } + if !head_sha.is_empty() { + query_args.push(("head_sha".to_string(), head_sha.to_string())); + } if page > 0 { query_args.push(("page".to_string(), page.to_string())); } @@ -3694,9 +7744,9 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/workflows/{}/runs?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(workflow_id), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&workflow_id.to_string()), query_ ), None, @@ -3716,16 +7766,23 @@ impl Actions { * * This function performs a `GET` to the `/repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing` endpoint. * - * Gets the number of billable minutes used by a specific workflow during the current billing cycle. Billable minutes only apply to workflows in private repositories that use GitHub-hosted runners. Usage is listed for each GitHub-hosted runner operating system in milliseconds. Any job re-runs are also included in the usage. The usage does not include the multiplier for macOS and Windows runners and is not rounded up to the nearest whole minute. For more information, see "[Managing billing for GitHub Actions](https://help.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-actions)". + * > [!WARNING] + * > This endpoint is in the process of closing down. Refer to "[Actions Get workflow usage and Get workflow run usage endpoints closing down](https://github.blog/changelog/2025-02-02-actions-get-workflow-usage-and-get-workflow-run-usage-endpoints-closing-down/)" for more information. + * + * Gets the number of billable minutes used by a specific workflow during the current billing cycle. Billable minutes only apply to workflows in private repositories that use GitHub-hosted runners. Usage is listed for each GitHub-hosted runner operating system in milliseconds. Any job re-runs are also included in the usage. The usage does not include the multiplier for macOS and Windows runners and is not rounded up to the nearest whole minute. For more information, see "[Managing billing for GitHub Actions](https://docs.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-actions)". + * + * You can replace `workflow_id` with the workflow file name. For example, you could use `main.yaml`. + * + * Anyone with read access to the repository can use this endpoint. * - * You can replace `workflow_id` with the workflow file name. For example, you could use `main.yaml`. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `workflow_id: &str` -- The ID of the workflow. You can also pass the workflow file name as a string. */ pub async fn get_workflow_usage( @@ -3737,9 +7794,9 @@ impl Actions { let url = self.client.url( &format!( "/repos/{}/{}/actions/workflows/{}/timing", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(workflow_id), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&workflow_id.to_string()), ), None, ); @@ -3756,22 +7813,29 @@ impl Actions { /** * List environment secrets. * - * This function performs a `GET` to the `/repositories/{repository_id}/environments/{environment_name}/secrets` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/environments/{environment_name}/secrets` endpoint. * - * Lists all secrets available in an environment without revealing their encrypted values. You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `secrets` repository permission to use this endpoint. + * Lists all secrets available in an environment without revealing their + * encrypted values. * - * FROM: + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `repository_id: i64` - * * `environment_name: &str` -- The name of the environment. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_environment_secrets( &self, - repository_id: i64, + owner: &str, + repo: &str, environment_name: &str, per_page: i64, page: i64, @@ -3786,9 +7850,10 @@ impl Actions { let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repositories/{}/environments/{}/secrets?{}", - crate::progenitor_support::encode_path(&repository_id.to_string()), - crate::progenitor_support::encode_path(environment_name), + "/repos/{}/{}/environments/{}/secrets?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), query_ ), None, @@ -3806,27 +7871,35 @@ impl Actions { /** * Get an environment public key. * - * This function performs a `GET` to the `/repositories/{repository_id}/environments/{environment_name}/secrets/public-key` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/environments/{environment_name}/secrets/public-key` endpoint. + * + * Get the public key for an environment, which you need to encrypt environment + * secrets. You need to encrypt a secret before you can create or update secrets. * - * Get the public key for an environment, which you need to encrypt environment secrets. You need to encrypt a secret before you can create or update secrets. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the `repo` scope. GitHub Apps must have the `secrets` repository permission to use this endpoint. + * Anyone with read access to the repository can use this endpoint. * - * FROM: + * If the repository is private, OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `repository_id: i64` - * * `environment_name: &str` -- The name of the environment. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. */ pub async fn get_environment_public_key( &self, - repository_id: i64, + owner: &str, + repo: &str, environment_name: &str, ) -> ClientResult> { let url = self.client.url( &format!( - "/repositories/{}/environments/{}/secrets/public-key", - crate::progenitor_support::encode_path(&repository_id.to_string()), - crate::progenitor_support::encode_path(environment_name), + "/repos/{}/{}/environments/{}/secrets/public-key", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), ), None, ); @@ -3843,30 +7916,37 @@ impl Actions { /** * Get an environment secret. * - * This function performs a `GET` to the `/repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/environments/{environment_name}/secrets/{secret_name}` endpoint. + * + * Gets a single environment secret without revealing its encrypted value. + * + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. * - * Gets a single environment secret without revealing its encrypted value. You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `secrets` repository permission to use this endpoint. + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `repository_id: i64` - * * `environment_name: &str` -- The name of the environment. - * * `secret_name: &str` -- secret_name parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `secret_name: &str` -- The name of the secret. */ pub async fn get_environment_secret( &self, - repository_id: i64, + owner: &str, + repo: &str, environment_name: &str, secret_name: &str, ) -> ClientResult> { let url = self.client.url( &format!( - "/repositories/{}/environments/{}/secrets/{}", - crate::progenitor_support::encode_path(&repository_id.to_string()), - crate::progenitor_support::encode_path(environment_name), - crate::progenitor_support::encode_path(secret_name), + "/repos/{}/{}/environments/{}/secrets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), ), None, ); @@ -3883,110 +7963,193 @@ impl Actions { /** * Create or update an environment secret. * - * This function performs a `PUT` to the `/repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}` endpoint. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/environments/{environment_name}/secrets/{secret_name}` endpoint. * * Creates or updates an environment secret with an encrypted value. Encrypt your secret using - * [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). You must authenticate using an access - * token with the `repo` scope to use this endpoint. GitHub Apps must have the `secrets` repository permission to use - * this endpoint. + * [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api)." * - * #### Example encrypting a secret using Node.js + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. * - * Encrypt your secret using the [tweetsodium](https://github.com/github/tweetsodium) library. + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * ``` - * const sodium = require('tweetsodium'); + * FROM: * - * const key = "base64-encoded-public-key"; - * const value = "plain-text-secret"; + * **Parameters:** * - * // Convert the message and key to Uint8Array's (Buffer implements that interface) - * const messageBytes = Buffer.from(value); - * const keyBytes = Buffer.from(key, 'base64'); + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn create_or_update_environment_secret( + &self, + owner: &str, + repo: &str, + environment_name: &str, + secret_name: &str, + body: &crate::types::ActionsCreateUpdateRepoSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/secrets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete an environment secret. * - * // Encrypt using LibSodium. - * const encryptedBytes = sodium.seal(messageBytes, keyBytes); + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/environments/{environment_name}/secrets/{secret_name}` endpoint. * - * // Base64 the encrypted secret - * const encrypted = Buffer.from(encryptedBytes).toString('base64'); + * Deletes a secret in an environment using the secret name. * - * console.log(encrypted); - * ``` + * Authenticated users must have collaborator access to a repository to create, update, or read secrets. * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * #### Example encrypting a secret using Python + * FROM: * - * Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/stable/public/#nacl-public-sealedbox) with Python 3. + * **Parameters:** * - * ``` - * from base64 import b64encode - * from nacl import encoding, public - * - * def encrypt(public_key: str, secret_value: str) -> str: - * """Encrypt a Unicode string using the public key.""" - * public_key = public.PublicKey(public_key.encode("utf-8"), encoding.Base64Encoder()) - * sealed_box = public.SealedBox(public_key) - * encrypted = sealed_box.encrypt(secret_value.encode("utf-8")) - * return b64encode(encrypted).decode("utf-8") - * ``` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn delete_environment_secret( + &self, + owner: &str, + repo: &str, + environment_name: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/secrets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List environment variables. * - * #### Example encrypting a secret using C# + * This function performs a `GET` to the `/repos/{owner}/{repo}/environments/{environment_name}/variables` endpoint. * - * Encrypt your secret using the [Sodium.Core](https://www.nuget.org/packages/Sodium.Core/) package. + * Lists all environment variables. * - * ``` - * var secretValue = System.Text.Encoding.UTF8.GetBytes("mySecret"); - * var publicKey = Convert.FromBase64String("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvvcCU="); + * Authenticated users must have collaborator access to a repository to create, update, or read variables. * - * var sealedPublicKeyBox = Sodium.SealedPublicKeyBox.Create(secretValue, publicKey); + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * Console.WriteLine(Convert.ToBase64String(sealedPublicKeyBox)); - * ``` + * FROM: * - * #### Example encrypting a secret using Ruby + * **Parameters:** * - * Encrypt your secret using the [rbnacl](https://github.com/RubyCrypto/rbnacl) gem. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `per_page: i64` -- The number of results per page (max 30). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_environment_variables( + &self, + owner: &str, + repo: &str, + environment_name: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/variables?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create an environment variable. * - * ```ruby - * require "rbnacl" - * require "base64" + * This function performs a `POST` to the `/repos/{owner}/{repo}/environments/{environment_name}/variables` endpoint. * - * key = Base64.decode64("+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0=") - * public_key = RbNaCl::PublicKey.new(key) + * Create an environment variable that you can reference in a GitHub Actions workflow. * - * box = RbNaCl::Boxes::Sealed.from_public_key(public_key) - * encrypted_secret = box.encrypt("my_secret") + * Authenticated users must have collaborator access to a repository to create, update, or read variables. * - * # Print the base64 encoded secret - * puts Base64.strict_encode64(encrypted_secret) - * ``` + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `repository_id: i64` - * * `environment_name: &str` -- The name of the environment. - * * `secret_name: &str` -- secret_name parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. */ - pub async fn create_or_update_environment_secret( + pub async fn create_environment_variable( &self, - repository_id: i64, + owner: &str, + repo: &str, environment_name: &str, - secret_name: &str, - body: &crate::types::ActionsCreateUpdateRepoSecretRequest, - ) -> ClientResult> { + body: &crate::types::ActionsCreateRepoVariableRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repositories/{}/environments/{}/secrets/{}", - crate::progenitor_support::encode_path(&repository_id.to_string()), - crate::progenitor_support::encode_path(environment_name), - crate::progenitor_support::encode_path(secret_name), + "/repos/{}/{}/environments/{}/variables", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), ), None, ); self.client - .put( + .post( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -3996,32 +8159,86 @@ impl Actions { .await } /** - * Delete an environment secret. + * Get an environment variable. * - * This function performs a `DELETE` to the `/repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/environments/{environment_name}/variables/{name}` endpoint. * - * Deletes a secret in an environment using the secret name. You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `secrets` repository permission to use this endpoint. + * Gets a specific variable in an environment. * - * FROM: + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `repository_id: i64` - * * `environment_name: &str` -- The name of the environment. - * * `secret_name: &str` -- secret_name parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `name: &str` -- The name of the variable. */ - pub async fn delete_environment_secret( + pub async fn get_environment_variable( &self, - repository_id: i64, + owner: &str, + repo: &str, + environment_name: &str, + name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/variables/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete an environment variable. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/environments/{environment_name}/variables/{name}` endpoint. + * + * Deletes an environment variable using the variable name. + * + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `name: &str` -- The name of the variable. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + */ + pub async fn delete_environment_variable( + &self, + owner: &str, + repo: &str, + name: &str, environment_name: &str, - secret_name: &str, ) -> ClientResult> { let url = self.client.url( &format!( - "/repositories/{}/environments/{}/secrets/{}", - crate::progenitor_support::encode_path(&repository_id.to_string()), - crate::progenitor_support::encode_path(environment_name), - crate::progenitor_support::encode_path(secret_name), + "/repos/{}/{}/environments/{}/variables/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), ), None, ); @@ -4035,4 +8252,52 @@ impl Actions { ) .await } + /** + * Update an environment variable. + * + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/environments/{environment_name}/variables/{name}` endpoint. + * + * Updates an environment variable that you can reference in a GitHub Actions workflow. + * + * Authenticated users must have collaborator access to a repository to create, update, or read variables. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `name: &str` -- The name of the variable. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + */ + pub async fn update_environment_variable( + &self, + owner: &str, + repo: &str, + name: &str, + environment_name: &str, + body: &crate::types::ActionsUpdateRepoVariableRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/variables/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } } diff --git a/github/src/activity.rs b/github/src/activity.rs index 6d5e7b3a..3ea11f79 100644 --- a/github/src/activity.rs +++ b/github/src/activity.rs @@ -16,14 +16,15 @@ impl Activity { * * This function performs a `GET` to the `/events` endpoint. * - * We delay the public events feed by five minutes, which means the most recent event returned by the public events API actually occurred at least five minutes ago. + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * FROM: + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_public_events( &self, @@ -56,14 +57,15 @@ impl Activity { * * As opposed to `list_public_events`, this function returns all the pages of the request at once. * - * We delay the public events feed by five minutes, which means the most recent event returned by the public events API actually occurred at least five minutes ago. + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * FROM: + * FROM: */ pub async fn list_all_public_events( &self, ) -> ClientResult>> { - let url = self.client.url("/events", None); + let url = self.client.url(&"/events".to_string(), None); self.client .get_all_pages( &url, @@ -79,22 +81,25 @@ impl Activity { * * This function performs a `GET` to the `/feeds` endpoint. * - * GitHub provides several timeline resources in [Atom](http://en.wikipedia.org/wiki/Atom_(standard)) format. The Feeds API lists all the feeds available to the authenticated user: + * Lists the feeds available to the authenticated user. The response provides a URL for each feed. You can then get a specific feed by sending a request to one of the feed URLs. * * * **Timeline**: The GitHub global public timeline - * * **User**: The public timeline for any user, using [URI template](https://docs.github.com/rest/overview/resources-in-the-rest-api#hypermedia) + * * **User**: The public timeline for any user, using `uri_template`. For more information, see "[Hypermedia](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#hypermedia)." * * **Current user public**: The public timeline for the authenticated user * * **Current user**: The private timeline for the authenticated user * * **Current user actor**: The private timeline for activity created by the authenticated user * * **Current user organizations**: The private timeline for the organizations the authenticated user is a member of. * * **Security advisories**: A collection of public announcements that provide information about security-related vulnerabilities in software on GitHub. * - * **Note**: Private feeds are only returned when [authenticating via Basic Auth](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) since current feed URIs use the older, non revocable auth tokens. + * By default, timeline resources are returned in JSON. You can specify the `application/atom+xml` type in the `Accept` header to return timeline resources in Atom format. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * > [!NOTE] + * > Private feeds are only returned when [authenticating via Basic Auth](https://docs.github.com/rest/authentication/authenticating-to-the-rest-api#using-basic-authentication) since current feed URIs use the older, non revocable auth tokens. + * + * FROM: */ pub async fn get_feeds(&self) -> ClientResult> { - let url = self.client.url("/feeds", None); + let url = self.client.url(&"/feeds".to_string(), None); self.client .get( &url, @@ -110,16 +115,17 @@ impl Activity { * * This function performs a `GET` to the `/networks/{owner}/{repo}/events` endpoint. * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_public_events_for_repo_network( &self, @@ -139,8 +145,8 @@ impl Activity { let url = self.client.url( &format!( "/networks/{}/{}/events?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -162,9 +168,10 @@ impl Activity { * * As opposed to `list_public_events_for_repo_network`, this function returns all the pages of the request at once. * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * - * FROM: + * FROM: */ pub async fn list_all_public_events_for_repo_network( &self, @@ -174,8 +181,8 @@ impl Activity { let url = self.client.url( &format!( "/networks/{}/{}/events", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -196,16 +203,16 @@ impl Activity { * * List all notifications for the current user, sorted by most recently updated. * - * FROM: + * FROM: * * **Parameters:** * * * `all: bool` -- If `true`, show notifications marked as read. * * `participating: bool` -- If `true`, only shows notifications in which the user is directly participating or mentioned. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. * * `before: chrono::DateTime` -- Only show notifications updated before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 50). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_notifications_for_authenticated_user( &self, @@ -213,8 +220,8 @@ impl Activity { participating: bool, since: Option>, before: Option>, - per_page: i64, page: i64, + per_page: i64, ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if all { @@ -256,7 +263,7 @@ impl Activity { * * List all notifications for the current user, sorted by most recently updated. * - * FROM: + * FROM: */ pub async fn list_all_notifications_for_authenticated_user( &self, @@ -295,15 +302,15 @@ impl Activity { * * This function performs a `PUT` to the `/notifications` endpoint. * - * Marks all notifications as "read" removes it from the [default view on GitHub](https://github.com/notifications). If the number of notifications is too large to complete in one request, you will receive a `202 Accepted` status and GitHub will run an asynchronous process to mark notifications as "read." To check whether any "unread" notifications remain, you can use the [List notifications for the authenticated user](https://docs.github.com/rest/reference/activity#list-notifications-for-the-authenticated-user) endpoint and pass the query parameter `all=false`. + * Marks all notifications as "read" for the current user. If the number of notifications is too large to complete in one request, you will receive a `202 Accepted` status and GitHub will run an asynchronous process to mark notifications as "read." To check whether any "unread" notifications remain, you can use the [List notifications for the authenticated user](https://docs.github.com/rest/activity/notifications#list-notifications-for-the-authenticated-user) endpoint and pass the query parameter `all=false`. * - * FROM: + * FROM: */ pub async fn mark_notifications_as_read( &self, body: &crate::types::ActivityMarkNotificationsAsReadRequest, - ) -> ClientResult> { - let url = self.client.url("/notifications", None); + ) -> ClientResult> { + let url = self.client.url(&"/notifications".to_string(), None); self.client .put( &url, @@ -319,13 +326,13 @@ impl Activity { * * This function performs a `GET` to the `/notifications/threads/{thread_id}` endpoint. * + * Gets information about a notification thread. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `thread_id: i64` -- thread_id parameter. + * * `thread_id: i64` -- The unique identifier of the notification thread. This corresponds to the value returned in the `id` field when you retrieve notifications (for example with the [`GET /notifications` operation](https://docs.github.com/rest/activity/notifications#list-notifications-for-the-authenticated-user)). */ pub async fn get_thread( &self, @@ -348,18 +355,49 @@ impl Activity { ) .await } + /** + * Mark a thread as done. + * + * This function performs a `DELETE` to the `/notifications/threads/{thread_id}` endpoint. + * + * Marks a thread as "done." Marking a thread as "done" is equivalent to marking a notification in your notification inbox on GitHub as done: https://github.com/notifications. + * + * FROM: + * + * **Parameters:** + * + * * `thread_id: i64` -- The unique identifier of the notification thread. This corresponds to the value returned in the `id` field when you retrieve notifications (for example with the [`GET /notifications` operation](https://docs.github.com/rest/activity/notifications#list-notifications-for-the-authenticated-user)). + */ + pub async fn mark_thread_as_done(&self, thread_id: i64) -> ClientResult> { + let url = self.client.url( + &format!( + "/notifications/threads/{}", + crate::progenitor_support::encode_path(&thread_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } /** * Mark a thread as read. * * This function performs a `PATCH` to the `/notifications/threads/{thread_id}` endpoint. * + * Marks a thread as "read." Marking a thread as "read" is equivalent to clicking a notification in your notification inbox on GitHub: https://github.com/notifications. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `thread_id: i64` -- thread_id parameter. + * * `thread_id: i64` -- The unique identifier of the notification thread. This corresponds to the value returned in the `id` field when you retrieve notifications (for example with the [`GET /notifications` operation](https://docs.github.com/rest/activity/notifications#list-notifications-for-the-authenticated-user)). */ pub async fn mark_thread_as_read(&self, thread_id: i64) -> ClientResult> { let url = self.client.url( @@ -384,15 +422,15 @@ impl Activity { * * This function performs a `GET` to the `/notifications/threads/{thread_id}/subscription` endpoint. * - * This checks to see if the current user is subscribed to a thread. You can also [get a repository subscription](https://docs.github.com/rest/reference/activity#get-a-repository-subscription). + * This checks to see if the current user is subscribed to a thread. You can also [get a repository subscription](https://docs.github.com/rest/activity/watching#get-a-repository-subscription). * * Note that subscriptions are only generated if a user is participating in a conversation--for example, they've replied to the thread, were **@mentioned**, or manually subscribe to a thread. * - * FROM: + * FROM: * * **Parameters:** * - * * `thread_id: i64` -- thread_id parameter. + * * `thread_id: i64` -- The unique identifier of the notification thread. This corresponds to the value returned in the `id` field when you retrieve notifications (for example with the [`GET /notifications` operation](https://docs.github.com/rest/activity/notifications#list-notifications-for-the-authenticated-user)). */ pub async fn get_thread_subscription_for_authenticated_user( &self, @@ -424,13 +462,13 @@ impl Activity { * * You can also use this endpoint to subscribe to threads that you are currently not receiving notifications for or to subscribed to threads that you have previously ignored. * - * Unsubscribing from a conversation in a repository that you are not watching is functionally equivalent to the [Delete a thread subscription](https://docs.github.com/rest/reference/activity#delete-a-thread-subscription) endpoint. + * Unsubscribing from a conversation in a repository that you are not watching is functionally equivalent to the [Delete a thread subscription](https://docs.github.com/rest/activity/notifications#delete-a-thread-subscription) endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `thread_id: i64` -- thread_id parameter. + * * `thread_id: i64` -- The unique identifier of the notification thread. This corresponds to the value returned in the `id` field when you retrieve notifications (for example with the [`GET /notifications` operation](https://docs.github.com/rest/activity/notifications#list-notifications-for-the-authenticated-user)). */ pub async fn set_thread_subscription( &self, @@ -459,13 +497,13 @@ impl Activity { * * This function performs a `DELETE` to the `/notifications/threads/{thread_id}/subscription` endpoint. * - * Mutes all future notifications for a conversation until you comment on the thread or get an **@mention**. If you are watching the repository of the thread, you will still receive notifications. To ignore future notifications for a repository you are watching, use the [Set a thread subscription](https://docs.github.com/rest/reference/activity#set-a-thread-subscription) endpoint and set `ignore` to `true`. + * Mutes all future notifications for a conversation until you comment on the thread or get an **@mention**. If you are watching the repository of the thread, you will still receive notifications. To ignore future notifications for a repository you are watching, use the [Set a thread subscription](https://docs.github.com/rest/activity/notifications#set-a-thread-subscription) endpoint and set `ignore` to `true`. * - * FROM: + * FROM: * * **Parameters:** * - * * `thread_id: i64` -- thread_id parameter. + * * `thread_id: i64` -- The unique identifier of the notification thread. This corresponds to the value returned in the `id` field when you retrieve notifications (for example with the [`GET /notifications` operation](https://docs.github.com/rest/activity/notifications#list-notifications-for-the-authenticated-user)). */ pub async fn delete_thread_subscription( &self, @@ -493,15 +531,16 @@ impl Activity { * * This function performs a `GET` to the `/orgs/{org}/events` endpoint. * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_public_org_events( &self, @@ -520,7 +559,7 @@ impl Activity { let url = self.client.url( &format!( "/orgs/{}/events?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -542,9 +581,10 @@ impl Activity { * * As opposed to `list_public_org_events`, this function returns all the pages of the request at once. * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * - * FROM: + * FROM: */ pub async fn list_all_public_org_events( &self, @@ -553,7 +593,7 @@ impl Activity { let url = self.client.url( &format!( "/orgs/{}/events", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -572,16 +612,17 @@ impl Activity { * * This function performs a `GET` to the `/repos/{owner}/{repo}/events` endpoint. * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_repo_events( &self, @@ -601,8 +642,8 @@ impl Activity { let url = self.client.url( &format!( "/repos/{}/{}/events?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -624,9 +665,10 @@ impl Activity { * * As opposed to `list_repo_events`, this function returns all the pages of the request at once. * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * - * FROM: + * FROM: */ pub async fn list_all_repo_events( &self, @@ -636,8 +678,8 @@ impl Activity { let url = self.client.url( &format!( "/repos/{}/{}/events", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -656,20 +698,20 @@ impl Activity { * * This function performs a `GET` to the `/repos/{owner}/{repo}/notifications` endpoint. * - * List all notifications for the current user. + * Lists all notifications for the current user in the specified repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `all: bool` -- If `true`, show notifications marked as read. * * `participating: bool` -- If `true`, only shows notifications in which the user is directly participating or mentioned. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. * * `before: chrono::DateTime` -- Only show notifications updated before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_repo_notifications_for_authenticated_user( &self, @@ -705,8 +747,8 @@ impl Activity { let url = self.client.url( &format!( "/repos/{}/{}/notifications?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -728,9 +770,9 @@ impl Activity { * * As opposed to `list_repo_notifications_for_authenticated_user`, this function returns all the pages of the request at once. * - * List all notifications for the current user. + * Lists all notifications for the current user in the specified repository. * - * FROM: + * FROM: */ pub async fn list_all_repo_notifications_for_authenticated_user( &self, @@ -758,8 +800,8 @@ impl Activity { let url = self.client.url( &format!( "/repos/{}/{}/notifications?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -779,14 +821,14 @@ impl Activity { * * This function performs a `PUT` to the `/repos/{owner}/{repo}/notifications` endpoint. * - * Marks all notifications in a repository as "read" removes them from the [default view on GitHub](https://github.com/notifications). If the number of notifications is too large to complete in one request, you will receive a `202 Accepted` status and GitHub will run an asynchronous process to mark notifications as "read." To check whether any "unread" notifications remain, you can use the [List repository notifications for the authenticated user](https://docs.github.com/rest/reference/activity#list-repository-notifications-for-the-authenticated-user) endpoint and pass the query parameter `all=false`. + * Marks all notifications in a repository as "read" for the current user. If the number of notifications is too large to complete in one request, you will receive a `202 Accepted` status and GitHub will run an asynchronous process to mark notifications as "read." To check whether any "unread" notifications remain, you can use the [List repository notifications for the authenticated user](https://docs.github.com/rest/activity/notifications#list-repository-notifications-for-the-authenticated-user) endpoint and pass the query parameter `all=false`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn mark_repo_notifications_as_read( &self, @@ -797,8 +839,8 @@ impl Activity { let url = self.client.url( &format!( "/repos/{}/{}/notifications", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -819,16 +861,18 @@ impl Activity { * * Lists the people that have starred the repository. * - * You can also find out _when_ stars were created by passing the following custom [media type](https://docs.github.com/rest/overview/media-types/) via the `Accept` header: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.star+json`**: Includes a timestamp of when the star was created. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_stargazers_for_repo( &self, @@ -848,8 +892,8 @@ impl Activity { let url = self.client.url( &format!( "/repos/{}/{}/stargazers?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -871,14 +915,14 @@ impl Activity { * * Lists the people watching the specified repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_watchers_for_repo( &self, @@ -898,8 +942,8 @@ impl Activity { let url = self.client.url( &format!( "/repos/{}/{}/subscribers?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -923,7 +967,7 @@ impl Activity { * * Lists the people watching the specified repository. * - * FROM: + * FROM: */ pub async fn list_all_watchers_for_repo( &self, @@ -933,8 +977,8 @@ impl Activity { let url = self.client.url( &format!( "/repos/{}/{}/subscribers", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -953,14 +997,14 @@ impl Activity { * * This function performs a `GET` to the `/repos/{owner}/{repo}/subscription` endpoint. * + * Gets information about whether the authenticated user is subscribed to the repository. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_repo_subscription( &self, @@ -970,8 +1014,8 @@ impl Activity { let url = self.client.url( &format!( "/repos/{}/{}/subscription", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -990,14 +1034,14 @@ impl Activity { * * This function performs a `PUT` to the `/repos/{owner}/{repo}/subscription` endpoint. * - * If you would like to watch a repository, set `subscribed` to `true`. If you would like to ignore notifications made within a repository, set `ignored` to `true`. If you would like to stop watching a repository, [delete the repository's subscription](https://docs.github.com/rest/reference/activity#delete-a-repository-subscription) completely. + * If you would like to watch a repository, set `subscribed` to `true`. If you would like to ignore notifications made within a repository, set `ignored` to `true`. If you would like to stop watching a repository, [delete the repository's subscription](https://docs.github.com/rest/activity/watching#delete-a-repository-subscription) completely. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn set_repo_subscription( &self, @@ -1008,8 +1052,8 @@ impl Activity { let url = self.client.url( &format!( "/repos/{}/{}/subscription", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -1028,14 +1072,14 @@ impl Activity { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/subscription` endpoint. * - * This endpoint should only be used to stop watching a repository. To control whether or not you wish to receive notifications from a repository, [set the repository's subscription manually](https://docs.github.com/rest/reference/activity#set-a-repository-subscription). + * This endpoint should only be used to stop watching a repository. To control whether or not you wish to receive notifications from a repository, [set the repository's subscription manually](https://docs.github.com/rest/activity/watching#set-a-repository-subscription). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn delete_repo_subscription( &self, @@ -1045,8 +1089,8 @@ impl Activity { let url = self.client.url( &format!( "/repos/{}/{}/subscription", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -1067,22 +1111,22 @@ impl Activity { * * Lists repositories the authenticated user has starred. * - * You can also find out _when_ stars were created by passing the following custom [media type](https://docs.github.com/rest/overview/media-types/) via the `Accept` header: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.star+json`**: Includes a timestamp of when the star was created. * - * FROM: + * FROM: * * **Parameters:** * - * * `sort: crate::types::Sort` -- One of `created` (when the repository was starred) or `updated` (when it was last pushed to). - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `sort: crate::types::SortData` -- The property to sort the results by. `created` means when the repository was starred. `updated` means when the repository was last pushed to. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_repos_starred_by_authenticated_user( &self, - sort: crate::types::Sort, + sort: crate::types::SortData, direction: crate::types::Order, per_page: i64, page: i64, @@ -1121,13 +1165,15 @@ impl Activity { * * Lists repositories the authenticated user has starred. * - * You can also find out _when_ stars were created by passing the following custom [media type](https://docs.github.com/rest/overview/media-types/) via the `Accept` header: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.star+json`**: Includes a timestamp of when the star was created. * - * FROM: + * FROM: */ pub async fn list_all_repos_starred_by_authenticated_user( &self, - sort: crate::types::Sort, + sort: crate::types::SortData, direction: crate::types::Order, ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); @@ -1154,14 +1200,14 @@ impl Activity { * * This function performs a `GET` to the `/user/starred/{owner}/{repo}` endpoint. * + * Whether the authenticated user has starred the repository. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn check_repo_is_starred_by_authenticated_user( &self, @@ -1171,8 +1217,8 @@ impl Activity { let url = self.client.url( &format!( "/user/starred/{}/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -1191,14 +1237,14 @@ impl Activity { * * This function performs a `PUT` to the `/user/starred/{owner}/{repo}` endpoint. * - * Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://docs.github.com/rest/overview/resources-in-the-rest-api#http-verbs)." + * Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)." * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn star_repo_for_authenticated_user( &self, @@ -1208,8 +1254,8 @@ impl Activity { let url = self.client.url( &format!( "/user/starred/{}/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -1228,14 +1274,14 @@ impl Activity { * * This function performs a `DELETE` to the `/user/starred/{owner}/{repo}` endpoint. * + * Unstar a repository that the authenticated user has previously starred. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn unstar_repo_for_authenticated_user( &self, @@ -1245,8 +1291,8 @@ impl Activity { let url = self.client.url( &format!( "/user/starred/{}/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -1267,12 +1313,12 @@ impl Activity { * * Lists repositories the authenticated user is watching. * - * FROM: + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_watched_repos_for_authenticated_user( &self, @@ -1309,12 +1355,12 @@ impl Activity { * * Lists repositories the authenticated user is watching. * - * FROM: + * FROM: */ pub async fn list_all_watched_repos_for_authenticated_user( &self, ) -> ClientResult>> { - let url = self.client.url("/user/subscriptions", None); + let url = self.client.url(&"/user/subscriptions".to_string(), None); self.client .get_all_pages( &url, @@ -1330,15 +1376,18 @@ impl Activity { * * This function performs a `GET` to the `/users/{username}/events` endpoint. * - * If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. + * If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. _Optional_: use the fine-grained token with following permission set to view private events: "Events" user permissions (read). * - * FROM: + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. + * + * FROM: * * **Parameters:** * - * * `username: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `username: &str` -- The handle for the GitHub user account. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_events_for_authenticated_user( &self, @@ -1357,7 +1406,7 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/events?{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), query_ ), None, @@ -1379,9 +1428,12 @@ impl Activity { * * As opposed to `list_events_for_authenticated_user`, this function returns all the pages of the request at once. * - * If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. + * If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. _Optional_: use the fine-grained token with following permission set to view private events: "Events" user permissions (read). + * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * FROM: + * FROM: */ pub async fn list_all_events_for_authenticated_user( &self, @@ -1390,7 +1442,7 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/events", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); @@ -1411,14 +1463,17 @@ impl Activity { * * This is the user's organization dashboard. You must be authenticated as the user to view this. * - * FROM: + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. + * + * FROM: * * **Parameters:** * - * * `username: &str` - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `username: &str` -- The handle for the GitHub user account. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_org_events_for_authenticated_user( &self, @@ -1438,8 +1493,8 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/events/orgs/{}?{}", - crate::progenitor_support::encode_path(username), - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -1463,7 +1518,10 @@ impl Activity { * * This is the user's organization dashboard. You must be authenticated as the user to view this. * - * FROM: + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. + * + * FROM: */ pub async fn list_all_org_events_for_authenticated_user( &self, @@ -1473,8 +1531,8 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/events/orgs/{}", - crate::progenitor_support::encode_path(username), - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -1493,15 +1551,16 @@ impl Activity { * * This function performs a `GET` to the `/users/{username}/events/public` endpoint. * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `username: &str` -- The handle for the GitHub user account. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_public_events_for_user( &self, @@ -1520,7 +1579,7 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/events/public?{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), query_ ), None, @@ -1542,9 +1601,10 @@ impl Activity { * * As opposed to `list_public_events_for_user`, this function returns all the pages of the request at once. * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * - * FROM: + * FROM: */ pub async fn list_all_public_events_for_user( &self, @@ -1553,7 +1613,7 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/events/public", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); @@ -1572,15 +1632,19 @@ impl Activity { * * This function performs a `GET` to the `/users/{username}/received_events` endpoint. * - * These are events that you've received by watching repos and following users. If you are authenticated as the given user, you will see private events. Otherwise, you'll only see public events. + * These are events that you've received by watching repositories and following users. If you are authenticated as the + * given user, you will see private events. Otherwise, you'll only see public events. + * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `username: &str` -- The handle for the GitHub user account. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_received_events_for_user( &self, @@ -1599,7 +1663,7 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/received_events?{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), query_ ), None, @@ -1621,9 +1685,13 @@ impl Activity { * * As opposed to `list_received_events_for_user`, this function returns all the pages of the request at once. * - * These are events that you've received by watching repos and following users. If you are authenticated as the given user, you will see private events. Otherwise, you'll only see public events. + * These are events that you've received by watching repositories and following users. If you are authenticated as the + * given user, you will see private events. Otherwise, you'll only see public events. + * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * FROM: + * FROM: */ pub async fn list_all_received_events_for_user( &self, @@ -1632,7 +1700,7 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/received_events", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); @@ -1651,15 +1719,16 @@ impl Activity { * * This function performs a `GET` to the `/users/{username}/received_events/public` endpoint. * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `username: &str` -- The handle for the GitHub user account. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_received_public_events_for_user( &self, @@ -1678,7 +1747,7 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/received_events/public?{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), query_ ), None, @@ -1700,9 +1769,10 @@ impl Activity { * * As opposed to `list_received_public_events_for_user`, this function returns all the pages of the request at once. * + * > [!NOTE] + * > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h. * - * - * FROM: + * FROM: */ pub async fn list_all_received_public_events_for_user( &self, @@ -1711,7 +1781,7 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/received_events/public", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); @@ -1732,24 +1802,24 @@ impl Activity { * * Lists repositories a user has starred. * - * You can also find out _when_ stars were created by passing the following custom [media type](https://docs.github.com/rest/overview/media-types/) via the `Accept` header: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.star+json`**: Includes a timestamp of when the star was created. * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` - * * `sort: crate::types::Sort` -- One of `created` (when the repository was starred) or `updated` (when it was last pushed to). - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `username: &str` -- The handle for the GitHub user account. + * * `sort: crate::types::SortData` -- The property to sort the results by. `created` means when the repository was starred. `updated` means when the repository was last pushed to. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_repos_starred_by_user( &self, username: &str, - sort: crate::types::Sort, + sort: crate::types::SortData, direction: crate::types::Order, per_page: i64, page: i64, @@ -1772,7 +1842,7 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/starred?{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), query_ ), None, @@ -1794,13 +1864,13 @@ impl Activity { * * Lists repositories a user is watching. * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `username: &str` -- The handle for the GitHub user account. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_repos_watched_by_user( &self, @@ -1819,7 +1889,7 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/subscriptions?{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), query_ ), None, @@ -1843,7 +1913,7 @@ impl Activity { * * Lists repositories a user is watching. * - * FROM: + * FROM: */ pub async fn list_all_repos_watched_by_user( &self, @@ -1852,7 +1922,7 @@ impl Activity { let url = self.client.url( &format!( "/users/{}/subscriptions", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); diff --git a/github/src/apps.rs b/github/src/apps.rs index 89e2ee47..7d015d45 100644 --- a/github/src/apps.rs +++ b/github/src/apps.rs @@ -16,16 +16,16 @@ impl Apps { * * This function performs a `GET` to the `/app` endpoint. * - * Returns the GitHub App associated with the authentication credentials used. To see how many app installations are associated with this GitHub App, see the `installations_count` in the response. For more details about your app's installations, see the "[List installations for the authenticated app](https://docs.github.com/rest/reference/apps#list-installations-for-the-authenticated-app)" endpoint. + * Returns the GitHub App associated with the authentication credentials used. To see how many app installations are associated with this GitHub App, see the `installations_count` in the response. For more details about your app's installations, see the "[List installations for the authenticated app](https://docs.github.com/rest/apps/apps#list-installations-for-the-authenticated-app)" endpoint. * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: */ pub async fn get_authenticated( &self, ) -> ClientResult> { - let url = self.client.url("/app", None); + let url = self.client.url(&"/app".to_string(), None); self.client .get( &url, @@ -43,7 +43,7 @@ impl Apps { * * Use this endpoint to complete the handshake necessary when implementing the [GitHub App Manifest flow](https://docs.github.com/apps/building-github-apps/creating-github-apps-from-a-manifest/). When you create a GitHub App with the manifest flow, you receive a temporary `code` used to retrieve the GitHub App's `id`, `pem` (private key), and `webhook_secret`. * - * FROM: + * FROM: * * **Parameters:** * @@ -56,7 +56,7 @@ impl Apps { let url = self.client.url( &format!( "/app-manifests/{}/conversions", - crate::progenitor_support::encode_path(code), + crate::progenitor_support::encode_path(&code.to_string()), ), None, ); @@ -65,7 +65,7 @@ impl Apps { &url, crate::Message { body: None, - content_type: Some("application/json".to_string()), + content_type: None, }, ) .await @@ -79,12 +79,12 @@ impl Apps { * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: */ pub async fn get_webhook_config_for_app( &self, ) -> ClientResult> { - let url = self.client.url("/app/hook/config", None); + let url = self.client.url(&"/app/hook/config".to_string(), None); self.client .get( &url, @@ -104,13 +104,13 @@ impl Apps { * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: */ pub async fn update_webhook_config_for_app( &self, body: &crate::types::AppsUpdateWebhookConfigAppRequest, ) -> ClientResult> { - let url = self.client.url("/app/hook/config", None); + let url = self.client.url(&"/app/hook/config".to_string(), None); self.client .patch( &url, @@ -130,11 +130,11 @@ impl Apps { * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". * * `cursor: &str` -- Used for pagination: the starting delivery from which the page of deliveries is fetched. Refer to the `link` header for the next and previous page cursors. */ pub async fn list_webhook_deliveries( @@ -174,7 +174,7 @@ impl Apps { * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: */ pub async fn list_all_webhook_deliveries( &self, @@ -207,7 +207,7 @@ impl Apps { * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * @@ -243,7 +243,7 @@ impl Apps { * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * @@ -252,7 +252,7 @@ impl Apps { pub async fn redeliver_webhook_delivery( &self, delivery_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( "/app/hook/deliveries/{}/attempts", @@ -270,22 +270,89 @@ impl Apps { ) .await } + /** + * List installation requests for the authenticated app. + * + * This function performs a `GET` to the `/app/installation-requests` endpoint. + * + * Lists all the pending installation requests for the authenticated GitHub App. + * + * FROM: + * + * **Parameters:** + * + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_installation_requests_for_authenticated_app( + &self, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self + .client + .url(&format!("/app/installation-requests?{}", query_), None); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List installation requests for the authenticated app. + * + * This function performs a `GET` to the `/app/installation-requests` endpoint. + * + * As opposed to `list_installation_requests_for_authenticated_app`, this function returns all the pages of the request at once. + * + * Lists all the pending installation requests for the authenticated GitHub App. + * + * FROM: + */ + pub async fn list_all_installation_requests_for_authenticated_app( + &self, + ) -> ClientResult>> { + let url = self + .client + .url(&"/app/installation-requests".to_string(), None); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } /** * List installations for the authenticated app. * * This function performs a `GET` to the `/app/installations` endpoint. * - * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. - * * The permissions the installation has are included under the `permissions` key. * - * FROM: + * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. + * + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. * * `outdated: &str` */ pub async fn list_installations( @@ -329,11 +396,11 @@ impl Apps { * * As opposed to `list_installations`, this function returns all the pages of the request at once. * - * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. - * * The permissions the installation has are included under the `permissions` key. * - * FROM: + * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. + * + * FROM: */ pub async fn list_all_installations( &self, @@ -366,15 +433,15 @@ impl Apps { * * This function performs a `GET` to the `/app/installations/{installation_id}` endpoint. * - * Enables an authenticated GitHub App to find an installation's information using the installation id. The installation's account type (`target_type`) will be either an organization or a user account, depending which account the repository belongs to. + * Enables an authenticated GitHub App to find an installation's information using the installation id. * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `installation_id: i64` -- installation_id parameter. + * * `installation_id: i64` -- The unique identifier of the installation. */ pub async fn get_installation( &self, @@ -402,15 +469,15 @@ impl Apps { * * This function performs a `DELETE` to the `/app/installations/{installation_id}` endpoint. * - * Uninstalls a GitHub App on a user, organization, or business account. If you prefer to temporarily suspend an app's access to your account's resources, then we recommend the "[Suspend an app installation](https://docs.github.com/rest/reference/apps/#suspend-an-app-installation)" endpoint. + * Uninstalls a GitHub App on a user, organization, or enterprise account. If you prefer to temporarily suspend an app's access to your account's resources, then we recommend the "[Suspend an app installation](https://docs.github.com/rest/apps/apps#suspend-an-app-installation)" endpoint. * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `installation_id: i64` -- installation_id parameter. + * * `installation_id: i64` -- The unique identifier of the installation. */ pub async fn delete_installation( &self, @@ -438,15 +505,19 @@ impl Apps { * * This function performs a `POST` to the `/app/installations/{installation_id}/access_tokens` endpoint. * - * Creates an installation access token that enables a GitHub App to make authenticated API requests for the app's installation on an organization or individual account. Installation tokens expire one hour from the time you create them. Using an expired token produces a status code of `401 - Unauthorized`, and requires creating a new installation token. By default the installation token has access to all repositories that the installation can access. To restrict the access to specific repositories, you can provide the `repository_ids` when creating the token. When you omit `repository_ids`, the response does not contain the `repositories` key. + * Creates an installation access token that enables a GitHub App to make authenticated API requests for the app's installation on an organization or individual account. Installation tokens expire one hour from the time you create them. Using an expired token produces a status code of `401 - Unauthorized`, and requires creating a new installation token. By default the installation token has access to all repositories that the installation can access. + * + * Optionally, you can use the `repositories` or `repository_ids` body parameters to specify individual repositories that the installation access token can access. If you don't use `repositories` or `repository_ids` to grant access to specific repositories, the installation access token will have access to all repositories that the installation was granted access to. The installation access token cannot be granted access to repositories that the installation was not granted access to. Up to 500 repositories can be listed in this manner. + * + * Optionally, use the `permissions` body parameter to specify the permissions that the installation access token should have. If `permissions` is not specified, the installation access token will have all of the permissions that were granted to the app. The installation access token cannot be granted permissions that the app was not granted. * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `installation_id: i64` -- installation_id parameter. + * * `installation_id: i64` -- The unique identifier of the installation. */ #[async_recursion::async_recursion] pub async fn create_installation_access_token( @@ -478,15 +549,15 @@ impl Apps { * * This function performs a `PUT` to the `/app/installations/{installation_id}/suspended` endpoint. * - * Suspends a GitHub App on a user, organization, or business account, which blocks the app from accessing the account's resources. When a GitHub App is suspended, the app's access to the GitHub API or webhook events is blocked for that account. + * Suspends a GitHub App on a user, organization, or enterprise account, which blocks the app from accessing the account's resources. When a GitHub App is suspended, the app's access to the GitHub API or webhook events is blocked for that account. * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `installation_id: i64` -- installation_id parameter. + * * `installation_id: i64` -- The unique identifier of the installation. */ pub async fn suspend_installation( &self, @@ -518,11 +589,11 @@ impl Apps { * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `installation_id: i64` -- installation_id parameter. + * * `installation_id: i64` -- The unique identifier of the installation. */ pub async fn unsuspend_installation( &self, @@ -550,14 +621,14 @@ impl Apps { * * This function performs a `DELETE` to the `/applications/{client_id}/grant` endpoint. * - * OAuth application owners can revoke a grant for their OAuth application and a specific user. You must use [Basic Authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) when accessing this endpoint, using the OAuth application's `client_id` and `client_secret` as the username and password. You must also provide a valid OAuth `access_token` as an input parameter and the grant for the token's owner will be deleted. - * Deleting an OAuth application's grant will also delete all OAuth tokens associated with the application for the user. Once deleted, the application will have no access to the user's account and will no longer be listed on [the application authorizations settings screen within GitHub](https://github.com/settings/applications#authorized). + * OAuth and GitHub application owners can revoke a grant for their application and a specific user. You must provide a valid OAuth `access_token` as an input parameter and the grant for the token's owner will be deleted. + * Deleting an application's grant will also delete all OAuth tokens associated with the application for the user. Once deleted, the application will have no access to the user's account and will no longer be listed on [the application authorizations settings screen within GitHub](https://github.com/settings/applications#authorized). * - * FROM: + * FROM: * * **Parameters:** * - * * `client_id: &str` -- The client ID of your GitHub app. + * * `client_id: &str` -- The client ID of the GitHub app. */ pub async fn delete_authorization( &self, @@ -567,7 +638,7 @@ impl Apps { let url = self.client.url( &format!( "/applications/{}/grant", - crate::progenitor_support::encode_path(client_id), + crate::progenitor_support::encode_path(&client_id.to_string()), ), None, ); @@ -581,59 +652,18 @@ impl Apps { ) .await } - /** - * Revoke a grant for an application. - * - * This function performs a `DELETE` to the `/applications/{client_id}/grants/{access_token}` endpoint. - * - * **Deprecation Notice:** GitHub will discontinue OAuth endpoints that contain `access_token` in the path parameter. We have introduced new endpoints that allow you to securely manage tokens for OAuth Apps by moving `access_token` to the request body. For more information, see the [blog post](https://developer.github.com/changes/2020-02-14-deprecating-oauth-app-endpoint/). - * - * OAuth application owners can revoke a grant for their OAuth application and a specific user. You must use [Basic Authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) when accessing this endpoint, using the OAuth application's `client_id` and `client_secret` as the username and password. You must also provide a valid token as `:access_token` and the grant for the token's owner will be deleted. - * - * Deleting an OAuth application's grant will also delete all OAuth tokens associated with the application for the user. Once deleted, the application will have no access to the user's account and will no longer be listed on [the Applications settings page under "Authorized OAuth Apps" on GitHub](https://github.com/settings/applications#authorized). - * - * FROM: - * - * **Parameters:** - * - * * `client_id: &str` -- The client ID of your GitHub app. - * * `access_token: &str` - */ - pub async fn revoke_grant_for_application( - &self, - client_id: &str, - access_token: &str, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/applications/{}/grants/{}", - crate::progenitor_support::encode_path(client_id), - crate::progenitor_support::encode_path(access_token), - ), - None, - ); - self.client - .delete( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } /** * Check a token. * * This function performs a `POST` to the `/applications/{client_id}/token` endpoint. * - * OAuth applications can use a special API method for checking OAuth token validity without exceeding the normal rate limits for failed login attempts. Authentication works differently with this particular endpoint. You must use [Basic Authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) to use this endpoint, where the username is the OAuth application `client_id` and the password is its `client_secret`. Invalid tokens will return `404 NOT FOUND`. + * OAuth applications and GitHub applications with OAuth authorizations can use this API method for checking OAuth token validity without exceeding the normal rate limits for failed login attempts. Authentication works differently with this particular endpoint. Invalid tokens will return `404 NOT FOUND`. * - * FROM: + * FROM: * * **Parameters:** * - * * `client_id: &str` -- The client ID of your GitHub app. + * * `client_id: &str` -- The client ID of the GitHub app. */ pub async fn check_token( &self, @@ -643,7 +673,7 @@ impl Apps { let url = self.client.url( &format!( "/applications/{}/token", - crate::progenitor_support::encode_path(client_id), + crate::progenitor_support::encode_path(&client_id.to_string()), ), None, ); @@ -662,13 +692,13 @@ impl Apps { * * This function performs a `DELETE` to the `/applications/{client_id}/token` endpoint. * - * OAuth application owners can revoke a single token for an OAuth application. You must use [Basic Authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) when accessing this endpoint, using the OAuth application's `client_id` and `client_secret` as the username and password. + * OAuth or GitHub application owners can revoke a single token for an OAuth application or a GitHub application with an OAuth authorization. * - * FROM: + * FROM: * * **Parameters:** * - * * `client_id: &str` -- The client ID of your GitHub app. + * * `client_id: &str` -- The client ID of the GitHub app. */ pub async fn delete_token( &self, @@ -678,7 +708,7 @@ impl Apps { let url = self.client.url( &format!( "/applications/{}/token", - crate::progenitor_support::encode_path(client_id), + crate::progenitor_support::encode_path(&client_id.to_string()), ), None, ); @@ -697,13 +727,13 @@ impl Apps { * * This function performs a `PATCH` to the `/applications/{client_id}/token` endpoint. * - * OAuth applications can use this API method to reset a valid OAuth token without end-user involvement. Applications must save the "token" property in the response because changes take effect immediately. You must use [Basic Authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) when accessing this endpoint, using the OAuth application's `client_id` and `client_secret` as the username and password. Invalid tokens will return `404 NOT FOUND`. + * OAuth applications and GitHub applications with OAuth authorizations can use this API method to reset a valid OAuth token without end-user involvement. Applications must save the "token" property in the response because changes take effect immediately. Invalid tokens will return `404 NOT FOUND`. * - * FROM: + * FROM: * * **Parameters:** * - * * `client_id: &str` -- The client ID of your GitHub app. + * * `client_id: &str` -- The client ID of the GitHub app. */ pub async fn reset_token( &self, @@ -713,7 +743,7 @@ impl Apps { let url = self.client.url( &format!( "/applications/{}/token", - crate::progenitor_support::encode_path(client_id), + crate::progenitor_support::encode_path(&client_id.to_string()), ), None, ); @@ -732,13 +762,17 @@ impl Apps { * * This function performs a `POST` to the `/applications/{client_id}/token/scoped` endpoint. * - * Use a non-scoped user-to-server OAuth access token to create a repository scoped and/or permission scoped user-to-server OAuth access token. You can specify which repositories the token can access and which permissions are granted to the token. You must use [Basic Authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) when accessing this endpoint, using the OAuth application's `client_id` and `client_secret` as the username and password. Invalid tokens will return `404 NOT FOUND`. + * Use a non-scoped user access token to create a repository-scoped and/or permission-scoped user access token. You can specify + * which repositories the token can access and which permissions are granted to the + * token. + * + * Invalid tokens will return `404 NOT FOUND`. * - * FROM: + * FROM: * * **Parameters:** * - * * `client_id: &str` -- The client ID of your GitHub app. + * * `client_id: &str` -- The client ID of the GitHub app. */ pub async fn scope_token( &self, @@ -748,7 +782,7 @@ impl Apps { let url = self.client.url( &format!( "/applications/{}/token/scoped", - crate::progenitor_support::encode_path(client_id), + crate::progenitor_support::encode_path(&client_id.to_string()), ), None, ); @@ -762,133 +796,15 @@ impl Apps { ) .await } - /** - * Check an authorization. - * - * This function performs a `GET` to the `/applications/{client_id}/tokens/{access_token}` endpoint. - * - * **Deprecation Notice:** GitHub will discontinue OAuth endpoints that contain `access_token` in the path parameter. We have introduced new endpoints that allow you to securely manage tokens for OAuth Apps by moving `access_token` to the request body. For more information, see the [blog post](https://developer.github.com/changes/2020-02-14-deprecating-oauth-app-endpoint/). - * - * OAuth applications can use a special API method for checking OAuth token validity without exceeding the normal rate limits for failed login attempts. Authentication works differently with this particular endpoint. You must use [Basic Authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) when accessing this endpoint, using the OAuth application's `client_id` and `client_secret` as the username and password. Invalid tokens will return `404 NOT FOUND`. - * - * FROM: - * - * **Parameters:** - * - * * `client_id: &str` -- The client ID of your GitHub app. - * * `access_token: &str` - */ - pub async fn check_authorization( - &self, - client_id: &str, - access_token: &str, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/applications/{}/tokens/{}", - crate::progenitor_support::encode_path(client_id), - crate::progenitor_support::encode_path(access_token), - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Reset an authorization. - * - * This function performs a `POST` to the `/applications/{client_id}/tokens/{access_token}` endpoint. - * - * **Deprecation Notice:** GitHub will discontinue OAuth endpoints that contain `access_token` in the path parameter. We have introduced new endpoints that allow you to securely manage tokens for OAuth Apps by moving `access_token` to the request body. For more information, see the [blog post](https://developer.github.com/changes/2020-02-14-deprecating-oauth-app-endpoint/). - * - * OAuth applications can use this API method to reset a valid OAuth token without end-user involvement. Applications must save the "token" property in the response because changes take effect immediately. You must use [Basic Authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) when accessing this endpoint, using the OAuth application's `client_id` and `client_secret` as the username and password. Invalid tokens will return `404 NOT FOUND`. - * - * FROM: - * - * **Parameters:** - * - * * `client_id: &str` -- The client ID of your GitHub app. - * * `access_token: &str` - */ - pub async fn reset_authorization( - &self, - client_id: &str, - access_token: &str, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/applications/{}/tokens/{}", - crate::progenitor_support::encode_path(client_id), - crate::progenitor_support::encode_path(access_token), - ), - None, - ); - self.client - .post( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Revoke an authorization for an application. - * - * This function performs a `DELETE` to the `/applications/{client_id}/tokens/{access_token}` endpoint. - * - * **Deprecation Notice:** GitHub will discontinue OAuth endpoints that contain `access_token` in the path parameter. We have introduced new endpoints that allow you to securely manage tokens for OAuth Apps by moving `access_token` to the request body. For more information, see the [blog post](https://developer.github.com/changes/2020-02-14-deprecating-oauth-app-endpoint/). - * - * OAuth application owners can revoke a single token for an OAuth application. You must use [Basic Authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) when accessing this endpoint, using the OAuth application's `client_id` and `client_secret` as the username and password. - * - * FROM: - * - * **Parameters:** - * - * * `client_id: &str` -- The client ID of your GitHub app. - * * `access_token: &str` - */ - pub async fn revoke_authorization_for_application( - &self, - client_id: &str, - access_token: &str, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/applications/{}/tokens/{}", - crate::progenitor_support::encode_path(client_id), - crate::progenitor_support::encode_path(access_token), - ), - None, - ); - self.client - .delete( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } /** * Get an app. * * This function performs a `GET` to the `/apps/{app_slug}` endpoint. * - * **Note**: The `:app_slug` is just the URL-friendly name of your GitHub App. You can find this on the settings page for your GitHub App (e.g., `https://github.com/settings/apps/:app_slug`). + * > [!NOTE] + * > The `:app_slug` is just the URL-friendly name of your GitHub App. You can find this on the settings page for your GitHub App (e.g., `https://github.com/settings/apps/:app_slug`). * - * If the GitHub App you specify is public, you can access this endpoint without authenticating. If the GitHub App you specify is private, you must authenticate with a [personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) or an [installation access token](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation) to access this endpoint. - * - * FROM: + * FROM: * * **Parameters:** * @@ -899,7 +815,10 @@ impl Apps { app_slug: &str, ) -> ClientResult> { let url = self.client.url( - &format!("/apps/{}", crate::progenitor_support::encode_path(app_slug),), + &format!( + "/apps/{}", + crate::progenitor_support::encode_path(&app_slug.to_string()), + ), None, ); self.client @@ -919,14 +838,12 @@ impl Apps { * * List repositories that an app installation can access. * - * You must use an [installation access token](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation) to access this endpoint. - * - * FROM: + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_repos_accessible_to_installation( &self, @@ -961,14 +878,12 @@ impl Apps { * * Revokes the installation token you're using to authenticate as an installation and access this endpoint. * - * Once an installation token is revoked, the token is invalidated and cannot be used. Other endpoints that require the revoked installation token must have a new installation token to work. You can create a new token using the "[Create an installation access token for an app](https://docs.github.com/rest/reference/apps#create-an-installation-access-token-for-an-app)" endpoint. - * - * You must use an [installation access token](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation) to access this endpoint. + * Once an installation token is revoked, the token is invalidated and cannot be used. Other endpoints that require the revoked installation token must have a new installation token to work. You can create a new token using the "[Create an installation access token for an app](https://docs.github.com/rest/apps/apps#create-an-installation-access-token-for-an-app)" endpoint. * - * FROM: + * FROM: */ pub async fn revoke_installation_access_token(&self) -> ClientResult> { - let url = self.client.url("/installation/token", None); + let url = self.client.url(&"/installation/token".to_string(), None); self.client .delete( &url, @@ -986,9 +901,9 @@ impl Apps { * * Shows whether the user or organization account actively subscribes to a plan listed by the authenticated GitHub App. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change. * - * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth Apps must use [basic authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) with their client ID and client secret to access this endpoint. + * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth apps must use [basic authentication](https://docs.github.com/rest/authentication/authenticating-to-the-rest-api#using-basic-authentication) with their client ID and client secret to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * @@ -1022,14 +937,14 @@ impl Apps { * * Lists all plans that are part of your GitHub Marketplace listing. * - * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth Apps must use [basic authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) with their client ID and client secret to access this endpoint. + * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth apps must use [basic authentication](https://docs.github.com/rest/authentication/authenticating-to-the-rest-api#using-basic-authentication) with their client ID and client secret to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_plans( &self, @@ -1066,14 +981,16 @@ impl Apps { * * Lists all plans that are part of your GitHub Marketplace listing. * - * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth Apps must use [basic authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) with their client ID and client secret to access this endpoint. + * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth apps must use [basic authentication](https://docs.github.com/rest/authentication/authenticating-to-the-rest-api#using-basic-authentication) with their client ID and client secret to access this endpoint. * - * FROM: + * FROM: */ pub async fn list_all_plans( &self, ) -> ClientResult>> { - let url = self.client.url("/marketplace_listing/plans", None); + let url = self + .client + .url(&"/marketplace_listing/plans".to_string(), None); self.client .get_all_pages( &url, @@ -1091,24 +1008,22 @@ impl Apps { * * Returns user and organization accounts associated with the specified plan, including free plans. For per-seat pricing, you see the list of accounts that have purchased the plan, including the number of seats purchased. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change. * - * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth Apps must use [basic authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) with their client ID and client secret to access this endpoint. + * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth apps must use [basic authentication](https://docs.github.com/rest/authentication/authenticating-to-the-rest-api#using-basic-authentication) with their client ID and client secret to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `plan_id: i64` -- plan_id parameter. - * * `sort: crate::types::Sort` -- One of `created` (when the repository was starred) or `updated` (when it was last pushed to). - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `plan_id: i64` -- The unique identifier of the plan. + * * `sort: crate::types::SortData` -- The property to sort the results by. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_accounts_for_plan( &self, plan_id: i64, - sort: crate::types::Sort, + sort: crate::types::SortData, direction: crate::types::Order, per_page: i64, page: i64, @@ -1154,14 +1069,14 @@ impl Apps { * * Returns user and organization accounts associated with the specified plan, including free plans. For per-seat pricing, you see the list of accounts that have purchased the plan, including the number of seats purchased. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change. * - * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth Apps must use [basic authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) with their client ID and client secret to access this endpoint. + * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth apps must use [basic authentication](https://docs.github.com/rest/authentication/authenticating-to-the-rest-api#using-basic-authentication) with their client ID and client secret to access this endpoint. * - * FROM: + * FROM: */ pub async fn list_all_accounts_for_plan( &self, plan_id: i64, - sort: crate::types::Sort, + sort: crate::types::SortData, direction: crate::types::Order, ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); @@ -1197,9 +1112,9 @@ impl Apps { * * Shows whether the user or organization account actively subscribes to a plan listed by the authenticated GitHub App. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change. * - * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth Apps must use [basic authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) with their client ID and client secret to access this endpoint. + * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth apps must use [basic authentication](https://docs.github.com/rest/authentication/authenticating-to-the-rest-api#using-basic-authentication) with their client ID and client secret to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * @@ -1233,14 +1148,14 @@ impl Apps { * * Lists all plans that are part of your GitHub Marketplace listing. * - * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth Apps must use [basic authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) with their client ID and client secret to access this endpoint. + * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth apps must use [basic authentication](https://docs.github.com/rest/authentication/authenticating-to-the-rest-api#using-basic-authentication) with their client ID and client secret to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_plans_stubbed( &self, @@ -1278,14 +1193,16 @@ impl Apps { * * Lists all plans that are part of your GitHub Marketplace listing. * - * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth Apps must use [basic authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) with their client ID and client secret to access this endpoint. + * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth apps must use [basic authentication](https://docs.github.com/rest/authentication/authenticating-to-the-rest-api#using-basic-authentication) with their client ID and client secret to access this endpoint. * - * FROM: + * FROM: */ pub async fn list_all_plans_stubbed( &self, ) -> ClientResult>> { - let url = self.client.url("/marketplace_listing/stubbed/plans", None); + let url = self + .client + .url(&"/marketplace_listing/stubbed/plans".to_string(), None); self.client .get_all_pages( &url, @@ -1303,24 +1220,22 @@ impl Apps { * * Returns repository and organization accounts associated with the specified plan, including free plans. For per-seat pricing, you see the list of accounts that have purchased the plan, including the number of seats purchased. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change. * - * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth Apps must use [basic authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) with their client ID and client secret to access this endpoint. + * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth apps must use [basic authentication](https://docs.github.com/rest/authentication/authenticating-to-the-rest-api#using-basic-authentication) with their client ID and client secret to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `plan_id: i64` -- plan_id parameter. - * * `sort: crate::types::Sort` -- One of `created` (when the repository was starred) or `updated` (when it was last pushed to). - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `plan_id: i64` -- The unique identifier of the plan. + * * `sort: crate::types::SortData` -- The property to sort the results by. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_accounts_for_plan_stubbed( &self, plan_id: i64, - sort: crate::types::Sort, + sort: crate::types::SortData, direction: crate::types::Order, per_page: i64, page: i64, @@ -1366,14 +1281,14 @@ impl Apps { * * Returns repository and organization accounts associated with the specified plan, including free plans. For per-seat pricing, you see the list of accounts that have purchased the plan, including the number of seats purchased. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change. * - * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth Apps must use [basic authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) with their client ID and client secret to access this endpoint. + * GitHub Apps must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. OAuth apps must use [basic authentication](https://docs.github.com/rest/authentication/authenticating-to-the-rest-api#using-basic-authentication) with their client ID and client secret to access this endpoint. * - * FROM: + * FROM: */ pub async fn list_all_accounts_for_plan_stubbed( &self, plan_id: i64, - sort: crate::types::Sort, + sort: crate::types::SortData, direction: crate::types::Order, ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); @@ -1411,11 +1326,11 @@ impl Apps { * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn get_org_installation( &self, @@ -1424,7 +1339,7 @@ impl Apps { let url = self.client.url( &format!( "/orgs/{}/installation", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -1438,51 +1353,6 @@ impl Apps { ) .await } - /** - * Create a content attachment. - * - * This function performs a `POST` to the `/repos/{owner}/{repo}/content_references/{content_reference_id}/attachments` endpoint. - * - * Creates an attachment under a content reference URL in the body or comment of an issue or pull request. Use the `id` and `repository` `full_name` of the content reference from the [`content_reference` event](https://docs.github.com/webhooks/event-payloads/#content_reference) to create an attachment. - * - * The app must create a content attachment within six hours of the content reference URL being posted. See "[Using content attachments](https://docs.github.com/apps/using-content-attachments/)" for details about content attachments. - * - * You must use an [installation access token](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation) to access this endpoint. - * - * FROM: - * - * **Parameters:** - * - * * `owner: &str` -- The owner of the repository. Determined from the `repository` `full_name` of the `content_reference` event. - * * `repo: &str` -- The name of the repository. Determined from the `repository` `full_name` of the `content_reference` event. - * * `content_reference_id: i64` -- The `id` of the `content_reference` event. - */ - pub async fn create_content_attachment( - &self, - owner: &str, - repo: &str, - content_reference_id: i64, - body: &crate::types::TeamsUpdateDiscussionInOrgRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/repos/{}/{}/content_references/{}/attachments", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&content_reference_id.to_string()), - ), - None, - ); - self.client - .post( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } /** * Get a repository installation for the authenticated app. * @@ -1492,12 +1362,12 @@ impl Apps { * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_repo_installation( &self, @@ -1507,8 +1377,8 @@ impl Apps { let url = self.client.url( &format!( "/repos/{}/{}/installation", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -1529,18 +1399,16 @@ impl Apps { * * Lists installations of your GitHub App that the authenticated user has explicit permission (`:read`, `:write`, or `:admin`) to access. * - * You must use a [user-to-server OAuth access token](https://docs.github.com/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps/#identifying-users-on-your-site), created for a user who has authorized your GitHub App, to access this endpoint. - * * The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership. * * You can find the permissions for the installation under the `permissions` key. * - * FROM: + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_installations_for_authenticated_user( &self, @@ -1577,17 +1445,15 @@ impl Apps { * * The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership. * - * You must use a [user-to-server OAuth access token](https://docs.github.com/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps/#identifying-users-on-your-site), created for a user who has authorized your GitHub App, to access this endpoint. - * * The access the user has to each repository is included in the hash under the `permissions` key. * - * FROM: + * FROM: * * **Parameters:** * - * * `installation_id: i64` -- installation_id parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `installation_id: i64` -- The unique identifier of the installation. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_installation_repos_for_authenticated_user( &self, @@ -1626,18 +1492,18 @@ impl Apps { * * This function performs a `PUT` to the `/user/installations/{installation_id}/repositories/{repository_id}` endpoint. * - * Add a single repository to an installation. The authenticated user must have admin access to the repository. + * Add a single repository to an installation. The authenticated user must have admin access to the repository. * - * You must use a personal access token (which you can create via the [command line](https://docs.github.com/github/authenticating-to-github/creating-a-personal-access-token) or [Basic Authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication)) to access this endpoint. + * This endpoint only works for PATs (classic) with the `repo` scope. * - * FROM: + * FROM: * * **Parameters:** * - * * `installation_id: i64` -- installation_id parameter. - * * `repository_id: i64` + * * `installation_id: i64` -- The unique identifier of the installation. + * * `repository_id: i64` -- The unique identifier of the repository. */ - pub async fn add_repo_to_installation( + pub async fn add_repo_to_installation_for_authenticated_user( &self, installation_id: i64, repository_id: i64, @@ -1665,18 +1531,18 @@ impl Apps { * * This function performs a `DELETE` to the `/user/installations/{installation_id}/repositories/{repository_id}` endpoint. * - * Remove a single repository from an installation. The authenticated user must have admin access to the repository. + * Remove a single repository from an installation. The authenticated user must have admin access to the repository. The installation must have the `repository_selection` of `selected`. * - * You must use a personal access token (which you can create via the [command line](https://docs.github.com/github/authenticating-to-github/creating-a-personal-access-token) or [Basic Authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication)) to access this endpoint. + * This endpoint only works for PATs (classic) with the `repo` scope. * - * FROM: + * FROM: * * **Parameters:** * - * * `installation_id: i64` -- installation_id parameter. - * * `repository_id: i64` + * * `installation_id: i64` -- The unique identifier of the installation. + * * `repository_id: i64` -- The unique identifier of the repository. */ - pub async fn remove_repo_from_installation( + pub async fn remove_repo_from_installation_for_authenticated_user( &self, installation_id: i64, repository_id: i64, @@ -1704,14 +1570,14 @@ impl Apps { * * This function performs a `GET` to the `/user/marketplace_purchases` endpoint. * - * Lists the active subscriptions for the authenticated user. You must use a [user-to-server OAuth access token](https://docs.github.com/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps/#identifying-users-on-your-site), created for a user who has authorized your GitHub App, to access this endpoint. . OAuth Apps must authenticate using an [OAuth token](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/). + * Lists the active subscriptions for the authenticated user. * - * FROM: + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_subscriptions_for_authenticated_user( &self, @@ -1746,14 +1612,16 @@ impl Apps { * * As opposed to `list_subscriptions_for_authenticated_user`, this function returns all the pages of the request at once. * - * Lists the active subscriptions for the authenticated user. You must use a [user-to-server OAuth access token](https://docs.github.com/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps/#identifying-users-on-your-site), created for a user who has authorized your GitHub App, to access this endpoint. . OAuth Apps must authenticate using an [OAuth token](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/). + * Lists the active subscriptions for the authenticated user. * - * FROM: + * FROM: */ pub async fn list_all_subscriptions_for_authenticated_user( &self, ) -> ClientResult>> { - let url = self.client.url("/user/marketplace_purchases", None); + let url = self + .client + .url(&"/user/marketplace_purchases".to_string(), None); self.client .get_all_pages( &url, @@ -1769,14 +1637,14 @@ impl Apps { * * This function performs a `GET` to the `/user/marketplace_purchases/stubbed` endpoint. * - * Lists the active subscriptions for the authenticated user. You must use a [user-to-server OAuth access token](https://docs.github.com/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps/#identifying-users-on-your-site), created for a user who has authorized your GitHub App, to access this endpoint. . OAuth Apps must authenticate using an [OAuth token](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/). + * Lists the active subscriptions for the authenticated user. * - * FROM: + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_subscriptions_for_authenticated_user_stubbed( &self, @@ -1812,14 +1680,16 @@ impl Apps { * * As opposed to `list_subscriptions_for_authenticated_user_stubbed`, this function returns all the pages of the request at once. * - * Lists the active subscriptions for the authenticated user. You must use a [user-to-server OAuth access token](https://docs.github.com/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps/#identifying-users-on-your-site), created for a user who has authorized your GitHub App, to access this endpoint. . OAuth Apps must authenticate using an [OAuth token](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/). + * Lists the active subscriptions for the authenticated user. * - * FROM: + * FROM: */ pub async fn list_all_subscriptions_for_authenticated_user_stubbed( &self, ) -> ClientResult>> { - let url = self.client.url("/user/marketplace_purchases/stubbed", None); + let url = self + .client + .url(&"/user/marketplace_purchases/stubbed".to_string(), None); self.client .get_all_pages( &url, @@ -1839,11 +1709,11 @@ impl Apps { * * You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` + * * `username: &str` -- The handle for the GitHub user account. */ pub async fn get_user_installation( &self, @@ -1852,7 +1722,7 @@ impl Apps { let url = self.client.url( &format!( "/users/{}/installation", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); diff --git a/github/src/billing.rs b/github/src/billing.rs index 8cf5434d..710782e8 100644 --- a/github/src/billing.rs +++ b/github/src/billing.rs @@ -12,30 +12,29 @@ impl Billing { } /** - * Get GitHub Actions billing for an enterprise. + * Get all budgets for an organization. * - * This function performs a `GET` to the `/enterprises/{enterprise}/settings/billing/actions` endpoint. + * This function performs a `GET` to the `/organizations/{org}/settings/billing/budgets` endpoint. * - * Gets the summary of the free and paid GitHub Actions minutes used. + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. * - * Paid minutes only apply to workflows in private repositories that use GitHub-hosted runners. Minutes used is listed for each GitHub-hosted runner operating system. Any job re-runs are also included in the usage. The usage does not include the multiplier for macOS and Windows runners and is not rounded up to the nearest whole minute. For more information, see "[Managing billing for GitHub Actions](https://help.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-actions)". + * Gets all budgets for an organization. The authenticated user must be an organization admin or billing manager. * - * The authenticated user must be an enterprise admin. - * - * FROM: + * FROM: * * **Parameters:** * - * * `enterprise: &str` -- The slug version of the enterprise name. You can also substitute this value with the enterprise id. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn get_github_actions_billing_ghe( + pub async fn get_all_budgets_org( &self, - enterprise: &str, - ) -> ClientResult> { + org: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/enterprises/{}/settings/billing/actions", - crate::progenitor_support::encode_path(enterprise), + "/organizations/{}/settings/billing/budgets", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -50,30 +49,32 @@ impl Billing { .await } /** - * Get GitHub Packages billing for an enterprise. + * Get a budget by ID for an organization. * - * This function performs a `GET` to the `/enterprises/{enterprise}/settings/billing/packages` endpoint. + * This function performs a `GET` to the `/organizations/{org}/settings/billing/budgets/{budget_id}` endpoint. * - * Gets the free and paid storage used for GitHub Packages in gigabytes. + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. * - * Paid minutes only apply to packages stored for private repositories. For more information, see "[Managing billing for GitHub Packages](https://help.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-packages)." + * Gets a budget by ID. The authenticated user must be an organization admin or billing manager. * - * The authenticated user must be an enterprise admin. - * - * FROM: + * FROM: * * **Parameters:** * - * * `enterprise: &str` -- The slug version of the enterprise name. You can also substitute this value with the enterprise id. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `budget_id: &str` -- The ID corresponding to the budget. */ - pub async fn get_github_packages_billing_ghe( + pub async fn get_budget_org( &self, - enterprise: &str, - ) -> ClientResult> { + org: &str, + budget_id: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/enterprises/{}/settings/billing/packages", - crate::progenitor_support::encode_path(enterprise), + "/organizations/{}/settings/billing/budgets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&budget_id.to_string()), ), None, ); @@ -88,35 +89,37 @@ impl Billing { .await } /** - * Get shared storage billing for an enterprise. + * Delete a budget for an organization. * - * This function performs a `GET` to the `/enterprises/{enterprise}/settings/billing/shared-storage` endpoint. + * This function performs a `DELETE` to the `/organizations/{org}/settings/billing/budgets/{budget_id}` endpoint. * - * Gets the estimated paid and estimated total storage used for GitHub Actions and Github Packages. + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. * - * Paid minutes only apply to packages stored for private repositories. For more information, see "[Managing billing for GitHub Packages](https://help.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-packages)." + * Deletes a budget by ID for an organization. The authenticated user must be an organization admin or billing manager. * - * The authenticated user must be an enterprise admin. - * - * FROM: + * FROM: * * **Parameters:** * - * * `enterprise: &str` -- The slug version of the enterprise name. You can also substitute this value with the enterprise id. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `budget_id: &str` -- The ID corresponding to the budget. */ - pub async fn get_shared_storage_billing_ghe( + pub async fn delete_budget_org( &self, - enterprise: &str, - ) -> ClientResult> { + org: &str, + budget_id: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/enterprises/{}/settings/billing/shared-storage", - crate::progenitor_support::encode_path(enterprise), + "/organizations/{}/settings/billing/budgets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&budget_id.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -126,30 +129,102 @@ impl Billing { .await } /** - * Get GitHub Actions billing for an organization. + * Update a budget for an organization. + * + * This function performs a `PATCH` to the `/organizations/{org}/settings/billing/budgets/{budget_id}` endpoint. * - * This function performs a `GET` to the `/orgs/{org}/settings/billing/actions` endpoint. + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. + * + * Updates an existing budget for an organization. The authenticated user must be an organization admin or billing manager. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `budget_id: &str` -- The ID corresponding to the budget. + */ + pub async fn update_budget_org( + &self, + org: &str, + budget_id: &str, + body: &crate::types::BillingUpdateBudgetOrgRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/organizations/{}/settings/billing/budgets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&budget_id.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get billing premium request usage report for an organization. * - * Gets the summary of the free and paid GitHub Actions minutes used. + * This function performs a `GET` to the `/organizations/{org}/settings/billing/premium_request/usage` endpoint. * - * Paid minutes only apply to workflows in private repositories that use GitHub-hosted runners. Minutes used is listed for each GitHub-hosted runner operating system. Any job re-runs are also included in the usage. The usage returned includes any minute multipliers for macOS and Windows runners, and is rounded up to the nearest whole minute. For more information, see "[Managing billing for GitHub Actions](https://help.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-actions)". + * Gets a report of premium request usage for an organization. To use this endpoint, you must be an administrator of an organization within an enterprise or an organization account. * - * Access tokens must have the `repo` or `admin:org` scope. + * **Note:** Only data from the past 24 months is accessible via this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `year: i64` -- If specified, only return results for a single year. The value of `year` is an integer with four digits representing a year. For example, `2025`. Default value is the current year. + * * `month: i64` -- If specified, only return results for a single month. The value of `month` is an integer between `1` and `12`. Default value is the current month. If no year is specified the default `year` is used. + * * `day: i64` -- If specified, only return results for a single day. The value of `day` is an integer between `1` and `31`. If no `year` or `month` is specified, the default `year` and `month` are used. + * * `user: &str` -- The user name to query usage for. The name is not case sensitive. + * * `model: &str` -- The model name to query usage for. The name is not case sensitive. + * * `product: &str` -- The product name to query usage for. The name is not case sensitive. */ - pub async fn get_github_actions_billing_org( + pub async fn get_github_billing_premium_request_usage_report_org( &self, org: &str, - ) -> ClientResult> { + year: i64, + month: i64, + day: i64, + user: &str, + model: &str, + product: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if day > 0 { + query_args.push(("day".to_string(), day.to_string())); + } + if !model.is_empty() { + query_args.push(("model".to_string(), model.to_string())); + } + if month > 0 { + query_args.push(("month".to_string(), month.to_string())); + } + if !product.is_empty() { + query_args.push(("product".to_string(), product.to_string())); + } + if !user.is_empty() { + query_args.push(("user".to_string(), user.to_string())); + } + if year > 0 { + query_args.push(("year".to_string(), year.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/settings/billing/actions", - crate::progenitor_support::encode_path(org), + "/organizations/{}/settings/billing/premium_request/usage?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ ), None, ); @@ -164,30 +239,46 @@ impl Billing { .await } /** - * Get GitHub Packages billing for an organization. - * - * This function performs a `GET` to the `/orgs/{org}/settings/billing/packages` endpoint. + * Get billing usage report for an organization. * - * Gets the free and paid storage used for GitHub Packages in gigabytes. + * This function performs a `GET` to the `/organizations/{org}/settings/billing/usage` endpoint. * - * Paid minutes only apply to packages stored for private repositories. For more information, see "[Managing billing for GitHub Packages](https://help.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-packages)." + * Gets a report of the total usage for an organization. To use this endpoint, you must be an administrator of an organization within an enterprise or an organization account. * - * Access tokens must have the `repo` or `admin:org` scope. + * **Note:** This endpoint is only available to organizations with access to the enhanced billing platform. For more information, see "[About the enhanced billing platform](https://docs.github.com/billing/using-the-new-billing-platform)." * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `year: i64` -- If specified, only return results for a single year. The value of `year` is an integer with four digits representing a year. For example, `2025`. Default value is the current year. + * * `month: i64` -- If specified, only return results for a single month. The value of `month` is an integer between `1` and `12`. If no year is specified the default `year` is used. + * * `day: i64` -- If specified, only return results for a single day. The value of `day` is an integer between `1` and `31`. If no `year` or `month` is specified, the default `year` and `month` are used. */ - pub async fn get_github_packages_billing_org( + pub async fn get_github_billing_usage_report_org( &self, org: &str, - ) -> ClientResult> { + year: i64, + month: i64, + day: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if day > 0 { + query_args.push(("day".to_string(), day.to_string())); + } + if month > 0 { + query_args.push(("month".to_string(), month.to_string())); + } + if year > 0 { + query_args.push(("year".to_string(), year.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/settings/billing/packages", - crate::progenitor_support::encode_path(org), + "/organizations/{}/settings/billing/usage?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ ), None, ); @@ -202,30 +293,64 @@ impl Billing { .await } /** - * Get shared storage billing for an organization. + * Get billing usage summary for an organization. * - * This function performs a `GET` to the `/orgs/{org}/settings/billing/shared-storage` endpoint. + * This function performs a `GET` to the `/organizations/{org}/settings/billing/usage/summary` endpoint. * - * Gets the estimated paid and estimated total storage used for GitHub Actions and Github Packages. + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. * - * Paid minutes only apply to packages stored for private repositories. For more information, see "[Managing billing for GitHub Packages](https://help.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-packages)." + * Gets a summary report of usage for an organization. To use this endpoint, you must be an administrator of an organization within an enterprise or an organization account. * - * Access tokens must have the `repo` or `admin:org` scope. + * **Note:** Only data from the past 24 months is accessible via this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `year: i64` -- If specified, only return results for a single year. The value of `year` is an integer with four digits representing a year. For example, `2025`. Default value is the current year. + * * `month: i64` -- If specified, only return results for a single month. The value of `month` is an integer between `1` and `12`. Default value is the current month. If no year is specified the default `year` is used. + * * `day: i64` -- If specified, only return results for a single day. The value of `day` is an integer between `1` and `31`. If no `year` or `month` is specified, the default `year` and `month` are used. + * * `repository: &str` -- The repository name to query for usage in the format owner/repository. + * * `product: &str` -- The product name to query usage for. The name is not case sensitive. + * * `sku: &str` -- The SKU to query for usage. */ - pub async fn get_shared_storage_billing_org( + pub async fn get_github_billing_usage_summary_report_org( &self, org: &str, - ) -> ClientResult> { + year: i64, + month: i64, + day: i64, + repository: &str, + product: &str, + sku: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if day > 0 { + query_args.push(("day".to_string(), day.to_string())); + } + if month > 0 { + query_args.push(("month".to_string(), month.to_string())); + } + if !product.is_empty() { + query_args.push(("product".to_string(), product.to_string())); + } + if !repository.is_empty() { + query_args.push(("repository".to_string(), repository.to_string())); + } + if !sku.is_empty() { + query_args.push(("sku".to_string(), sku.to_string())); + } + if year > 0 { + query_args.push(("year".to_string(), year.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/settings/billing/shared-storage", - crate::progenitor_support::encode_path(org), + "/organizations/{}/settings/billing/usage/summary?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ ), None, ); @@ -240,30 +365,56 @@ impl Billing { .await } /** - * Get GitHub Actions billing for a user. + * Get billing premium request usage report for a user. * - * This function performs a `GET` to the `/users/{username}/settings/billing/actions` endpoint. + * This function performs a `GET` to the `/users/{username}/settings/billing/premium_request/usage` endpoint. * - * Gets the summary of the free and paid GitHub Actions minutes used. + * Gets a report of premium request usage for a user. * - * Paid minutes only apply to workflows in private repositories that use GitHub-hosted runners. Minutes used is listed for each GitHub-hosted runner operating system. Any job re-runs are also included in the usage. The usage returned includes any minute multipliers for macOS and Windows runners, and is rounded up to the nearest whole minute. For more information, see "[Managing billing for GitHub Actions](https://help.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-actions)". + * **Note:** Only data from the past 24 months is accessible via this endpoint. * - * Access tokens must have the `user` scope. - * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` + * * `username: &str` -- The handle for the GitHub user account. + * * `year: i64` -- If specified, only return results for a single year. The value of `year` is an integer with four digits representing a year. For example, `2025`. Default value is the current year. + * * `month: i64` -- If specified, only return results for a single month. The value of `month` is an integer between `1` and `12`. Default value is the current month. If no year is specified the default `year` is used. + * * `day: i64` -- If specified, only return results for a single day. The value of `day` is an integer between `1` and `31`. If no `year` or `month` is specified, the default `year` and `month` are used. + * * `model: &str` -- The model name to query usage for. The name is not case sensitive. + * * `product: &str` -- The product name to query usage for. The name is not case sensitive. */ - pub async fn get_github_actions_billing_user( + pub async fn get_github_billing_premium_request_usage_report_user( &self, username: &str, - ) -> ClientResult> { + year: i64, + month: i64, + day: i64, + model: &str, + product: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if day > 0 { + query_args.push(("day".to_string(), day.to_string())); + } + if !model.is_empty() { + query_args.push(("model".to_string(), model.to_string())); + } + if month > 0 { + query_args.push(("month".to_string(), month.to_string())); + } + if !product.is_empty() { + query_args.push(("product".to_string(), product.to_string())); + } + if year > 0 { + query_args.push(("year".to_string(), year.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/users/{}/settings/billing/actions", - crate::progenitor_support::encode_path(username), + "/users/{}/settings/billing/premium_request/usage?{}", + crate::progenitor_support::encode_path(&username.to_string()), + query_ ), None, ); @@ -278,30 +429,46 @@ impl Billing { .await } /** - * Get GitHub Packages billing for a user. - * - * This function performs a `GET` to the `/users/{username}/settings/billing/packages` endpoint. + * Get billing usage report for a user. * - * Gets the free and paid storage used for GitHub Packages in gigabytes. + * This function performs a `GET` to the `/users/{username}/settings/billing/usage` endpoint. * - * Paid minutes only apply to packages stored for private repositories. For more information, see "[Managing billing for GitHub Packages](https://help.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-packages)." + * Gets a report of the total usage for a user. * - * Access tokens must have the `user` scope. + * **Note:** This endpoint is only available to users with access to the enhanced billing platform. * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` + * * `username: &str` -- The handle for the GitHub user account. + * * `year: i64` -- If specified, only return results for a single year. The value of `year` is an integer with four digits representing a year. For example, `2025`. Default value is the current year. + * * `month: i64` -- If specified, only return results for a single month. The value of `month` is an integer between `1` and `12`. If no year is specified the default `year` is used. + * * `day: i64` -- If specified, only return results for a single day. The value of `day` is an integer between `1` and `31`. If no `year` or `month` is specified, the default `year` and `month` are used. */ - pub async fn get_github_packages_billing_user( + pub async fn get_github_billing_usage_report_user( &self, username: &str, - ) -> ClientResult> { + year: i64, + month: i64, + day: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if day > 0 { + query_args.push(("day".to_string(), day.to_string())); + } + if month > 0 { + query_args.push(("month".to_string(), month.to_string())); + } + if year > 0 { + query_args.push(("year".to_string(), year.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/users/{}/settings/billing/packages", - crate::progenitor_support::encode_path(username), + "/users/{}/settings/billing/usage?{}", + crate::progenitor_support::encode_path(&username.to_string()), + query_ ), None, ); @@ -316,30 +483,64 @@ impl Billing { .await } /** - * Get shared storage billing for a user. + * Get billing usage summary for a user. * - * This function performs a `GET` to the `/users/{username}/settings/billing/shared-storage` endpoint. + * This function performs a `GET` to the `/users/{username}/settings/billing/usage/summary` endpoint. * - * Gets the estimated paid and estimated total storage used for GitHub Actions and Github Packages. + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. * - * Paid minutes only apply to packages stored for private repositories. For more information, see "[Managing billing for GitHub Packages](https://help.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-packages)." + * Gets a summary report of usage for a user. * - * Access tokens must have the `user` scope. + * **Note:** Only data from the past 24 months is accessible via this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` + * * `username: &str` -- The handle for the GitHub user account. + * * `year: i64` -- If specified, only return results for a single year. The value of `year` is an integer with four digits representing a year. For example, `2025`. Default value is the current year. + * * `month: i64` -- If specified, only return results for a single month. The value of `month` is an integer between `1` and `12`. Default value is the current month. If no year is specified the default `year` is used. + * * `day: i64` -- If specified, only return results for a single day. The value of `day` is an integer between `1` and `31`. If no `year` or `month` is specified, the default `year` and `month` are used. + * * `repository: &str` -- The repository name to query for usage in the format owner/repository. + * * `product: &str` -- The product name to query usage for. The name is not case sensitive. + * * `sku: &str` -- The SKU to query for usage. */ - pub async fn get_shared_storage_billing_user( + pub async fn get_github_billing_usage_summary_report_user( &self, username: &str, - ) -> ClientResult> { + year: i64, + month: i64, + day: i64, + repository: &str, + product: &str, + sku: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if day > 0 { + query_args.push(("day".to_string(), day.to_string())); + } + if month > 0 { + query_args.push(("month".to_string(), month.to_string())); + } + if !product.is_empty() { + query_args.push(("product".to_string(), product.to_string())); + } + if !repository.is_empty() { + query_args.push(("repository".to_string(), repository.to_string())); + } + if !sku.is_empty() { + query_args.push(("sku".to_string(), sku.to_string())); + } + if year > 0 { + query_args.push(("year".to_string(), year.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/users/{}/settings/billing/shared-storage", - crate::progenitor_support::encode_path(username), + "/users/{}/settings/billing/usage/summary?{}", + crate::progenitor_support::encode_path(&username.to_string()), + query_ ), None, ); diff --git a/github/src/campaigns.rs b/github/src/campaigns.rs new file mode 100644 index 00000000..d3d610fa --- /dev/null +++ b/github/src/campaigns.rs @@ -0,0 +1,297 @@ +use crate::Client; +use crate::ClientResult; + +pub struct Campaigns { + pub client: Client, +} + +impl Campaigns { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + Campaigns { client } + } + + /** + * List campaigns for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/campaigns` endpoint. + * + * Lists campaigns in an organization. + * + * The authenticated user must be an owner or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `state: crate::types::CampaignState` -- If specified, only campaigns with this state will be returned. + * * `sort: crate::types::CampaignsListOrgSort` -- The property by which to sort the results. + */ + pub async fn list_org_campaigns( + &self, + org: &str, + page: i64, + per_page: i64, + direction: crate::types::Order, + state: crate::types::CampaignState, + sort: crate::types::CampaignsListOrgSort, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.to_string().is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/campaigns?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List campaigns for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/campaigns` endpoint. + * + * As opposed to `list_org_campaigns`, this function returns all the pages of the request at once. + * + * Lists campaigns in an organization. + * + * The authenticated user must be an owner or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. + * + * FROM: + */ + pub async fn list_all_org_campaigns( + &self, + org: &str, + direction: crate::types::Order, + state: crate::types::CampaignState, + sort: crate::types::CampaignsListOrgSort, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.to_string().is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/campaigns?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a campaign for an organization. + * + * This function performs a `POST` to the `/orgs/{org}/campaigns` endpoint. + * + * Create a campaign for an organization. + * + * The authenticated user must be an owner or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. + * + * Fine-grained tokens must have the "Code scanning alerts" repository permissions (read) on all repositories included + * in the campaign. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_campaign( + &self, + org: &str, + body: &crate::types::CampaignsCreateCampaignRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/campaigns", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a campaign for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/campaigns/{campaign_number}` endpoint. + * + * Gets a campaign for an organization. + * + * The authenticated user must be an owner or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `campaign_number: i64` -- The campaign number. + */ + pub async fn get_campaign_summary( + &self, + org: &str, + campaign_number: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/campaigns/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&campaign_number.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a campaign for an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/campaigns/{campaign_number}` endpoint. + * + * Deletes a campaign in an organization. + * + * The authenticated user must be an owner or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `campaign_number: i64` -- The campaign number. + */ + pub async fn delete_campaign( + &self, + org: &str, + campaign_number: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/campaigns/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&campaign_number.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a campaign. + * + * This function performs a `PATCH` to the `/orgs/{org}/campaigns/{campaign_number}` endpoint. + * + * Updates a campaign in an organization. + * + * The authenticated user must be an owner or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `campaign_number: i64` -- The campaign number. + */ + pub async fn update_campaign( + &self, + org: &str, + campaign_number: i64, + body: &crate::types::CampaignsUpdateCampaignRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/campaigns/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&campaign_number.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } +} diff --git a/github/src/checks.rs b/github/src/checks.rs index 6d73a0ee..2e698e17 100644 --- a/github/src/checks.rs +++ b/github/src/checks.rs @@ -16,18 +16,21 @@ impl Checks { * * This function performs a `POST` to the `/repos/{owner}/{repo}/check-runs` endpoint. * - * **Note:** The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array. + * Creates a new check run for a specific commit in a repository. * - * Creates a new check run for a specific commit in a repository. Your GitHub App must have the `checks:write` permission to create check runs. + * To create a check run, you must use a GitHub App. OAuth apps and authenticated users are not able to create a check suite. * * In a check suite, GitHub limits the number of check runs with the same name to 1000. Once these check runs exceed 1000, GitHub will start to automatically delete older check runs. * - * FROM: + * > [!NOTE] + * > The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn create( &self, @@ -38,8 +41,8 @@ impl Checks { let url = self.client.url( &format!( "/repos/{}/{}/check-runs", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -58,17 +61,20 @@ impl Checks { * * This function performs a `GET` to the `/repos/{owner}/{repo}/check-runs/{check_run_id}` endpoint. * - * **Note:** The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array. + * Gets a single check run using its `id`. + * + * > [!NOTE] + * > The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array. * - * Gets a single check run using its `id`. GitHub Apps must have the `checks:read` permission on a private repository or pull access to a public repository to get check runs. OAuth Apps and authenticated users must have the `repo` scope to get check runs in a private repository. + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint on a private repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `check_run_id: i64` -- check_run_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `check_run_id: i64` -- The unique identifier of the check run. */ pub async fn get( &self, @@ -79,8 +85,8 @@ impl Checks { let url = self.client.url( &format!( "/repos/{}/{}/check-runs/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&check_run_id.to_string()), ), None, @@ -100,17 +106,20 @@ impl Checks { * * This function performs a `PATCH` to the `/repos/{owner}/{repo}/check-runs/{check_run_id}` endpoint. * - * **Note:** The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array. + * Updates a check run for a specific commit in a repository. + * + * > [!NOTE] + * > The endpoints to manage checks only look for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array. * - * Updates a check run for a specific commit in a repository. Your GitHub App must have the `checks:write` permission to edit check runs. + * OAuth apps and personal access tokens (classic) cannot use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `check_run_id: i64` -- check_run_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `check_run_id: i64` -- The unique identifier of the check run. */ pub async fn update( &self, @@ -122,8 +131,8 @@ impl Checks { let url = self.client.url( &format!( "/repos/{}/{}/check-runs/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&check_run_id.to_string()), ), None, @@ -143,17 +152,19 @@ impl Checks { * * This function performs a `GET` to the `/repos/{owner}/{repo}/check-runs/{check_run_id}/annotations` endpoint. * - * Lists annotations for a check run using the annotation `id`. GitHub Apps must have the `checks:read` permission on a private repository or pull access to a public repository to get annotations for a check run. OAuth Apps and authenticated users must have the `repo` scope to get annotations for a check run in a private repository. + * Lists annotations for a check run using the annotation `id`. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint on a private repository. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `check_run_id: i64` -- check_run_id parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `check_run_id: i64` -- The unique identifier of the check run. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_annotations( &self, @@ -174,8 +185,8 @@ impl Checks { let url = self.client.url( &format!( "/repos/{}/{}/check-runs/{}/annotations?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&check_run_id.to_string()), query_ ), @@ -198,9 +209,11 @@ impl Checks { * * As opposed to `list_annotations`, this function returns all the pages of the request at once. * - * Lists annotations for a check run using the annotation `id`. GitHub Apps must have the `checks:read` permission on a private repository or pull access to a public repository to get annotations for a check run. OAuth Apps and authenticated users must have the `repo` scope to get annotations for a check run in a private repository. + * Lists annotations for a check run using the annotation `id`. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint on a private repository. * - * FROM: + * FROM: */ pub async fn list_all_annotations( &self, @@ -211,8 +224,8 @@ impl Checks { let url = self.client.url( &format!( "/repos/{}/{}/check-runs/{}/annotations", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&check_run_id.to_string()), ), None, @@ -227,21 +240,66 @@ impl Checks { ) .await } + /** + * Rerequest a check run. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/check-runs/{check_run_id}/rerequest` endpoint. + * + * Triggers GitHub to rerequest an existing check run, without pushing new code to a repository. This endpoint will trigger the [`check_run` webhook](https://docs.github.com/webhooks/event-payloads/#check_run) event with the action `rerequested`. When a check run is `rerequested`, the `status` of the check suite it belongs to is reset to `queued` and the `conclusion` is cleared. The check run itself is not updated. GitHub apps recieving the [`check_run` webhook](https://docs.github.com/webhooks/event-payloads/#check_run) with the `rerequested` action should then decide if the check run should be reset or updated and call the [update `check_run` endpoint](https://docs.github.com/rest/checks/runs#update-a-check-run) to update the check_run if desired. + * + * For more information about how to re-run GitHub Actions jobs, see "[Re-run a job from a workflow run](https://docs.github.com/rest/actions/workflow-runs#re-run-a-job-from-a-workflow-run)". + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `check_run_id: i64` -- The unique identifier of the check run. + */ + pub async fn rerequest_run( + &self, + owner: &str, + repo: &str, + check_run_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/check-runs/{}/rerequest", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&check_run_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } /** * Create a check suite. * * This function performs a `POST` to the `/repos/{owner}/{repo}/check-suites` endpoint. * - * **Note:** The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array and a `null` value for `head_branch`. + * Creates a check suite manually. By default, check suites are automatically created when you create a [check run](https://docs.github.com/rest/checks/runs). You only need to use this endpoint for manually creating check suites when you've disabled automatic creation using "[Update repository preferences for check suites](https://docs.github.com/rest/checks/suites#update-repository-preferences-for-check-suites)". * - * By default, check suites are automatically created when you create a [check run](https://docs.github.com/rest/reference/checks#check-runs). You only need to use this endpoint for manually creating check suites when you've disabled automatic creation using "[Update repository preferences for check suites](https://docs.github.com/rest/reference/checks#update-repository-preferences-for-check-suites)". Your GitHub App must have the `checks:write` permission to create check suites. + * > [!NOTE] + * > The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array and a `null` value for `head_branch`. * - * FROM: + * OAuth apps and personal access tokens (classic) cannot use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn create_suite( &self, @@ -252,8 +310,8 @@ impl Checks { let url = self.client.url( &format!( "/repos/{}/{}/check-suites", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -272,14 +330,15 @@ impl Checks { * * This function performs a `PATCH` to the `/repos/{owner}/{repo}/check-suites/preferences` endpoint. * - * Changes the default automatic flow when creating check suites. By default, a check suite is automatically created each time code is pushed to a repository. When you disable the automatic creation of check suites, you can manually [Create a check suite](https://docs.github.com/rest/reference/checks#create-a-check-suite). You must have admin permissions in the repository to set preferences for check suites. + * Changes the default automatic flow when creating check suites. By default, a check suite is automatically created each time code is pushed to a repository. When you disable the automatic creation of check suites, you can manually [Create a check suite](https://docs.github.com/rest/checks/suites#create-a-check-suite). + * You must have admin permissions in the repository to set preferences for check suites. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn set_suites_preferences( &self, @@ -290,8 +349,8 @@ impl Checks { let url = self.client.url( &format!( "/repos/{}/{}/check-suites/preferences", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -310,17 +369,20 @@ impl Checks { * * This function performs a `GET` to the `/repos/{owner}/{repo}/check-suites/{check_suite_id}` endpoint. * - * **Note:** The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array and a `null` value for `head_branch`. + * Gets a single check suite using its `id`. + * + * > [!NOTE] + * > The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array and a `null` value for `head_branch`. * - * Gets a single check suite using its `id`. GitHub Apps must have the `checks:read` permission on a private repository or pull access to a public repository to get check suites. OAuth Apps and authenticated users must have the `repo` scope to get check suites in a private repository. + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint on a private repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `check_suite_id: i64` -- check_suite_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `check_suite_id: i64` -- The unique identifier of the check suite. */ pub async fn get_suite( &self, @@ -331,8 +393,8 @@ impl Checks { let url = self.client.url( &format!( "/repos/{}/{}/check-suites/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&check_suite_id.to_string()), ), None, @@ -352,24 +414,25 @@ impl Checks { * * This function performs a `GET` to the `/repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs` endpoint. * - * **Note:** The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array. + * Lists check runs for a check suite using its `id`. * - * Lists check runs for a check suite using its `id`. GitHub Apps must have the `checks:read` permission on a private repository or pull access to a public repository to get check runs. OAuth Apps and authenticated users must have the `repo` scope to get check runs in a private repository. + * > [!NOTE] + * > The endpoints to manage checks only look for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint on a private repository. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `check_suite_id: i64` -- check_suite_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `check_suite_id: i64` -- The unique identifier of the check suite. * * `check_name: &str` -- Returns check runs with the specified `name`. - * * `status: crate::types::JobStatus` -- Returns check runs with the specified `status`. Can be one of `queued`, `in_progress`, or `completed`. - * * `filter: crate::types::ActionsListJobsWorkflowRunFilter` -- Filters jobs by their `completed_at` timestamp. Can be one of: - * \\* `latest`: Returns jobs from the most recent execution of the workflow run. - * \\* `all`: Returns all jobs for a workflow run, including from old executions of the workflow run. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `status: crate::types::JobStepsStatus` -- The phase of the lifecycle that the job is currently in. + * * `filter: crate::types::ActionsListJobsWorkflowRunFilter` -- Filters jobs by their `completed_at` timestamp. `latest` returns jobs from the most recent execution of the workflow run. `all` returns all jobs for a workflow run, including from old executions of the workflow run. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_suite( &self, @@ -377,7 +440,7 @@ impl Checks { repo: &str, check_suite_id: i64, check_name: &str, - status: crate::types::JobStatus, + status: crate::types::JobStepsStatus, filter: crate::types::ActionsListJobsWorkflowRunFilter, per_page: i64, page: i64, @@ -402,8 +465,8 @@ impl Checks { let url = self.client.url( &format!( "/repos/{}/{}/check-suites/{}/check-runs?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&check_suite_id.to_string()), query_ ), @@ -426,27 +489,25 @@ impl Checks { * * Triggers GitHub to rerequest an existing check suite, without pushing new code to a repository. This endpoint will trigger the [`check_suite` webhook](https://docs.github.com/webhooks/event-payloads/#check_suite) event with the action `rerequested`. When a check suite is `rerequested`, its `status` is reset to `queued` and the `conclusion` is cleared. * - * To rerequest a check suite, your GitHub App must have the `checks:read` permission on a private repository or pull access to a public repository. - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `check_suite_id: i64` -- check_suite_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `check_suite_id: i64` -- The unique identifier of the check suite. */ pub async fn rerequest_suite( &self, owner: &str, repo: &str, check_suite_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( "/repos/{}/{}/check-suites/{}/rerequest", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&check_suite_id.to_string()), ), None, @@ -466,24 +527,27 @@ impl Checks { * * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{ref}/check-runs` endpoint. * - * **Note:** The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array. + * Lists check runs for a commit ref. The `ref` can be a SHA, branch name, or a tag name. + * + * > [!NOTE] + * > The endpoints to manage checks only look for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array. * - * Lists check runs for a commit ref. The `ref` can be a SHA, branch name, or a tag name. GitHub Apps must have the `checks:read` permission on a private repository or pull access to a public repository to get check runs. OAuth Apps and authenticated users must have the `repo` scope to get check runs in a private repository. + * If there are more than 1000 check suites on a single git reference, this endpoint will limit check runs to the 1000 most recent check suites. To iterate over all possible check runs, use the [List check suites for a Git reference](https://docs.github.com/rest/reference/checks#list-check-suites-for-a-git-reference) endpoint and provide the `check_suite_id` parameter to the [List check runs in a check suite](https://docs.github.com/rest/reference/checks#list-check-runs-in-a-check-suite) endpoint. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint on a private repository. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `ref_: &str` -- ref parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The commit reference. Can be a commit SHA, branch name (`heads/BRANCH_NAME`), or tag name (`tags/TAG_NAME`). For more information, see "[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)" in the Git documentation. * * `check_name: &str` -- Returns check runs with the specified `name`. - * * `status: crate::types::JobStatus` -- Returns check runs with the specified `status`. Can be one of `queued`, `in_progress`, or `completed`. - * * `filter: crate::types::ActionsListJobsWorkflowRunFilter` -- Filters jobs by their `completed_at` timestamp. Can be one of: - * \\* `latest`: Returns jobs from the most recent execution of the workflow run. - * \\* `all`: Returns all jobs for a workflow run, including from old executions of the workflow run. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `status: crate::types::JobStepsStatus` -- The phase of the lifecycle that the job is currently in. + * * `filter: crate::types::ActionsListJobsWorkflowRunFilter` -- Filters jobs by their `completed_at` timestamp. `latest` returns jobs from the most recent execution of the workflow run. `all` returns all jobs for a workflow run, including from old executions of the workflow run. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". * * `app_id: i64` */ pub async fn list_for_ref( @@ -492,7 +556,7 @@ impl Checks { repo: &str, ref_: &str, check_name: &str, - status: crate::types::JobStatus, + status: crate::types::JobStepsStatus, filter: crate::types::ActionsListJobsWorkflowRunFilter, per_page: i64, page: i64, @@ -521,9 +585,9 @@ impl Checks { let url = self.client.url( &format!( "/repos/{}/{}/commits/{}/check-runs?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), query_ ), None, @@ -543,21 +607,24 @@ impl Checks { * * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{ref}/check-suites` endpoint. * - * **Note:** The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array and a `null` value for `head_branch`. + * Lists check suites for a commit `ref`. The `ref` can be a SHA, branch name, or a tag name. + * + * > [!NOTE] + * > The endpoints to manage checks only look for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array and a `null` value for `head_branch`. * - * Lists check suites for a commit `ref`. The `ref` can be a SHA, branch name, or a tag name. GitHub Apps must have the `checks:read` permission on a private repository or pull access to a public repository to list check suites. OAuth Apps and authenticated users must have the `repo` scope to get check suites in a private repository. + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint on a private repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `ref_: &str` -- ref parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The commit reference. Can be a commit SHA, branch name (`heads/BRANCH_NAME`), or tag name (`tags/TAG_NAME`). For more information, see "[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)" in the Git documentation. * * `app_id: i64` -- Filters check suites by GitHub App `id`. * * `check_name: &str` -- Returns check runs with the specified `name`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_suites_for_ref( &self, @@ -586,9 +653,9 @@ impl Checks { let url = self.client.url( &format!( "/repos/{}/{}/commits/{}/check-suites?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), query_ ), None, diff --git a/github/src/classroom.rs b/github/src/classroom.rs new file mode 100644 index 00000000..addfaf88 --- /dev/null +++ b/github/src/classroom.rs @@ -0,0 +1,369 @@ +use crate::Client; +use crate::ClientResult; + +pub struct Classroom { + pub client: Client, +} + +impl Classroom { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + Classroom { client } + } + + /** + * Get an assignment. + * + * This function performs a `GET` to the `/assignments/{assignment_id}` endpoint. + * + * Gets a GitHub Classroom assignment. Assignment will only be returned if the current user is an administrator of the GitHub Classroom for the assignment. + * + * FROM: + * + * **Parameters:** + * + * * `assignment_id: i64` -- The unique identifier of the classroom assignment. + */ + pub async fn get_an_assignment( + &self, + assignment_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/assignments/{}", + crate::progenitor_support::encode_path(&assignment_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List accepted assignments for an assignment. + * + * This function performs a `GET` to the `/assignments/{assignment_id}/accepted_assignments` endpoint. + * + * Lists any assignment repositories that have been created by students accepting a GitHub Classroom assignment. Accepted assignments will only be returned if the current user is an administrator of the GitHub Classroom for the assignment. + * + * FROM: + * + * **Parameters:** + * + * * `assignment_id: i64` -- The unique identifier of the classroom assignment. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_accepted_assignments_for_an_assignment( + &self, + assignment_id: i64, + page: i64, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/assignments/{}/accepted_assignments?{}", + crate::progenitor_support::encode_path(&assignment_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List accepted assignments for an assignment. + * + * This function performs a `GET` to the `/assignments/{assignment_id}/accepted_assignments` endpoint. + * + * As opposed to `list_accepted_assignments_for_an_assignment`, this function returns all the pages of the request at once. + * + * Lists any assignment repositories that have been created by students accepting a GitHub Classroom assignment. Accepted assignments will only be returned if the current user is an administrator of the GitHub Classroom for the assignment. + * + * FROM: + */ + pub async fn list_all_accepted_assignments_for_an_assignment( + &self, + assignment_id: i64, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/assignments/{}/accepted_assignments", + crate::progenitor_support::encode_path(&assignment_id.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get assignment grades. + * + * This function performs a `GET` to the `/assignments/{assignment_id}/grades` endpoint. + * + * Gets grades for a GitHub Classroom assignment. Grades will only be returned if the current user is an administrator of the GitHub Classroom for the assignment. + * + * FROM: + * + * **Parameters:** + * + * * `assignment_id: i64` -- The unique identifier of the classroom assignment. + */ + pub async fn get_assignment_grades( + &self, + assignment_id: i64, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/assignments/{}/grades", + crate::progenitor_support::encode_path(&assignment_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get assignment grades. + * + * This function performs a `GET` to the `/assignments/{assignment_id}/grades` endpoint. + * + * As opposed to `get_assignment_grades`, this function returns all the pages of the request at once. + * + * Gets grades for a GitHub Classroom assignment. Grades will only be returned if the current user is an administrator of the GitHub Classroom for the assignment. + * + * FROM: + */ + pub async fn get_all_assignment_grades( + &self, + assignment_id: i64, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/assignments/{}/grades", + crate::progenitor_support::encode_path(&assignment_id.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List classrooms. + * + * This function performs a `GET` to the `/classrooms` endpoint. + * + * Lists GitHub Classroom classrooms for the current user. Classrooms will only be returned if the current user is an administrator of one or more GitHub Classrooms. + * + * FROM: + * + * **Parameters:** + * + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_classrooms( + &self, + page: i64, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url(&format!("/classrooms?{}", query_), None); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List classrooms. + * + * This function performs a `GET` to the `/classrooms` endpoint. + * + * As opposed to `list_classrooms`, this function returns all the pages of the request at once. + * + * Lists GitHub Classroom classrooms for the current user. Classrooms will only be returned if the current user is an administrator of one or more GitHub Classrooms. + * + * FROM: + */ + pub async fn list_all_classrooms( + &self, + ) -> ClientResult>> { + let url = self.client.url(&"/classrooms".to_string(), None); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a classroom. + * + * This function performs a `GET` to the `/classrooms/{classroom_id}` endpoint. + * + * Gets a GitHub Classroom classroom for the current user. Classroom will only be returned if the current user is an administrator of the GitHub Classroom. + * + * FROM: + * + * **Parameters:** + * + * * `classroom_id: i64` -- The unique identifier of the classroom. + */ + pub async fn get_a_classroom( + &self, + classroom_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/classrooms/{}", + crate::progenitor_support::encode_path(&classroom_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List assignments for a classroom. + * + * This function performs a `GET` to the `/classrooms/{classroom_id}/assignments` endpoint. + * + * Lists GitHub Classroom assignments for a classroom. Assignments will only be returned if the current user is an administrator of the GitHub Classroom. + * + * FROM: + * + * **Parameters:** + * + * * `classroom_id: i64` -- The unique identifier of the classroom. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_assignments_for_a_classroom( + &self, + classroom_id: i64, + page: i64, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/classrooms/{}/assignments?{}", + crate::progenitor_support::encode_path(&classroom_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List assignments for a classroom. + * + * This function performs a `GET` to the `/classrooms/{classroom_id}/assignments` endpoint. + * + * As opposed to `list_assignments_for_a_classroom`, this function returns all the pages of the request at once. + * + * Lists GitHub Classroom assignments for a classroom. Assignments will only be returned if the current user is an administrator of the GitHub Classroom. + * + * FROM: + */ + pub async fn list_all_assignments_for_a_classroom( + &self, + classroom_id: i64, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/classrooms/{}/assignments", + crate::progenitor_support::encode_path(&classroom_id.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } +} diff --git a/github/src/code_scanning.rs b/github/src/code_scanning.rs index 0c399a42..9e746380 100644 --- a/github/src/code_scanning.rs +++ b/github/src/code_scanning.rs @@ -11,33 +11,213 @@ impl CodeScanning { CodeScanning { client } } + /** + * List code scanning alerts for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/code-scanning/alerts` endpoint. + * + * Lists code scanning alerts for the default branch for all eligible repositories in an organization. Eligible repositories are repositories that are owned by organizations that you own or for which you are a security manager. For more information, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)." + * + * The authenticated user must be an owner or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` or `repo`s cope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `tool_name: &str` -- The name of a code scanning tool. Only results by this tool will be listed. You can specify the tool by using either `tool_name` or `tool_guid`, but not both. + * * `tool_guid: &str` -- The GUID of a code scanning tool. Only results by this tool will be listed. Note that some code scanning tools may not include a GUID in their analysis data. You can specify the tool by using either `tool_guid` or `tool_name`, but not both. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `state: crate::types::CodeScanningAlertStateQuery` -- If specified, only code scanning alerts with this state will be returned. + * * `sort: crate::types::SortData` -- The property by which to sort the results. + * * `severity: crate::types::CodeScanningAlertSeverity` -- If specified, only code scanning alerts with this severity will be returned. + * * `assignees: &str` -- Filter alerts by assignees. Provide a comma-separated list of user handles (e.g., `octocat` or `octocat,hubot`). + * Use `*` to list alerts with at least one assignee or `none` to list alerts with no assignees. + * . + */ + pub async fn list_alerts_for_org( + &self, + org: &str, + tool_name: &str, + tool_guid: &str, + before: &str, + after: &str, + page: i64, + per_page: i64, + direction: crate::types::Order, + state: crate::types::CodeScanningAlertStateQuery, + sort: crate::types::SortData, + severity: crate::types::CodeScanningAlertSeverity, + assignees: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !assignees.is_empty() { + query_args.push(("assignees".to_string(), assignees.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !severity.to_string().is_empty() { + query_args.push(("severity".to_string(), severity.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.to_string().is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + if !tool_guid.is_empty() { + query_args.push(("tool_guid".to_string(), tool_guid.to_string())); + } + if !tool_name.is_empty() { + query_args.push(("tool_name".to_string(), tool_name.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/code-scanning/alerts?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List code scanning alerts for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/code-scanning/alerts` endpoint. + * + * As opposed to `list_alerts_for_org`, this function returns all the pages of the request at once. + * + * Lists code scanning alerts for the default branch for all eligible repositories in an organization. Eligible repositories are repositories that are owned by organizations that you own or for which you are a security manager. For more information, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)." + * + * The authenticated user must be an owner or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` or `repo`s cope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + */ + pub async fn list_all_alerts_for_org( + &self, + org: &str, + tool_name: &str, + tool_guid: &str, + before: &str, + after: &str, + direction: crate::types::Order, + state: crate::types::CodeScanningAlertStateQuery, + sort: crate::types::SortData, + severity: crate::types::CodeScanningAlertSeverity, + assignees: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !assignees.is_empty() { + query_args.push(("assignees".to_string(), assignees.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !severity.to_string().is_empty() { + query_args.push(("severity".to_string(), severity.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.to_string().is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + if !tool_guid.is_empty() { + query_args.push(("tool_guid".to_string(), tool_guid.to_string())); + } + if !tool_name.is_empty() { + query_args.push(("tool_name".to_string(), tool_name.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/code-scanning/alerts?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } /** * List code scanning alerts for a repository. * * This function performs a `GET` to the `/repos/{owner}/{repo}/code-scanning/alerts` endpoint. * - * Lists all open code scanning alerts for the default branch (usually `main` - * or `master`). You must use an access token with the `security_events` scope to use - * this endpoint. GitHub Apps must have the `security_events` read permission to use - * this endpoint. + * Lists code scanning alerts. * * The response includes a `most_recent_instance` object. * This provides details of the most recent instance of this alert - * for the default branch or for the specified Git reference - * (if you used `ref` in the request). + * for the default branch (or for the specified Git reference if you used `ref` in the request). + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `tool_name: &str` -- The name of a code scanning tool. Only results by this tool will be listed. You can specify the tool by using either `tool_name` or `tool_guid`, but not both. * * `tool_guid: &str` -- The GUID of a code scanning tool. Only results by this tool will be listed. Note that some code scanning tools may not include a GUID in their analysis data. You can specify the tool by using either `tool_guid` or `tool_name`, but not both. - * * `page: i64` -- Page number of the results to fetch. - * * `per_page: i64` -- Results per page (max 100). + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". * * `ref_: &str` -- The Git reference for the results you want to list. The `ref` for a branch can be formatted either as `refs/heads/` or simply ``. To reference a pull request use `refs/pull//merge`. - * * `state: crate::types::CodeScanningAlertState` -- Set to `open`, `fixed`, or `dismissed` to list code scanning alerts in a specific state. + * * `pr: i64` -- The number of the pull request for the results you want to list. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `sort: crate::types::SortData` -- The property by which to sort the results. + * * `state: crate::types::CodeScanningAlertStateQuery` -- If specified, only code scanning alerts with this state will be returned. + * * `severity: crate::types::CodeScanningAlertSeverity` -- If specified, only code scanning alerts with this severity will be returned. + * * `assignees: &str` -- Filter alerts by assignees. Provide a comma-separated list of user handles (e.g., `octocat` or `octocat,hubot`). + * Use `*` to list alerts with at least one assignee or `none` to list alerts with no assignees. + * . */ pub async fn list_alerts_for_repo( &self, @@ -48,18 +228,46 @@ impl CodeScanning { page: i64, per_page: i64, ref_: &str, - state: crate::types::CodeScanningAlertState, + pr: i64, + direction: crate::types::Order, + before: &str, + after: &str, + sort: crate::types::SortData, + state: crate::types::CodeScanningAlertStateQuery, + severity: crate::types::CodeScanningAlertSeverity, + assignees: &str, ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !assignees.is_empty() { + query_args.push(("assignees".to_string(), assignees.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } if page > 0 { query_args.push(("page".to_string(), page.to_string())); } if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } + if pr > 0 { + query_args.push(("pr".to_string(), pr.to_string())); + } if !ref_.is_empty() { query_args.push(("ref".to_string(), ref_.to_string())); } + if !severity.to_string().is_empty() { + query_args.push(("severity".to_string(), severity.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } if !state.to_string().is_empty() { query_args.push(("state".to_string(), state.to_string())); } @@ -73,8 +281,8 @@ impl CodeScanning { let url = self.client.url( &format!( "/repos/{}/{}/code-scanning/alerts?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -96,17 +304,15 @@ impl CodeScanning { * * As opposed to `list_alerts_for_repo`, this function returns all the pages of the request at once. * - * Lists all open code scanning alerts for the default branch (usually `main` - * or `master`). You must use an access token with the `security_events` scope to use - * this endpoint. GitHub Apps must have the `security_events` read permission to use - * this endpoint. + * Lists code scanning alerts. * * The response includes a `most_recent_instance` object. * This provides details of the most recent instance of this alert - * for the default branch or for the specified Git reference - * (if you used `ref` in the request). + * for the default branch (or for the specified Git reference if you used `ref` in the request). * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: */ pub async fn list_all_alerts_for_repo( &self, @@ -115,12 +321,40 @@ impl CodeScanning { tool_name: &str, tool_guid: &str, ref_: &str, - state: crate::types::CodeScanningAlertState, + pr: i64, + direction: crate::types::Order, + before: &str, + after: &str, + sort: crate::types::SortData, + state: crate::types::CodeScanningAlertStateQuery, + severity: crate::types::CodeScanningAlertSeverity, + assignees: &str, ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !assignees.is_empty() { + query_args.push(("assignees".to_string(), assignees.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if pr > 0 { + query_args.push(("pr".to_string(), pr.to_string())); + } if !ref_.is_empty() { query_args.push(("ref".to_string(), ref_.to_string())); } + if !severity.to_string().is_empty() { + query_args.push(("severity".to_string(), severity.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } if !state.to_string().is_empty() { query_args.push(("state".to_string(), state.to_string())); } @@ -134,8 +368,8 @@ impl CodeScanning { let url = self.client.url( &format!( "/repos/{}/{}/code-scanning/alerts?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -155,17 +389,16 @@ impl CodeScanning { * * This function performs a `GET` to the `/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}` endpoint. * - * Gets a single code scanning alert. You must use an access token with the `security_events` scope to use this endpoint. GitHub Apps must have the `security_events` read permission to use this endpoint. + * Gets a single code scanning alert. * - * **Deprecation notice**: - * The instances field is deprecated and will, in future, not be included in the response for this endpoint. The example response reflects this change. The same information can now be retrieved via a GET request to the URL specified by `instances_url`. + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `alert_number: i64` -- The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the `number` field in the response from the `GET /repos/{owner}/{repo}/code-scanning/alerts` operation. */ pub async fn get_alert( @@ -177,8 +410,8 @@ impl CodeScanning { let url = self.client.url( &format!( "/repos/{}/{}/code-scanning/alerts/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&alert_number.to_string()), ), None, @@ -198,14 +431,15 @@ impl CodeScanning { * * This function performs a `PATCH` to the `/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}` endpoint. * - * Updates the status of a single code scanning alert. You must use an access token with the `security_events` scope to use this endpoint. GitHub Apps must have the `security_events` write permission to use this endpoint. + * Updates the status of a single code scanning alert. + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `alert_number: i64` -- The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the `number` field in the response from the `GET /repos/{owner}/{repo}/code-scanning/alerts` operation. */ pub async fn update_alert( @@ -218,8 +452,8 @@ impl CodeScanning { let url = self.client.url( &format!( "/repos/{}/{}/code-scanning/alerts/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&alert_number.to_string()), ), None, @@ -234,23 +468,159 @@ impl CodeScanning { ) .await } + /** + * Get the status of an autofix for a code scanning alert. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix` endpoint. + * + * Gets the status and description of an autofix for a code scanning alert. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `alert_number: i64` -- The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the `number` field in the response from the `GET /repos/{owner}/{repo}/code-scanning/alerts` operation. + */ + pub async fn get_autofix( + &self, + owner: &str, + repo: &str, + alert_number: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-scanning/alerts/{}/autofix", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&alert_number.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create an autofix for a code scanning alert. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix` endpoint. + * + * Creates an autofix for a code scanning alert. + * + * If a new autofix is to be created as a result of this request or is currently being generated, then this endpoint will return a 202 Accepted response. + * + * If an autofix already exists for a given alert, then this endpoint will return a 200 OK response. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `alert_number: i64` -- The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the `number` field in the response from the `GET /repos/{owner}/{repo}/code-scanning/alerts` operation. + */ + pub async fn create_autofix( + &self, + owner: &str, + repo: &str, + alert_number: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-scanning/alerts/{}/autofix", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&alert_number.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Commit an autofix for a code scanning alert. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix/commits` endpoint. + * + * Commits an autofix for a code scanning alert. + * + * If an autofix is committed as a result of this request, then this endpoint will return a 201 Created response. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `alert_number: i64` -- The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the `number` field in the response from the `GET /repos/{owner}/{repo}/code-scanning/alerts` operation. + */ + pub async fn commit_autofix( + &self, + owner: &str, + repo: &str, + alert_number: i64, + body: &crate::types::CodeScanningAutofixCommits, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-scanning/alerts/{}/autofix/commits", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&alert_number.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } /** * List instances of a code scanning alert. * * This function performs a `GET` to the `/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances` endpoint. * - * Lists all instances of the specified code scanning alert. You must use an access token with the `security_events` scope to use this endpoint. GitHub Apps must have the `security_events` read permission to use this endpoint. + * Lists all instances of the specified code scanning alert. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `alert_number: i64` -- The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the `number` field in the response from the `GET /repos/{owner}/{repo}/code-scanning/alerts` operation. - * * `page: i64` -- Page number of the results to fetch. - * * `per_page: i64` -- Results per page (max 100). + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". * * `ref_: &str` -- The Git reference for the results you want to list. The `ref` for a branch can be formatted either as `refs/heads/` or simply ``. To reference a pull request use `refs/pull//merge`. + * * `pr: i64` -- The number of the pull request for the results you want to list. */ pub async fn list_alert_instances( &self, @@ -260,7 +630,8 @@ impl CodeScanning { page: i64, per_page: i64, ref_: &str, - ) -> ClientResult>> { + pr: i64, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if page > 0 { query_args.push(("page".to_string(), page.to_string())); @@ -268,6 +639,9 @@ impl CodeScanning { if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } + if pr > 0 { + query_args.push(("pr".to_string(), pr.to_string())); + } if !ref_.is_empty() { query_args.push(("ref".to_string(), ref_.to_string())); } @@ -275,8 +649,8 @@ impl CodeScanning { let url = self.client.url( &format!( "/repos/{}/{}/code-scanning/alerts/{}/instances?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&alert_number.to_string()), query_ ), @@ -299,9 +673,11 @@ impl CodeScanning { * * As opposed to `list_alert_instances`, this function returns all the pages of the request at once. * - * Lists all instances of the specified code scanning alert. You must use an access token with the `security_events` scope to use this endpoint. GitHub Apps must have the `security_events` read permission to use this endpoint. + * Lists all instances of the specified code scanning alert. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. * - * FROM: + * FROM: */ pub async fn list_all_alert_instances( &self, @@ -309,8 +685,12 @@ impl CodeScanning { repo: &str, alert_number: i64, ref_: &str, - ) -> ClientResult>> { + pr: i64, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); + if pr > 0 { + query_args.push(("pr".to_string(), pr.to_string())); + } if !ref_.is_empty() { query_args.push(("ref".to_string(), ref_.to_string())); } @@ -318,8 +698,8 @@ impl CodeScanning { let url = self.client.url( &format!( "/repos/{}/{}/code-scanning/alerts/{}/instances?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&alert_number.to_string()), query_ ), @@ -351,24 +731,26 @@ impl CodeScanning { * For very old analyses this data is not available, * and `0` is returned in this field. * - * You must use an access token with the `security_events` scope to use this endpoint. - * GitHub Apps must have the `security_events` read permission to use this endpoint. + * > [!WARNING] + * > **Closing down notice:** The `tool_name` field is closing down and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the `tool` field. * - * **Deprecation notice**: - * The `tool_name` field is deprecated and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the `tool` field. + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `tool_name: &str` -- The name of a code scanning tool. Only results by this tool will be listed. You can specify the tool by using either `tool_name` or `tool_guid`, but not both. * * `tool_guid: &str` -- The GUID of a code scanning tool. Only results by this tool will be listed. Note that some code scanning tools may not include a GUID in their analysis data. You can specify the tool by using either `tool_guid` or `tool_name`, but not both. - * * `page: i64` -- Page number of the results to fetch. - * * `per_page: i64` -- Results per page (max 100). + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `pr: i64` -- The number of the pull request for the results you want to list. * * `ref_: &str` -- The Git reference for the analyses you want to list. The `ref` for a branch can be formatted either as `refs/heads/` or simply ``. To reference a pull request use `refs/pull//merge`. * * `sarif_id: &str` -- Filter analyses belonging to the same SARIF upload. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `sort: crate::types::CodeScanningListRecentAnalysesSort` -- The property by which to sort the results. */ pub async fn list_recent_analyses( &self, @@ -378,22 +760,34 @@ impl CodeScanning { tool_guid: &str, page: i64, per_page: i64, + pr: i64, ref_: &str, sarif_id: &str, + direction: crate::types::Order, + sort: crate::types::CodeScanningListRecentAnalysesSort, ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } if page > 0 { query_args.push(("page".to_string(), page.to_string())); } if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } + if pr > 0 { + query_args.push(("pr".to_string(), pr.to_string())); + } if !ref_.is_empty() { query_args.push(("ref".to_string(), ref_.to_string())); } if !sarif_id.is_empty() { query_args.push(("sarif_id".to_string(), sarif_id.to_string())); } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } if !tool_guid.is_empty() { query_args.push(("tool_guid".to_string(), tool_guid.to_string())); } @@ -404,8 +798,8 @@ impl CodeScanning { let url = self.client.url( &format!( "/repos/{}/{}/code-scanning/analyses?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -438,13 +832,12 @@ impl CodeScanning { * For very old analyses this data is not available, * and `0` is returned in this field. * - * You must use an access token with the `security_events` scope to use this endpoint. - * GitHub Apps must have the `security_events` read permission to use this endpoint. + * > [!WARNING] + * > **Closing down notice:** The `tool_name` field is closing down and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the `tool` field. * - * **Deprecation notice**: - * The `tool_name` field is deprecated and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the `tool` field. + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. * - * FROM: + * FROM: */ pub async fn list_all_recent_analyses( &self, @@ -452,16 +845,28 @@ impl CodeScanning { repo: &str, tool_name: &str, tool_guid: &str, + pr: i64, ref_: &str, sarif_id: &str, + direction: crate::types::Order, + sort: crate::types::CodeScanningListRecentAnalysesSort, ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if pr > 0 { + query_args.push(("pr".to_string(), pr.to_string())); + } if !ref_.is_empty() { query_args.push(("ref".to_string(), ref_.to_string())); } if !sarif_id.is_empty() { query_args.push(("sarif_id".to_string(), sarif_id.to_string())); } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } if !tool_guid.is_empty() { query_args.push(("tool_guid".to_string(), tool_guid.to_string())); } @@ -472,8 +877,8 @@ impl CodeScanning { let url = self.client.url( &format!( "/repos/{}/{}/code-scanning/analyses?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -494,8 +899,6 @@ impl CodeScanning { * This function performs a `GET` to the `/repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}` endpoint. * * Gets a specified code scanning analysis for a repository. - * You must use an access token with the `security_events` scope to use this endpoint. - * GitHub Apps must have the `security_events` read permission to use this endpoint. * * The default JSON response contains fields that describe the analysis. * This includes the Git reference and commit SHA to which the analysis relates, @@ -507,20 +910,18 @@ impl CodeScanning { * For very old analyses this data is not available, * and `0` is returned in this field. * - * If you use the Accept header `application/sarif+json`, - * the response contains the analysis data that was uploaded. - * This is formatted as - * [SARIF version 2.1.0](https://docs.oasis-open.org/sarif/sarif/v2.1.0/cs01/sarif-v2.1.0-cs01.html). + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/sarif+json`**: Instead of returning a summary of the analysis, this endpoint returns a subset of the analysis data that was uploaded. The data is formatted as [SARIF version 2.1.0](https://docs.oasis-open.org/sarif/sarif/v2.1.0/cs01/sarif-v2.1.0-cs01.html). It also returns additional data such as the `github/alertNumber` and `github/alertUrl` properties. * - * **Deprecation notice**: - * The `tool_name` field is deprecated and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the `tool` field. + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `analysis_id: i64` -- The ID of the analysis, as returned from the `GET /repos/{owner}/{repo}/code-scanning/analyses` operation. */ pub async fn get_analysis( @@ -532,8 +933,8 @@ impl CodeScanning { let url = self.client.url( &format!( "/repos/{}/{}/code-scanning/analyses/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&analysis_id.to_string()), ), None, @@ -553,10 +954,7 @@ impl CodeScanning { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}` endpoint. * - * Deletes a specified code scanning analysis from a repository. For - * private repositories, you must use an access token with the `repo` scope. For public repositories, - * you must use an access token with `public_repo` and `repo:security_events` scopes. - * GitHub Apps must have the `security_events` write permission to use this endpoint. + * Deletes a specified code scanning analysis from a repository. * * You can delete one analysis at a time. * To delete a series of analyses, start with the most recent analysis and work backwards. @@ -576,8 +974,7 @@ impl CodeScanning { * * * `ref` * * `tool` - * * `analysis_key` - * * `environment` + * * `category` * * If you attempt to delete an analysis that is not the most recent in a set, * you'll get a 400 response with the message: @@ -587,13 +984,13 @@ impl CodeScanning { * ``` * * The response from a successful `DELETE` operation provides you with - * two alternative URLs for deleting the next analysis in the set - * (see the example default response below). + * two alternative URLs for deleting the next analysis in the set: + * `next_analysis_url` and `confirm_delete_url`. * Use the `next_analysis_url` URL if you want to avoid accidentally deleting the final analysis - * in the set. This is a useful option if you want to preserve at least one analysis + * in a set. This is a useful option if you want to preserve at least one analysis * for the specified tool in your repository. * Use the `confirm_delete_url` URL if you are content to remove all analyses for a tool. - * When you delete the last analysis in a set the value of `next_analysis_url` and `confirm_delete_url` + * When you delete the last analysis in a set, the value of `next_analysis_url` and `confirm_delete_url` * in the 200 response is `null`. * * As an example of the deletion process, @@ -603,9 +1000,11 @@ impl CodeScanning { * You therefore have two separate sets of analyses for this tool. * You've now decided that you want to remove all of the analyses for the tool. * To do this you must make 15 separate deletion requests. - * To start, you must find the deletable analysis for one of the sets, - * step through deleting the analyses in that set, - * and then repeat the process for the second set. + * To start, you must find an analysis that's identified as deletable. + * Each set of analyses always has one that's identified as deletable. + * Having found the deletable analysis for one of the two sets, + * delete this analysis and then continue deleting the next analysis in the set until they're all deleted. + * Then repeat the process for the second set. * The procedure therefore consists of a nested loop: * * **Outer loop**: @@ -618,12 +1017,14 @@ impl CodeScanning { * * The above process assumes that you want to remove all trace of the tool's analyses from the GitHub user interface, for the specified repository, and it therefore uses the `confirm_delete_url` value. Alternatively, you could use the `next_analysis_url` value, which would leave the last analysis in each set undeleted to avoid removing a tool's analysis entirely. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `analysis_id: i64` -- The ID of the analysis, as returned from the `GET /repos/{owner}/{repo}/code-scanning/analyses` operation. * * `confirm_delete: &str` -- Allow deletion if the specified analysis is the last in a set. If you attempt to delete the final analysis in a set without setting this parameter to `true`, you'll get a 400 response with the message: `Analysis is last of its type and deletion may result in the loss of historical alert data. Please specify confirm_delete.`. */ @@ -642,8 +1043,8 @@ impl CodeScanning { let url = self.client.url( &format!( "/repos/{}/{}/code-scanning/analyses/{}?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&analysis_id.to_string()), query_ ), @@ -659,12 +1060,391 @@ impl CodeScanning { ) .await } + /** + * List CodeQL databases for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/code-scanning/codeql/databases` endpoint. + * + * Lists the CodeQL databases that are available in a repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn list_codeql_databases( + &self, + owner: &str, + repo: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-scanning/codeql/databases", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List CodeQL databases for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/code-scanning/codeql/databases` endpoint. + * + * As opposed to `list_codeql_databases`, this function returns all the pages of the request at once. + * + * Lists the CodeQL databases that are available in a repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + */ + pub async fn list_all_codeql_databases( + &self, + owner: &str, + repo: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-scanning/codeql/databases", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a CodeQL database for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/code-scanning/codeql/databases/{language}` endpoint. + * + * Gets a CodeQL database for a language in a repository. + * + * By default this endpoint returns JSON metadata about the CodeQL database. To + * download the CodeQL database binary content, set the `Accept` header of the request + * to [`application/zip`](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types), and make sure + * your HTTP client is configured to follow redirects or use the `Location` header + * to make a second request to get the redirect URL. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `language: &str` -- The language of the CodeQL database. + */ + pub async fn get_codeql_database( + &self, + owner: &str, + repo: &str, + language: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-scanning/codeql/databases/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&language.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a CodeQL database. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/code-scanning/codeql/databases/{language}` endpoint. + * + * Deletes a CodeQL database for a language in a repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `language: &str` -- The language of the CodeQL database. + */ + pub async fn delete_codeql_database( + &self, + owner: &str, + repo: &str, + language: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-scanning/codeql/databases/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&language.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a CodeQL variant analysis. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/code-scanning/codeql/variant-analyses` endpoint. + * + * Creates a new CodeQL variant analysis, which will run a CodeQL query against one or more repositories. + * + * Get started by learning more about [running CodeQL queries at scale with Multi-Repository Variant Analysis](https://docs.github.com/code-security/codeql-for-vs-code/getting-started-with-codeql-for-vs-code/running-codeql-queries-at-scale-with-multi-repository-variant-analysis). + * + * Use the `owner` and `repo` parameters in the URL to specify the controller repository that + * will be used for running GitHub Actions workflows and storing the results of the CodeQL variant analysis. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_variant_analysis( + &self, + owner: &str, + repo: &str, + body: &crate::types::CodeScanningCreateVariantAnalysisRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-scanning/codeql/variant-analyses", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get the summary of a CodeQL variant analysis. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/code-scanning/codeql/variant-analyses/{codeql_variant_analysis_id}` endpoint. + * + * Gets the summary of a CodeQL variant analysis. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `codeql_variant_analysis_id: i64` -- The unique identifier of the variant analysis. + */ + pub async fn get_variant_analysis( + &self, + owner: &str, + repo: &str, + codeql_variant_analysis_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-scanning/codeql/variant-analyses/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&codeql_variant_analysis_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get the analysis status of a repository in a CodeQL variant analysis. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/code-scanning/codeql/variant-analyses/{codeql_variant_analysis_id}/repos/{repo_owner}/{repo_name}` endpoint. + * + * Gets the analysis status of a repository in a CodeQL variant analysis. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the controller repository. + * * `codeql_variant_analysis_id: i64` -- The ID of the variant analysis. + * * `repo_owner: &str` -- The account owner of the variant analysis repository. The name is not case sensitive. + * * `repo_name: &str` -- The name of the variant analysis repository. + */ + pub async fn get_variant_analysis_repo_task( + &self, + owner: &str, + repo: &str, + codeql_variant_analysis_id: i64, + repo_owner: &str, + repo_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-scanning/codeql/variant-analyses/{}/repos/{}/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&codeql_variant_analysis_id.to_string()), + crate::progenitor_support::encode_path(&repo_owner.to_string()), + crate::progenitor_support::encode_path(&repo_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a code scanning default setup configuration. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/code-scanning/default-setup` endpoint. + * + * Gets a code scanning default setup configuration. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_default_setup( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-scanning/default-setup", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a code scanning default setup configuration. + * + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/code-scanning/default-setup` endpoint. + * + * Updates a code scanning default setup configuration. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn update_default_setup( + &self, + owner: &str, + repo: &str, + body: &crate::types::CodeScanningDefaultSetupUpdate, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-scanning/default-setup", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } /** * Upload an analysis as SARIF data. * * This function performs a `POST` to the `/repos/{owner}/{repo}/code-scanning/sarifs` endpoint. * - * Uploads SARIF data containing the results of a code scanning analysis to make the results available in a repository. You must use an access token with the `security_events` scope to use this endpoint. GitHub Apps must have the `security_events` write permission to use this endpoint. + * Uploads SARIF data containing the results of a code scanning analysis to make the results available in a repository. For troubleshooting information, see "[Troubleshooting SARIF uploads](https://docs.github.com/code-security/code-scanning/troubleshooting-sarif)." * * There are two places where you can upload code scanning results. * - If you upload to a pull request, for example `--ref refs/pull/42/merge` or `--ref refs/pull/42/head`, then the results appear as alerts in a pull request check. For more information, see "[Triaging code scanning alerts in pull requests](/code-security/secure-coding/triaging-code-scanning-alerts-in-pull-requests)." @@ -676,18 +1456,35 @@ impl CodeScanning { * gzip -c analysis-data.sarif | base64 -w0 * ``` * - * SARIF upload supports a maximum of 5000 results per analysis run. Any results over this limit are ignored and any SARIF uploads with more than 25,000 results are rejected. Typically, but not necessarily, a SARIF file contains a single run of a single tool. If a code scanning tool generates too many results, you should update the analysis configuration to run only the most important rules or queries. + * SARIF upload supports a maximum number of entries per the following data objects, and an analysis will be rejected if any of these objects is above its maximum value. For some objects, there are additional values over which the entries will be ignored while keeping the most important entries whenever applicable. + * To get the most out of your analysis when it includes data above the supported limits, try to optimize the analysis configuration. For example, for the CodeQL tool, identify and remove the most noisy queries. For more information, see "[SARIF results exceed one or more limits](https://docs.github.com/code-security/code-scanning/troubleshooting-sarif/results-exceed-limit)." + * + * + * | **SARIF data** | **Maximum values** | **Additional limits** | + * |----------------------------------|:------------------:|----------------------------------------------------------------------------------| + * | Runs per file | 20 | | + * | Results per run | 25,000 | Only the top 5,000 results will be included, prioritized by severity. | + * | Rules per run | 25,000 | | + * | Tool extensions per run | 100 | | + * | Thread Flow Locations per result | 10,000 | Only the top 1,000 Thread Flow Locations will be included, using prioritization. | + * | Location per result | 1,000 | Only 100 locations will be included. | + * | Tags per rule | 20 | Only 10 tags will be included. | + * + * + * The `202 Accepted` response includes an `id` value. + * You can use this ID to check the status of the upload by using it in the `/sarifs/{sarif_id}` endpoint. + * For more information, see "[Get information about a SARIF upload](/rest/code-scanning/code-scanning#get-information-about-a-sarif-upload)." + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. * - * The `202 Accepted`, response includes an `id` value. - * You can use this ID to check the status of the upload by using this for the `/sarifs/{sarif_id}` endpoint. - * For more information, see "[Get information about a SARIF upload](/rest/reference/code-scanning#get-information-about-a-sarif-upload)." + * This endpoint is limited to 1,000 requests per hour for each user or app installation calling it. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn upload_sarif( &self, @@ -698,8 +1495,8 @@ impl CodeScanning { let url = self.client.url( &format!( "/repos/{}/{}/code-scanning/sarifs", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -718,14 +1515,15 @@ impl CodeScanning { * * This function performs a `GET` to the `/repos/{owner}/{repo}/code-scanning/sarifs/{sarif_id}` endpoint. * - * Gets information about a SARIF upload, including the status and the URL of the analysis that was uploaded so that you can retrieve details of the analysis. For more information, see "[Get a code scanning analysis for a repository](/rest/reference/code-scanning#get-a-code-scanning-analysis-for-a-repository)." You must use an access token with the `security_events` scope to use this endpoint. GitHub Apps must have the `security_events` read permission to use this endpoint. + * Gets information about a SARIF upload, including the status and the URL of the analysis that was uploaded so that you can retrieve details of the analysis. For more information, see "[Get a code scanning analysis for a repository](/rest/code-scanning/code-scanning#get-a-code-scanning-analysis-for-a-repository)." + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `sarif_id: &str` -- The SARIF ID obtained after uploading. */ pub async fn get_sarif( @@ -737,9 +1535,9 @@ impl CodeScanning { let url = self.client.url( &format!( "/repos/{}/{}/code-scanning/sarifs/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(sarif_id), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&sarif_id.to_string()), ), None, ); diff --git a/github/src/code_security.rs b/github/src/code_security.rs new file mode 100644 index 00000000..a79a02f6 --- /dev/null +++ b/github/src/code_security.rs @@ -0,0 +1,1208 @@ +use crate::Client; +use crate::ClientResult; + +pub struct CodeSecurity { + pub client: Client, +} + +impl CodeSecurity { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + CodeSecurity { client } + } + + /** + * Get code security configurations for an enterprise. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/code-security/configurations` endpoint. + * + * Lists all code security configurations available in an enterprise. + * + * The authenticated user must be an administrator of the enterprise in order to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:enterprise` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn get_configurations_for_enterprise( + &self, + enterprise: &str, + per_page: i64, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/enterprises/{}/code-security/configurations?{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get code security configurations for an enterprise. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/code-security/configurations` endpoint. + * + * As opposed to `get_configurations_for_enterprise`, this function returns all the pages of the request at once. + * + * Lists all code security configurations available in an enterprise. + * + * The authenticated user must be an administrator of the enterprise in order to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:enterprise` scope to use this endpoint. + * + * FROM: + */ + pub async fn get_all_configurations_for_enterprise( + &self, + enterprise: &str, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/enterprises/{}/code-security/configurations?{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a code security configuration for an enterprise. + * + * This function performs a `POST` to the `/enterprises/{enterprise}/code-security/configurations` endpoint. + * + * Creates a code security configuration in an enterprise. + * + * The authenticated user must be an administrator of the enterprise in order to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:enterprise` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + */ + pub async fn create_configuration_for_enterprise( + &self, + enterprise: &str, + body: &crate::types::CodeSecurityCreateConfigurationEnterpriseRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/code-security/configurations", + crate::progenitor_support::encode_path(&enterprise.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get default code security configurations for an enterprise. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/code-security/configurations/defaults` endpoint. + * + * Lists the default code security configurations for an enterprise. + * + * The authenticated user must be an administrator of the enterprise in order to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:enterprise` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + */ + pub async fn get_default_configurations_for_enterprise( + &self, + enterprise: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/enterprises/{}/code-security/configurations/defaults", + crate::progenitor_support::encode_path(&enterprise.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get default code security configurations for an enterprise. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/code-security/configurations/defaults` endpoint. + * + * As opposed to `get_default_configurations_for_enterprise`, this function returns all the pages of the request at once. + * + * Lists the default code security configurations for an enterprise. + * + * The authenticated user must be an administrator of the enterprise in order to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:enterprise` scope to use this endpoint. + * + * FROM: + */ + pub async fn get_all_default_configurations_for_enterprise( + &self, + enterprise: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/enterprises/{}/code-security/configurations/defaults", + crate::progenitor_support::encode_path(&enterprise.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Retrieve a code security configuration of an enterprise. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/code-security/configurations/{configuration_id}` endpoint. + * + * Gets a code security configuration available in an enterprise. + * + * The authenticated user must be an administrator of the enterprise in order to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:enterprise` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `configuration_id: i64` -- The unique identifier of the code security configuration. + */ + pub async fn get_single_configuration_for_enterprise( + &self, + enterprise: &str, + configuration_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/code-security/configurations/{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a code security configuration for an enterprise. + * + * This function performs a `DELETE` to the `/enterprises/{enterprise}/code-security/configurations/{configuration_id}` endpoint. + * + * Deletes a code security configuration from an enterprise. + * Repositories attached to the configuration will retain their settings but will no longer be associated with + * the configuration. + * + * The authenticated user must be an administrator for the enterprise to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:enterprise` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `configuration_id: i64` -- The unique identifier of the code security configuration. + */ + pub async fn delete_configuration_for_enterprise( + &self, + enterprise: &str, + configuration_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/code-security/configurations/{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a custom code security configuration for an enterprise. + * + * This function performs a `PATCH` to the `/enterprises/{enterprise}/code-security/configurations/{configuration_id}` endpoint. + * + * Updates a code security configuration in an enterprise. + * + * The authenticated user must be an administrator of the enterprise in order to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:enterprise` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `configuration_id: i64` -- The unique identifier of the code security configuration. + */ + pub async fn update_enterprise_configuration( + &self, + enterprise: &str, + configuration_id: i64, + body: &crate::types::CodeSecurityUpdateEnterpriseConfigurationRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/code-security/configurations/{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Attach an enterprise configuration to repositories. + * + * This function performs a `POST` to the `/enterprises/{enterprise}/code-security/configurations/{configuration_id}/attach` endpoint. + * + * Attaches an enterprise code security configuration to repositories. If the repositories specified are already attached to a configuration, they will be re-attached to the provided configuration. + * + * If insufficient GHAS licenses are available to attach the configuration to a repository, only free features will be enabled. + * + * The authenticated user must be an administrator for the enterprise to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:enterprise` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `configuration_id: i64` -- The unique identifier of the code security configuration. + */ + pub async fn attach_enterprise_configuration( + &self, + enterprise: &str, + configuration_id: i64, + body: &crate::types::CodeSecurityAttachEnterpriseConfigurationRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/code-security/configurations/{}/attach", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Set a code security configuration as a default for an enterprise. + * + * This function performs a `PUT` to the `/enterprises/{enterprise}/code-security/configurations/{configuration_id}/defaults` endpoint. + * + * Sets a code security configuration as a default to be applied to new repositories in your enterprise. + * + * This configuration will be applied by default to the matching repository type when created, but only for organizations within the enterprise that do not already have a default code security configuration set. + * + * The authenticated user must be an administrator for the enterprise to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:enterprise` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `configuration_id: i64` -- The unique identifier of the code security configuration. + */ + pub async fn set_configuration_as_default_for_enterprise( + &self, + enterprise: &str, + configuration_id: i64, + body: &crate::types::CodeSecuritySetConfigurationAsDefaultRequest, + ) -> ClientResult> + { + let url = self.client.url( + &format!( + "/enterprises/{}/code-security/configurations/{}/defaults", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get repositories associated with an enterprise code security configuration. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/code-security/configurations/{configuration_id}/repositories` endpoint. + * + * Lists the repositories associated with an enterprise code security configuration in an organization. + * + * The authenticated user must be an administrator of the enterprise in order to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:enterprise` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `configuration_id: i64` -- The unique identifier of the code security configuration. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `status: &str` -- A comma-separated list of statuses. If specified, only repositories with these attachment statuses will be returned. + * + * Can be: `all`, `attached`, `attaching`, `removed`, `enforced`, `failed`, `updating`, `removed_by_enterprise`. + */ + pub async fn get_repositories_for_enterprise_configuration( + &self, + enterprise: &str, + configuration_id: i64, + per_page: i64, + before: &str, + after: &str, + status: &str, + ) -> ClientResult>> + { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !status.is_empty() { + query_args.push(("status".to_string(), status.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/enterprises/{}/code-security/configurations/{}/repositories?{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get repositories associated with an enterprise code security configuration. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/code-security/configurations/{configuration_id}/repositories` endpoint. + * + * As opposed to `get_repositories_for_enterprise_configuration`, this function returns all the pages of the request at once. + * + * Lists the repositories associated with an enterprise code security configuration in an organization. + * + * The authenticated user must be an administrator of the enterprise in order to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:enterprise` scope to use this endpoint. + * + * FROM: + */ + pub async fn get_all_repositories_for_enterprise_configuration( + &self, + enterprise: &str, + configuration_id: i64, + before: &str, + after: &str, + status: &str, + ) -> ClientResult>> + { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !status.is_empty() { + query_args.push(("status".to_string(), status.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/enterprises/{}/code-security/configurations/{}/repositories?{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get code security configurations for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/code-security/configurations` endpoint. + * + * Lists all code security configurations available in an organization. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `target_type: crate::types::CodeSecurityGetConfigurationsOrgTargetType` -- The target type of the code security configuration. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn get_configurations_for_org( + &self, + org: &str, + target_type: crate::types::CodeSecurityGetConfigurationsOrgTargetType, + per_page: i64, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !target_type.to_string().is_empty() { + query_args.push(("target_type".to_string(), target_type.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get code security configurations for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/code-security/configurations` endpoint. + * + * As opposed to `get_configurations_for_org`, this function returns all the pages of the request at once. + * + * Lists all code security configurations available in an organization. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:org` scope to use this endpoint. + * + * FROM: + */ + pub async fn get_all_configurations_for_org( + &self, + org: &str, + target_type: crate::types::CodeSecurityGetConfigurationsOrgTargetType, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !target_type.to_string().is_empty() { + query_args.push(("target_type".to_string(), target_type.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a code security configuration. + * + * This function performs a `POST` to the `/orgs/{org}/code-security/configurations` endpoint. + * + * Creates a code security configuration in an organization. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `write:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_configuration( + &self, + org: &str, + body: &crate::types::CodeSecurityCreateConfigurationRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get default code security configurations. + * + * This function performs a `GET` to the `/orgs/{org}/code-security/configurations/defaults` endpoint. + * + * Lists the default code security configurations for an organization. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn get_default_configurations( + &self, + org: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations/defaults", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get default code security configurations. + * + * This function performs a `GET` to the `/orgs/{org}/code-security/configurations/defaults` endpoint. + * + * As opposed to `get_default_configurations`, this function returns all the pages of the request at once. + * + * Lists the default code security configurations for an organization. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:org` scope to use this endpoint. + * + * FROM: + */ + pub async fn get_all_default_configurations( + &self, + org: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations/defaults", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Detach configurations from repositories. + * + * This function performs a `DELETE` to the `/orgs/{org}/code-security/configurations/detach` endpoint. + * + * Detach code security configuration(s) from a set of repositories. + * Repositories will retain their settings but will no longer be associated with the configuration. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `write:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn detach_configuration( + &self, + org: &str, + body: &crate::types::CodeSecurityDetachConfigurationRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations/detach", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a code security configuration. + * + * This function performs a `GET` to the `/orgs/{org}/code-security/configurations/{configuration_id}` endpoint. + * + * Gets a code security configuration available in an organization. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `write:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `configuration_id: i64` -- The unique identifier of the code security configuration. + */ + pub async fn get_configuration( + &self, + org: &str, + configuration_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a code security configuration. + * + * This function performs a `DELETE` to the `/orgs/{org}/code-security/configurations/{configuration_id}` endpoint. + * + * Deletes the desired code security configuration from an organization. + * Repositories attached to the configuration will retain their settings but will no longer be associated with + * the configuration. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `write:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `configuration_id: i64` -- The unique identifier of the code security configuration. + */ + pub async fn delete_configuration( + &self, + org: &str, + configuration_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a code security configuration. + * + * This function performs a `PATCH` to the `/orgs/{org}/code-security/configurations/{configuration_id}` endpoint. + * + * Updates a code security configuration in an organization. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `write:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `configuration_id: i64` -- The unique identifier of the code security configuration. + */ + pub async fn update_configuration( + &self, + org: &str, + configuration_id: i64, + body: &crate::types::CodeSecurityUpdateConfigurationRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Attach a configuration to repositories. + * + * This function performs a `POST` to the `/orgs/{org}/code-security/configurations/{configuration_id}/attach` endpoint. + * + * Attach a code security configuration to a set of repositories. If the repositories specified are already attached to a configuration, they will be re-attached to the provided configuration. + * + * If insufficient GHAS licenses are available to attach the configuration to a repository, only free features will be enabled. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `write:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `configuration_id: i64` -- The unique identifier of the code security configuration. + */ + pub async fn attach_configuration( + &self, + org: &str, + configuration_id: i64, + body: &crate::types::CodeSecurityAttachConfigurationRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations/{}/attach", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Set a code security configuration as a default for an organization. + * + * This function performs a `PUT` to the `/orgs/{org}/code-security/configurations/{configuration_id}/defaults` endpoint. + * + * Sets a code security configuration as a default to be applied to new repositories in your organization. + * + * This configuration will be applied to the matching repository type (all, none, public, private and internal) by default when they are created. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `write:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `configuration_id: i64` -- The unique identifier of the code security configuration. + */ + pub async fn set_configuration_as_default( + &self, + org: &str, + configuration_id: i64, + body: &crate::types::CodeSecuritySetConfigurationAsDefaultRequest, + ) -> ClientResult> + { + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations/{}/defaults", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get repositories associated with a code security configuration. + * + * This function performs a `GET` to the `/orgs/{org}/code-security/configurations/{configuration_id}/repositories` endpoint. + * + * Lists the repositories associated with a code security configuration in an organization. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `configuration_id: i64` -- The unique identifier of the code security configuration. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `status: &str` -- A comma-separated list of statuses. If specified, only repositories with these attachment statuses will be returned. + * + * Can be: `all`, `attached`, `attaching`, `detached`, `removed`, `enforced`, `failed`, `updating`, `removed_by_enterprise`. + */ + pub async fn get_repositories_for_configuration( + &self, + org: &str, + configuration_id: i64, + per_page: i64, + before: &str, + after: &str, + status: &str, + ) -> ClientResult>> + { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !status.is_empty() { + query_args.push(("status".to_string(), status.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations/{}/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get repositories associated with a code security configuration. + * + * This function performs a `GET` to the `/orgs/{org}/code-security/configurations/{configuration_id}/repositories` endpoint. + * + * As opposed to `get_repositories_for_configuration`, this function returns all the pages of the request at once. + * + * Lists the repositories associated with a code security configuration in an organization. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:org` scope to use this endpoint. + * + * FROM: + */ + pub async fn get_all_repositories_for_configuration( + &self, + org: &str, + configuration_id: i64, + before: &str, + after: &str, + status: &str, + ) -> ClientResult>> + { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !status.is_empty() { + query_args.push(("status".to_string(), status.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/code-security/configurations/{}/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&configuration_id.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get the code security configuration associated with a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/code-security-configuration` endpoint. + * + * Get the code security configuration that manages a repository's code security settings. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_configuration_for_repository( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/code-security-configuration", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } +} diff --git a/github/src/codes_of_conduct.rs b/github/src/codes_of_conduct.rs index 9a290b03..c4a092cd 100644 --- a/github/src/codes_of_conduct.rs +++ b/github/src/codes_of_conduct.rs @@ -16,14 +16,14 @@ impl CodesOfConduct { * * This function performs a `GET` to the `/codes_of_conduct` endpoint. * + * Returns array of all GitHub's codes of conduct. * - * - * FROM: + * FROM: */ pub async fn get_all_codes_of_conduct( &self, ) -> ClientResult>> { - let url = self.client.url("/codes_of_conduct", None); + let url = self.client.url(&"/codes_of_conduct".to_string(), None); self.client .get( &url, @@ -41,14 +41,14 @@ impl CodesOfConduct { * * As opposed to `get_all_codes_of_conduct`, this function returns all the pages of the request at once. * + * Returns array of all GitHub's codes of conduct. * - * - * FROM: + * FROM: */ pub async fn get_all_all_codes_of_conduct( &self, ) -> ClientResult>> { - let url = self.client.url("/codes_of_conduct", None); + let url = self.client.url(&"/codes_of_conduct".to_string(), None); self.client .get_all_pages( &url, @@ -64,9 +64,9 @@ impl CodesOfConduct { * * This function performs a `GET` to the `/codes_of_conduct/{key}` endpoint. * + * Returns information about the specified GitHub code of conduct. * - * - * FROM: + * FROM: * * **Parameters:** * @@ -79,46 +79,7 @@ impl CodesOfConduct { let url = self.client.url( &format!( "/codes_of_conduct/{}", - crate::progenitor_support::encode_path(key), - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Get the code of conduct for a repository. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/community/code_of_conduct` endpoint. - * - * Returns the contents of the repository's code of conduct file, if one is detected. - * - * A code of conduct is detected if there is a file named `CODE_OF_CONDUCT` in the root directory of the repository. GitHub detects which code of conduct it is using fuzzy matching. - * - * FROM: - * - * **Parameters:** - * - * * `owner: &str` - * * `repo: &str` - */ - pub async fn get_for_repo( - &self, - owner: &str, - repo: &str, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/repos/{}/{}/community/code_of_conduct", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&key.to_string()), ), None, ); diff --git a/github/src/codespaces.rs b/github/src/codespaces.rs new file mode 100644 index 00000000..f542b883 --- /dev/null +++ b/github/src/codespaces.rs @@ -0,0 +1,2034 @@ +use crate::Client; +use crate::ClientResult; + +pub struct Codespaces { + pub client: Client, +} + +impl Codespaces { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + Codespaces { client } + } + + /** + * List codespaces for the organization. + * + * This function performs a `GET` to the `/orgs/{org}/codespaces` endpoint. + * + * Lists the codespaces associated to a specified organization. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn list_in_organization( + &self, + per_page: i64, + page: i64, + org: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/codespaces?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Manage access control for organization codespaces. + * + * This function performs a `PUT` to the `/orgs/{org}/codespaces/access` endpoint. + * + * Sets which users can access codespaces in an organization. This is synonymous with granting or revoking codespaces access permissions for users according to the visibility. + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn set_codespaces_access( + &self, + org: &str, + body: &crate::types::CodespacesSetAccessRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/codespaces/access", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Add users to Codespaces access for an organization. + * + * This function performs a `POST` to the `/orgs/{org}/codespaces/access/selected_users` endpoint. + * + * Codespaces for the specified users will be billed to the organization. + * + * To use this endpoint, the access settings for the organization must be set to `selected_members`. + * For information on how to change this setting, see "[Manage access control for organization codespaces](https://docs.github.com/rest/codespaces/organizations#manage-access-control-for-organization-codespaces)." + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn set_codespaces_access_users( + &self, + org: &str, + body: &crate::types::CopilotAddSeatsUsersRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/codespaces/access/selected_users", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Remove users from Codespaces access for an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/codespaces/access/selected_users` endpoint. + * + * Codespaces for the specified users will no longer be billed to the organization. + * + * To use this endpoint, the access settings for the organization must be set to `selected_members`. + * For information on how to change this setting, see "[Manage access control for organization codespaces](https://docs.github.com/rest/codespaces/organizations#manage-access-control-for-organization-codespaces)." + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn delete_codespaces_access_users( + &self, + org: &str, + body: &crate::types::CopilotAddSeatsUsersRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/codespaces/access/selected_users", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List organization secrets. + * + * This function performs a `GET` to the `/orgs/{org}/codespaces/secrets` endpoint. + * + * Lists all Codespaces development environment secrets available at the organization-level without revealing their encrypted + * values. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_org_secrets( + &self, + org: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/codespaces/secrets?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get an organization public key. + * + * This function performs a `GET` to the `/orgs/{org}/codespaces/secrets/public-key` endpoint. + * + * Gets a public key for an organization, which is required in order to encrypt secrets. You need to encrypt the value of a secret before you can create or update secrets. + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn get_org_public_key( + &self, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/codespaces/secrets/public-key", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get an organization secret. + * + * This function performs a `GET` to the `/orgs/{org}/codespaces/secrets/{secret_name}` endpoint. + * + * Gets an organization development environment secret without revealing its encrypted value. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn get_org_secret( + &self, + org: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/codespaces/secrets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create or update an organization secret. + * + * This function performs a `PUT` to the `/orgs/{org}/codespaces/secrets/{secret_name}` endpoint. + * + * Creates or updates an organization development environment secret with an encrypted value. Encrypt your secret using + * [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api)." + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn create_or_update_org_secret( + &self, + org: &str, + secret_name: &str, + body: &crate::types::CodespacesCreateUpdateOrgSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/codespaces/secrets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete an organization secret. + * + * This function performs a `DELETE` to the `/orgs/{org}/codespaces/secrets/{secret_name}` endpoint. + * + * Deletes an organization development environment secret using the secret name. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn delete_org_secret( + &self, + org: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/codespaces/secrets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List selected repositories for an organization secret. + * + * This function performs a `GET` to the `/orgs/{org}/codespaces/secrets/{secret_name}/repositories` endpoint. + * + * Lists all repositories that have been selected when the `visibility` + * for repository access to a secret is set to `selected`. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_selected_repos_for_org_secret( + &self, + org: &str, + secret_name: &str, + page: i64, + per_page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/codespaces/secrets/{}/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set selected repositories for an organization secret. + * + * This function performs a `PUT` to the `/orgs/{org}/codespaces/secrets/{secret_name}/repositories` endpoint. + * + * Replaces all repositories for an organization development environment secret when the `visibility` + * for repository access is set to `selected`. The visibility is set when you [Create + * or update an organization secret](https://docs.github.com/rest/codespaces/organization-secrets#create-or-update-an-organization-secret). + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn set_selected_repos_for_org_secret( + &self, + org: &str, + secret_name: &str, + body: &crate::types::CodespacesSetRepositoriesSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/codespaces/secrets/{}/repositories", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Add selected repository to an organization secret. + * + * This function performs a `PUT` to the `/orgs/{org}/codespaces/secrets/{secret_name}/repositories/{repository_id}` endpoint. + * + * Adds a repository to an organization development environment secret when the `visibility` for repository access is set to `selected`. The visibility is set when you [Create or update an organization secret](https://docs.github.com/rest/codespaces/organization-secrets#create-or-update-an-organization-secret). + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + * * `repository_id: i64` + */ + pub async fn add_selected_repo_to_org_secret( + &self, + org: &str, + secret_name: &str, + repository_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/codespaces/secrets/{}/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove selected repository from an organization secret. + * + * This function performs a `DELETE` to the `/orgs/{org}/codespaces/secrets/{secret_name}/repositories/{repository_id}` endpoint. + * + * Removes a repository from an organization development environment secret when the `visibility` + * for repository access is set to `selected`. The visibility is set when you [Create + * or update an organization secret](https://docs.github.com/rest/codespaces/organization-secrets#create-or-update-an-organization-secret). + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + * * `repository_id: i64` + */ + pub async fn remove_selected_repo_from_org_secret( + &self, + org: &str, + secret_name: &str, + repository_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/codespaces/secrets/{}/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List codespaces for a user in organization. + * + * This function performs a `GET` to the `/orgs/{org}/members/{username}/codespaces` endpoint. + * + * Lists the codespaces that a member of an organization has for repositories in that organization. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn get_codespaces_for_user_in_org( + &self, + per_page: i64, + page: i64, + org: &str, + username: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/members/{}/codespaces?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a codespace from the organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/members/{username}/codespaces/{codespace_name}` endpoint. + * + * Deletes a user's codespace. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + * * `codespace_name: &str` -- The name of the codespace. + */ + pub async fn delete_from_organization( + &self, + org: &str, + username: &str, + codespace_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/members/{}/codespaces/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&codespace_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Stop a codespace for an organization user. + * + * This function performs a `POST` to the `/orgs/{org}/members/{username}/codespaces/{codespace_name}/stop` endpoint. + * + * Stops a user's codespace. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + * * `codespace_name: &str` -- The name of the codespace. + */ + pub async fn stop_in_organization( + &self, + org: &str, + username: &str, + codespace_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/members/{}/codespaces/{}/stop", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&codespace_name.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List codespaces in a repository for the authenticated user. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/codespaces` endpoint. + * + * Lists the codespaces associated to a specified repository and the authenticated user. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn list_in_repository_for_authenticated_user( + &self, + per_page: i64, + page: i64, + owner: &str, + repo: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/codespaces?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a codespace in a repository. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/codespaces` endpoint. + * + * Creates a codespace owned by the authenticated user in the specified repository. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_with_repo_for_authenticated_user( + &self, + owner: &str, + repo: &str, + body: &crate::types::CodespacesCreateWithRepoRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/codespaces", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List devcontainer configurations in a repository for the authenticated user. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/codespaces/devcontainers` endpoint. + * + * Lists the devcontainer.json files associated with a specified repository and the authenticated user. These files + * specify launchpoint configurations for codespaces created within the repository. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn list_devcontainers_in_repository_for_authenticated_user( + &self, + per_page: i64, + page: i64, + owner: &str, + repo: &str, + ) -> ClientResult> + { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/codespaces/devcontainers?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List available machine types for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/codespaces/machines` endpoint. + * + * List the machine types available for a given repository based on its configuration. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `location: &str` -- The location to check for available machines. Assigned by IP if not provided. + * * `client_ip: &str` -- IP for location auto-detection when proxying a request. + * * `ref_: &str` -- The branch or commit to check for prebuild availability and devcontainer restrictions. + */ + pub async fn repo_machines_for_authenticated_user( + &self, + owner: &str, + repo: &str, + location: &str, + client_ip: &str, + ref_: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !client_ip.is_empty() { + query_args.push(("client_ip".to_string(), client_ip.to_string())); + } + if !location.is_empty() { + query_args.push(("location".to_string(), location.to_string())); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/codespaces/machines?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get default attributes for a codespace. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/codespaces/new` endpoint. + * + * Gets the default attributes for codespaces created by the user with the repository. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The branch or commit to check for a default devcontainer path. If not specified, the default branch will be checked. + * * `client_ip: &str` -- An alternative IP for default location auto-detection, such as when proxying a request. + */ + pub async fn pre_flight_with_repo_for_authenticated_user( + &self, + owner: &str, + repo: &str, + ref_: &str, + client_ip: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !client_ip.is_empty() { + query_args.push(("client_ip".to_string(), client_ip.to_string())); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/codespaces/new?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Check if permissions defined by a devcontainer have been accepted by the authenticated user. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/codespaces/permissions_check` endpoint. + * + * Checks whether the permissions defined by a given devcontainer configuration have been accepted by the authenticated user. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The git reference that points to the location of the devcontainer configuration to use for the permission check. The value of `ref` will typically be a branch name (`heads/BRANCH_NAME`). For more information, see "[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)" in the Git documentation. + * * `devcontainer_path: &str` -- Path to the devcontainer.json configuration to use for the permission check. + */ + pub async fn check_permissions_for_devcontainer( + &self, + owner: &str, + repo: &str, + ref_: &str, + devcontainer_path: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !devcontainer_path.is_empty() { + query_args.push(( + "devcontainer_path".to_string(), + devcontainer_path.to_string(), + )); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/codespaces/permissions_check?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List repository secrets. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/codespaces/secrets` endpoint. + * + * Lists all development environment secrets available in a repository without revealing their encrypted + * values. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_repo_secrets( + &self, + owner: &str, + repo: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/codespaces/secrets?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a repository public key. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/codespaces/secrets/public-key` endpoint. + * + * Gets your public key, which you need to encrypt secrets. You need to + * encrypt a secret before you can create or update secrets. + * + * If the repository is private, OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_repo_public_key( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/codespaces/secrets/public-key", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a repository secret. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/codespaces/secrets/{secret_name}` endpoint. + * + * Gets a single repository development environment secret without revealing its encrypted value. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn get_repo_secret( + &self, + owner: &str, + repo: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/codespaces/secrets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create or update a repository secret. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/codespaces/secrets/{secret_name}` endpoint. + * + * Creates or updates a repository development environment secret with an encrypted value. Encrypt your secret using + * [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api)." + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. The associated user must be a repository admin. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn create_or_update_repo_secret( + &self, + owner: &str, + repo: &str, + secret_name: &str, + body: &crate::types::CodespacesCreateUpdateRepoSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/codespaces/secrets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete a repository secret. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/codespaces/secrets/{secret_name}` endpoint. + * + * Deletes a development environment secret in a repository using the secret name. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. The associated user must be a repository admin. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn delete_repo_secret( + &self, + owner: &str, + repo: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/codespaces/secrets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a codespace from a pull request. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/pulls/{pull_number}/codespaces` endpoint. + * + * Creates a codespace owned by the authenticated user for the specified pull request. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. + */ + pub async fn create_with_pr_for_authenticated_user( + &self, + owner: &str, + repo: &str, + pull_number: i64, + body: &crate::types::CodespacesCreateWithPrRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/pulls/{}/codespaces", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&pull_number.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List codespaces for the authenticated user. + * + * This function performs a `GET` to the `/user/codespaces` endpoint. + * + * Lists the authenticated user's codespaces. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `repository_id: i64` -- ID of the Repository to filter on. + */ + pub async fn list_for_authenticated_user( + &self, + per_page: i64, + page: i64, + repository_id: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if repository_id > 0 { + query_args.push(("repository_id".to_string(), repository_id.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self + .client + .url(&format!("/user/codespaces?{}", query_), None); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a codespace for the authenticated user. + * + * This function performs a `POST` to the `/user/codespaces` endpoint. + * + * Creates a new codespace, owned by the authenticated user. + * + * This endpoint requires either a `repository_id` OR a `pull_request` but not both. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + */ + pub async fn create_for_authenticated_user( + &self, + body: &crate::types::CodespacesCreateRequestOneOf, + ) -> ClientResult> { + let url = self.client.url(&"/user/codespaces".to_string(), None); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List secrets for the authenticated user. + * + * This function performs a `GET` to the `/user/codespaces/secrets` endpoint. + * + * Lists all development environment secrets available for a user's codespaces without revealing their + * encrypted values. + * + * The authenticated user must have Codespaces access to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` or `codespace:secrets` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_secrets_for_authenticated_user( + &self, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self + .client + .url(&format!("/user/codespaces/secrets?{}", query_), None); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get public key for the authenticated user. + * + * This function performs a `GET` to the `/user/codespaces/secrets/public-key` endpoint. + * + * Gets your public key, which you need to encrypt secrets. You need to encrypt a secret before you can create or update secrets. + * + * The authenticated user must have Codespaces access to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` or `codespace:secrets` scope to use this endpoint. + * + * FROM: + */ + pub async fn get_public_key_for_authenticated_user( + &self, + ) -> ClientResult> { + let url = self + .client + .url(&"/user/codespaces/secrets/public-key".to_string(), None); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a secret for the authenticated user. + * + * This function performs a `GET` to the `/user/codespaces/secrets/{secret_name}` endpoint. + * + * Gets a development environment secret available to a user's codespaces without revealing its encrypted value. + * + * The authenticated user must have Codespaces access to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` or `codespace:secrets` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn get_secret_for_authenticated_user( + &self, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/secrets/{}", + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create or update a secret for the authenticated user. + * + * This function performs a `PUT` to the `/user/codespaces/secrets/{secret_name}` endpoint. + * + * Creates or updates a development environment secret for a user's codespace with an encrypted value. Encrypt your secret using + * [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api)." + * + * The authenticated user must have Codespaces access to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` or `codespace:secrets` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn create_or_update_secret_for_authenticated_user( + &self, + secret_name: &str, + body: &crate::types::CodespacesCreateUpdateSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/secrets/{}", + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete a secret for the authenticated user. + * + * This function performs a `DELETE` to the `/user/codespaces/secrets/{secret_name}` endpoint. + * + * Deletes a development environment secret from a user's codespaces using the secret name. Deleting the secret will remove access from all codespaces that were allowed to access the secret. + * + * The authenticated user must have Codespaces access to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` or `codespace:secrets` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn delete_secret_for_authenticated_user( + &self, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/secrets/{}", + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List selected repositories for a user secret. + * + * This function performs a `GET` to the `/user/codespaces/secrets/{secret_name}/repositories` endpoint. + * + * List the repositories that have been granted the ability to use a user's development environment secret. + * + * The authenticated user must have Codespaces access to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` or `codespace:secrets` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn list_repositories_for_secret_for_authenticated_user( + &self, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/secrets/{}/repositories", + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set selected repositories for a user secret. + * + * This function performs a `PUT` to the `/user/codespaces/secrets/{secret_name}/repositories` endpoint. + * + * Select the repositories that will use a user's development environment secret. + * + * The authenticated user must have Codespaces access to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` or `codespace:secrets` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn set_repositories_for_secret_for_authenticated_user( + &self, + secret_name: &str, + body: &crate::types::CodespacesSetRepositoriesSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/secrets/{}/repositories", + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Add a selected repository to a user secret. + * + * This function performs a `PUT` to the `/user/codespaces/secrets/{secret_name}/repositories/{repository_id}` endpoint. + * + * Adds a repository to the selected repositories for a user's development environment secret. + * + * The authenticated user must have Codespaces access to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` or `codespace:secrets` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `secret_name: &str` -- The name of the secret. + * * `repository_id: i64` + */ + pub async fn add_repository_for_secret_for_authenticated_user( + &self, + secret_name: &str, + repository_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/secrets/{}/repositories/{}", + crate::progenitor_support::encode_path(&secret_name.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove a selected repository from a user secret. + * + * This function performs a `DELETE` to the `/user/codespaces/secrets/{secret_name}/repositories/{repository_id}` endpoint. + * + * Removes a repository from the selected repositories for a user's development environment secret. + * + * The authenticated user must have Codespaces access to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` or `codespace:secrets` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `secret_name: &str` -- The name of the secret. + * * `repository_id: i64` + */ + pub async fn remove_repository_for_secret_for_authenticated_user( + &self, + secret_name: &str, + repository_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/secrets/{}/repositories/{}", + crate::progenitor_support::encode_path(&secret_name.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a codespace for the authenticated user. + * + * This function performs a `GET` to the `/user/codespaces/{codespace_name}` endpoint. + * + * Gets information about a user's codespace. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `codespace_name: &str` -- The name of the codespace. + */ + pub async fn get_for_authenticated_user( + &self, + codespace_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/{}", + crate::progenitor_support::encode_path(&codespace_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a codespace for the authenticated user. + * + * This function performs a `DELETE` to the `/user/codespaces/{codespace_name}` endpoint. + * + * Deletes a user's codespace. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `codespace_name: &str` -- The name of the codespace. + */ + pub async fn delete_for_authenticated_user( + &self, + codespace_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/{}", + crate::progenitor_support::encode_path(&codespace_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a codespace for the authenticated user. + * + * This function performs a `PATCH` to the `/user/codespaces/{codespace_name}` endpoint. + * + * Updates a codespace owned by the authenticated user. Currently only the codespace's machine type and recent folders can be modified using this endpoint. + * + * If you specify a new machine type it will be applied the next time your codespace is started. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `codespace_name: &str` -- The name of the codespace. + */ + pub async fn update_for_authenticated_user( + &self, + codespace_name: &str, + body: &crate::types::CodespacesUpdateRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/{}", + crate::progenitor_support::encode_path(&codespace_name.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Export a codespace for the authenticated user. + * + * This function performs a `POST` to the `/user/codespaces/{codespace_name}/exports` endpoint. + * + * Triggers an export of the specified codespace and returns a URL and ID where the status of the export can be monitored. + * + * If changes cannot be pushed to the codespace's repository, they will be pushed to a new or previously-existing fork instead. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `codespace_name: &str` -- The name of the codespace. + */ + pub async fn export_for_authenticated_user( + &self, + codespace_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/{}/exports", + crate::progenitor_support::encode_path(&codespace_name.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get details about a codespace export. + * + * This function performs a `GET` to the `/user/codespaces/{codespace_name}/exports/{export_id}` endpoint. + * + * Gets information about an export of a codespace. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `codespace_name: &str` -- The name of the codespace. + * * `export_id: &str` -- The ID of the export operation, or `latest`. Currently only `latest` is currently supported. + */ + pub async fn get_export_details_for_authenticated_user( + &self, + codespace_name: &str, + export_id: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/{}/exports/{}", + crate::progenitor_support::encode_path(&codespace_name.to_string()), + crate::progenitor_support::encode_path(&export_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List machine types for a codespace. + * + * This function performs a `GET` to the `/user/codespaces/{codespace_name}/machines` endpoint. + * + * List the machine types a codespace can transition to use. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `codespace_name: &str` -- The name of the codespace. + */ + pub async fn codespace_machines_for_authenticated_user( + &self, + codespace_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/{}/machines", + crate::progenitor_support::encode_path(&codespace_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a repository from an unpublished codespace. + * + * This function performs a `POST` to the `/user/codespaces/{codespace_name}/publish` endpoint. + * + * Publishes an unpublished codespace, creating a new repository and assigning it to the codespace. + * + * The codespace's token is granted write permissions to the repository, allowing the user to push their changes. + * + * This will fail for a codespace that is already published, meaning it has an associated repository. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `codespace_name: &str` -- The name of the codespace. + */ + pub async fn publish_for_authenticated_user( + &self, + codespace_name: &str, + body: &crate::types::CodespacesPublishRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/{}/publish", + crate::progenitor_support::encode_path(&codespace_name.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Start a codespace for the authenticated user. + * + * This function performs a `POST` to the `/user/codespaces/{codespace_name}/start` endpoint. + * + * Starts a user's codespace. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `codespace_name: &str` -- The name of the codespace. + */ + pub async fn start_for_authenticated_user( + &self, + codespace_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/{}/start", + crate::progenitor_support::encode_path(&codespace_name.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Stop a codespace for the authenticated user. + * + * This function performs a `POST` to the `/user/codespaces/{codespace_name}/stop` endpoint. + * + * Stops a user's codespace. + * + * OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `codespace_name: &str` -- The name of the codespace. + */ + pub async fn stop_for_authenticated_user( + &self, + codespace_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/user/codespaces/{}/stop", + crate::progenitor_support::encode_path(&codespace_name.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } +} diff --git a/github/src/copilot.rs b/github/src/copilot.rs new file mode 100644 index 00000000..71c34d27 --- /dev/null +++ b/github/src/copilot.rs @@ -0,0 +1,599 @@ +use crate::Client; +use crate::ClientResult; + +pub struct Copilot { + pub client: Client, +} + +impl Copilot { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + Copilot { client } + } + + /** + * Get Copilot seat information and settings for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/copilot/billing` endpoint. + * + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. + * + * Gets information about an organization's Copilot subscription, including seat breakdown + * and feature policies. To configure these settings, go to your organization's settings on GitHub.com. + * For more information, see "[Managing policies for Copilot in your organization](https://docs.github.com/copilot/managing-copilot/managing-policies-for-copilot-business-in-your-organization)." + * + * Only organization owners can view details about the organization's Copilot Business or Copilot Enterprise subscription. + * + * OAuth app tokens and personal access tokens (classic) need either the `manage_billing:copilot` or `read:org` scopes to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn get_copilot_organization_details( + &self, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/copilot/billing", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List all Copilot seat assignments for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/copilot/billing/seats` endpoint. + * + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. + * + * Lists all Copilot seats for which an organization with a Copilot Business or Copilot Enterprise subscription is currently being billed. + * Only organization owners can view assigned seats. + * + * Each seat object contains information about the assigned user's most recent Copilot activity. Users must have telemetry enabled in their IDE for Copilot in the IDE activity to be reflected in `last_activity_at`. + * For more information about activity data, see [Metrics data properties for GitHub Copilot](https://docs.github.com/copilot/reference/metrics-data). + * + * OAuth app tokens and personal access tokens (classic) need either the `manage_billing:copilot` or `read:org` scopes to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_copilot_seats( + &self, + org: &str, + page: i64, + per_page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/copilot/billing/seats?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Add teams to the Copilot subscription for an organization. + * + * This function performs a `POST` to the `/orgs/{org}/copilot/billing/selected_teams` endpoint. + * + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. + * + * Purchases a GitHub Copilot seat for all users within each specified team. + * The organization will be billed for each seat based on the organization's Copilot plan. For more information about Copilot pricing, see "[About billing for GitHub Copilot in your organization](https://docs.github.com/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-the-copilot-subscription-for-your-organization/about-billing-for-github-copilot-in-your-organization)." + * + * Only organization owners can purchase Copilot seats for their organization members. The organization must have a Copilot Business or Copilot Enterprise subscription and a configured suggestion matching policy. + * For more information about setting up a Copilot subscription, see "[Subscribing to Copilot for your organization](https://docs.github.com/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-the-copilot-subscription-for-your-organization/subscribing-to-copilot-for-your-organization)." + * For more information about setting a suggestion matching policy, see "[Managing policies for Copilot in your organization](https://docs.github.com/copilot/managing-copilot/managing-github-copilot-in-your-organization/setting-policies-for-copilot-in-your-organization/managing-policies-for-copilot-in-your-organization#policies-for-suggestion-matching)." + * + * The response contains the total number of new seats that were created and existing seats that were refreshed. + * + * OAuth app tokens and personal access tokens (classic) need either the `manage_billing:copilot` or `admin:org` scopes to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn add_copilot_seats_for_teams( + &self, + org: &str, + body: &crate::types::CopilotAddSeatsTeamsRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/copilot/billing/selected_teams", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Remove teams from the Copilot subscription for an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/copilot/billing/selected_teams` endpoint. + * + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. + * + * Sets seats for all members of each team specified to "pending cancellation". + * This will cause the members of the specified team(s) to lose access to GitHub Copilot at the end of the current billing cycle unless they retain access through another team. + * For more information about disabling access to Copilot, see "[Revoking access to Copilot for members of your organization](https://docs.github.com/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-access-to-github-copilot-in-your-organization/revoking-access-to-copilot-for-members-of-your-organization)." + * + * Only organization owners can cancel Copilot seats for their organization members. + * + * The response contains the total number of seats set to "pending cancellation". + * + * OAuth app tokens and personal access tokens (classic) need either the `manage_billing:copilot` or `admin:org` scopes to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn cancel_copilot_seat_assignment_for_teams( + &self, + org: &str, + body: &crate::types::CopilotAddSeatsTeamsRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/copilot/billing/selected_teams", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Add users to the Copilot subscription for an organization. + * + * This function performs a `POST` to the `/orgs/{org}/copilot/billing/selected_users` endpoint. + * + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. + * + * Purchases a GitHub Copilot seat for each user specified. + * The organization will be billed for each seat based on the organization's Copilot plan. For more information about Copilot pricing, see "[About billing for GitHub Copilot in your organization](https://docs.github.com/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-the-copilot-subscription-for-your-organization/about-billing-for-github-copilot-in-your-organization)." + * + * Only organization owners can purchase Copilot seats for their organization members. The organization must have a Copilot Business or Copilot Enterprise subscription and a configured suggestion matching policy. + * For more information about setting up a Copilot subscription, see "[Subscribing to Copilot for your organization](https://docs.github.com/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-the-copilot-subscription-for-your-organization/subscribing-to-copilot-for-your-organization)." + * For more information about setting a suggestion matching policy, see "[Managing policies for Copilot in your organization](https://docs.github.com/copilot/managing-copilot/managing-github-copilot-in-your-organization/setting-policies-for-copilot-in-your-organization/managing-policies-for-copilot-in-your-organization#policies-for-suggestion-matching)." + * + * The response contains the total number of new seats that were created and existing seats that were refreshed. + * + * OAuth app tokens and personal access tokens (classic) need either the `manage_billing:copilot` or `admin:org` scopes to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn add_copilot_seats_for_users( + &self, + org: &str, + body: &crate::types::CopilotAddSeatsUsersRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/copilot/billing/selected_users", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Remove users from the Copilot subscription for an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/copilot/billing/selected_users` endpoint. + * + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. + * + * Sets seats for all users specified to "pending cancellation". + * This will cause the specified users to lose access to GitHub Copilot at the end of the current billing cycle unless they retain access through team membership. + * For more information about disabling access to Copilot, see "[Revoking access to Copilot for members of your organization](https://docs.github.com/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-access-to-github-copilot-in-your-organization/revoking-access-to-copilot-for-members-of-your-organization)." + * + * Only organization owners can cancel Copilot seats for their organization members. + * + * The response contains the total number of seats set to "pending cancellation". + * + * OAuth app tokens and personal access tokens (classic) need either the `manage_billing:copilot` or `admin:org` scopes to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn cancel_copilot_seat_assignment_for_users( + &self, + org: &str, + body: &crate::types::CopilotAddSeatsUsersRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/copilot/billing/selected_users", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get Copilot metrics for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/copilot/metrics` endpoint. + * + * Use this endpoint to see a breakdown of aggregated metrics for various GitHub Copilot features. See the response schema tab for detailed metrics definitions. + * + * > [!NOTE] + * > This endpoint will only return results for a given day if the organization contained **five or more members with active Copilot licenses** on that day, as evaluated at the end of that day. + * + * The response contains metrics for up to 100 days prior. Metrics are processed once per day for the previous day, + * and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics, + * they must have telemetry enabled in their IDE. + * + * To access this endpoint, the Copilot Metrics API access policy must be enabled for the organization. + * Only organization owners and owners and billing managers of the parent enterprise can view Copilot metrics. + * + * OAuth app tokens and personal access tokens (classic) need either the `manage_billing:copilot`, `read:org`, or `read:enterprise` scopes to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `since: &str` -- Show usage metrics since this date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format (`YYYY-MM-DDTHH:MM:SSZ`). Maximum value is 100 days ago. + * * `until: &str` -- Show usage metrics until this date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format (`YYYY-MM-DDTHH:MM:SSZ`) and should not preceed the `since` date if it is passed. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of days of metrics to display per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn copilot_metrics_for_organization( + &self, + org: &str, + since: &str, + until: &str, + page: i64, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !since.is_empty() { + query_args.push(("since".to_string(), since.to_string())); + } + if !until.is_empty() { + query_args.push(("until".to_string(), until.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/copilot/metrics?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get Copilot metrics for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/copilot/metrics` endpoint. + * + * As opposed to `copilot_metrics_for_organization`, this function returns all the pages of the request at once. + * + * Use this endpoint to see a breakdown of aggregated metrics for various GitHub Copilot features. See the response schema tab for detailed metrics definitions. + * + * > [!NOTE] + * > This endpoint will only return results for a given day if the organization contained **five or more members with active Copilot licenses** on that day, as evaluated at the end of that day. + * + * The response contains metrics for up to 100 days prior. Metrics are processed once per day for the previous day, + * and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics, + * they must have telemetry enabled in their IDE. + * + * To access this endpoint, the Copilot Metrics API access policy must be enabled for the organization. + * Only organization owners and owners and billing managers of the parent enterprise can view Copilot metrics. + * + * OAuth app tokens and personal access tokens (classic) need either the `manage_billing:copilot`, `read:org`, or `read:enterprise` scopes to use this endpoint. + * + * FROM: + */ + pub async fn get_all_copilot_metrics_for_organization( + &self, + org: &str, + since: &str, + until: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !since.is_empty() { + query_args.push(("since".to_string(), since.to_string())); + } + if !until.is_empty() { + query_args.push(("until".to_string(), until.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/copilot/metrics?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get Copilot seat assignment details for a user. + * + * This function performs a `GET` to the `/orgs/{org}/members/{username}/copilot` endpoint. + * + * > [!NOTE] + * > This endpoint is in public preview and is subject to change. + * + * Gets the GitHub Copilot seat details for a member of an organization who currently has access to GitHub Copilot. + * + * The seat object contains information about the user's most recent Copilot activity. Users must have telemetry enabled in their IDE for Copilot in the IDE activity to be reflected in `last_activity_at`. + * For more information about activity data, see [Metrics data properties for GitHub Copilot](https://docs.github.com/copilot/reference/metrics-data). + * + * Only organization owners can view Copilot seat assignment details for members of their organization. + * + * OAuth app tokens and personal access tokens (classic) need either the `manage_billing:copilot` or `read:org` scopes to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn get_copilot_seat_details_for_user( + &self, + org: &str, + username: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/members/{}/copilot", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get Copilot metrics for a team. + * + * This function performs a `GET` to the `/orgs/{org}/team/{team_slug}/copilot/metrics` endpoint. + * + * Use this endpoint to see a breakdown of aggregated metrics for various GitHub Copilot features. See the response schema tab for detailed metrics definitions. + * + * > [!NOTE] + * > This endpoint will only return results for a given day if the team had **five or more members with active Copilot licenses** on that day, as evaluated at the end of that day. + * + * The response contains metrics for up to 100 days prior. Metrics are processed once per day for the previous day, + * and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics, + * they must have telemetry enabled in their IDE. + * + * To access this endpoint, the Copilot Metrics API access policy must be enabled for the organization containing the team within GitHub settings. + * Only organization owners for the organization that contains this team and owners and billing managers of the parent enterprise can view Copilot metrics for a team. + * + * OAuth app tokens and personal access tokens (classic) need either the `manage_billing:copilot`, `read:org`, or `read:enterprise` scopes to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `since: &str` -- Show usage metrics since this date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format (`YYYY-MM-DDTHH:MM:SSZ`). Maximum value is 100 days ago. + * * `until: &str` -- Show usage metrics until this date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format (`YYYY-MM-DDTHH:MM:SSZ`) and should not preceed the `since` date if it is passed. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of days of metrics to display per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn copilot_metrics_for_team( + &self, + org: &str, + team_slug: &str, + since: &str, + until: &str, + page: i64, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !since.is_empty() { + query_args.push(("since".to_string(), since.to_string())); + } + if !until.is_empty() { + query_args.push(("until".to_string(), until.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/team/{}/copilot/metrics?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get Copilot metrics for a team. + * + * This function performs a `GET` to the `/orgs/{org}/team/{team_slug}/copilot/metrics` endpoint. + * + * As opposed to `copilot_metrics_for_team`, this function returns all the pages of the request at once. + * + * Use this endpoint to see a breakdown of aggregated metrics for various GitHub Copilot features. See the response schema tab for detailed metrics definitions. + * + * > [!NOTE] + * > This endpoint will only return results for a given day if the team had **five or more members with active Copilot licenses** on that day, as evaluated at the end of that day. + * + * The response contains metrics for up to 100 days prior. Metrics are processed once per day for the previous day, + * and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics, + * they must have telemetry enabled in their IDE. + * + * To access this endpoint, the Copilot Metrics API access policy must be enabled for the organization containing the team within GitHub settings. + * Only organization owners for the organization that contains this team and owners and billing managers of the parent enterprise can view Copilot metrics for a team. + * + * OAuth app tokens and personal access tokens (classic) need either the `manage_billing:copilot`, `read:org`, or `read:enterprise` scopes to use this endpoint. + * + * FROM: + */ + pub async fn get_all_copilot_metrics_for_team( + &self, + org: &str, + team_slug: &str, + since: &str, + until: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !since.is_empty() { + query_args.push(("since".to_string(), since.to_string())); + } + if !until.is_empty() { + query_args.push(("until".to_string(), until.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/team/{}/copilot/metrics?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } +} diff --git a/github/src/credentials.rs b/github/src/credentials.rs new file mode 100644 index 00000000..4f838e81 --- /dev/null +++ b/github/src/credentials.rs @@ -0,0 +1,50 @@ +use crate::Client; +use crate::ClientResult; + +pub struct Credentials { + pub client: Client, +} + +impl Credentials { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + Credentials { client } + } + + /** + * Revoke a list of credentials. + * + * This function performs a `POST` to the `/credentials/revoke` endpoint. + * + * Submit a list of credentials to be revoked. This endpoint is intended to revoke credentials the caller does not own and may have found exposed on GitHub.com or elsewhere. It can also be used for credentials associated with an old user account that you no longer have access to. Credential owners will be notified of the revocation. + * + * This endpoint currently accepts the following credential types: + * - Personal access tokens (classic) + * - Fine-grained personal access tokens + * + * Revoked credentials may impact users on GitHub Free, Pro, & Team and GitHub Enterprise Cloud, and GitHub Enterprise Cloud with Enterprise Managed Users. + * GitHub cannot reactivate any credentials that have been revoked; new credentials will need to be generated. + * + * To prevent abuse, this API is limited to only 60 unauthenticated requests per hour and a max of 1000 tokens per API request. + * + * > [!NOTE] + * > Any authenticated requests will return a 403. + * + * FROM: + */ + pub async fn revoke( + &self, + body: &crate::types::CredentialsRevokeRequest, + ) -> ClientResult> { + let url = self.client.url(&"/credentials/revoke".to_string(), None); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } +} diff --git a/github/src/dependabot.rs b/github/src/dependabot.rs new file mode 100644 index 00000000..7bfd8b92 --- /dev/null +++ b/github/src/dependabot.rs @@ -0,0 +1,1502 @@ +use crate::Client; +use crate::ClientResult; + +pub struct Dependabot { + pub client: Client, +} + +impl Dependabot { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + Dependabot { client } + } + + /** + * List Dependabot alerts for an enterprise. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/dependabot/alerts` endpoint. + * + * Lists Dependabot alerts for repositories that are owned by the specified enterprise. + * + * The authenticated user must be a member of the enterprise to use this endpoint. + * + * Alerts are only returned for organizations in the enterprise for which you are an organization owner or a security manager. For more information about security managers, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)." + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `state: &str` -- A comma-separated list of states. If specified, only alerts with these states will be returned. + * + * Can be: `auto_dismissed`, `dismissed`, `fixed`, `open`. + * * `severity: &str` -- A comma-separated list of severities. If specified, only alerts with these severities will be returned. + * + * Can be: `low`, `medium`, `high`, `critical`. + * * `ecosystem: &str` -- A comma-separated list of ecosystems. If specified, only alerts for these ecosystems will be returned. + * + * Can be: `composer`, `go`, `maven`, `npm`, `nuget`, `pip`, `pub`, `rubygems`, `rust`. + * * `package: &str` -- A comma-separated list of package names. If specified, only alerts for these packages will be returned. + * * `epss_percentage: &str` -- CVE Exploit Prediction Scoring System (EPSS) percentage. Can be specified as: + * - An exact number (`n`) + * - Comparators such as `>n`, `=n`, `<=n` + * - A range like `n..n`, where `n` is a number from 0.0 to 1.0 + * + * Filters the list of alerts based on EPSS percentages. If specified, only alerts with the provided EPSS percentages will be returned. + * * `has: &str` -- Filters the list of alerts based on whether the alert has the given value. If specified, only alerts meeting this criterion will be returned. + * Multiple `has` filters can be passed to filter for alerts that have all of the values. Currently, only `patch` is supported. + * * `scope: crate::types::Scope` -- The scope of the vulnerable dependency. If specified, only alerts with this scope will be returned. + * * `sort: crate::types::Sort` -- The property by which to sort the results. + * `created` means when the alert was created. + * `updated` means when the alert's state last changed. + * `epss_percentage` sorts alerts by the Exploit Prediction Scoring System (EPSS) percentage. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_alerts_for_enterprise( + &self, + enterprise: &str, + state: &str, + severity: &str, + ecosystem: &str, + package: &str, + epss_percentage: &str, + has: &str, + scope: crate::types::Scope, + sort: crate::types::Sort, + direction: crate::types::Order, + before: &str, + after: &str, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !ecosystem.is_empty() { + query_args.push(("ecosystem".to_string(), ecosystem.to_string())); + } + if !epss_percentage.is_empty() { + query_args.push(("epss_percentage".to_string(), epss_percentage.to_string())); + } + if !has.is_empty() { + query_args.push(("has".to_string(), has.to_string())); + } + if !package.is_empty() { + query_args.push(("package".to_string(), package.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !scope.to_string().is_empty() { + query_args.push(("scope".to_string(), scope.to_string())); + } + if !severity.is_empty() { + query_args.push(("severity".to_string(), severity.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/enterprises/{}/dependabot/alerts?{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List Dependabot alerts for an enterprise. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/dependabot/alerts` endpoint. + * + * As opposed to `list_alerts_for_enterprise`, this function returns all the pages of the request at once. + * + * Lists Dependabot alerts for repositories that are owned by the specified enterprise. + * + * The authenticated user must be a member of the enterprise to use this endpoint. + * + * Alerts are only returned for organizations in the enterprise for which you are an organization owner or a security manager. For more information about security managers, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)." + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. + * + * FROM: + */ + pub async fn list_all_alerts_for_enterprise( + &self, + enterprise: &str, + state: &str, + severity: &str, + ecosystem: &str, + package: &str, + epss_percentage: &str, + has: &str, + scope: crate::types::Scope, + sort: crate::types::Sort, + direction: crate::types::Order, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !ecosystem.is_empty() { + query_args.push(("ecosystem".to_string(), ecosystem.to_string())); + } + if !epss_percentage.is_empty() { + query_args.push(("epss_percentage".to_string(), epss_percentage.to_string())); + } + if !has.is_empty() { + query_args.push(("has".to_string(), has.to_string())); + } + if !package.is_empty() { + query_args.push(("package".to_string(), package.to_string())); + } + if !scope.to_string().is_empty() { + query_args.push(("scope".to_string(), scope.to_string())); + } + if !severity.is_empty() { + query_args.push(("severity".to_string(), severity.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/enterprises/{}/dependabot/alerts?{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Lists the repositories Dependabot can access in an organization. + * + * This function performs a `GET` to the `/organizations/{org}/dependabot/repository-access` endpoint. + * + * Lists repositories that organization admins have allowed Dependabot to access when updating dependencies. + * > [!NOTE] + * > This operation supports both server-to-server and user-to-server access. + * Unauthorized users will not see the existence of this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `page: i64` -- The page number of results to fetch. + * * `per_page: i64` -- Number of results per page. + */ + pub async fn repository_access_for_org( + &self, + org: &str, + page: i64, + per_page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/organizations/{}/dependabot/repository-access?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Updates Dependabot's repository access list for an organization. + * + * This function performs a `PATCH` to the `/organizations/{org}/dependabot/repository-access` endpoint. + * + * Updates repositories according to the list of repositories that organization admins have given Dependabot access to when they've updated dependencies. + * + * > [!NOTE] + * > This operation supports both server-to-server and user-to-server access. + * Unauthorized users will not see the existence of this endpoint. + * + * **Example request body:** + * ```json + * { + * "repository_ids_to_add": [123, 456], + * "repository_ids_to_remove": [789] + * } + * ``` + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn update_repository_access_for_org( + &self, + org: &str, + body: &crate::types::DependabotUpdateRepositoryAccessOrgRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/organizations/{}/dependabot/repository-access", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Set the default repository access level for Dependabot. + * + * This function performs a `PUT` to the `/organizations/{org}/dependabot/repository-access/default-level` endpoint. + * + * Sets the default level of repository access Dependabot will have while performing an update. Available values are: + * - 'public' - Dependabot will only have access to public repositories, unless access is explicitly granted to non-public repositories. + * - 'internal' - Dependabot will only have access to public and internal repositories, unless access is explicitly granted to private repositories. + * + * Unauthorized users will not see the existence of this endpoint. + * + * This operation supports both server-to-server and user-to-server access. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn set_repository_access_default_level( + &self, + org: &str, + body: &crate::types::DependabotSetRepositoryAccessDefaultLevelRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/organizations/{}/dependabot/repository-access/default-level", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List Dependabot alerts for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/dependabot/alerts` endpoint. + * + * Lists Dependabot alerts for an organization. + * + * The authenticated user must be an owner or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `state: &str` -- A comma-separated list of states. If specified, only alerts with these states will be returned. + * + * Can be: `auto_dismissed`, `dismissed`, `fixed`, `open`. + * * `severity: &str` -- A comma-separated list of severities. If specified, only alerts with these severities will be returned. + * + * Can be: `low`, `medium`, `high`, `critical`. + * * `ecosystem: &str` -- A comma-separated list of ecosystems. If specified, only alerts for these ecosystems will be returned. + * + * Can be: `composer`, `go`, `maven`, `npm`, `nuget`, `pip`, `pub`, `rubygems`, `rust`. + * * `package: &str` -- A comma-separated list of package names. If specified, only alerts for these packages will be returned. + * * `epss_percentage: &str` -- CVE Exploit Prediction Scoring System (EPSS) percentage. Can be specified as: + * - An exact number (`n`) + * - Comparators such as `>n`, `=n`, `<=n` + * - A range like `n..n`, where `n` is a number from 0.0 to 1.0 + * + * Filters the list of alerts based on EPSS percentages. If specified, only alerts with the provided EPSS percentages will be returned. + * * `artifact_registry_url: &str` -- A comma-separated list of artifact registry URLs. If specified, only alerts for repositories with storage records matching these URLs will be returned. + * * `artifact_registry: &str` -- A comma-separated list of Artifact Registry name strings. If specified, only alerts for repositories with storage records matching these registries will be returned. + * + * Can be: `jfrog-artifactory`. + * * `has: &str` -- Filters the list of alerts based on whether the alert has the given value. If specified, only alerts meeting this criterion will be returned. + * Multiple `has` filters can be passed to filter for alerts that have all of the values. + * * `runtime_risk: &str` -- A comma-separated list of runtime risk strings. If specified, only alerts for repositories with deployment records matching these risks will be returned. + * + * Can be: `critical-resource`, `internet-exposed`, `sensitive-data`, `lateral-movement`. + * * `scope: crate::types::Scope` -- The scope of the vulnerable dependency. If specified, only alerts with this scope will be returned. + * * `sort: crate::types::Sort` -- The property by which to sort the results. + * `created` means when the alert was created. + * `updated` means when the alert's state last changed. + * `epss_percentage` sorts alerts by the Exploit Prediction Scoring System (EPSS) percentage. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_alerts_for_org( + &self, + org: &str, + state: &str, + severity: &str, + ecosystem: &str, + package: &str, + epss_percentage: &str, + artifact_registry_url: &str, + artifact_registry: &str, + has: &str, + runtime_risk: &str, + scope: crate::types::Scope, + sort: crate::types::Sort, + direction: crate::types::Order, + before: &str, + after: &str, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !artifact_registry.is_empty() { + query_args.push(( + "artifact_registry".to_string(), + artifact_registry.to_string(), + )); + } + if !artifact_registry_url.is_empty() { + query_args.push(( + "artifact_registry_url".to_string(), + artifact_registry_url.to_string(), + )); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !ecosystem.is_empty() { + query_args.push(("ecosystem".to_string(), ecosystem.to_string())); + } + if !epss_percentage.is_empty() { + query_args.push(("epss_percentage".to_string(), epss_percentage.to_string())); + } + if !has.is_empty() { + query_args.push(("has".to_string(), has.to_string())); + } + if !package.is_empty() { + query_args.push(("package".to_string(), package.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !runtime_risk.is_empty() { + query_args.push(("runtime_risk".to_string(), runtime_risk.to_string())); + } + if !scope.to_string().is_empty() { + query_args.push(("scope".to_string(), scope.to_string())); + } + if !severity.is_empty() { + query_args.push(("severity".to_string(), severity.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/dependabot/alerts?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List Dependabot alerts for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/dependabot/alerts` endpoint. + * + * As opposed to `list_alerts_for_org`, this function returns all the pages of the request at once. + * + * Lists Dependabot alerts for an organization. + * + * The authenticated user must be an owner or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: + */ + pub async fn list_all_alerts_for_org( + &self, + org: &str, + state: &str, + severity: &str, + ecosystem: &str, + package: &str, + epss_percentage: &str, + artifact_registry_url: &str, + artifact_registry: &str, + has: &str, + runtime_risk: &str, + scope: crate::types::Scope, + sort: crate::types::Sort, + direction: crate::types::Order, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !artifact_registry.is_empty() { + query_args.push(( + "artifact_registry".to_string(), + artifact_registry.to_string(), + )); + } + if !artifact_registry_url.is_empty() { + query_args.push(( + "artifact_registry_url".to_string(), + artifact_registry_url.to_string(), + )); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !ecosystem.is_empty() { + query_args.push(("ecosystem".to_string(), ecosystem.to_string())); + } + if !epss_percentage.is_empty() { + query_args.push(("epss_percentage".to_string(), epss_percentage.to_string())); + } + if !has.is_empty() { + query_args.push(("has".to_string(), has.to_string())); + } + if !package.is_empty() { + query_args.push(("package".to_string(), package.to_string())); + } + if !runtime_risk.is_empty() { + query_args.push(("runtime_risk".to_string(), runtime_risk.to_string())); + } + if !scope.to_string().is_empty() { + query_args.push(("scope".to_string(), scope.to_string())); + } + if !severity.is_empty() { + query_args.push(("severity".to_string(), severity.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/dependabot/alerts?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List organization secrets. + * + * This function performs a `GET` to the `/orgs/{org}/dependabot/secrets` endpoint. + * + * Lists all secrets available in an organization without revealing their + * encrypted values. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_org_secrets( + &self, + org: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/dependabot/secrets?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get an organization public key. + * + * This function performs a `GET` to the `/orgs/{org}/dependabot/secrets/public-key` endpoint. + * + * Gets your public key, which you need to encrypt secrets. You need to + * encrypt a secret before you can create or update secrets. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn get_org_public_key( + &self, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/dependabot/secrets/public-key", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get an organization secret. + * + * This function performs a `GET` to the `/orgs/{org}/dependabot/secrets/{secret_name}` endpoint. + * + * Gets a single organization secret without revealing its encrypted value. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn get_org_secret( + &self, + org: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/dependabot/secrets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create or update an organization secret. + * + * This function performs a `PUT` to the `/orgs/{org}/dependabot/secrets/{secret_name}` endpoint. + * + * Creates or updates an organization secret with an encrypted value. Encrypt your secret using + * [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api)." + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn create_or_update_org_secret( + &self, + org: &str, + secret_name: &str, + body: &crate::types::DependabotCreateUpdateOrgSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/dependabot/secrets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete an organization secret. + * + * This function performs a `DELETE` to the `/orgs/{org}/dependabot/secrets/{secret_name}` endpoint. + * + * Deletes a secret in an organization using the secret name. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn delete_org_secret( + &self, + org: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/dependabot/secrets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List selected repositories for an organization secret. + * + * This function performs a `GET` to the `/orgs/{org}/dependabot/secrets/{secret_name}/repositories` endpoint. + * + * Lists all repositories that have been selected when the `visibility` + * for repository access to a secret is set to `selected`. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_selected_repos_for_org_secret( + &self, + org: &str, + secret_name: &str, + page: i64, + per_page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/dependabot/secrets/{}/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set selected repositories for an organization secret. + * + * This function performs a `PUT` to the `/orgs/{org}/dependabot/secrets/{secret_name}/repositories` endpoint. + * + * Replaces all repositories for an organization secret when the `visibility` + * for repository access is set to `selected`. The visibility is set when you [Create + * or update an organization secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret). + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn set_selected_repos_for_org_secret( + &self, + org: &str, + secret_name: &str, + body: &crate::types::CodespacesSetRepositoriesSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/dependabot/secrets/{}/repositories", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Add selected repository to an organization secret. + * + * This function performs a `PUT` to the `/orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}` endpoint. + * + * Adds a repository to an organization secret when the `visibility` for + * repository access is set to `selected`. The visibility is set when you [Create or + * update an organization secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret). + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + * * `repository_id: i64` + */ + pub async fn add_selected_repo_to_org_secret( + &self, + org: &str, + secret_name: &str, + repository_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/dependabot/secrets/{}/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove selected repository from an organization secret. + * + * This function performs a `DELETE` to the `/orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}` endpoint. + * + * Removes a repository from an organization secret when the `visibility` + * for repository access is set to `selected`. The visibility is set when you [Create + * or update an organization secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret). + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + * * `repository_id: i64` + */ + pub async fn remove_selected_repo_from_org_secret( + &self, + org: &str, + secret_name: &str, + repository_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/dependabot/secrets/{}/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List Dependabot alerts for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/dependabot/alerts` endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `state: &str` -- A comma-separated list of states. If specified, only alerts with these states will be returned. + * + * Can be: `auto_dismissed`, `dismissed`, `fixed`, `open`. + * * `severity: &str` -- A comma-separated list of severities. If specified, only alerts with these severities will be returned. + * + * Can be: `low`, `medium`, `high`, `critical`. + * * `ecosystem: &str` -- A comma-separated list of ecosystems. If specified, only alerts for these ecosystems will be returned. + * + * Can be: `composer`, `go`, `maven`, `npm`, `nuget`, `pip`, `pub`, `rubygems`, `rust`. + * * `package: &str` -- A comma-separated list of package names. If specified, only alerts for these packages will be returned. + * * `manifest: &str` -- A comma-separated list of full manifest paths. If specified, only alerts for these manifests will be returned. + * * `epss_percentage: &str` -- CVE Exploit Prediction Scoring System (EPSS) percentage. Can be specified as: + * - An exact number (`n`) + * - Comparators such as `>n`, `=n`, `<=n` + * - A range like `n..n`, where `n` is a number from 0.0 to 1.0 + * + * Filters the list of alerts based on EPSS percentages. If specified, only alerts with the provided EPSS percentages will be returned. + * * `has: &str` -- Filters the list of alerts based on whether the alert has the given value. If specified, only alerts meeting this criterion will be returned. + * Multiple `has` filters can be passed to filter for alerts that have all of the values. Currently, only `patch` is supported. + * * `scope: crate::types::Scope` -- The scope of the vulnerable dependency. If specified, only alerts with this scope will be returned. + * * `sort: crate::types::Sort` -- The property by which to sort the results. + * `created` means when the alert was created. + * `updated` means when the alert's state last changed. + * `epss_percentage` sorts alerts by the Exploit Prediction Scoring System (EPSS) percentage. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_alerts_for_repo( + &self, + owner: &str, + repo: &str, + state: &str, + severity: &str, + ecosystem: &str, + package: &str, + manifest: &str, + epss_percentage: &str, + has: &str, + scope: crate::types::Scope, + sort: crate::types::Sort, + direction: crate::types::Order, + per_page: i64, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !ecosystem.is_empty() { + query_args.push(("ecosystem".to_string(), ecosystem.to_string())); + } + if !epss_percentage.is_empty() { + query_args.push(("epss_percentage".to_string(), epss_percentage.to_string())); + } + if !has.is_empty() { + query_args.push(("has".to_string(), has.to_string())); + } + if !manifest.is_empty() { + query_args.push(("manifest".to_string(), manifest.to_string())); + } + if !package.is_empty() { + query_args.push(("package".to_string(), package.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !scope.to_string().is_empty() { + query_args.push(("scope".to_string(), scope.to_string())); + } + if !severity.is_empty() { + query_args.push(("severity".to_string(), severity.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/dependabot/alerts?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List Dependabot alerts for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/dependabot/alerts` endpoint. + * + * As opposed to `list_alerts_for_repo`, this function returns all the pages of the request at once. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: + */ + pub async fn list_all_alerts_for_repo( + &self, + owner: &str, + repo: &str, + state: &str, + severity: &str, + ecosystem: &str, + package: &str, + manifest: &str, + epss_percentage: &str, + has: &str, + scope: crate::types::Scope, + sort: crate::types::Sort, + direction: crate::types::Order, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !ecosystem.is_empty() { + query_args.push(("ecosystem".to_string(), ecosystem.to_string())); + } + if !epss_percentage.is_empty() { + query_args.push(("epss_percentage".to_string(), epss_percentage.to_string())); + } + if !has.is_empty() { + query_args.push(("has".to_string(), has.to_string())); + } + if !manifest.is_empty() { + query_args.push(("manifest".to_string(), manifest.to_string())); + } + if !package.is_empty() { + query_args.push(("package".to_string(), package.to_string())); + } + if !scope.to_string().is_empty() { + query_args.push(("scope".to_string(), scope.to_string())); + } + if !severity.is_empty() { + query_args.push(("severity".to_string(), severity.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/dependabot/alerts?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a Dependabot alert. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/dependabot/alerts/{alert_number}` endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `alert_number: i64` -- The number that identifies a Dependabot alert in its repository. + * You can find this at the end of the URL for a Dependabot alert within GitHub, + * or in `number` fields in the response from the + * `GET /repos/{owner}/{repo}/dependabot/alerts` operation. + */ + pub async fn get_alert( + &self, + owner: &str, + repo: &str, + alert_number: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/dependabot/alerts/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&alert_number.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a Dependabot alert. + * + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/dependabot/alerts/{alert_number}` endpoint. + * + * The authenticated user must have access to security alerts for the repository to use this endpoint. For more information, see "[Granting access to security alerts](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-security-and-analysis-settings-for-your-repository#granting-access-to-security-alerts)." + * + * OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `alert_number: i64` -- The number that identifies a Dependabot alert in its repository. + * You can find this at the end of the URL for a Dependabot alert within GitHub, + * or in `number` fields in the response from the + * `GET /repos/{owner}/{repo}/dependabot/alerts` operation. + */ + pub async fn update_alert( + &self, + owner: &str, + repo: &str, + alert_number: i64, + body: &crate::types::DependabotUpdateAlertRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/dependabot/alerts/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&alert_number.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List repository secrets. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/dependabot/secrets` endpoint. + * + * Lists all secrets available in a repository without revealing their encrypted + * values. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_repo_secrets( + &self, + owner: &str, + repo: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/dependabot/secrets?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a repository public key. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/dependabot/secrets/public-key` endpoint. + * + * Gets your public key, which you need to encrypt secrets. You need to + * encrypt a secret before you can create or update secrets. Anyone with read access + * to the repository can use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint if the repository is private. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_repo_public_key( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/dependabot/secrets/public-key", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a repository secret. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/dependabot/secrets/{secret_name}` endpoint. + * + * Gets a single repository secret without revealing its encrypted value. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn get_repo_secret( + &self, + owner: &str, + repo: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/dependabot/secrets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create or update a repository secret. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/dependabot/secrets/{secret_name}` endpoint. + * + * Creates or updates a repository secret with an encrypted value. Encrypt your secret using + * [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api)." + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn create_or_update_repo_secret( + &self, + owner: &str, + repo: &str, + secret_name: &str, + body: &crate::types::CodespacesCreateUpdateRepoSecretRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/dependabot/secrets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete a repository secret. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/dependabot/secrets/{secret_name}` endpoint. + * + * Deletes a secret in a repository using the secret name. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn delete_repo_secret( + &self, + owner: &str, + repo: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/dependabot/secrets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } +} diff --git a/github/src/dependency_graph.rs b/github/src/dependency_graph.rs new file mode 100644 index 00000000..30d05e10 --- /dev/null +++ b/github/src/dependency_graph.rs @@ -0,0 +1,185 @@ +use crate::Client; +use crate::ClientResult; + +pub struct DependencyGraph { + pub client: Client, +} + +impl DependencyGraph { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + DependencyGraph { client } + } + + /** + * Get a diff of the dependencies between commits. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/dependency-graph/compare/{basehead}` endpoint. + * + * Gets the diff of the dependency changes between two commits of a repository, based on the changes to the dependency manifests made in those commits. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `basehead: &str` -- The base and head Git revisions to compare. The Git revisions will be resolved to commit SHAs. Named revisions will be resolved to their corresponding HEAD commits, and an appropriate merge base will be determined. This parameter expects the format `{base}...{head}`. + * * `name: &str` -- The full path, relative to the repository root, of the dependency manifest file. + */ + pub async fn diff_range( + &self, + owner: &str, + repo: &str, + basehead: &str, + name: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !name.is_empty() { + query_args.push(("name".to_string(), name.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/dependency-graph/compare/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&basehead.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a diff of the dependencies between commits. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/dependency-graph/compare/{basehead}` endpoint. + * + * As opposed to `diff_range`, this function returns all the pages of the request at once. + * + * Gets the diff of the dependency changes between two commits of a repository, based on the changes to the dependency manifests made in those commits. + * + * FROM: + */ + pub async fn get_all_diff_range( + &self, + owner: &str, + repo: &str, + basehead: &str, + name: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !name.is_empty() { + query_args.push(("name".to_string(), name.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/dependency-graph/compare/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&basehead.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Export a software bill of materials (SBOM) for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/dependency-graph/sbom` endpoint. + * + * Exports the software bill of materials (SBOM) for a repository in SPDX JSON format. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn export_sbom( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/dependency-graph/sbom", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a snapshot of dependencies for a repository. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/dependency-graph/snapshots` endpoint. + * + * Create a new snapshot of a repository's dependencies. + * + * The authenticated user must have access to the repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_repository_snapshot( + &self, + owner: &str, + repo: &str, + body: &crate::types::Snapshot, + ) -> ClientResult> + { + let url = self.client.url( + &format!( + "/repos/{}/{}/dependency-graph/snapshots", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } +} diff --git a/github/src/emojis.rs b/github/src/emojis.rs index bb4098fb..85d67c54 100644 --- a/github/src/emojis.rs +++ b/github/src/emojis.rs @@ -18,10 +18,10 @@ impl Emojis { * * Lists all the emojis available to use on GitHub. * - * FROM: + * FROM: */ pub async fn get(&self) -> ClientResult> { - let url = self.client.url("/emojis", None); + let url = self.client.url(&"/emojis".to_string(), None); self.client .get( &url, diff --git a/github/src/enterprise_team_memberships.rs b/github/src/enterprise_team_memberships.rs new file mode 100644 index 00000000..5e469b81 --- /dev/null +++ b/github/src/enterprise_team_memberships.rs @@ -0,0 +1,294 @@ +use crate::Client; +use crate::ClientResult; + +pub struct EnterpriseTeamMemberships { + pub client: Client, +} + +impl EnterpriseTeamMemberships { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + EnterpriseTeamMemberships { client } + } + + /** + * List members in an enterprise team. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/teams/{enterprise-team}/memberships` endpoint. + * + * Lists all team members in an enterprise team. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `enterprise_team: &str` -- The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list( + &self, + enterprise: &str, + enterprise_team: &str, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/memberships?{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List members in an enterprise team. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/teams/{enterprise-team}/memberships` endpoint. + * + * As opposed to `list`, this function returns all the pages of the request at once. + * + * Lists all team members in an enterprise team. + * + * FROM: + */ + pub async fn list_all( + &self, + enterprise: &str, + enterprise_team: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/memberships", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Bulk add team members. + * + * This function performs a `POST` to the `/enterprises/{enterprise}/teams/{enterprise-team}/memberships/add` endpoint. + * + * Add multiple team members to an enterprise team. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `enterprise_team: &str` -- The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. + */ + pub async fn bulk_add( + &self, + enterprise: &str, + enterprise_team: &str, + body: &crate::types::EnterpriseTeamMembershipsBulkAddRequest, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/memberships/add", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Bulk remove team members. + * + * This function performs a `POST` to the `/enterprises/{enterprise}/teams/{enterprise-team}/memberships/remove` endpoint. + * + * Remove multiple team members from an enterprise team. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `enterprise_team: &str` -- The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. + */ + pub async fn bulk_remove( + &self, + enterprise: &str, + enterprise_team: &str, + body: &crate::types::EnterpriseTeamMembershipsBulkAddRequest, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/memberships/remove", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get enterprise team membership. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/teams/{enterprise-team}/memberships/{username}` endpoint. + * + * Returns whether the user is a member of the enterprise team. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `enterprise_team: &str` -- The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn get( + &self, + enterprise: &str, + enterprise_team: &str, + username: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/memberships/{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Add team member. + * + * This function performs a `PUT` to the `/enterprises/{enterprise}/teams/{enterprise-team}/memberships/{username}` endpoint. + * + * Add a team member to an enterprise team. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `enterprise_team: &str` -- The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn add( + &self, + enterprise: &str, + enterprise_team: &str, + username: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/memberships/{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove team membership. + * + * This function performs a `DELETE` to the `/enterprises/{enterprise}/teams/{enterprise-team}/memberships/{username}` endpoint. + * + * Remove membership of a specific user from a particular team in an enterprise. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `enterprise_team: &str` -- The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn remove( + &self, + enterprise: &str, + enterprise_team: &str, + username: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/memberships/{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } +} diff --git a/github/src/enterprise_team_organizations.rs b/github/src/enterprise_team_organizations.rs new file mode 100644 index 00000000..10cf6a47 --- /dev/null +++ b/github/src/enterprise_team_organizations.rs @@ -0,0 +1,294 @@ +use crate::Client; +use crate::ClientResult; + +pub struct EnterpriseTeamOrganizations { + pub client: Client, +} + +impl EnterpriseTeamOrganizations { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + EnterpriseTeamOrganizations { client } + } + + /** + * Get organization assignments. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/teams/{enterprise-team}/organizations` endpoint. + * + * Get all organizations assigned to an enterprise team + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `enterprise_team: &str` -- The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn get_assignments( + &self, + enterprise: &str, + enterprise_team: &str, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/organizations?{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get organization assignments. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/teams/{enterprise-team}/organizations` endpoint. + * + * As opposed to `get_assignments`, this function returns all the pages of the request at once. + * + * Get all organizations assigned to an enterprise team + * + * FROM: + */ + pub async fn get_all_assignments( + &self, + enterprise: &str, + enterprise_team: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/organizations", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Add organization assignments. + * + * This function performs a `POST` to the `/enterprises/{enterprise}/teams/{enterprise-team}/organizations/add` endpoint. + * + * Assign an enterprise team to multiple organizations. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `enterprise_team: &str` -- The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. + */ + pub async fn bulk_add( + &self, + enterprise: &str, + enterprise_team: &str, + body: &crate::types::EnterpriseTeamOrganizationsBulkAddRequest, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/organizations/add", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Remove organization assignments. + * + * This function performs a `POST` to the `/enterprises/{enterprise}/teams/{enterprise-team}/organizations/remove` endpoint. + * + * Unassign an enterprise team from multiple organizations. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `enterprise_team: &str` -- The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. + */ + pub async fn bulk_remove( + &self, + enterprise: &str, + enterprise_team: &str, + body: &crate::types::EnterpriseTeamOrganizationsBulkAddRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/organizations/remove", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get organization assignment. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/teams/{enterprise-team}/organizations/{org}` endpoint. + * + * Check if an enterprise team is assigned to an organization + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `enterprise_team: &str` -- The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn get_assignment( + &self, + enterprise: &str, + enterprise_team: &str, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/organizations/{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Add an organization assignment. + * + * This function performs a `PUT` to the `/enterprises/{enterprise}/teams/{enterprise-team}/organizations/{org}` endpoint. + * + * Assign an enterprise team to an organization. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `enterprise_team: &str` -- The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn add( + &self, + enterprise: &str, + enterprise_team: &str, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/organizations/{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete an organization assignment. + * + * This function performs a `DELETE` to the `/enterprises/{enterprise}/teams/{enterprise-team}/organizations/{org}` endpoint. + * + * Unassign an enterprise team from an organization. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `enterprise_team: &str` -- The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn delete( + &self, + enterprise: &str, + enterprise_team: &str, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}/organizations/{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&enterprise_team.to_string()), + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } +} diff --git a/github/src/enterprise_teams.rs b/github/src/enterprise_teams.rs new file mode 100644 index 00000000..97787b33 --- /dev/null +++ b/github/src/enterprise_teams.rs @@ -0,0 +1,242 @@ +use crate::Client; +use crate::ClientResult; + +pub struct EnterpriseTeams { + pub client: Client, +} + +impl EnterpriseTeams { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + EnterpriseTeams { client } + } + + /** + * List enterprise teams. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/teams` endpoint. + * + * List all teams in the enterprise for the authenticated user + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list( + &self, + enterprise: &str, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/enterprises/{}/teams?{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List enterprise teams. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/teams` endpoint. + * + * As opposed to `list`, this function returns all the pages of the request at once. + * + * List all teams in the enterprise for the authenticated user + * + * FROM: + */ + pub async fn list_all( + &self, + enterprise: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams", + crate::progenitor_support::encode_path(&enterprise.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create an enterprise team. + * + * This function performs a `POST` to the `/enterprises/{enterprise}/teams` endpoint. + * + * To create an enterprise team, the authenticated user must be an owner of the enterprise. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + */ + pub async fn create( + &self, + enterprise: &str, + body: &crate::types::EnterpriseTeamsCreateRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams", + crate::progenitor_support::encode_path(&enterprise.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get an enterprise team. + * + * This function performs a `GET` to the `/enterprises/{enterprise}/teams/{team_slug}` endpoint. + * + * Gets a team using the team's slug. To create the slug, GitHub replaces special characters in the name string, changes all words to lowercase, and replaces spaces with a `-` separator and adds the "ent:" prefix. For example, "My TEam Näme" would become `ent:my-team-name`. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `team_slug: &str` -- The slug of the team name. + */ + pub async fn get( + &self, + enterprise: &str, + team_slug: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete an enterprise team. + * + * This function performs a `DELETE` to the `/enterprises/{enterprise}/teams/{team_slug}` endpoint. + * + * To delete an enterprise team, the authenticated user must be an enterprise owner. + * + * If you are an enterprise owner, deleting an enterprise team will delete all of its IdP mappings as well. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `team_slug: &str` -- The slug of the team name. + */ + pub async fn delete( + &self, + enterprise: &str, + team_slug: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update an enterprise team. + * + * This function performs a `PATCH` to the `/enterprises/{enterprise}/teams/{team_slug}` endpoint. + * + * To edit a team, the authenticated user must be an enterprise owner. + * + * FROM: + * + * **Parameters:** + * + * * `enterprise: &str` -- The slug version of the enterprise name. + * * `team_slug: &str` -- The slug of the team name. + */ + pub async fn update( + &self, + enterprise: &str, + team_slug: &str, + body: &crate::types::EnterpriseTeamsUpdateRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/enterprises/{}/teams/{}", + crate::progenitor_support::encode_path(&enterprise.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } +} diff --git a/github/src/gists.rs b/github/src/gists.rs index 13e885aa..f320f15d 100644 --- a/github/src/gists.rs +++ b/github/src/gists.rs @@ -18,13 +18,13 @@ impl Gists { * * Lists the authenticated user's gists or if called anonymously, this endpoint returns all public gists: * - * FROM: + * FROM: * * **Parameters:** * - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list( &self, @@ -63,7 +63,7 @@ impl Gists { * * Lists the authenticated user's gists or if called anonymously, this endpoint returns all public gists: * - * FROM: + * FROM: */ pub async fn list_all( &self, @@ -92,15 +92,16 @@ impl Gists { * * Allows you to add a new gist with one or more files. * - * **Note:** Don't name your files "gistfile" with a numerical suffix. This is the format of the automatic naming scheme that Gist uses internally. + * > [!NOTE] + * > Don't name your files "gistfile" with a numerical suffix. This is the format of the automatic naming scheme that Gist uses internally. * - * FROM: + * FROM: */ pub async fn create( &self, body: &crate::types::GistsCreateRequest, ) -> ClientResult> { - let url = self.client.url("/gists", None); + let url = self.client.url(&"/gists".to_string(), None); self.client .post( &url, @@ -118,15 +119,15 @@ impl Gists { * * List public gists sorted by most recently updated to least recently updated. * - * Note: With [pagination](https://docs.github.com/rest/overview/resources-in-the-rest-api#pagination), you can fetch up to 3000 gists. For example, you can fetch 100 pages with 30 gists per page or 30 pages with 100 gists per page. + * Note: With [pagination](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api), you can fetch up to 3000 gists. For example, you can fetch 100 pages with 30 gists per page or 30 pages with 100 gists per page. * - * FROM: + * FROM: * * **Parameters:** * - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_public( &self, @@ -165,9 +166,9 @@ impl Gists { * * List public gists sorted by most recently updated to least recently updated. * - * Note: With [pagination](https://docs.github.com/rest/overview/resources-in-the-rest-api#pagination), you can fetch up to 3000 gists. For example, you can fetch 100 pages with 30 gists per page or 30 pages with 100 gists per page. + * Note: With [pagination](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api), you can fetch up to 3000 gists. For example, you can fetch 100 pages with 30 gists per page or 30 pages with 100 gists per page. * - * FROM: + * FROM: */ pub async fn list_all_public( &self, @@ -196,13 +197,13 @@ impl Gists { * * List the authenticated user's starred gists: * - * FROM: + * FROM: * * **Parameters:** * - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_starred( &self, @@ -241,7 +242,7 @@ impl Gists { * * List the authenticated user's starred gists: * - * FROM: + * FROM: */ pub async fn list_all_starred( &self, @@ -268,20 +269,28 @@ impl Gists { * * This function performs a `GET` to the `/gists/{gist_id}` endpoint. * + * Gets a specified gist. * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.base64+json`**: Returns the base64-encoded contents. This can be useful if your gist contains any invalid UTF-8 sequences. + * + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. + * * `gist_id: &str` -- The unique identifier of the gist. */ pub async fn get( &self, gist_id: &str, ) -> ClientResult> { let url = self.client.url( - &format!("/gists/{}", crate::progenitor_support::encode_path(gist_id),), + &format!( + "/gists/{}", + crate::progenitor_support::encode_path(&gist_id.to_string()), + ), None, ); self.client @@ -301,15 +310,18 @@ impl Gists { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. + * * `gist_id: &str` -- The unique identifier of the gist. */ pub async fn delete(&self, gist_id: &str) -> ClientResult> { let url = self.client.url( - &format!("/gists/{}", crate::progenitor_support::encode_path(gist_id),), + &format!( + "/gists/{}", + crate::progenitor_support::encode_path(&gist_id.to_string()), + ), None, ); self.client @@ -327,13 +339,22 @@ impl Gists { * * This function performs a `PATCH` to the `/gists/{gist_id}` endpoint. * - * Allows you to update or delete a gist file and rename gist files. Files from the previous version of the gist that aren't explicitly changed during an edit are unchanged. + * Allows you to update a gist's description and to update, delete, or rename gist files. Files + * from the previous version of the gist that aren't explicitly changed during an edit + * are unchanged. * - * FROM: + * At least one of `description` or `files` is required. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.base64+json`**: Returns the base64-encoded contents. This can be useful if your gist contains any invalid UTF-8 sequences. + * + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. + * * `gist_id: &str` -- The unique identifier of the gist. */ pub async fn update( &self, @@ -341,7 +362,10 @@ impl Gists { body: &crate::types::GistsUpdateRequest, ) -> ClientResult> { let url = self.client.url( - &format!("/gists/{}", crate::progenitor_support::encode_path(gist_id),), + &format!( + "/gists/{}", + crate::progenitor_support::encode_path(&gist_id.to_string()), + ), None, ); self.client @@ -359,15 +383,20 @@ impl Gists { * * This function performs a `GET` to the `/gists/{gist_id}/comments` endpoint. * + * Lists the comments on a gist. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.base64+json`**: Returns the base64-encoded contents. This can be useful if your gist contains any invalid UTF-8 sequences. * - * FROM: + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `gist_id: &str` -- The unique identifier of the gist. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_comments( &self, @@ -386,7 +415,7 @@ impl Gists { let url = self.client.url( &format!( "/gists/{}/comments?{}", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), query_ ), None, @@ -408,9 +437,14 @@ impl Gists { * * As opposed to `list_comments`, this function returns all the pages of the request at once. * + * Lists the comments on a gist. * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.base64+json`**: Returns the base64-encoded contents. This can be useful if your gist contains any invalid UTF-8 sequences. + * + * FROM: */ pub async fn list_all_comments( &self, @@ -419,7 +453,7 @@ impl Gists { let url = self.client.url( &format!( "/gists/{}/comments", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), ), None, ); @@ -438,13 +472,18 @@ impl Gists { * * This function performs a `POST` to the `/gists/{gist_id}/comments` endpoint. * + * Creates a comment on a gist. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.base64+json`**: Returns the base64-encoded contents. This can be useful if your gist contains any invalid UTF-8 sequences. * - * FROM: + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. + * * `gist_id: &str` -- The unique identifier of the gist. */ pub async fn create_comment( &self, @@ -454,7 +493,7 @@ impl Gists { let url = self.client.url( &format!( "/gists/{}/comments", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), ), None, ); @@ -473,14 +512,19 @@ impl Gists { * * This function performs a `GET` to the `/gists/{gist_id}/comments/{comment_id}` endpoint. * + * Gets a comment on a gist. * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.base64+json`**: Returns the base64-encoded contents. This can be useful if your gist contains any invalid UTF-8 sequences. + * + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. - * * `comment_id: i64` -- comment_id parameter. + * * `gist_id: &str` -- The unique identifier of the gist. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn get_comment( &self, @@ -490,7 +534,7 @@ impl Gists { let url = self.client.url( &format!( "/gists/{}/comments/{}", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, @@ -512,12 +556,12 @@ impl Gists { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. - * * `comment_id: i64` -- comment_id parameter. + * * `gist_id: &str` -- The unique identifier of the gist. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn delete_comment( &self, @@ -527,7 +571,7 @@ impl Gists { let url = self.client.url( &format!( "/gists/{}/comments/{}", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, @@ -547,14 +591,19 @@ impl Gists { * * This function performs a `PATCH` to the `/gists/{gist_id}/comments/{comment_id}` endpoint. * + * Updates a comment on a gist. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.base64+json`**: Returns the base64-encoded contents. This can be useful if your gist contains any invalid UTF-8 sequences. * - * FROM: + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. - * * `comment_id: i64` -- comment_id parameter. + * * `gist_id: &str` -- The unique identifier of the gist. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn update_comment( &self, @@ -565,7 +614,7 @@ impl Gists { let url = self.client.url( &format!( "/gists/{}/comments/{}", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, @@ -587,13 +636,13 @@ impl Gists { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `gist_id: &str` -- The unique identifier of the gist. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_commits( &self, @@ -612,7 +661,7 @@ impl Gists { let url = self.client.url( &format!( "/gists/{}/commits?{}", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), query_ ), None, @@ -636,7 +685,7 @@ impl Gists { * * * - * FROM: + * FROM: */ pub async fn list_all_commits( &self, @@ -645,7 +694,7 @@ impl Gists { let url = self.client.url( &format!( "/gists/{}/commits", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), ), None, ); @@ -666,13 +715,13 @@ impl Gists { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `gist_id: &str` -- The unique identifier of the gist. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_forks( &self, @@ -691,7 +740,7 @@ impl Gists { let url = self.client.url( &format!( "/gists/{}/forks?{}", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), query_ ), None, @@ -715,7 +764,7 @@ impl Gists { * * * - * FROM: + * FROM: */ pub async fn list_all_forks( &self, @@ -724,7 +773,7 @@ impl Gists { let url = self.client.url( &format!( "/gists/{}/forks", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), ), None, ); @@ -743,13 +792,13 @@ impl Gists { * * This function performs a `POST` to the `/gists/{gist_id}/forks` endpoint. * - * **Note**: This was previously `/gists/:gist_id/fork`. * - * FROM: + * + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. + * * `gist_id: &str` -- The unique identifier of the gist. */ pub async fn fork( &self, @@ -758,7 +807,7 @@ impl Gists { let url = self.client.url( &format!( "/gists/{}/forks", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), ), None, ); @@ -779,17 +828,17 @@ impl Gists { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. + * * `gist_id: &str` -- The unique identifier of the gist. */ pub async fn check_is_starred(&self, gist_id: &str) -> ClientResult> { let url = self.client.url( &format!( "/gists/{}/star", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), ), None, ); @@ -808,19 +857,19 @@ impl Gists { * * This function performs a `PUT` to the `/gists/{gist_id}/star` endpoint. * - * Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://docs.github.com/rest/overview/resources-in-the-rest-api#http-verbs)." + * Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)." * - * FROM: + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. + * * `gist_id: &str` -- The unique identifier of the gist. */ pub async fn star(&self, gist_id: &str) -> ClientResult> { let url = self.client.url( &format!( "/gists/{}/star", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), ), None, ); @@ -841,17 +890,17 @@ impl Gists { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. + * * `gist_id: &str` -- The unique identifier of the gist. */ pub async fn unstar(&self, gist_id: &str) -> ClientResult> { let url = self.client.url( &format!( "/gists/{}/star", - crate::progenitor_support::encode_path(gist_id), + crate::progenitor_support::encode_path(&gist_id.to_string()), ), None, ); @@ -870,13 +919,18 @@ impl Gists { * * This function performs a `GET` to the `/gists/{gist_id}/{sha}` endpoint. * + * Gets a specified gist revision. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.base64+json`**: Returns the base64-encoded contents. This can be useful if your gist contains any invalid UTF-8 sequences. * - * FROM: + * FROM: * * **Parameters:** * - * * `gist_id: &str` -- gist_id parameter. + * * `gist_id: &str` -- The unique identifier of the gist. * * `sha: &str` */ pub async fn get_revision( @@ -887,8 +941,8 @@ impl Gists { let url = self.client.url( &format!( "/gists/{}/{}", - crate::progenitor_support::encode_path(gist_id), - crate::progenitor_support::encode_path(sha), + crate::progenitor_support::encode_path(&gist_id.to_string()), + crate::progenitor_support::encode_path(&sha.to_string()), ), None, ); @@ -909,14 +963,14 @@ impl Gists { * * Lists public gists for the specified user: * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `username: &str` -- The handle for the GitHub user account. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_user( &self, @@ -939,7 +993,7 @@ impl Gists { let url = self.client.url( &format!( "/users/{}/gists?{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), query_ ), None, @@ -963,7 +1017,7 @@ impl Gists { * * Lists public gists for the specified user: * - * FROM: + * FROM: */ pub async fn list_all_for_user( &self, @@ -978,7 +1032,7 @@ impl Gists { let url = self.client.url( &format!( "/users/{}/gists?{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), query_ ), None, diff --git a/github/src/git.rs b/github/src/git.rs index c5651fa6..7cb95fb3 100644 --- a/github/src/git.rs +++ b/github/src/git.rs @@ -18,12 +18,12 @@ impl Git { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn create_blob( &self, @@ -34,8 +34,8 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/blobs", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -56,14 +56,19 @@ impl Git { * * The `content` in the response will always be Base64 encoded. * - * _Note_: This API supports blobs up to 100 megabytes in size. + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw blob data. + * - **`application/vnd.github+json`**: Returns a JSON representation of the blob with `content` as a base64 encoded string. This is the default if no media type is specified. + * + * **Note** This endpoint supports blobs up to 100 megabytes in size. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `file_sha: &str` */ pub async fn get_blob( @@ -75,9 +80,9 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/blobs/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(file_sha), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&file_sha.to_string()), ), None, ); @@ -96,7 +101,7 @@ impl Git { * * This function performs a `POST` to the `/repos/{owner}/{repo}/git/commits` endpoint. * - * Creates a new Git [commit object](https://git-scm.com/book/en/v1/Git-Internals-Git-Objects#Commit-Objects). + * Creates a new Git [commit object](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects). * * **Signature verification object** * @@ -105,9 +110,10 @@ impl Git { * | Name | Type | Description | * | ---- | ---- | ----------- | * | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. | - * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. | + * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in the table below. | * | `signature` | `string` | The signature that was extracted from the commit. | * | `payload` | `string` | The value that was signed. | + * | `verified_at` | `string` | The date the signature was verified by GitHub. | * * These are the possible values for `reason` in the `verification` object: * @@ -120,19 +126,19 @@ impl Git { * | `unsigned` | The object does not include a signature. | * | `unknown_signature_type` | A non-PGP signature was found in the commit. | * | `no_user` | No user was associated with the `committer` email address in the commit. | - * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on her/his account. | + * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. | * | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. | * | `unknown_key` | The key that made the signature has not been registered with any user's account. | * | `malformed_signature` | There was an error parsing the signature. | * | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. | * | `valid` | None of the above errors applied, so the signature is considered to be verified. | * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn create_commit( &self, @@ -143,8 +149,8 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/commits", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -159,11 +165,13 @@ impl Git { .await } /** - * Get a commit. + * Get a commit object. * * This function performs a `GET` to the `/repos/{owner}/{repo}/git/commits/{commit_sha}` endpoint. * - * Gets a Git [commit object](https://git-scm.com/book/en/v1/Git-Internals-Git-Objects#Commit-Objects). + * Gets a Git [commit object](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects). + * + * To get the contents of a commit, see "[Get a commit](/rest/commits/commits#get-a-commit)." * * **Signature verification object** * @@ -172,9 +180,10 @@ impl Git { * | Name | Type | Description | * | ---- | ---- | ----------- | * | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. | - * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. | + * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in the table below. | * | `signature` | `string` | The signature that was extracted from the commit. | * | `payload` | `string` | The value that was signed. | + * | `verified_at` | `string` | The date the signature was verified by GitHub. | * * These are the possible values for `reason` in the `verification` object: * @@ -187,20 +196,20 @@ impl Git { * | `unsigned` | The object does not include a signature. | * | `unknown_signature_type` | A non-PGP signature was found in the commit. | * | `no_user` | No user was associated with the `committer` email address in the commit. | - * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on her/his account. | + * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. | * | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. | * | `unknown_key` | The key that made the signature has not been registered with any user's account. | * | `malformed_signature` | There was an error parsing the signature. | * | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. | * | `valid` | None of the above errors applied, so the signature is considered to be verified. | * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `commit_sha: &str` -- commit_sha parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `commit_sha: &str` -- The SHA of the commit. */ pub async fn get_commit( &self, @@ -211,9 +220,9 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/commits/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(commit_sha), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&commit_sha.to_string()), ), None, ); @@ -236,43 +245,31 @@ impl Git { * * When you use this endpoint without providing a `:ref`, it will return an array of all the references from your Git database, including notes and stashes if they exist on the server. Anything in the namespace is returned, not just `heads` and `tags`. * - * **Note:** You need to explicitly [request a pull request](https://docs.github.com/rest/reference/pulls#get-a-pull-request) to trigger a test merge commit, which checks the mergeability of pull requests. For more information, see "[Checking mergeability of pull requests](https://docs.github.com/rest/guides/getting-started-with-the-git-database-api#checking-mergeability-of-pull-requests)". + * > [!NOTE] + * > You need to explicitly [request a pull request](https://docs.github.com/rest/pulls/pulls#get-a-pull-request) to trigger a test merge commit, which checks the mergeability of pull requests. For more information, see "[Checking mergeability of pull requests](https://docs.github.com/rest/guides/getting-started-with-the-git-database-api#checking-mergeability-of-pull-requests)". * * If you request matching references for a branch named `feature` but the branch `feature` doesn't exist, the response can still include other matching head refs that start with the word `feature`, such as `featureA` and `featureB`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `ref_: &str` -- ref parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The Git reference. For more information, see "[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)" in the Git documentation. */ pub async fn list_matching_refs( &self, owner: &str, repo: &str, ref_: &str, - per_page: i64, - page: i64, ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/git/matching-refs/{}?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), - query_ + "/repos/{}/{}/git/matching-refs/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), ), None, ); @@ -297,11 +294,12 @@ impl Git { * * When you use this endpoint without providing a `:ref`, it will return an array of all the references from your Git database, including notes and stashes if they exist on the server. Anything in the namespace is returned, not just `heads` and `tags`. * - * **Note:** You need to explicitly [request a pull request](https://docs.github.com/rest/reference/pulls#get-a-pull-request) to trigger a test merge commit, which checks the mergeability of pull requests. For more information, see "[Checking mergeability of pull requests](https://docs.github.com/rest/guides/getting-started-with-the-git-database-api#checking-mergeability-of-pull-requests)". + * > [!NOTE] + * > You need to explicitly [request a pull request](https://docs.github.com/rest/pulls/pulls#get-a-pull-request) to trigger a test merge commit, which checks the mergeability of pull requests. For more information, see "[Checking mergeability of pull requests](https://docs.github.com/rest/guides/getting-started-with-the-git-database-api#checking-mergeability-of-pull-requests)". * * If you request matching references for a branch named `feature` but the branch `feature` doesn't exist, the response can still include other matching head refs that start with the word `feature`, such as `featureA` and `featureB`. * - * FROM: + * FROM: */ pub async fn list_all_matching_refs( &self, @@ -312,9 +310,9 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/matching-refs/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), ), None, ); @@ -335,15 +333,16 @@ impl Git { * * Returns a single reference from your Git database. The `:ref` in the URL must be formatted as `heads/` for branches and `tags/` for tags. If the `:ref` doesn't match an existing ref, a `404` is returned. * - * **Note:** You need to explicitly [request a pull request](https://docs.github.com/rest/reference/pulls#get-a-pull-request) to trigger a test merge commit, which checks the mergeability of pull requests. For more information, see "[Checking mergeability of pull requests](https://docs.github.com/rest/guides/getting-started-with-the-git-database-api#checking-mergeability-of-pull-requests)". + * > [!NOTE] + * > You need to explicitly [request a pull request](https://docs.github.com/rest/pulls/pulls#get-a-pull-request) to trigger a test merge commit, which checks the mergeability of pull requests. For more information, see "[Checking mergeability of pull requests](https://docs.github.com/rest/guides/getting-started-with-the-git-database-api#checking-mergeability-of-pull-requests)". * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `ref_: &str` -- ref parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The Git reference. For more information, see "[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)" in the Git documentation. */ pub async fn get_ref( &self, @@ -354,9 +353,9 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/ref/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), ), None, ); @@ -377,12 +376,12 @@ impl Git { * * Creates a reference for your repository. You are unable to create new references for empty repositories, even if the commit SHA-1 hash used exists. Empty repositories are repositories without branches. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn create_ref( &self, @@ -393,8 +392,8 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/refs", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -413,15 +412,15 @@ impl Git { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/git/refs/{ref}` endpoint. * + * Deletes the provided reference. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `ref_: &str` -- ref parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The Git reference. For more information, see "[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)" in the Git documentation. */ pub async fn delete_ref( &self, @@ -432,9 +431,9 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/refs/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), ), None, ); @@ -453,15 +452,15 @@ impl Git { * * This function performs a `PATCH` to the `/repos/{owner}/{repo}/git/refs/{ref}` endpoint. * + * Updates the provided reference to point to a new SHA. For more information, see "[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)" in the Git documentation. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `ref_: &str` -- ref parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The Git reference. For more information, see "[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)" in the Git documentation. */ pub async fn update_ref( &self, @@ -473,9 +472,9 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/refs/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), ), None, ); @@ -494,7 +493,7 @@ impl Git { * * This function performs a `POST` to the `/repos/{owner}/{repo}/git/tags` endpoint. * - * Note that creating a tag object does not create the reference that makes a tag in Git. If you want to create an annotated tag in Git, you have to do this call to create the tag object, and then [create](https://docs.github.com/rest/reference/git#create-a-reference) the `refs/tags/[tag]` reference. If you want to create a lightweight tag, you only have to [create](https://docs.github.com/rest/reference/git#create-a-reference) the tag reference - this call would be unnecessary. + * Note that creating a tag object does not create the reference that makes a tag in Git. If you want to create an annotated tag in Git, you have to do this call to create the tag object, and then [create](https://docs.github.com/rest/git/refs#create-a-reference) the `refs/tags/[tag]` reference. If you want to create a lightweight tag, you only have to [create](https://docs.github.com/rest/git/refs#create-a-reference) the tag reference - this call would be unnecessary. * * **Signature verification object** * @@ -506,6 +505,7 @@ impl Git { * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. | * | `signature` | `string` | The signature that was extracted from the commit. | * | `payload` | `string` | The value that was signed. | + * | `verified_at` | `string` | The date the signature was verified by GitHub. | * * These are the possible values for `reason` in the `verification` object: * @@ -518,19 +518,19 @@ impl Git { * | `unsigned` | The object does not include a signature. | * | `unknown_signature_type` | A non-PGP signature was found in the commit. | * | `no_user` | No user was associated with the `committer` email address in the commit. | - * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on her/his account. | + * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. | * | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. | * | `unknown_key` | The key that made the signature has not been registered with any user's account. | * | `malformed_signature` | There was an error parsing the signature. | * | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. | * | `valid` | None of the above errors applied, so the signature is considered to be verified. | * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn create_tag( &self, @@ -541,8 +541,8 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/tags", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -571,6 +571,7 @@ impl Git { * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. | * | `signature` | `string` | The signature that was extracted from the commit. | * | `payload` | `string` | The value that was signed. | + * | `verified_at` | `string` | The date the signature was verified by GitHub. | * * These are the possible values for `reason` in the `verification` object: * @@ -583,19 +584,19 @@ impl Git { * | `unsigned` | The object does not include a signature. | * | `unknown_signature_type` | A non-PGP signature was found in the commit. | * | `no_user` | No user was associated with the `committer` email address in the commit. | - * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on her/his account. | + * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. | * | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. | * | `unknown_key` | The key that made the signature has not been registered with any user's account. | * | `malformed_signature` | There was an error parsing the signature. | * | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. | * | `valid` | None of the above errors applied, so the signature is considered to be verified. | * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `tag_sha: &str` */ pub async fn get_tag( @@ -607,9 +608,9 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/tags/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(tag_sha), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&tag_sha.to_string()), ), None, ); @@ -630,14 +631,16 @@ impl Git { * * The tree creation API accepts nested entries. If you specify both a tree and a nested path modifying that tree, this endpoint will overwrite the contents of the tree with the new path contents, and create a new tree structure. * - * If you use this endpoint to add, delete, or modify the file contents in a tree, you will need to commit the tree and then update a branch to point to the commit. For more information see "[Create a commit](https://docs.github.com/rest/reference/git#create-a-commit)" and "[Update a reference](https://docs.github.com/rest/reference/git#update-a-reference)." + * If you use this endpoint to add, delete, or modify the file contents in a tree, you will need to commit the tree and then update a branch to point to the commit. For more information see "[Create a commit](https://docs.github.com/rest/git/commits#create-a-commit)" and "[Update a reference](https://docs.github.com/rest/git/refs#update-a-reference)." + * + * Returns an error if you try to delete a file that does not exist. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn create_tree( &self, @@ -648,8 +651,8 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/trees", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -668,17 +671,20 @@ impl Git { * * This function performs a `GET` to the `/repos/{owner}/{repo}/git/trees/{tree_sha}` endpoint. * - * Returns a single tree using the SHA1 value for that tree. + * Returns a single tree using the SHA1 value or ref name for that tree. * * If `truncated` is `true` in the response then the number of items in the `tree` array exceeded our maximum limit. If you need to fetch more items, use the non-recursive method of fetching trees, and fetch one sub-tree at a time. * - * FROM: + * > [!NOTE] + * > The limit for the `tree` array is 100,000 entries with a maximum size of 7 MB when using the `recursive` parameter. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `tree_sha: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `tree_sha: &str` -- The SHA1 value or ref (branch or tag) name of the tree. * * `recursive: &str` -- Setting this parameter to any value returns the objects or subtrees referenced by the tree specified in `:tree_sha`. For example, setting `recursive` to any of the following will enable returning objects or subtrees: `0`, `1`, `"true"`, and `"false"`. Omit this parameter to prevent recursively returning objects or subtrees. */ pub async fn get_tree( @@ -696,9 +702,9 @@ impl Git { let url = self.client.url( &format!( "/repos/{}/{}/git/trees/{}?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(tree_sha), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&tree_sha.to_string()), query_ ), None, diff --git a/github/src/gitignore.rs b/github/src/gitignore.rs index 77d335b4..ae4d5332 100644 --- a/github/src/gitignore.rs +++ b/github/src/gitignore.rs @@ -16,12 +16,12 @@ impl Gitignore { * * This function performs a `GET` to the `/gitignore/templates` endpoint. * - * List all templates available to pass as an option when [creating a repository](https://docs.github.com/rest/reference/repos#create-a-repository-for-the-authenticated-user). + * List all templates available to pass as an option when [creating a repository](https://docs.github.com/rest/repos/repos#create-a-repository-for-the-authenticated-user). * - * FROM: + * FROM: */ pub async fn get_all_templates(&self) -> ClientResult>> { - let url = self.client.url("/gitignore/templates", None); + let url = self.client.url(&"/gitignore/templates".to_string(), None); self.client .get( &url, @@ -39,12 +39,12 @@ impl Gitignore { * * As opposed to `get_all_templates`, this function returns all the pages of the request at once. * - * List all templates available to pass as an option when [creating a repository](https://docs.github.com/rest/reference/repos#create-a-repository-for-the-authenticated-user). + * List all templates available to pass as an option when [creating a repository](https://docs.github.com/rest/repos/repos#create-a-repository-for-the-authenticated-user). * - * FROM: + * FROM: */ pub async fn get_all_all_templates(&self) -> ClientResult>> { - let url = self.client.url("/gitignore/templates", None); + let url = self.client.url(&"/gitignore/templates".to_string(), None); self.client .get_all_pages( &url, @@ -60,10 +60,13 @@ impl Gitignore { * * This function performs a `GET` to the `/gitignore/templates/{name}` endpoint. * - * The API also allows fetching the source of a single template. - * Use the raw [media type](https://docs.github.com/rest/overview/media-types/) to get the raw contents. + * Get the content of a gitignore template. * - * FROM: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw .gitignore contents. + * + * FROM: * * **Parameters:** * @@ -76,7 +79,7 @@ impl Gitignore { let url = self.client.url( &format!( "/gitignore/templates/{}", - crate::progenitor_support::encode_path(name), + crate::progenitor_support::encode_path(&name.to_string()), ), None, ); diff --git a/github/src/hosted_compute.rs b/github/src/hosted_compute.rs new file mode 100644 index 00000000..44449d9c --- /dev/null +++ b/github/src/hosted_compute.rs @@ -0,0 +1,259 @@ +use crate::Client; +use crate::ClientResult; + +pub struct HostedCompute { + pub client: Client, +} + +impl HostedCompute { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + HostedCompute { client } + } + + /** + * List hosted compute network configurations for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/settings/network-configurations` endpoint. + * + * Lists all hosted compute network configurations configured in an organization. + * + * OAuth app tokens and personal access tokens (classic) need the `read:network_configurations` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_network_configurations_for_org( + &self, + org: &str, + per_page: i64, + page: i64, + ) -> ClientResult< + crate::Response, + > { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/settings/network-configurations?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a hosted compute network configuration for an organization. + * + * This function performs a `POST` to the `/orgs/{org}/settings/network-configurations` endpoint. + * + * Creates a hosted compute network configuration for an organization. + * + * OAuth app tokens and personal access tokens (classic) need the `write:network_configurations` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_network_configuration_for_org( + &self, + org: &str, + body: &crate::types::HostedComputeCreateNetworkConfigurationOrgRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/settings/network-configurations", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a hosted compute network configuration for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/settings/network-configurations/{network_configuration_id}` endpoint. + * + * Gets a hosted compute network configuration configured in an organization. + * + * OAuth app tokens and personal access tokens (classic) need the `read:network_configurations` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `network_configuration_id: &str` -- Unique identifier of the hosted compute network configuration. + */ + pub async fn get_network_configuration_for_org( + &self, + org: &str, + network_configuration_id: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/settings/network-configurations/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&network_configuration_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a hosted compute network configuration from an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/settings/network-configurations/{network_configuration_id}` endpoint. + * + * Deletes a hosted compute network configuration from an organization. + * + * OAuth app tokens and personal access tokens (classic) need the `write:network_configurations` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `network_configuration_id: &str` -- Unique identifier of the hosted compute network configuration. + */ + pub async fn delete_network_configuration_from_org( + &self, + org: &str, + network_configuration_id: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/settings/network-configurations/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&network_configuration_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a hosted compute network configuration for an organization. + * + * This function performs a `PATCH` to the `/orgs/{org}/settings/network-configurations/{network_configuration_id}` endpoint. + * + * Updates a hosted compute network configuration for an organization. + * + * OAuth app tokens and personal access tokens (classic) need the `write:network_configurations` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `network_configuration_id: &str` -- Unique identifier of the hosted compute network configuration. + */ + pub async fn update_network_configuration_for_org( + &self, + org: &str, + network_configuration_id: &str, + body: &crate::types::HostedComputeUpdateNetworkConfigurationOrgRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/settings/network-configurations/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&network_configuration_id.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a hosted compute network settings resource for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/settings/network-settings/{network_settings_id}` endpoint. + * + * Gets a hosted compute network settings resource configured for an organization. + * + * OAuth app tokens and personal access tokens (classic) need the `read:network_configurations` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `network_settings_id: &str` -- Unique identifier of the hosted compute network settings. + */ + pub async fn get_network_settings_for_org( + &self, + org: &str, + network_settings_id: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/settings/network-settings/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&network_settings_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } +} diff --git a/github/src/interactions.rs b/github/src/interactions.rs index 19c739a0..2acd29b7 100644 --- a/github/src/interactions.rs +++ b/github/src/interactions.rs @@ -18,11 +18,11 @@ impl Interactions { * * Shows which type of GitHub user can interact with this organization and when the restriction expires. If there is no restrictions, you will see an empty response. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn get_restrictions_for_org( &self, @@ -31,7 +31,7 @@ impl Interactions { let url = self.client.url( &format!( "/orgs/{}/interaction-limits", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -52,11 +52,11 @@ impl Interactions { * * Temporarily restricts interactions to a certain type of GitHub user in any public repository in the given organization. You must be an organization owner to set these restrictions. Setting the interaction limit at the organization level will overwrite any interaction limits that are set for individual repositories owned by the organization. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn set_restrictions_for_org( &self, @@ -66,7 +66,7 @@ impl Interactions { let url = self.client.url( &format!( "/orgs/{}/interaction-limits", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -87,11 +87,11 @@ impl Interactions { * * Removes all interaction restrictions from public repositories in the given organization. You must be an organization owner to remove restrictions. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn remove_restrictions_for_org( &self, @@ -100,7 +100,7 @@ impl Interactions { let url = self.client.url( &format!( "/orgs/{}/interaction-limits", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -121,12 +121,12 @@ impl Interactions { * * Shows which type of GitHub user can interact with this repository and when the restriction expires. If there are no restrictions, you will see an empty response. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_restrictions_for_repo( &self, @@ -136,8 +136,8 @@ impl Interactions { let url = self.client.url( &format!( "/repos/{}/{}/interaction-limits", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -158,12 +158,12 @@ impl Interactions { * * Temporarily restricts interactions to a certain type of GitHub user within the given repository. You must have owner or admin access to set these restrictions. If an interaction limit is set for the user or organization that owns this repository, you will receive a `409 Conflict` response and will not be able to use this endpoint to change the interaction limit for a single repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn set_restrictions_for_repo( &self, @@ -174,8 +174,8 @@ impl Interactions { let url = self.client.url( &format!( "/repos/{}/{}/interaction-limits", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -196,12 +196,12 @@ impl Interactions { * * Removes all interaction restrictions from the given repository. You must have owner or admin access to remove restrictions. If the interaction limit is set for the user or organization that owns this repository, you will receive a `409 Conflict` response and will not be able to use this endpoint to change the interaction limit for a single repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn remove_restrictions_for_repo( &self, @@ -211,8 +211,8 @@ impl Interactions { let url = self.client.url( &format!( "/repos/{}/{}/interaction-limits", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -233,12 +233,14 @@ impl Interactions { * * Shows which type of GitHub user can interact with your public repositories and when the restriction expires. * - * FROM: + * FROM: */ pub async fn get_restrictions_for_authenticated_user( &self, ) -> ClientResult> { - let url = self.client.url("/user/interaction-limits", None); + let url = self + .client + .url(&"/user/interaction-limits".to_string(), None); self.client .get( &url, @@ -256,13 +258,15 @@ impl Interactions { * * Temporarily restricts which type of GitHub user can interact with your public repositories. Setting the interaction limit at the user level will overwrite any interaction limits that are set for individual repositories owned by the user. * - * FROM: + * FROM: */ pub async fn set_restrictions_for_authenticated_user( &self, body: &crate::types::InteractionLimit, ) -> ClientResult> { - let url = self.client.url("/user/interaction-limits", None); + let url = self + .client + .url(&"/user/interaction-limits".to_string(), None); self.client .put( &url, @@ -280,12 +284,14 @@ impl Interactions { * * Removes any interaction restrictions from your public repositories. * - * FROM: + * FROM: */ pub async fn remove_restrictions_for_authenticated_user( &self, ) -> ClientResult> { - let url = self.client.url("/user/interaction-limits", None); + let url = self + .client + .url(&"/user/interaction-limits".to_string(), None); self.client .delete( &url, diff --git a/github/src/issues.rs b/github/src/issues.rs index 72669aa2..57c1b46c 100644 --- a/github/src/issues.rs +++ b/github/src/issues.rs @@ -20,35 +20,32 @@ impl Issues { * repositories, and organization repositories. You can use the `filter` query parameter to fetch issues that are not * necessarily assigned to you. * + * > [!NOTE] + * > GitHub's REST API considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull request id, use the "[List pull requests](https://docs.github.com/rest/pulls/pulls#list-pull-requests)" endpoint. * - * **Note**: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this - * reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by - * the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull - * request id, use the "[List pull requests](https://docs.github.com/rest/reference/pulls#list-pull-requests)" endpoint. + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `filter: crate::types::Filter` -- Indicates which sorts of issues to return. Can be one of: - * \\* `assigned`: Issues assigned to you - * \\* `created`: Issues created by you - * \\* `mentioned`: Issues mentioning you - * \\* `subscribed`: Issues you're subscribed to updates for - * \\* `all` or `repos`: All issues the authenticated user can see, regardless of participation or creation. - * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. Can be either `open`, `closed`, or `all`. + * * `filter: crate::types::Filter` -- Indicates which sorts of issues to return. `assigned` means issues assigned to you. `created` means issues created by you. `mentioned` means issues mentioning you. `subscribed` means issues you're subscribed to updates for. `all` or `repos` means all issues you can see, regardless of participation or creation. + * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. * * `labels: &str` -- A list of comma separated label names. Example: `bug,ui,@high`. - * * `sort: crate::types::IssuesListSort` -- What to sort results by. Can be either `created`, `updated`, `comments`. - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `sort: crate::types::IssuesListSort` -- What to sort results by. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. * * `collab: bool` * * `orgs: bool` * * `owned: bool` * * `pulls: bool` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list( &self, @@ -125,13 +122,17 @@ impl Issues { * repositories, and organization repositories. You can use the `filter` query parameter to fetch issues that are not * necessarily assigned to you. * + * > [!NOTE] + * > GitHub's REST API considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull request id, use the "[List pull requests](https://docs.github.com/rest/pulls/pulls#list-pull-requests)" endpoint. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * **Note**: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this - * reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by - * the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull - * request id, use the "[List pull requests](https://docs.github.com/rest/reference/pulls#list-pull-requests)" endpoint. + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: */ pub async fn list_all( &self, @@ -196,31 +197,30 @@ impl Issues { * * List issues in an organization assigned to the authenticated user. * - * **Note**: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this - * reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by - * the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull - * request id, use the "[List pull requests](https://docs.github.com/rest/reference/pulls#list-pull-requests)" endpoint. + * > [!NOTE] + * > GitHub's REST API considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull request id, use the "[List pull requests](https://docs.github.com/rest/pulls/pulls#list-pull-requests)" endpoint. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `filter: crate::types::Filter` -- Indicates which sorts of issues to return. Can be one of: - * \\* `assigned`: Issues assigned to you - * \\* `created`: Issues created by you - * \\* `mentioned`: Issues mentioning you - * \\* `subscribed`: Issues you're subscribed to updates for - * \\* `all` or `repos`: All issues the authenticated user can see, regardless of participation or creation. - * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. Can be either `open`, `closed`, or `all`. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `filter: crate::types::Filter` -- Indicates which sorts of issues to return. `assigned` means issues assigned to you. `created` means issues created by you. `mentioned` means issues mentioning you. `subscribed` means issues you're subscribed to updates for. `all` or `repos` means all issues you can see, regardless of participation or creation. + * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. * * `labels: &str` -- A list of comma separated label names. Example: `bug,ui,@high`. - * * `sort: crate::types::IssuesListSort` -- What to sort results by. Can be either `created`, `updated`, `comments`. - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `type_: &str` -- Can be the name of an issue type. + * * `sort: crate::types::IssuesListSort` -- What to sort results by. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_org( &self, @@ -228,6 +228,7 @@ impl Issues { filter: crate::types::Filter, state: crate::types::IssuesListState, labels: &str, + type_: &str, sort: crate::types::IssuesListSort, direction: crate::types::Order, since: Option>, @@ -259,11 +260,14 @@ impl Issues { if !state.to_string().is_empty() { query_args.push(("state".to_string(), state.to_string())); } + if !type_.is_empty() { + query_args.push(("type".to_string(), type_.to_string())); + } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( "/orgs/{}/issues?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -287,12 +291,17 @@ impl Issues { * * List issues in an organization assigned to the authenticated user. * - * **Note**: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this - * reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by - * the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull - * request id, use the "[List pull requests](https://docs.github.com/rest/reference/pulls#list-pull-requests)" endpoint. + * > [!NOTE] + * > GitHub's REST API considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull request id, use the "[List pull requests](https://docs.github.com/rest/pulls/pulls#list-pull-requests)" endpoint. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: */ pub async fn list_all_for_org( &self, @@ -300,6 +309,7 @@ impl Issues { filter: crate::types::Filter, state: crate::types::IssuesListState, labels: &str, + type_: &str, sort: crate::types::IssuesListSort, direction: crate::types::Order, since: Option>, @@ -323,11 +333,14 @@ impl Issues { if !state.to_string().is_empty() { query_args.push(("state".to_string(), state.to_string())); } + if !type_.is_empty() { + query_args.push(("type".to_string(), type_.to_string())); + } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( "/orgs/{}/issues?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -347,16 +360,16 @@ impl Issues { * * This function performs a `GET` to the `/repos/{owner}/{repo}/assignees` endpoint. * - * Lists the [available assignees](https://help.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users/) for issues in a repository. + * Lists the [available assignees](https://docs.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users/) for issues in a repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_assignees( &self, @@ -376,8 +389,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/assignees?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -399,9 +412,9 @@ impl Issues { * * As opposed to `list_assignees`, this function returns all the pages of the request at once. * - * Lists the [available assignees](https://help.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users/) for issues in a repository. + * Lists the [available assignees](https://docs.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users/) for issues in a repository. * - * FROM: + * FROM: */ pub async fn list_all_assignees( &self, @@ -411,8 +424,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/assignees", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -437,12 +450,12 @@ impl Issues { * * Otherwise a `404` status code is returned. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `assignee: &str` */ pub async fn check_user_can_be_assigned( @@ -454,9 +467,9 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/assignees/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(assignee), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&assignee.to_string()), ), None, ); @@ -475,32 +488,36 @@ impl Issues { * * This function performs a `GET` to the `/repos/{owner}/{repo}/issues` endpoint. * - * List issues in a repository. + * List issues in a repository. Only open issues will be listed. * - * **Note**: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this - * reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by - * the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull - * request id, use the "[List pull requests](https://docs.github.com/rest/reference/pulls#list-pull-requests)" endpoint. + * > [!NOTE] + * > GitHub's REST API considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull request id, use the "[List pull requests](https://docs.github.com/rest/pulls/pulls#list-pull-requests)" endpoint. * - * FROM: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `milestone: &str` -- If an `integer` is passed, it should refer to a milestone by its `number` field. If the string `*` is passed, issues with any milestone are accepted. If the string `none` is passed, issues without milestones are returned. - * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. Can be either `open`, `closed`, or `all`. + * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. * * `assignee: &str` -- Can be the name of a user. Pass in `none` for issues with no assigned user, and `*` for issues assigned to any user. + * * `type_: &str` -- Can be the name of an issue type. If the string `*` is passed, issues with any type are accepted. If the string `none` is passed, issues without type are returned. * * `creator: &str` -- The user that created the issue. * * `mentioned: &str` -- A user that's mentioned in the issue. * * `labels: &str` -- A list of comma separated label names. Example: `bug,ui,@high`. - * * `sort: crate::types::IssuesListSort` -- What to sort results by. Can be either `created`, `updated`, `comments`. - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `sort: crate::types::IssuesListSort` -- What to sort results by. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_repo( &self, @@ -509,6 +526,7 @@ impl Issues { milestone: &str, state: crate::types::IssuesListState, assignee: &str, + type_: &str, creator: &str, mentioned: &str, labels: &str, @@ -517,7 +535,7 @@ impl Issues { since: Option>, per_page: i64, page: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if !assignee.is_empty() { query_args.push(("assignee".to_string(), assignee.to_string())); @@ -552,12 +570,15 @@ impl Issues { if !state.to_string().is_empty() { query_args.push(("state".to_string(), state.to_string())); } + if !type_.is_empty() { + query_args.push(("type".to_string(), type_.to_string())); + } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( "/repos/{}/{}/issues?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -579,14 +600,19 @@ impl Issues { * * As opposed to `list_for_repo`, this function returns all the pages of the request at once. * - * List issues in a repository. + * List issues in a repository. Only open issues will be listed. * - * **Note**: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this - * reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by - * the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull - * request id, use the "[List pull requests](https://docs.github.com/rest/reference/pulls#list-pull-requests)" endpoint. + * > [!NOTE] + * > GitHub's REST API considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull request id, use the "[List pull requests](https://docs.github.com/rest/pulls/pulls#list-pull-requests)" endpoint. * - * FROM: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: */ pub async fn list_all_for_repo( &self, @@ -595,13 +621,14 @@ impl Issues { milestone: &str, state: crate::types::IssuesListState, assignee: &str, + type_: &str, creator: &str, mentioned: &str, labels: &str, sort: crate::types::IssuesListSort, direction: crate::types::Order, since: Option>, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if !assignee.is_empty() { query_args.push(("assignee".to_string(), assignee.to_string())); @@ -630,12 +657,15 @@ impl Issues { if !state.to_string().is_empty() { query_args.push(("state".to_string(), state.to_string())); } + if !type_.is_empty() { + query_args.push(("type".to_string(), type_.to_string())); + } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( "/repos/{}/{}/issues?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -655,16 +685,24 @@ impl Issues { * * This function performs a `POST` to the `/repos/{owner}/{repo}/issues` endpoint. * - * Any user with pull access to a repository can create an issue. If [issues are disabled in the repository](https://help.github.com/articles/disabling-issues/), the API returns a `410 Gone` status. + * Any user with pull access to a repository can create an issue. If [issues are disabled in the repository](https://docs.github.com/articles/disabling-issues/), the API returns a `410 Gone` status. * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" + * and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." * - * FROM: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn create( &self, @@ -675,8 +713,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -695,27 +733,34 @@ impl Issues { * * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/comments` endpoint. * - * By default, Issue Comments are ordered by ascending ID. + * You can use the REST API to list comments on issues and pull requests for a repository. Every pull request is an issue, but not every issue is a pull request. + * + * By default, issue comments are ordered by ascending ID. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `sort: crate::types::Sort` -- One of `created` (when the repository was starred) or `updated` (when it was last pushed to). - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `sort: crate::types::SortData` -- The property to sort the results by. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_comments_for_repo( &self, owner: &str, repo: &str, - sort: crate::types::Sort, + sort: crate::types::SortData, direction: crate::types::Order, since: Option>, per_page: i64, @@ -741,8 +786,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/comments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -764,15 +809,24 @@ impl Issues { * * As opposed to `list_comments_for_repo`, this function returns all the pages of the request at once. * - * By default, Issue Comments are ordered by ascending ID. + * You can use the REST API to list comments on issues and pull requests for a repository. Every pull request is an issue, but not every issue is a pull request. + * + * By default, issue comments are ordered by ascending ID. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: */ pub async fn list_all_comments_for_repo( &self, owner: &str, repo: &str, - sort: crate::types::Sort, + sort: crate::types::SortData, direction: crate::types::Order, since: Option>, ) -> ClientResult>> { @@ -790,8 +844,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/comments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -811,15 +865,22 @@ impl Issues { * * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/comments/{comment_id}` endpoint. * + * You can use the REST API to get comments on issues and pull requests. Every pull request is an issue, but not every issue is a pull request. * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn get_comment( &self, @@ -830,8 +891,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/comments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, @@ -851,15 +912,15 @@ impl Issues { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/issues/comments/{comment_id}` endpoint. * + * You can use the REST API to delete comments on issues and pull requests. Every pull request is an issue, but not every issue is a pull request. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn delete_comment( &self, @@ -870,8 +931,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/comments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, @@ -891,15 +952,22 @@ impl Issues { * * This function performs a `PATCH` to the `/repos/{owner}/{repo}/issues/comments/{comment_id}` endpoint. * + * You can use the REST API to update comments on issues and pull requests. Every pull request is an issue, but not every issue is a pull request. * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn update_comment( &self, @@ -911,8 +979,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/comments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, @@ -927,21 +995,108 @@ impl Issues { ) .await } + /** + * Pin an issue comment. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/issues/comments/{comment_id}/pin` endpoint. + * + * You can use the REST API to pin comments on issues. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. + */ + pub async fn pin_comment( + &self, + owner: &str, + repo: &str, + comment_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/comments/{}/pin", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&comment_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Unpin an issue comment. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/issues/comments/{comment_id}/pin` endpoint. + * + * You can use the REST API to unpin comments on issues. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. + */ + pub async fn unpin_comment( + &self, + owner: &str, + repo: &str, + comment_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/comments/{}/pin", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&comment_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } /** * List issue events for a repository. * * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/events` endpoint. * + * Lists events for a repository. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_events_for_repo( &self, @@ -961,8 +1116,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/events?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -984,9 +1139,9 @@ impl Issues { * * As opposed to `list_events_for_repo`, this function returns all the pages of the request at once. * + * Lists events for a repository. * - * - * FROM: + * FROM: */ pub async fn list_all_events_for_repo( &self, @@ -996,8 +1151,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/events", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -1016,14 +1171,14 @@ impl Issues { * * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/events/{event_id}` endpoint. * + * Gets a single event by the event id. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `event_id: i64` */ pub async fn get_event( @@ -1035,8 +1190,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/events/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&event_id.to_string()), ), None, @@ -1056,25 +1211,30 @@ impl Issues { * * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}` endpoint. * - * The API returns a [`301 Moved Permanently` status](https://docs.github.com/rest/overview/resources-in-the-rest-api#http-redirects-redirects) if the issue was - * [transferred](https://help.github.com/articles/transferring-an-issue-to-another-repository/) to another repository. If + * The API returns a [`301 Moved Permanently` status](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api#follow-redirects) if the issue was + * [transferred](https://docs.github.com/articles/transferring-an-issue-to-another-repository/) to another repository. If * the issue was transferred to or deleted from a repository where the authenticated user lacks read access, the API * returns a `404 Not Found` status. If the issue was deleted from a repository where the authenticated user has read * access, the API returns a `410 Gone` status. To receive webhook events for transferred and deleted issues, subscribe * to the [`issues`](https://docs.github.com/webhooks/event-payloads/#issues) webhook. * - * **Note**: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this - * reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by - * the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull - * request id, use the "[List pull requests](https://docs.github.com/rest/reference/pulls#list-pull-requests)" endpoint. + * > [!NOTE] + * > GitHub's REST API considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull request id, use the "[List pull requests](https://docs.github.com/rest/pulls/pulls#list-pull-requests)" endpoint. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. */ pub async fn get( &self, @@ -1085,8 +1245,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), ), None, @@ -1106,15 +1266,22 @@ impl Issues { * * This function performs a `PATCH` to the `/repos/{owner}/{repo}/issues/{issue_number}` endpoint. * - * Issue owners and users with push access can edit an issue. + * Issue owners and users with push access or Triage role can edit an issue. * - * FROM: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. */ pub async fn update( &self, @@ -1126,8 +1293,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), ), None, @@ -1149,13 +1316,13 @@ impl Issues { * * Adds up to 10 assignees to an issue. Users already assigned to an issue are not replaced. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. */ pub async fn add_assignees( &self, @@ -1163,12 +1330,12 @@ impl Issues { repo: &str, issue_number: i64, body: &crate::types::IssuesAddAssigneesRequest, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/assignees", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), ), None, @@ -1190,13 +1357,13 @@ impl Issues { * * Removes one or more assignees from an issue. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. */ pub async fn remove_assignees( &self, @@ -1204,12 +1371,12 @@ impl Issues { repo: &str, issue_number: i64, body: &crate::types::IssuesAddAssigneesRequest, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/assignees", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), ), None, @@ -1224,23 +1391,79 @@ impl Issues { ) .await } + /** + * Check if a user can be assigned to a issue. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/assignees/{assignee}` endpoint. + * + * Checks if a user has permission to be assigned to a specific issue. + * + * If the `assignee` can be assigned to this issue, a `204` status code with no content is returned. + * + * Otherwise a `404` status code is returned. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + * * `assignee: &str` + */ + pub async fn check_user_can_be_assigned_to_issue( + &self, + owner: &str, + repo: &str, + issue_number: i64, + assignee: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/assignees/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + crate::progenitor_support::encode_path(&assignee.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } /** * List issue comments. * * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/comments` endpoint. * - * Issue Comments are ordered by ascending ID. + * You can use the REST API to list comments on issues and pull requests. Every pull request is an issue, but not every issue is a pull request. + * + * Issue comments are ordered by ascending ID. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_comments( &self, @@ -1265,8 +1488,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/comments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), query_ ), @@ -1289,9 +1512,18 @@ impl Issues { * * As opposed to `list_comments`, this function returns all the pages of the request at once. * - * Issue Comments are ordered by ascending ID. + * You can use the REST API to list comments on issues and pull requests. Every pull request is an issue, but not every issue is a pull request. + * + * Issue comments are ordered by ascending ID. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: */ pub async fn list_all_comments( &self, @@ -1308,8 +1540,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/comments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), query_ ), @@ -1330,15 +1562,27 @@ impl Issues { * * This function performs a `POST` to the `/repos/{owner}/{repo}/issues/{issue_number}/comments` endpoint. * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * You can use the REST API to create comments on issues and pull requests. Every pull request is an issue, but not every issue is a pull request. * - * FROM: + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). + * Creating content too quickly using this endpoint may result in secondary rate limiting. + * For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" + * and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. */ pub async fn create_comment( &self, @@ -1350,8 +1594,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/comments", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), ), None, @@ -1367,30 +1611,37 @@ impl Issues { .await } /** - * List issue events. + * List dependencies an issue is blocked by. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/events` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by` endpoint. + * + * You can use the REST API to list the dependencies an issue is blocked by. * + * This endpoint supports the following custom media types. For more information, see [Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types). * + * - **`application/vnd.github.raw+json`**: Returns the raw Markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the Markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's Markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_events( + pub async fn list_dependencies_blocked_by( &self, owner: &str, repo: &str, issue_number: i64, per_page: i64, page: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if page > 0 { query_args.push(("page".to_string(), page.to_string())); @@ -1401,9 +1652,9 @@ impl Issues { let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/issues/{}/events?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/issues/{}/dependencies/blocked_by?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), query_ ), @@ -1420,27 +1671,34 @@ impl Issues { .await } /** - * List issue events. + * List dependencies an issue is blocked by. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/events` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by` endpoint. * - * As opposed to `list_events`, this function returns all the pages of the request at once. + * As opposed to `list_dependencies_blocked_by`, this function returns all the pages of the request at once. + * + * You can use the REST API to list the dependencies an issue is blocked by. * + * This endpoint supports the following custom media types. For more information, see [Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types). * + * - **`application/vnd.github.raw+json`**: Returns the raw Markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the Markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's Markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: */ - pub async fn list_all_events( + pub async fn list_all_dependencies_blocked_by( &self, owner: &str, repo: &str, issue_number: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/issues/{}/events", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/issues/{}/dependencies/blocked_by", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), ), None, @@ -1456,86 +1714,102 @@ impl Issues { .await } /** - * List labels for an issue. + * Add a dependency an issue is blocked by. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/labels` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by` endpoint. * + * You can use the REST API to add a 'blocked by' relationship to an issue. * + * Creating content too quickly using this endpoint may result in secondary rate limiting. + * For more information, see [Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits) + * and [Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api). * - * FROM: + * This endpoint supports the following custom media types. For more information, see [Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types). + * + * - **`application/vnd.github.raw+json`**: Returns the raw Markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the Markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's Markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. */ - pub async fn list_labels_on_issue( + pub async fn add_blocked_by_dependency( &self, owner: &str, repo: &str, issue_number: i64, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + body: &crate::types::IssuesAddBlockedByDependencyRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/issues/{}/labels?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/issues/{}/dependencies/blocked_by", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), - query_ ), None, ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List labels for an issue. + * Remove dependency an issue is blocked by. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/labels` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by/{issue_id}` endpoint. * - * As opposed to `list_labels_on_issue`, this function returns all the pages of the request at once. + * You can use the REST API to remove a dependency that an issue is blocked by. + * + * Removing content too quickly using this endpoint may result in secondary rate limiting. + * For more information, see [Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits) + * and [Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api). + * + * This endpoint supports the following custom media types. For more information, see [Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types). + * - **`application/vnd.github.raw+json`**: Returns the raw Markdown body. Response will include `body`. This is the default if you do not pass a specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the Markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's Markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * + * FROM: * + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + * * `issue_id: i64` -- The id of the blocking issue to remove as a dependency. */ - pub async fn list_all_labels_on_issue( + pub async fn remove_dependency_blocked_by( &self, owner: &str, repo: &str, issue_number: i64, - ) -> ClientResult>> { + issue_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/issues/{}/labels", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/issues/{}/dependencies/blocked_by/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), + crate::progenitor_support::encode_path(&issue_id.to_string()), ), None, ); self.client - .get_all_pages( + .delete( &url, crate::Message { body: None, @@ -1545,119 +1819,153 @@ impl Issues { .await } /** - * Set labels for an issue. + * List dependencies an issue is blocking. * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/issues/{issue_number}/labels` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocking` endpoint. * - * Removes any previous labels and sets the new labels for an issue. + * You can use the REST API to list the dependencies an issue is blocking. + * + * This endpoint supports the following custom media types. For more information, see [Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types). + * + * - **`application/vnd.github.raw+json`**: Returns the raw Markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the Markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's Markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn set_labels( + pub async fn list_dependencies_blocking( &self, owner: &str, repo: &str, issue_number: i64, - body: &crate::types::IssuesSetLabelsRequestAnyOf, - ) -> ClientResult>> { + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/issues/{}/labels", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/issues/{}/dependencies/blocking?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), + query_ ), None, ); self.client - .put( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Add labels to an issue. + * List dependencies an issue is blocking. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/issues/{issue_number}/labels` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocking` endpoint. * + * As opposed to `list_dependencies_blocking`, this function returns all the pages of the request at once. * + * You can use the REST API to list the dependencies an issue is blocking. * - * FROM: + * This endpoint supports the following custom media types. For more information, see [Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types). * - * **Parameters:** + * - **`application/vnd.github.raw+json`**: Returns the raw Markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the Markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's Markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. + * FROM: */ - pub async fn add_labels( + pub async fn list_all_dependencies_blocking( &self, owner: &str, repo: &str, issue_number: i64, - body: &crate::types::IssuesAddLabelsRequestOneOf, - ) -> ClientResult>> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/issues/{}/labels", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/issues/{}/dependencies/blocking", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), ), None, ); self.client - .post( + .get_all_pages( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Remove all labels from an issue. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/issues/{issue_number}/labels` endpoint. + * List issue events. * + * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/events` endpoint. * + * Lists all events for an issue. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn remove_all_labels( + pub async fn list_events( &self, owner: &str, repo: &str, issue_number: i64, - ) -> ClientResult> { + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/issues/{}/labels", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/issues/{}/events?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), + query_ ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -1667,19 +1975,266 @@ impl Issues { .await } /** - * Remove a label from an issue. + * List issue events. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/events` endpoint. + * + * As opposed to `list_events`, this function returns all the pages of the request at once. + * + * Lists all events for an issue. + * + * FROM: + */ + pub async fn list_all_events( + &self, + owner: &str, + repo: &str, + issue_number: i64, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/events", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List labels for an issue. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/labels` endpoint. + * + * Lists all labels for an issue. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_labels_on_issue( + &self, + owner: &str, + repo: &str, + issue_number: i64, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/labels?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List labels for an issue. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/labels` endpoint. + * + * As opposed to `list_labels_on_issue`, this function returns all the pages of the request at once. + * + * Lists all labels for an issue. + * + * FROM: + */ + pub async fn list_all_labels_on_issue( + &self, + owner: &str, + repo: &str, + issue_number: i64, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/labels", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set labels for an issue. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/issues/{issue_number}/labels` endpoint. + * + * Removes any previous labels and sets the new labels for an issue. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + */ + pub async fn set_labels( + &self, + owner: &str, + repo: &str, + issue_number: i64, + body: &crate::types::IssuesAddLabelsRequestOneOf, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/labels", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Add labels to an issue. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/issues/{issue_number}/labels` endpoint. + * + * Adds labels to an issue. If you provide an empty array of labels, all labels are removed from the issue. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + */ + pub async fn add_labels( + &self, + owner: &str, + repo: &str, + issue_number: i64, + body: &crate::types::IssuesAddLabelsRequestOneOf, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/labels", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Remove all labels from an issue. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/issues/{issue_number}/labels` endpoint. + * + * Removes all labels from an issue. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + */ + pub async fn remove_all_labels( + &self, + owner: &str, + repo: &str, + issue_number: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/labels", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove a label from an issue. * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/issues/{issue_number}/labels/{name}` endpoint. * * Removes the specified label from the issue, and returns the remaining labels on the issue. This endpoint returns a `404 Not Found` status if the label does not exist. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. * * `name: &str` */ pub async fn remove_label( @@ -1692,10 +2247,10 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/labels/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), - crate::progenitor_support::encode_path(name), + crate::progenitor_support::encode_path(&name.to_string()), ), None, ); @@ -1716,15 +2271,15 @@ impl Issues { * * Users with push access can lock an issue or pull request's conversation. * - * Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://docs.github.com/rest/overview/resources-in-the-rest-api#http-verbs)." + * Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)." * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. */ pub async fn lock( &self, @@ -1736,8 +2291,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/lock", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), ), None, @@ -1759,13 +2314,13 @@ impl Issues { * * Users with push access can unlock an issue's conversation. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. */ pub async fn unlock( &self, @@ -1776,8 +2331,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/lock", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), ), None, @@ -1792,22 +2347,314 @@ impl Issues { ) .await } + /** + * Get parent issue. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/parent` endpoint. + * + * You can use the REST API to get the parent issue of a sub-issue. + * + * This endpoint supports the following custom media types. For more information, see [Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types). + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + */ + pub async fn get_parent( + &self, + owner: &str, + repo: &str, + issue_number: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/parent", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove sub-issue. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/issues/{issue_number}/sub_issue` endpoint. + * + * You can use the REST API to remove a sub-issue from an issue. + * Removing content too quickly using this endpoint may result in secondary rate limiting. + * For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" + * and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass a specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + */ + pub async fn remove_sub_issue( + &self, + owner: &str, + repo: &str, + issue_number: i64, + body: &crate::types::IssuesRemoveSubIssueRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/sub_issue", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List sub-issues. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/sub_issues` endpoint. + * + * You can use the REST API to list the sub-issues on an issue. + * + * This endpoint supports the following custom media types. For more information, see [Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types). + * + * - **`application/vnd.github.raw+json`**: Returns the raw Markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the Markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's Markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_sub_issues( + &self, + owner: &str, + repo: &str, + issue_number: i64, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/sub_issues?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List sub-issues. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/sub_issues` endpoint. + * + * As opposed to `list_sub_issues`, this function returns all the pages of the request at once. + * + * You can use the REST API to list the sub-issues on an issue. + * + * This endpoint supports the following custom media types. For more information, see [Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types). + * + * - **`application/vnd.github.raw+json`**: Returns the raw Markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the Markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's Markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: + */ + pub async fn list_all_sub_issues( + &self, + owner: &str, + repo: &str, + issue_number: i64, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/sub_issues", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Add sub-issue. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/issues/{issue_number}/sub_issues` endpoint. + * + * You can use the REST API to add sub-issues to issues. + * + * Creating content too quickly using this endpoint may result in secondary rate limiting. + * For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" + * and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + */ + pub async fn add_sub_issue( + &self, + owner: &str, + repo: &str, + issue_number: i64, + body: &crate::types::IssuesAddSubIssueRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/sub_issues", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Reprioritize sub-issue. + * + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/issues/{issue_number}/sub_issues/priority` endpoint. + * + * You can use the REST API to reprioritize a sub-issue to a different position in the parent list. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + */ + pub async fn reprioritize_sub_issue( + &self, + owner: &str, + repo: &str, + issue_number: i64, + body: &crate::types::IssuesReprioritizeSubIssueRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/issues/{}/sub_issues/priority", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&issue_number.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } /** * List timeline events for an issue. * * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/timeline` endpoint. * + * List all timeline events for an issue. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_events_for_timeline( &self, @@ -1816,7 +2663,7 @@ impl Issues { issue_number: i64, per_page: i64, page: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if page > 0 { query_args.push(("page".to_string(), page.to_string())); @@ -1828,8 +2675,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/timeline?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), query_ ), @@ -1852,21 +2699,21 @@ impl Issues { * * As opposed to `list_events_for_timeline`, this function returns all the pages of the request at once. * + * List all timeline events for an issue. * - * - * FROM: + * FROM: */ pub async fn list_all_events_for_timeline( &self, owner: &str, repo: &str, issue_number: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/timeline", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), ), None, @@ -1886,16 +2733,16 @@ impl Issues { * * This function performs a `GET` to the `/repos/{owner}/{repo}/labels` endpoint. * + * Lists all labels for a repository. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_labels_for_repo( &self, @@ -1915,8 +2762,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/labels?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -1938,9 +2785,9 @@ impl Issues { * * As opposed to `list_labels_for_repo`, this function returns all the pages of the request at once. * + * Lists all labels for a repository. * - * - * FROM: + * FROM: */ pub async fn list_all_labels_for_repo( &self, @@ -1950,8 +2797,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/labels", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -1970,14 +2817,14 @@ impl Issues { * * This function performs a `POST` to the `/repos/{owner}/{repo}/labels` endpoint. * + * Creates a label for the specified repository with the given name and color. The name and color parameters are required. The color must be a valid [hexadecimal color code](http://www.color-hex.com/). * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn create_label( &self, @@ -1988,8 +2835,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/labels", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -2008,14 +2855,14 @@ impl Issues { * * This function performs a `GET` to the `/repos/{owner}/{repo}/labels/{name}` endpoint. * + * Gets a label using the given name. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `name: &str` */ pub async fn get_label( @@ -2027,9 +2874,9 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/labels/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(name), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), ), None, ); @@ -2048,14 +2895,14 @@ impl Issues { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/labels/{name}` endpoint. * + * Deletes a label using the given label name. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `name: &str` */ pub async fn delete_label( @@ -2067,9 +2914,9 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/labels/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(name), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), ), None, ); @@ -2088,14 +2935,14 @@ impl Issues { * * This function performs a `PATCH` to the `/repos/{owner}/{repo}/labels/{name}` endpoint. * + * Updates a label using the given label name. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `name: &str` */ pub async fn update_label( @@ -2108,9 +2955,9 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/labels/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(name), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&name.to_string()), ), None, ); @@ -2129,21 +2976,19 @@ impl Issues { * * This function performs a `GET` to the `/repos/{owner}/{repo}/milestones` endpoint. * + * Lists milestones for a repository. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. Can be either `open`, `closed`, or `all`. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `state: crate::types::IssuesListState` -- The state of the milestone. Either `open`, `closed`, or `all`. * * `sort: crate::types::IssuesListMilestonesSort` -- What to sort results by. Either `due_on` or `completeness`. - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_milestones( &self, @@ -2175,8 +3020,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/milestones?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -2198,9 +3043,9 @@ impl Issues { * * As opposed to `list_milestones`, this function returns all the pages of the request at once. * + * Lists milestones for a repository. * - * - * FROM: + * FROM: */ pub async fn list_all_milestones( &self, @@ -2224,8 +3069,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/milestones?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -2245,14 +3090,14 @@ impl Issues { * * This function performs a `POST` to the `/repos/{owner}/{repo}/milestones` endpoint. * + * Creates a milestone. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn create_milestone( &self, @@ -2263,8 +3108,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/milestones", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -2283,15 +3128,15 @@ impl Issues { * * This function performs a `GET` to the `/repos/{owner}/{repo}/milestones/{milestone_number}` endpoint. * + * Gets a milestone using the given milestone number. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `milestone_number: i64` -- milestone_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `milestone_number: i64` -- The number that identifies the milestone. */ pub async fn get_milestone( &self, @@ -2302,8 +3147,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/milestones/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&milestone_number.to_string()), ), None, @@ -2323,15 +3168,15 @@ impl Issues { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/milestones/{milestone_number}` endpoint. * + * Deletes a milestone using the given milestone number. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `milestone_number: i64` -- milestone_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `milestone_number: i64` -- The number that identifies the milestone. */ pub async fn delete_milestone( &self, @@ -2342,8 +3187,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/milestones/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&milestone_number.to_string()), ), None, @@ -2365,26 +3210,26 @@ impl Issues { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `milestone_number: i64` -- milestone_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `milestone_number: i64` -- The number that identifies the milestone. */ pub async fn update_milestone( &self, owner: &str, repo: &str, milestone_number: i64, - body: &crate::types::IssuesCreateMilestoneRequest, + body: &crate::types::IssuesUpdateMilestoneRequest, ) -> ClientResult> { let url = self.client.url( &format!( "/repos/{}/{}/milestones/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&milestone_number.to_string()), ), None, @@ -2404,17 +3249,17 @@ impl Issues { * * This function performs a `GET` to the `/repos/{owner}/{repo}/milestones/{milestone_number}/labels` endpoint. * + * Lists labels for issues in a milestone. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `milestone_number: i64` -- milestone_number parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `milestone_number: i64` -- The number that identifies the milestone. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_labels_for_milestone( &self, @@ -2435,8 +3280,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/milestones/{}/labels?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&milestone_number.to_string()), query_ ), @@ -2459,9 +3304,9 @@ impl Issues { * * As opposed to `list_labels_for_milestone`, this function returns all the pages of the request at once. * + * Lists labels for issues in a milestone. * - * - * FROM: + * FROM: */ pub async fn list_all_labels_for_milestone( &self, @@ -2472,8 +3317,8 @@ impl Issues { let url = self.client.url( &format!( "/repos/{}/{}/milestones/{}/labels", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&milestone_number.to_string()), ), None, @@ -2495,30 +3340,28 @@ impl Issues { * * List issues across owned and member repositories assigned to the authenticated user. * - * **Note**: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this - * reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by - * the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull - * request id, use the "[List pull requests](https://docs.github.com/rest/reference/pulls#list-pull-requests)" endpoint. + * > [!NOTE] + * > GitHub's REST API considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull request id, use the "[List pull requests](https://docs.github.com/rest/pulls/pulls#list-pull-requests)" endpoint. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `filter: crate::types::Filter` -- Indicates which sorts of issues to return. Can be one of: - * \\* `assigned`: Issues assigned to you - * \\* `created`: Issues created by you - * \\* `mentioned`: Issues mentioning you - * \\* `subscribed`: Issues you're subscribed to updates for - * \\* `all` or `repos`: All issues the authenticated user can see, regardless of participation or creation. - * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. Can be either `open`, `closed`, or `all`. + * * `filter: crate::types::Filter` -- Indicates which sorts of issues to return. `assigned` means issues assigned to you. `created` means issues created by you. `mentioned` means issues mentioning you. `subscribed` means issues you're subscribed to updates for. `all` or `repos` means all issues you can see, regardless of participation or creation. + * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. * * `labels: &str` -- A list of comma separated label names. Example: `bug,ui,@high`. - * * `sort: crate::types::IssuesListSort` -- What to sort results by. Can be either `created`, `updated`, `comments`. - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `sort: crate::types::IssuesListSort` -- What to sort results by. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_authenticated_user( &self, @@ -2577,12 +3420,17 @@ impl Issues { * * List issues across owned and member repositories assigned to the authenticated user. * - * **Note**: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this - * reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by - * the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull - * request id, use the "[List pull requests](https://docs.github.com/rest/reference/pulls#list-pull-requests)" endpoint. + * > [!NOTE] + * > GitHub's REST API considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the `pull_request` key. Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull request id, use the "[List pull requests](https://docs.github.com/rest/pulls/pulls#list-pull-requests)" endpoint. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: */ pub async fn list_all_for_authenticated_user( &self, diff --git a/github/src/lib.rs b/github/src/lib.rs index c3131aa3..d81706d1 100644 --- a/github/src/lib.rs +++ b/github/src/lib.rs @@ -14,7 +14,7 @@ //! //! | name | url | //! |----|----| -//! | Support | | +//! | Support | | //! //! ### License //! @@ -119,10 +119,10 @@ //! use base64::{Engine, engine::general_purpose::STANDARD}; //! //! let app_id_str = env::var("GH_APP_ID").unwrap(); -//! let app_id = app_id_str.parse::().unwrap(); +//! let app_id = app_id_str.parse::().unwrap(); //! //! let app_installation_id_str = env::var("GH_INSTALLATION_ID").unwrap(); -//! let app_installation_id = app_installation_id_str.parse::().unwrap(); +//! let app_installation_id = app_installation_id_str.parse::().unwrap(); //! //! let encoded_private_key = env::var("GH_PRIVATE_KEY").unwrap(); //! let private_key = STANDARD.decode(encoded_private_key).unwrap(); @@ -183,22 +183,44 @@ pub mod apps; pub mod auth; /// Monitor charges and usage from Actions and Packages. pub mod billing; +/// Endpoints to manage campaigns via the REST API. +pub mod campaigns; /// Rich interactions with checks run by your integrations. pub mod checks; +/// Interact with GitHub Classroom. +pub mod classroom; /// Retrieve code scanning alerts from a repository. pub mod code_scanning; +/// Endpoints to manage Code security using the REST API. +pub mod code_security; /// Insight into codes of conduct for your communities. pub mod codes_of_conduct; +/// Endpoints to manage Codespaces using the REST API. +pub mod codespaces; +/// Endpoints to manage Copilot using the REST API. +pub mod copilot; +/// Revoke compromised or leaked GitHub credentials. +pub mod credentials; +/// Endpoints to manage Dependabot. +pub mod dependabot; +/// Endpoints to access Dependency Graph features. +pub mod dependency_graph; /// List emojis available to use on GitHub. pub mod emojis; -/// Administer a GitHub enterprise. -pub mod enterprise_admin; +/// Endpoints to manage GitHub Enterprise Team memberships. +pub mod enterprise_team_memberships; +/// Endpoints to manage GitHub Enterprise Team organization assignments. +pub mod enterprise_team_organizations; +/// Endpoints to manage GitHub Enterprise Teams. +pub mod enterprise_teams; /// View, modify your gists. pub mod gists; /// Raw Git functionality. pub mod git; /// View gitignore templates. pub mod gitignore; +/// Manage hosted compute networking resources. +pub mod hosted_compute; #[cfg(feature = "httpcache")] #[cfg_attr(docsrs, doc(cfg(feature = "httpcache")))] pub mod http_cache; @@ -208,19 +230,21 @@ pub mod interactions; pub mod issues; /// View various OSS licenses. pub mod licenses; -/// Render Github flavored markdown. +/// Render GitHub flavored Markdown. pub mod markdown; /// Endpoints that give information about the API. pub mod meta; /// Move projects to or from GitHub. pub mod migrations; -/// Manage access of OAuth applications. -pub mod oauth_authorizations; -/// Interact with GitHub Orgs. +/// Endpoints to manage GitHub OIDC configuration using the REST API. +pub mod oidc; +/// Interact with organizations. pub mod orgs; /// Manage packages for authenticated users and organizations. pub mod packages; -/// Interact with GitHub Projects. +/// Manage private registry configurations. +pub mod private_registries; +/// Endpoints to manage Projects using the REST API. pub mod projects; /// Interact with GitHub Pull Requests. pub mod pulls; @@ -230,12 +254,12 @@ pub mod rate_limit; pub mod reactions; /// Interact with GitHub Repos. pub mod repos; -/// Provisioning of GitHub organization membership for SCIM-enabled providers. -pub mod scim; -/// Look for stuff on GitHub. +/// Search for specific items on GitHub. pub mod search; /// Retrieve secret scanning alerts from a repository. pub mod secret_scanning; +/// Manage security advisories. +pub mod security_advisories; /// Interact with GitHub Teams. pub mod teams; pub mod types; @@ -479,7 +503,7 @@ impl Client { self.credentials = credentials.into(); } - fn credentials( + fn get_credentials( &self, authentication: crate::auth::AuthenticationConstraint, ) -> Option<&crate::auth::Credentials> { @@ -491,7 +515,7 @@ impl Client { ) => creds, ( crate::auth::AuthenticationConstraint::JWT, - Some(crate::auth::Credentials::InstallationToken(apptoken)), + Some(&crate::auth::Credentials::InstallationToken(ref apptoken)), ) => Some(apptoken.jwt()), (crate::auth::AuthenticationConstraint::JWT, _) => { log::info!( @@ -509,23 +533,23 @@ impl Client { ) -> ClientResult<(reqwest::Url, Option)> { let mut parsed_url = uri.parse::()?; - match self.credentials(authentication) { - Some(crate::auth::Credentials::Client(id, secret)) => { + match self.get_credentials(authentication) { + Some(&crate::auth::Credentials::Client(ref id, ref secret)) => { parsed_url .query_pairs_mut() .append_pair("client_id", id) .append_pair("client_secret", secret); Ok((parsed_url, None)) } - Some(crate::auth::Credentials::Token(token)) => { + Some(&crate::auth::Credentials::Token(ref token)) => { let auth = format!("token {}", token); Ok((parsed_url, Some(auth))) } - Some(crate::auth::Credentials::JWT(jwt)) => { + Some(&crate::auth::Credentials::JWT(ref jwt)) => { let auth = format!("Bearer {}", jwt.token()); Ok((parsed_url, Some(auth))) } - Some(crate::auth::Credentials::InstallationToken(apptoken)) => { + Some(&crate::auth::Credentials::InstallationToken(ref apptoken)) => { let token = if let Some(token) = apptoken.token().await { token } else { @@ -539,7 +563,7 @@ impl Client { let token = self .apps() .create_installation_access_token( - apptoken.installation_id, + apptoken.installation_id as i64, &types::AppsCreateInstallationAccessTokenRequest { permissions: Default::default(), repositories: Default::default(), @@ -804,7 +828,7 @@ impl Client { { self.request_entity( http::Method::GET, - uri, + &uri, message, media, crate::auth::AuthenticationConstraint::Unconstrained, @@ -832,7 +856,7 @@ impl Client { { self.request( http::Method::GET, - uri, + &uri, Message::default(), crate::utils::MediaType::Json, crate::auth::AuthenticationConstraint::Unconstrained, @@ -880,7 +904,7 @@ impl Client { where D: serde::de::DeserializeOwned + 'static + Send, { - self.request_entity(http::Method::POST, uri, message, media, authentication) + self.request_entity(http::Method::POST, &uri, message, media, authentication) .await } @@ -895,7 +919,7 @@ impl Client { { self.request_entity( http::Method::PATCH, - uri, + &uri, message, media, crate::auth::AuthenticationConstraint::Unconstrained, @@ -930,7 +954,7 @@ impl Client { { self.request_entity( http::Method::PUT, - uri, + &uri, message, media, crate::auth::AuthenticationConstraint::Unconstrained, @@ -944,7 +968,7 @@ impl Client { { self.request_entity( http::Method::DELETE, - uri, + &uri, message, crate::utils::MediaType::Json, crate::auth::AuthenticationConstraint::Unconstrained, @@ -1018,9 +1042,14 @@ impl Client { emojis::Emojis::new(self.clone()) } - /// Administer a GitHub enterprise. - pub fn enterprise_admin(&self) -> enterprise_admin::EnterpriseAdmin { - enterprise_admin::EnterpriseAdmin::new(self.clone()) + /// Endpoints to manage Dependabot. + pub fn dependabot(&self) -> dependabot::Dependabot { + dependabot::Dependabot::new(self.clone()) + } + + /// Endpoints to access Dependency Graph features. + pub fn dependency_graph(&self) -> dependency_graph::DependencyGraph { + dependency_graph::DependencyGraph::new(self.clone()) } /// View, modify your gists. @@ -1038,11 +1067,6 @@ impl Client { gitignore::Gitignore::new(self.clone()) } - /// Owner or admin management of users interactions. - pub fn interactions(&self) -> interactions::Interactions { - interactions::Interactions::new(self.clone()) - } - /// Interact with GitHub Issues. pub fn issues(&self) -> issues::Issues { issues::Issues::new(self.clone()) @@ -1053,7 +1077,7 @@ impl Client { licenses::Licenses::new(self.clone()) } - /// Render Github flavored markdown. + /// Render GitHub flavored Markdown. pub fn markdown(&self) -> markdown::Markdown { markdown::Markdown::new(self.clone()) } @@ -1068,12 +1092,12 @@ impl Client { migrations::Migrations::new(self.clone()) } - /// Manage access of OAuth applications. - pub fn oauth_authorizations(&self) -> oauth_authorizations::OauthAuthorizations { - oauth_authorizations::OauthAuthorizations::new(self.clone()) + /// Endpoints to manage GitHub OIDC configuration using the REST API. + pub fn oidc(&self) -> oidc::Oidc { + oidc::Oidc::new(self.clone()) } - /// Interact with GitHub Orgs. + /// Interact with organizations. pub fn orgs(&self) -> orgs::Orgs { orgs::Orgs::new(self.clone()) } @@ -1083,11 +1107,6 @@ impl Client { packages::Packages::new(self.clone()) } - /// Interact with GitHub Projects. - pub fn projects(&self) -> projects::Projects { - projects::Projects::new(self.clone()) - } - /// Interact with GitHub Pull Requests. pub fn pulls(&self) -> pulls::Pulls { pulls::Pulls::new(self.clone()) @@ -1108,12 +1127,7 @@ impl Client { repos::Repos::new(self.clone()) } - /// Provisioning of GitHub organization membership for SCIM-enabled providers. - pub fn scim(&self) -> scim::Scim { - scim::Scim::new(self.clone()) - } - - /// Look for stuff on GitHub. + /// Search for specific items on GitHub. pub fn search(&self) -> search::Search { search::Search::new(self.clone()) } @@ -1132,4 +1146,78 @@ impl Client { pub fn users(&self) -> users::Users { users::Users::new(self.clone()) } + + /// Endpoints to manage Codespaces using the REST API. + pub fn codespaces(&self) -> codespaces::Codespaces { + codespaces::Codespaces::new(self.clone()) + } + + /// Endpoints to manage Copilot using the REST API. + pub fn copilot(&self) -> copilot::Copilot { + copilot::Copilot::new(self.clone()) + } + + /// Manage security advisories. + pub fn security_advisories(&self) -> security_advisories::SecurityAdvisories { + security_advisories::SecurityAdvisories::new(self.clone()) + } + + /// Owner or admin management of users interactions. + pub fn interactions(&self) -> interactions::Interactions { + interactions::Interactions::new(self.clone()) + } + + /// Interact with GitHub Classroom. + pub fn classroom(&self) -> classroom::Classroom { + classroom::Classroom::new(self.clone()) + } + + /// Endpoints to manage GitHub Enterprise Teams. + pub fn enterprise_teams(&self) -> enterprise_teams::EnterpriseTeams { + enterprise_teams::EnterpriseTeams::new(self.clone()) + } + + /// Endpoints to manage GitHub Enterprise Team memberships. + pub fn enterprise_team_memberships( + &self, + ) -> enterprise_team_memberships::EnterpriseTeamMemberships { + enterprise_team_memberships::EnterpriseTeamMemberships::new(self.clone()) + } + + /// Endpoints to manage GitHub Enterprise Team organization assignments. + pub fn enterprise_team_organizations( + &self, + ) -> enterprise_team_organizations::EnterpriseTeamOrganizations { + enterprise_team_organizations::EnterpriseTeamOrganizations::new(self.clone()) + } + + /// Endpoints to manage Code security using the REST API. + pub fn code_security(&self) -> code_security::CodeSecurity { + code_security::CodeSecurity::new(self.clone()) + } + + /// Manage private registry configurations. + pub fn private_registries(&self) -> private_registries::PrivateRegistries { + private_registries::PrivateRegistries::new(self.clone()) + } + + /// Manage hosted compute networking resources. + pub fn hosted_compute(&self) -> hosted_compute::HostedCompute { + hosted_compute::HostedCompute::new(self.clone()) + } + + /// Revoke compromised or leaked GitHub credentials. + pub fn credentials(&self) -> credentials::Credentials { + credentials::Credentials::new(self.clone()) + } + + /// Endpoints to manage campaigns via the REST API. + pub fn campaigns(&self) -> campaigns::Campaigns { + campaigns::Campaigns::new(self.clone()) + } + + /// Endpoints to manage Projects using the REST API. + pub fn projects(&self) -> projects::Projects { + projects::Projects::new(self.clone()) + } } diff --git a/github/src/licenses.rs b/github/src/licenses.rs index 64be31f3..8f884667 100644 --- a/github/src/licenses.rs +++ b/github/src/licenses.rs @@ -16,22 +16,22 @@ impl Licenses { * * This function performs a `GET` to the `/licenses` endpoint. * + * Lists the most commonly used licenses on GitHub. For more information, see "[Licensing a repository ](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository)." * - * - * FROM: + * FROM: * * **Parameters:** * * * `featured: bool` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn get_all_commonly_used( &self, featured: bool, per_page: i64, page: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if featured { query_args.push(("featured".to_string(), featured.to_string())); @@ -61,14 +61,14 @@ impl Licenses { * * As opposed to `get_all_commonly_used`, this function returns all the pages of the request at once. * + * Lists the most commonly used licenses on GitHub. For more information, see "[Licensing a repository ](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository)." * - * - * FROM: + * FROM: */ pub async fn get_all_all_commonly_used( &self, featured: bool, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if featured { query_args.push(("featured".to_string(), featured.to_string())); @@ -90,22 +90,19 @@ impl Licenses { * * This function performs a `GET` to the `/licenses/{license}` endpoint. * + * Gets information about a specific license. For more information, see "[Licensing a repository ](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository)." * - * - * FROM: + * FROM: * * **Parameters:** * * * `license: &str` */ - pub async fn get( - &self, - license: &str, - ) -> ClientResult> { + pub async fn get(&self, license: &str) -> ClientResult> { let url = self.client.url( &format!( "/licenses/{}", - crate::progenitor_support::encode_path(license), + crate::progenitor_support::encode_path(&license.to_string()), ), None, ); @@ -126,25 +123,36 @@ impl Licenses { * * This method returns the contents of the repository's license file, if one is detected. * - * Similar to [Get repository content](https://docs.github.com/rest/reference/repos#get-repository-content), this method also supports [custom media types](https://docs.github.com/rest/overview/media-types) for retrieving the raw license content or rendered license HTML. + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw contents of the license. + * - **`application/vnd.github.html+json`**: Returns the license contents in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup). + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The Git reference for the results you want to list. The `ref` for a branch can be formatted either as `refs/heads/` or simply ``. To reference a pull request use `refs/pull//merge`. */ pub async fn get_for_repo( &self, owner: &str, repo: &str, + ref_: &str, ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/license", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/license?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); diff --git a/github/src/markdown.rs b/github/src/markdown.rs index 5912e2d6..dd03592c 100644 --- a/github/src/markdown.rs +++ b/github/src/markdown.rs @@ -16,15 +16,15 @@ impl Markdown { * * This function performs a `POST` to the `/markdown` endpoint. * + * Depending on what is rendered in the Markdown, you may need to provide additional token scopes for labels, such as `issues:read` or `pull_requests:read`. * - * - * FROM: + * FROM: */ pub async fn render( &self, body: &crate::types::MarkdownRenderRequest, ) -> ClientResult> { - let url = self.client.url("/markdown", None); + let url = self.client.url(&"/markdown".to_string(), None); self.client .post( &url, @@ -42,13 +42,13 @@ impl Markdown { * * You must send Markdown as plain text (using a `Content-Type` header of `text/plain` or `text/x-markdown`) to this endpoint, rather than using JSON format. In raw mode, [GitHub Flavored Markdown](https://github.github.com/gfm/) is not supported and Markdown will be rendered in plain format like a README.md file. Markdown content must be 400 KB or less. * - * FROM: + * FROM: */ pub async fn render_raw>( &self, body: T, ) -> ClientResult> { - let url = self.client.url("/markdown/raw", None); + let url = self.client.url(&"/markdown/raw".to_string(), None); self.client .post( &url, diff --git a/github/src/meta.rs b/github/src/meta.rs index 920dd93f..e93f7e0b 100644 --- a/github/src/meta.rs +++ b/github/src/meta.rs @@ -18,9 +18,9 @@ impl Meta { * * Get Hypermedia links to resources accessible in GitHub's REST API * - * FROM: + * FROM: */ - pub async fn root(&self) -> ClientResult> { + pub async fn root(&self) -> ClientResult> { let url = self.client.url("", None); self.client .get( @@ -37,14 +37,19 @@ impl Meta { * * This function performs a `GET` to the `/meta` endpoint. * - * Returns meta information about GitHub, including a list of GitHub's IP addresses. For more information, see "[About GitHub's IP addresses](https://help.github.com/articles/about-github-s-ip-addresses/)." + * Returns meta information about GitHub, including a list of GitHub's IP addresses. For more information, see "[About GitHub's IP addresses](https://docs.github.com/articles/about-github-s-ip-addresses/)." * - * **Note:** The IP addresses shown in the documentation's response are only example values. You must always query the API directly to get the latest list of IP addresses. + * The API's response also includes a list of GitHub's domain names. * - * FROM: + * The values shown in the documentation's response are example values. You must always query the API directly to get the latest values. + * + * > [!NOTE] + * > This endpoint returns both IPv4 and IPv6 addresses. However, not all features support IPv6. You should refer to the specific documentation for each feature to determine if IPv6 is supported. + * + * FROM: */ pub async fn get(&self) -> ClientResult> { - let url = self.client.url("/meta", None); + let url = self.client.url(&"/meta".to_string(), None); self.client .get( &url, @@ -62,7 +67,7 @@ impl Meta { * * Get the octocat as ASCII art * - * FROM: + * FROM: * * **Parameters:** * @@ -85,15 +90,65 @@ impl Meta { ) .await } + /** + * Get all API versions. + * + * This function performs a `GET` to the `/versions` endpoint. + * + * Get all supported GitHub API versions. + * + * FROM: + */ + pub async fn get_all_versions( + &self, + ) -> ClientResult>>> { + let url = self.client.url(&"/versions".to_string(), None); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get all API versions. + * + * This function performs a `GET` to the `/versions` endpoint. + * + * As opposed to `get_all_versions`, this function returns all the pages of the request at once. + * + * Get all supported GitHub API versions. + * + * FROM: + */ + pub async fn get_all_all_versions( + &self, + ) -> ClientResult>>> { + let url = self.client.url(&"/versions".to_string(), None); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } /** * Get the Zen of GitHub. * * This function performs a `GET` to the `/zen` endpoint. * * Get a random sentence from the Zen of GitHub + * + * FROM: */ pub async fn get_zen(&self) -> ClientResult> { - let url = self.client.url("/zen", None); + let url = self.client.url(&"/zen".to_string(), None); self.client .get( &url, diff --git a/github/src/migrations.rs b/github/src/migrations.rs index 7f9fdd74..8b229433 100644 --- a/github/src/migrations.rs +++ b/github/src/migrations.rs @@ -16,15 +16,17 @@ impl Migrations { * * This function performs a `GET` to the `/orgs/{org}/migrations` endpoint. * - * Lists the most recent migrations. + * Lists the most recent migrations, including both exports (which can be started through the REST API) and imports (which cannot be started using the REST API). * - * FROM: + * A list of `repositories` is only returned for export migrations. + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". * * `exclude: &[String]` -- Exclude attributes from the API response to improve performance. */ pub async fn list_for_org( @@ -48,7 +50,7 @@ impl Migrations { let url = self.client.url( &format!( "/orgs/{}/migrations?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -70,9 +72,11 @@ impl Migrations { * * As opposed to `list_for_org`, this function returns all the pages of the request at once. * - * Lists the most recent migrations. + * Lists the most recent migrations, including both exports (which can be started through the REST API) and imports (which cannot be started using the REST API). + * + * A list of `repositories` is only returned for export migrations. * - * FROM: + * FROM: */ pub async fn list_all_for_org( &self, @@ -87,7 +91,7 @@ impl Migrations { let url = self.client.url( &format!( "/orgs/{}/migrations?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -109,11 +113,11 @@ impl Migrations { * * Initiates the generation of a migration archive. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn start_for_org( &self, @@ -123,7 +127,7 @@ impl Migrations { let url = self.client.url( &format!( "/orgs/{}/migrations", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -151,12 +155,12 @@ impl Migrations { * * `exported`, which means the migration finished successfully. * * `failed`, which means the migration failed. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `migration_id: i64` -- migration_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `migration_id: i64` -- The unique identifier of the migration. * * `exclude: &[String]` -- Exclude attributes from the API response to improve performance. */ pub async fn get_status_for_org( @@ -173,7 +177,7 @@ impl Migrations { let url = self.client.url( &format!( "/orgs/{}/migrations/{}?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&migration_id.to_string()), query_ ), @@ -196,12 +200,12 @@ impl Migrations { * * Fetches the URL to a migration archive. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `migration_id: i64` -- migration_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `migration_id: i64` -- The unique identifier of the migration. */ pub async fn download_archive_for_org( &self, @@ -211,7 +215,7 @@ impl Migrations { let url = self.client.url( &format!( "/orgs/{}/migrations/{}/archive", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&migration_id.to_string()), ), None, @@ -233,12 +237,12 @@ impl Migrations { * * Deletes a previous migration archive. Migration archives are automatically deleted after seven days. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `migration_id: i64` -- migration_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `migration_id: i64` -- The unique identifier of the migration. */ pub async fn delete_archive_for_org( &self, @@ -248,7 +252,7 @@ impl Migrations { let url = self.client.url( &format!( "/orgs/{}/migrations/{}/archive", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&migration_id.to_string()), ), None, @@ -268,14 +272,14 @@ impl Migrations { * * This function performs a `DELETE` to the `/orgs/{org}/migrations/{migration_id}/repos/{repo_name}/lock` endpoint. * - * Unlocks a repository that was locked for migration. You should unlock each migrated repository and [delete them](https://docs.github.com/rest/reference/repos#delete-a-repository) when the migration is complete and you no longer need the source data. + * Unlocks a repository that was locked for migration. You should unlock each migrated repository and [delete them](https://docs.github.com/rest/repos/repos#delete-a-repository) when the migration is complete and you no longer need the source data. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `migration_id: i64` -- migration_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `migration_id: i64` -- The unique identifier of the migration. * * `repo_name: &str` -- repo_name parameter. */ pub async fn unlock_repo_for_org( @@ -287,9 +291,9 @@ impl Migrations { let url = self.client.url( &format!( "/orgs/{}/migrations/{}/repos/{}/lock", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&migration_id.to_string()), - crate::progenitor_support::encode_path(repo_name), + crate::progenitor_support::encode_path(&repo_name.to_string()), ), None, ); @@ -310,14 +314,14 @@ impl Migrations { * * List all the repositories for this organization migration. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `migration_id: i64` -- migration_id parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `migration_id: i64` -- The unique identifier of the migration. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_repos_for_org( &self, @@ -337,7 +341,7 @@ impl Migrations { let url = self.client.url( &format!( "/orgs/{}/migrations/{}/repositories?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&migration_id.to_string()), query_ ), @@ -362,7 +366,7 @@ impl Migrations { * * List all the repositories for this organization migration. * - * FROM: + * FROM: */ pub async fn list_all_repos_for_org( &self, @@ -372,7 +376,7 @@ impl Migrations { let url = self.client.url( &format!( "/orgs/{}/migrations/{}/repositories", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&migration_id.to_string()), ), None, @@ -394,6 +398,9 @@ impl Migrations { * * View the progress of an import. * + * > [!WARNING] + * > **Endpoint closing down notice:** Due to very low levels of usage and available alternatives, this endpoint is closing down and will no longer be available from 00:00 UTC on April 12, 2024. For more details and alternatives, see the [changelog](https://gh.io/source-imports-api-deprecation). + * * **Import status** * * This section includes details about the possible values of the `status` field of the Import Progress response. @@ -408,11 +415,11 @@ impl Migrations { * * If there are problems, you will see one of these in the `status` field: * - * * `auth_failed` - the import requires authentication in order to connect to the original repository. To update authentication for the import, please see the [Update an import](https://docs.github.com/rest/reference/migrations#update-an-import) section. - * * `error` - the import encountered an error. The import progress response will include the `failed_step` and an error message. Contact [GitHub Support](https://support.github.com/contact?tags=rest-api) for more information. - * * `detection_needs_auth` - the importer requires authentication for the originating repository to continue detection. To update authentication for the import, please see the [Update an import](https://docs.github.com/rest/reference/migrations#update-an-import) section. - * * `detection_found_nothing` - the importer didn't recognize any source control at the URL. To resolve, [Cancel the import](https://docs.github.com/rest/reference/migrations#cancel-an-import) and [retry](https://docs.github.com/rest/reference/migrations#start-an-import) with the correct URL. - * * `detection_found_multiple` - the importer found several projects or repositories at the provided URL. When this is the case, the Import Progress response will also include a `project_choices` field with the possible project choices as values. To update project choice, please see the [Update an import](https://docs.github.com/rest/reference/migrations#update-an-import) section. + * * `auth_failed` - the import requires authentication in order to connect to the original repository. To update authentication for the import, please see the [Update an import](https://docs.github.com/rest/migrations/source-imports#update-an-import) section. + * * `error` - the import encountered an error. The import progress response will include the `failed_step` and an error message. Contact [GitHub Support](https://support.github.com/contact?tags=dotcom-rest-api) for more information. + * * `detection_needs_auth` - the importer requires authentication for the originating repository to continue detection. To update authentication for the import, please see the [Update an import](https://docs.github.com/rest/migrations/source-imports#update-an-import) section. + * * `detection_found_nothing` - the importer didn't recognize any source control at the URL. To resolve, [Cancel the import](https://docs.github.com/rest/migrations/source-imports#cancel-an-import) and [retry](https://docs.github.com/rest/migrations/source-imports#start-an-import) with the correct URL. + * * `detection_found_multiple` - the importer found several projects or repositories at the provided URL. When this is the case, the Import Progress response will also include a `project_choices` field with the possible project choices as values. To update project choice, please see the [Update an import](https://docs.github.com/rest/migrations/source-imports#update-an-import) section. * * **The project_choices field** * @@ -427,12 +434,12 @@ impl Migrations { * * `large_files_size` - the total size in gigabytes of files larger than 100MB found in the originating repository. * * `large_files_count` - the total number of files larger than 100MB found in the originating repository. To see a list of these files, make a "Get Large Files" request. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_import_status( &self, @@ -442,8 +449,8 @@ impl Migrations { let url = self.client.url( &format!( "/repos/{}/{}/import", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -463,13 +470,18 @@ impl Migrations { * This function performs a `PUT` to the `/repos/{owner}/{repo}/import` endpoint. * * Start a source import to a GitHub repository using GitHub Importer. + * Importing into a GitHub repository with GitHub Actions enabled is not supported and will + * return a status `422 Unprocessable Entity` response. + * + * > [!WARNING] + * > **Endpoint closing down notice:** Due to very low levels of usage and available alternatives, this endpoint is closing down and will no longer be available from 00:00 UTC on April 12, 2024. For more details and alternatives, see the [changelog](https://gh.io/source-imports-api-deprecation). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn start_import( &self, @@ -480,8 +492,8 @@ impl Migrations { let url = self.client.url( &format!( "/repos/{}/{}/import", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -502,12 +514,15 @@ impl Migrations { * * Stop an import for a repository. * - * FROM: + * > [!WARNING] + * > **Endpoint closing down notice:** Due to very low levels of usage and available alternatives, this endpoint is closing down and will no longer be available from 00:00 UTC on April 12, 2024. For more details and alternatives, see the [changelog](https://gh.io/source-imports-api-deprecation). + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn cancel_import( &self, @@ -517,8 +532,8 @@ impl Migrations { let url = self.client.url( &format!( "/repos/{}/{}/import", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -540,12 +555,19 @@ impl Migrations { * An import can be updated with credentials or a project choice by passing in the appropriate parameters in this API * request. If no parameters are provided, the import will be restarted. * - * FROM: + * Some servers (e.g. TFS servers) can have several projects at a single URL. In those cases the import progress will + * have the status `detection_found_multiple` and the Import Progress response will include a `project_choices` array. + * You can select the project to import by providing one of the objects in the `project_choices` array in the update request. + * + * > [!WARNING] + * > **Endpoint closing down notice:** Due to very low levels of usage and available alternatives, this endpoint is closing down and will no longer be available from 00:00 UTC on April 12, 2024. For more details and alternatives, see the [changelog](https://gh.io/source-imports-api-deprecation). + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn update_import( &self, @@ -556,8 +578,8 @@ impl Migrations { let url = self.client.url( &format!( "/repos/{}/{}/import", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -578,14 +600,17 @@ impl Migrations { * * Each type of source control system represents authors in a different way. For example, a Git commit author has a display name and an email address, but a Subversion commit author just has a username. The GitHub Importer will make the author information valid, but the author might not be correct. For example, it will change the bare Subversion username `hubot` into something like `hubot `. * - * This endpoint and the [Map a commit author](https://docs.github.com/rest/reference/migrations#map-a-commit-author) endpoint allow you to provide correct Git author information. + * This endpoint and the [Map a commit author](https://docs.github.com/rest/migrations/source-imports#map-a-commit-author) endpoint allow you to provide correct Git author information. * - * FROM: + * > [!WARNING] + * > **Endpoint closing down notice:** Due to very low levels of usage and available alternatives, this endpoint is closing down and will no longer be available from 00:00 UTC on April 12, 2024. For more details and alternatives, see the [changelog](https://gh.io/source-imports-api-deprecation). + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `since: i64` -- A user ID. Only return users with an ID greater than this ID. */ pub async fn get_commit_authors( @@ -602,8 +627,8 @@ impl Migrations { let url = self.client.url( &format!( "/repos/{}/{}/import/authors?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -627,9 +652,12 @@ impl Migrations { * * Each type of source control system represents authors in a different way. For example, a Git commit author has a display name and an email address, but a Subversion commit author just has a username. The GitHub Importer will make the author information valid, but the author might not be correct. For example, it will change the bare Subversion username `hubot` into something like `hubot `. * - * This endpoint and the [Map a commit author](https://docs.github.com/rest/reference/migrations#map-a-commit-author) endpoint allow you to provide correct Git author information. + * This endpoint and the [Map a commit author](https://docs.github.com/rest/migrations/source-imports#map-a-commit-author) endpoint allow you to provide correct Git author information. + * + * > [!WARNING] + * > **Endpoint closing down notice:** Due to very low levels of usage and available alternatives, this endpoint is closing down and will no longer be available from 00:00 UTC on April 12, 2024. For more details and alternatives, see the [changelog](https://gh.io/source-imports-api-deprecation). * - * FROM: + * FROM: */ pub async fn get_all_commit_authors( &self, @@ -645,8 +673,8 @@ impl Migrations { let url = self.client.url( &format!( "/repos/{}/{}/import/authors?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -666,14 +694,18 @@ impl Migrations { * * This function performs a `PATCH` to the `/repos/{owner}/{repo}/import/authors/{author_id}` endpoint. * - * Update an author's identity for the import. Your application can continue updating authors any time before you push new commits to the repository. + * Update an author's identity for the import. Your application can continue updating authors any time before you push + * new commits to the repository. * - * FROM: + * > [!WARNING] + * > **Endpoint closing down notice:** Due to very low levels of usage and available alternatives, this endpoint is closing down and will no longer be available from 00:00 UTC on April 12, 2024. For more details and alternatives, see the [changelog](https://gh.io/source-imports-api-deprecation). + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `author_id: i64` */ pub async fn map_commit_author( @@ -681,13 +713,13 @@ impl Migrations { owner: &str, repo: &str, author_id: i64, - body: &crate::types::Author, + body: &crate::types::MigrationsMapCommitAuthorRequest, ) -> ClientResult> { let url = self.client.url( &format!( "/repos/{}/{}/import/authors/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&author_id.to_string()), ), None, @@ -709,12 +741,15 @@ impl Migrations { * * List files larger than 100MB found during the import * - * FROM: + * > [!WARNING] + * > **Endpoint closing down notice:** Due to very low levels of usage and available alternatives, this endpoint is closing down and will no longer be available from 00:00 UTC on April 12, 2024. For more details and alternatives, see the [changelog](https://gh.io/source-imports-api-deprecation). + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_large_files( &self, @@ -724,8 +759,8 @@ impl Migrations { let url = self.client.url( &format!( "/repos/{}/{}/import/large_files", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -748,7 +783,10 @@ impl Migrations { * * List files larger than 100MB found during the import * - * FROM: + * > [!WARNING] + * > **Endpoint closing down notice:** Due to very low levels of usage and available alternatives, this endpoint is closing down and will no longer be available from 00:00 UTC on April 12, 2024. For more details and alternatives, see the [changelog](https://gh.io/source-imports-api-deprecation). + * + * FROM: */ pub async fn get_all_large_files( &self, @@ -758,8 +796,8 @@ impl Migrations { let url = self.client.url( &format!( "/repos/{}/{}/import/large_files", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -778,14 +816,21 @@ impl Migrations { * * This function performs a `PATCH` to the `/repos/{owner}/{repo}/import/lfs` endpoint. * - * You can import repositories from Subversion, Mercurial, and TFS that include files larger than 100MB. This ability is powered by [Git LFS](https://git-lfs.github.com). You can learn more about our LFS feature and working with large files [on our help site](https://help.github.com/articles/versioning-large-files/). + * You can import repositories from Subversion, Mercurial, and TFS that include files larger than 100MB. This ability + * is powered by [Git LFS](https://git-lfs.com). + * + * You can learn more about our LFS feature and working with large files [on our help + * site](https://docs.github.com/repositories/working-with-files/managing-large-files). + * + * > [!WARNING] + * > **Endpoint closing down notice:** Due to very low levels of usage and available alternatives, this endpoint is closing down and will no longer be available from 00:00 UTC on April 12, 2024. For more details and alternatives, see the [changelog](https://gh.io/source-imports-api-deprecation). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn set_lfs_preference( &self, @@ -796,8 +841,8 @@ impl Migrations { let url = self.client.url( &format!( "/repos/{}/{}/import/lfs", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -818,12 +863,12 @@ impl Migrations { * * Lists all migrations a user has started. * - * FROM: + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_authenticated_user( &self, @@ -860,12 +905,12 @@ impl Migrations { * * Lists all migrations a user has started. * - * FROM: + * FROM: */ pub async fn list_all_for_authenticated_user( &self, ) -> ClientResult>> { - let url = self.client.url("/user/migrations", None); + let url = self.client.url(&"/user/migrations".to_string(), None); self.client .get_all_pages( &url, @@ -883,13 +928,13 @@ impl Migrations { * * Initiates the generation of a user migration archive. * - * FROM: + * FROM: */ pub async fn start_for_authenticated_user( &self, body: &crate::types::MigrationsStartRequest, ) -> ClientResult> { - let url = self.client.url("/user/migrations", None); + let url = self.client.url(&"/user/migrations".to_string(), None); self.client .post( &url, @@ -912,14 +957,14 @@ impl Migrations { * * `exported` - the migration finished successfully. * * `failed` - the migration failed. * - * Once the migration has been `exported` you can [download the migration archive](https://docs.github.com/rest/reference/migrations#download-a-user-migration-archive). + * Once the migration has been `exported` you can [download the migration archive](https://docs.github.com/rest/migrations/users#download-a-user-migration-archive). * - * FROM: + * FROM: * * **Parameters:** * - * * `migration_id: i64` -- migration_id parameter. - * * `exclude: &[String]` -- The list of events for the GitHub app. + * * `migration_id: i64` -- The unique identifier of the migration. + * * `exclude: &[String]` -- The functions in the package that are affected by the vulnerability. */ pub async fn get_status_for_authenticated_user( &self, @@ -976,11 +1021,11 @@ impl Migrations { * * The archive will also contain an `attachments` directory that includes all attachment files uploaded to GitHub.com and a `repositories` directory that contains the repository's Git data. * - * FROM: + * FROM: * * **Parameters:** * - * * `migration_id: i64` -- migration_id parameter. + * * `migration_id: i64` -- The unique identifier of the migration. */ pub async fn get_archive_for_authenticated_user( &self, @@ -1008,13 +1053,13 @@ impl Migrations { * * This function performs a `DELETE` to the `/user/migrations/{migration_id}/archive` endpoint. * - * Deletes a previous migration archive. Downloadable migration archives are automatically deleted after seven days. Migration metadata, which is returned in the [List user migrations](https://docs.github.com/rest/reference/migrations#list-user-migrations) and [Get a user migration status](https://docs.github.com/rest/reference/migrations#get-a-user-migration-status) endpoints, will continue to be available even after an archive is deleted. + * Deletes a previous migration archive. Downloadable migration archives are automatically deleted after seven days. Migration metadata, which is returned in the [List user migrations](https://docs.github.com/rest/migrations/users#list-user-migrations) and [Get a user migration status](https://docs.github.com/rest/migrations/users#get-a-user-migration-status) endpoints, will continue to be available even after an archive is deleted. * - * FROM: + * FROM: * * **Parameters:** * - * * `migration_id: i64` -- migration_id parameter. + * * `migration_id: i64` -- The unique identifier of the migration. */ pub async fn delete_archive_for_authenticated_user( &self, @@ -1042,13 +1087,13 @@ impl Migrations { * * This function performs a `DELETE` to the `/user/migrations/{migration_id}/repos/{repo_name}/lock` endpoint. * - * Unlocks a repository. You can lock repositories when you [start a user migration](https://docs.github.com/rest/reference/migrations#start-a-user-migration). Once the migration is complete you can unlock each repository to begin using it again or [delete the repository](https://docs.github.com/rest/reference/repos#delete-a-repository) if you no longer need the source data. Returns a status of `404 Not Found` if the repository is not locked. + * Unlocks a repository. You can lock repositories when you [start a user migration](https://docs.github.com/rest/migrations/users#start-a-user-migration). Once the migration is complete you can unlock each repository to begin using it again or [delete the repository](https://docs.github.com/rest/repos/repos#delete-a-repository) if you no longer need the source data. Returns a status of `404 Not Found` if the repository is not locked. * - * FROM: + * FROM: * * **Parameters:** * - * * `migration_id: i64` -- migration_id parameter. + * * `migration_id: i64` -- The unique identifier of the migration. * * `repo_name: &str` -- repo_name parameter. */ pub async fn unlock_repo_for_authenticated_user( @@ -1060,7 +1105,7 @@ impl Migrations { &format!( "/user/migrations/{}/repos/{}/lock", crate::progenitor_support::encode_path(&migration_id.to_string()), - crate::progenitor_support::encode_path(repo_name), + crate::progenitor_support::encode_path(&repo_name.to_string()), ), None, ); @@ -1081,15 +1126,15 @@ impl Migrations { * * Lists all the repositories for this user migration. * - * FROM: + * FROM: * * **Parameters:** * - * * `migration_id: i64` -- migration_id parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `migration_id: i64` -- The unique identifier of the migration. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_repos_for_user( + pub async fn list_repos_for_authenticated_user( &self, migration_id: i64, per_page: i64, @@ -1126,13 +1171,13 @@ impl Migrations { * * This function performs a `GET` to the `/user/migrations/{migration_id}/repositories` endpoint. * - * As opposed to `list_repos_for_user`, this function returns all the pages of the request at once. + * As opposed to `list_repos_for_authenticated_user`, this function returns all the pages of the request at once. * * Lists all the repositories for this user migration. * - * FROM: + * FROM: */ - pub async fn list_all_repos_for_user( + pub async fn list_all_repos_for_authenticated_user( &self, migration_id: i64, ) -> ClientResult>> { diff --git a/github/src/oidc.rs b/github/src/oidc.rs new file mode 100644 index 00000000..63b2faeb --- /dev/null +++ b/github/src/oidc.rs @@ -0,0 +1,87 @@ +use crate::Client; +use crate::ClientResult; + +pub struct Oidc { + pub client: Client, +} + +impl Oidc { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + Oidc { client } + } + + /** + * Get the customization template for an OIDC subject claim for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/actions/oidc/customization/sub` endpoint. + * + * Gets the customization template for an OpenID Connect (OIDC) subject claim. + * + * OAuth app tokens and personal access tokens (classic) need the `read:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn get_oidc_custom_sub_template_for_org( + &self, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/oidc/customization/sub", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set the customization template for an OIDC subject claim for an organization. + * + * This function performs a `PUT` to the `/orgs/{org}/actions/oidc/customization/sub` endpoint. + * + * Creates or updates the customization template for an OpenID Connect (OIDC) subject claim. + * + * OAuth app tokens and personal access tokens (classic) need the `write:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn update_oidc_custom_sub_template_for_org( + &self, + org: &str, + body: &crate::types::OidcCustomSub, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/actions/oidc/customization/sub", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } +} diff --git a/github/src/orgs.rs b/github/src/orgs.rs index e9ea56e5..25485f6d 100644 --- a/github/src/orgs.rs +++ b/github/src/orgs.rs @@ -16,16 +16,17 @@ impl Orgs { * * This function performs a `GET` to the `/organizations` endpoint. * - * Lists all organizations, in the order that they were created on GitHub. + * Lists all organizations, in the order that they were created. * - * **Note:** Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header) to get the URL for the next page of organizations. + * > [!NOTE] + * > Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of organizations. * - * FROM: + * FROM: * * **Parameters:** * * * `since: i64` -- An organization ID. Only return organizations with an ID greater than this ID. - * * `per_page: i64` -- Results per page (max 100). + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list( &self, @@ -58,11 +59,12 @@ impl Orgs { * * As opposed to `list`, this function returns all the pages of the request at once. * - * Lists all organizations, in the order that they were created on GitHub. + * Lists all organizations, in the order that they were created. * - * **Note:** Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header) to get the URL for the next page of organizations. + * > [!NOTE] + * > Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of organizations. * - * FROM: + * FROM: */ pub async fn list_all( &self, @@ -89,22 +91,31 @@ impl Orgs { * * This function performs a `GET` to the `/orgs/{org}` endpoint. * - * To see many of the organization response values, you need to be an authenticated organization owner with the `admin:org` scope. When the value of `two_factor_requirement_enabled` is `true`, the organization requires all members, billing managers, and outside collaborators to enable [two-factor authentication](https://help.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/). + * Gets information about an organization. * - * GitHub Apps with the `Organization plan` permission can use this endpoint to retrieve information about an organization's GitHub plan. See "[Authenticating with GitHub Apps](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/)" for details. For an example response, see 'Response with GitHub plan information' below." + * When the value of `two_factor_requirement_enabled` is `true`, the organization requires all members, billing managers, outside collaborators, guest collaborators, repository collaborators, or everyone with access to any repository within the organization to enable [two-factor authentication](https://docs.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/). * - * FROM: + * To see the full details about an organization, the authenticated user must be an organization owner. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to see the full details about an organization. + * + * To see information about an organization's GitHub plan, GitHub Apps need the `Organization plan` permission. + * + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn get( &self, org: &str, ) -> ClientResult> { let url = self.client.url( - &format!("/orgs/{}", crate::progenitor_support::encode_path(org),), + &format!( + "/orgs/{}", + crate::progenitor_support::encode_path(&org.to_string()), + ), None, ); self.client @@ -117,20 +128,65 @@ impl Orgs { ) .await } + /** + * Delete an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}` endpoint. + * + * Deletes an organization and all its repositories. + * + * The organization login will be unavailable for 90 days after deletion. + * + * Please review the Terms of Service regarding account deletion before using this endpoint: + * + * https://docs.github.com/site-policy/github-terms/github-terms-of-service + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn delete(&self, org: &str) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } /** * Update an organization. * * This function performs a `PATCH` to the `/orgs/{org}` endpoint. * - * **Parameter Deprecation Notice:** GitHub will replace and discontinue `members_allowed_repository_creation_type` in favor of more granular permissions. The new input parameters are `members_can_create_public_repositories`, `members_can_create_private_repositories` for all organizations and `members_can_create_internal_repositories` for organizations associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+. For more information, see the [blog post](https://developer.github.com/changes/2019-12-03-internal-visibility-changes). + * > [!WARNING] + * > **Closing down notice:** GitHub will replace and discontinue `members_allowed_repository_creation_type` in favor of more granular permissions. The new input parameters are `members_can_create_public_repositories`, `members_can_create_private_repositories` for all organizations and `members_can_create_internal_repositories` for organizations associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+. For more information, see the [blog post](https://developer.github.com/changes/2019-12-03-internal-visibility-changes). + * + * > [!WARNING] + * > **Closing down notice:** Code security product enablement for new repositories through the organization API is closing down. Please use [code security configurations](https://docs.github.com/rest/code-security/configurations#set-a-code-security-configuration-as-a-default-for-an-organization) to set defaults instead. For more information on setting a default security configuration, see the [changelog](https://github.blog/changelog/2024-07-09-sunsetting-security-settings-defaults-parameters-in-the-organizations-rest-api/). * - * Enables an authenticated organization owner with the `admin:org` scope to update the organization's profile and member privileges. + * Updates the organization's profile and member privileges. * - * FROM: + * The authenticated user must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` or `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn update( &self, @@ -138,7 +194,10 @@ impl Orgs { body: &crate::types::OrgsUpdateRequest, ) -> ClientResult> { let url = self.client.url( - &format!("/orgs/{}", crate::progenitor_support::encode_path(org),), + &format!( + "/orgs/{}", + crate::progenitor_support::encode_path(&org.to_string()), + ), None, ); self.client @@ -152,46 +211,234 @@ impl Orgs { .await } /** - * Get the audit log for an organization. + * Create an artifact deployment record. + * + * This function performs a `POST` to the `/orgs/{org}/artifacts/metadata/deployment-record` endpoint. + * + * Create or update deployment records for an artifact associated + * with an organization. + * This endpoint allows you to record information about a specific + * artifact, such as its name, digest, environments, cluster, and + * deployment. + * The deployment name has to be uniqe within a cluster (i.e a + * combination of logical, physical environment and cluster) as it + * identifies unique deployment. + * Multiple requests for the same combination of logical, physical + * environment, cluster and deployment name will only create one + * record, successive request will update the existing record. + * This allows for a stable tracking of a deployment where the actual + * deployed artifact can change over time. + * + * FROM: * - * This function performs a `GET` to the `/orgs/{org}/audit-log` endpoint. + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_artifact_deployment_record( + &self, + org: &str, + body: &crate::types::OrgsCreateArtifactDeploymentRecordRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/artifacts/metadata/deployment-record", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Set cluster deployment records. * - * Gets the audit log for an organization. For more information, see "[Reviewing the audit log for your organization](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization)." + * This function performs a `POST` to the `/orgs/{org}/artifacts/metadata/deployment-record/cluster/{cluster}` endpoint. * - * To use this endpoint, you must be an organization owner, and you must use an access token with the `admin:org` scope. GitHub Apps must have the `organization_administration` read permission to use this endpoint. + * Set deployment records for a given cluster. + * If proposed records in the 'deployments' field have identical 'cluster', 'logical_environment', + * 'physical_environment', and 'deployment_name' values as existing records, the existing records will be updated. + * If no existing records match, new records will be created. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `phrase: &str` -- A search phrase. For more information, see [Searching the audit log](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization#searching-the-audit-log). - * * `include: crate::types::Include` -- The event types to include: - * - * - `web` - returns web (non-Git) events - * - `git` - returns Git events - * - `all` - returns both web and Git events - * - * The default is `web`. - * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header). If specified, the query only searches for events after this cursor. - * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header). If specified, the query only searches for events before this cursor. - * * `order: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `cluster: &str` -- The cluster name. */ - pub async fn get_audit_log( + pub async fn set_cluster_deployment_records( &self, org: &str, - phrase: &str, - include: crate::types::Include, - after: &str, - before: &str, - order: crate::types::Order, + cluster: &str, + body: &crate::types::OrgsSetClusterDeploymentRecordsRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/artifacts/metadata/deployment-record/cluster/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&cluster.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Create artifact metadata storage record. + * + * This function performs a `POST` to the `/orgs/{org}/artifacts/metadata/storage-record` endpoint. + * + * Create metadata storage records for artifacts associated with an organization. + * This endpoint will create a new artifact storage record on behalf of any artifact matching the provided digest and + * associated with a repository owned by the organization. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_artifact_storage_record( + &self, + org: &str, + body: &crate::types::OrgsCreateArtifactStorageRecordRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/artifacts/metadata/storage-record", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List artifact deployment records. + * + * This function performs a `GET` to the `/orgs/{org}/artifacts/{subject_digest}/metadata/deployment-records` endpoint. + * + * List deployment records for an artifact metadata associated with an organization. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `subject_digest: &str` -- The SHA256 digest of the artifact, in the form `sha256:HEX_DIGEST`. + */ + pub async fn list_artifact_deployment_records( + &self, + org: &str, + subject_digest: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/artifacts/{}/metadata/deployment-records", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&subject_digest.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List artifact storage records. + * + * This function performs a `GET` to the `/orgs/{org}/artifacts/{subject_digest}/metadata/storage-records` endpoint. + * + * List a collection of artifact storage records with a given subject digest that are associated with repositories owned by an organization. + * + * The collection of storage records returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the `content:read` permission is required. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `subject_digest: &str` -- The parameter should be set to the attestation's subject's SHA256 digest, in the form `sha256:HEX_DIGEST`. + */ + pub async fn list_artifact_storage_records( + &self, + org: &str, + subject_digest: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/artifacts/{}/metadata/storage-records", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&subject_digest.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List attestations by bulk subject digests. + * + * This function performs a `POST` to the `/orgs/{org}/attestations/bulk-list` endpoint. + * + * List a collection of artifact attestations associated with any entry in a list of subject digests owned by an organization. + * + * The collection of attestations returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the `attestations:read` permission is required. + * + * **Please note:** in order to offer meaningful security benefits, an attestation's signature and timestamps **must** be cryptographically verified, and the identity of the attestation signer **must** be validated. Attestations can be verified using the [GitHub CLI `attestation verify` command](https://cli.github.com/manual/gh_attestation_verify). For more information, see [our guide on how to use artifact attestations to establish a build's provenance](https://docs.github.com/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds). + * + * FROM: + * + * **Parameters:** + * + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn list_attestations_bulk( + &self, per_page: i64, - page: i64, - ) -> ClientResult>> { + before: &str, + after: &str, + org: &str, + body: &crate::types::OrgsListAttestationsBulkRequest, + ) -> ClientResult> { let mut query_args: Vec<(String, String)> = Default::default(); if !after.is_empty() { query_args.push(("after".to_string(), after.to_string())); @@ -199,62 +446,125 @@ impl Orgs { if !before.is_empty() { query_args.push(("before".to_string(), before.to_string())); } - if !include.to_string().is_empty() { - query_args.push(("include".to_string(), include.to_string())); - } - if !order.to_string().is_empty() { - query_args.push(("order".to_string(), order.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } - if !phrase.is_empty() { - query_args.push(("phrase".to_string(), phrase.to_string())); - } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/audit-log?{}", - crate::progenitor_support::encode_path(org), + "/orgs/{}/attestations/bulk-list?{}", + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, ); self.client - .get( + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete attestations in bulk. + * + * This function performs a `POST` to the `/orgs/{org}/attestations/delete-request` endpoint. + * + * Delete artifact attestations in bulk by either subject digests or unique ID. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn delete_attestations_bulk(&self, org: &str) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/attestations/delete-request", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( &url, crate::Message { body: None, - content_type: None, + content_type: Some("application/json".to_string()), }, ) .await } /** - * Get the audit log for an organization. + * Delete attestations by subject digest. * - * This function performs a `GET` to the `/orgs/{org}/audit-log` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/attestations/digest/{subject_digest}` endpoint. * - * As opposed to `get_audit_log`, this function returns all the pages of the request at once. + * Delete an artifact attestation by subject digest. * - * Gets the audit log for an organization. For more information, see "[Reviewing the audit log for your organization](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization)." + * FROM: * - * To use this endpoint, you must be an organization owner, and you must use an access token with the `admin:org` scope. GitHub Apps must have the `organization_administration` read permission to use this endpoint. + * **Parameters:** * - * FROM: + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `subject_digest: &str` -- Subject Digest. */ - pub async fn get_all_audit_log( + pub async fn delete_attestations_by_subject_digest( &self, org: &str, - phrase: &str, - include: crate::types::Include, - after: &str, + subject_digest: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/attestations/digest/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&subject_digest.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List attestation repositories. + * + * This function performs a `GET` to the `/orgs/{org}/attestations/repositories` endpoint. + * + * List repositories owned by the provided organization that have created at least one attested artifact + * Results will be sorted in ascending order by repository ID + * + * FROM: + * + * **Parameters:** + * + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `predicate_type: &str` -- Optional filter for fetching attestations with a given predicate type. + * This option accepts `provenance`, `sbom`, `release`, or freeform text + * for custom predicate types. + */ + pub async fn list_attestation_repositories( + &self, + per_page: i64, before: &str, - order: crate::types::Order, - ) -> ClientResult>> { + after: &str, + org: &str, + predicate_type: &str, + ) -> ClientResult>> + { let mut query_args: Vec<(String, String)> = Default::default(); if !after.is_empty() { query_args.push(("after".to_string(), after.to_string())); @@ -262,26 +572,2983 @@ impl Orgs { if !before.is_empty() { query_args.push(("before".to_string(), before.to_string())); } - if !include.to_string().is_empty() { - query_args.push(("include".to_string(), include.to_string())); - } - if !order.to_string().is_empty() { - query_args.push(("order".to_string(), order.to_string())); + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); } - if !phrase.is_empty() { - query_args.push(("phrase".to_string(), phrase.to_string())); + if !predicate_type.is_empty() { + query_args.push(("predicate_type".to_string(), predicate_type.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/audit-log?{}", - crate::progenitor_support::encode_path(org), - query_ + "/orgs/{}/attestations/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List attestation repositories. + * + * This function performs a `GET` to the `/orgs/{org}/attestations/repositories` endpoint. + * + * As opposed to `list_attestation_repositories`, this function returns all the pages of the request at once. + * + * List repositories owned by the provided organization that have created at least one attested artifact + * Results will be sorted in ascending order by repository ID + * + * FROM: + */ + pub async fn list_all_attestation_repositories( + &self, + before: &str, + after: &str, + org: &str, + predicate_type: &str, + ) -> ClientResult>> + { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !predicate_type.is_empty() { + query_args.push(("predicate_type".to_string(), predicate_type.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/attestations/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete attestations by ID. + * + * This function performs a `DELETE` to the `/orgs/{org}/attestations/{attestation_id}` endpoint. + * + * Delete an artifact attestation by unique ID that is associated with a repository owned by an org. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `attestation_id: i64` -- Attestation ID. + */ + pub async fn delete_attestations_by_id( + &self, + org: &str, + attestation_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/attestations/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&attestation_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List attestations. + * + * This function performs a `GET` to the `/orgs/{org}/attestations/{subject_digest}` endpoint. + * + * List a collection of artifact attestations with a given subject digest that are associated with repositories owned by an organization. + * + * The collection of attestations returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the `attestations:read` permission is required. + * + * **Please note:** in order to offer meaningful security benefits, an attestation's signature and timestamps **must** be cryptographically verified, and the identity of the attestation signer **must** be validated. Attestations can be verified using the [GitHub CLI `attestation verify` command](https://cli.github.com/manual/gh_attestation_verify). For more information, see [our guide on how to use artifact attestations to establish a build's provenance](https://docs.github.com/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds). + * + * FROM: + * + * **Parameters:** + * + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `subject_digest: &str` -- The parameter should be set to the attestation's subject's SHA256 digest, in the form `sha256:HEX_DIGEST`. + * * `predicate_type: &str` -- Optional filter for fetching attestations with a given predicate type. + * This option accepts `provenance`, `sbom`, `release`, or freeform text + * for custom predicate types. + */ + pub async fn list_attestations( + &self, + per_page: i64, + before: &str, + after: &str, + org: &str, + subject_digest: &str, + predicate_type: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !predicate_type.is_empty() { + query_args.push(("predicate_type".to_string(), predicate_type.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/attestations/{}?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&subject_digest.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List users blocked by an organization. + * + * This function performs a `GET` to the `/orgs/{org}/blocks` endpoint. + * + * List the users blocked by an organization. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_blocked_users( + &self, + org: &str, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/blocks?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List users blocked by an organization. + * + * This function performs a `GET` to the `/orgs/{org}/blocks` endpoint. + * + * As opposed to `list_blocked_users`, this function returns all the pages of the request at once. + * + * List the users blocked by an organization. + * + * FROM: + */ + pub async fn list_all_blocked_users( + &self, + org: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/orgs/{}/blocks", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Check if a user is blocked by an organization. + * + * This function performs a `GET` to the `/orgs/{org}/blocks/{username}` endpoint. + * + * Returns a 204 if the given user is blocked by the given organization. Returns a 404 if the organization is not blocking the user, or if the user account has been identified as spam by GitHub. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn check_blocked_user( + &self, + org: &str, + username: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/blocks/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Block a user from an organization. + * + * This function performs a `PUT` to the `/orgs/{org}/blocks/{username}` endpoint. + * + * Blocks the given user on behalf of the specified organization and returns a 204. If the organization cannot block the given user a 422 is returned. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn block_user(&self, org: &str, username: &str) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/blocks/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Unblock a user from an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/blocks/{username}` endpoint. + * + * Unblocks the given user on behalf of the specified organization. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn unblock_user( + &self, + org: &str, + username: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/blocks/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List failed organization invitations. + * + * This function performs a `GET` to the `/orgs/{org}/failed_invitations` endpoint. + * + * The return hash contains `failed_at` and `failed_reason` fields which represent the time at which the invitation failed and the reason for the failure. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_failed_invitations( + &self, + org: &str, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/failed_invitations?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List failed organization invitations. + * + * This function performs a `GET` to the `/orgs/{org}/failed_invitations` endpoint. + * + * As opposed to `list_failed_invitations`, this function returns all the pages of the request at once. + * + * The return hash contains `failed_at` and `failed_reason` fields which represent the time at which the invitation failed and the reason for the failure. + * + * FROM: + */ + pub async fn list_all_failed_invitations( + &self, + org: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/orgs/{}/failed_invitations", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List organization webhooks. + * + * This function performs a `GET` to the `/orgs/{org}/hooks` endpoint. + * + * List webhooks for an organization. + * + * The authenticated user must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit + * webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_webhooks( + &self, + org: &str, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/hooks?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List organization webhooks. + * + * This function performs a `GET` to the `/orgs/{org}/hooks` endpoint. + * + * As opposed to `list_webhooks`, this function returns all the pages of the request at once. + * + * List webhooks for an organization. + * + * The authenticated user must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit + * webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + */ + pub async fn list_all_webhooks( + &self, + org: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/orgs/{}/hooks", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create an organization webhook. + * + * This function performs a `POST` to the `/orgs/{org}/hooks` endpoint. + * + * Create a hook that posts payloads in JSON format. + * + * You must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or + * edit webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_webhook( + &self, + org: &str, + body: &crate::types::OrgsCreateWebhookRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/hooks", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get an organization webhook. + * + * This function performs a `GET` to the `/orgs/{org}/hooks/{hook_id}` endpoint. + * + * Returns a webhook configured in an organization. To get only the webhook + * `config` properties, see "[Get a webhook configuration for an organization](/rest/orgs/webhooks#get-a-webhook-configuration-for-an-organization). + * + * You must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit + * webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + */ + pub async fn get_webhook( + &self, + org: &str, + hook_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/hooks/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete an organization webhook. + * + * This function performs a `DELETE` to the `/orgs/{org}/hooks/{hook_id}` endpoint. + * + * Delete a webhook for an organization. + * + * The authenticated user must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit + * webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + */ + pub async fn delete_webhook( + &self, + org: &str, + hook_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/hooks/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update an organization webhook. + * + * This function performs a `PATCH` to the `/orgs/{org}/hooks/{hook_id}` endpoint. + * + * Updates a webhook configured in an organization. When you update a webhook, + * the `secret` will be overwritten. If you previously had a `secret` set, you must + * provide the same `secret` or set a new `secret` or the secret will be removed. If + * you are only updating individual webhook `config` properties, use "[Update a webhook + * configuration for an organization](/rest/orgs/webhooks#update-a-webhook-configuration-for-an-organization)". + * + * You must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit + * webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + */ + pub async fn update_webhook( + &self, + org: &str, + hook_id: i64, + body: &crate::types::OrgsUpdateWebhookRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/hooks/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a webhook configuration for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/hooks/{hook_id}/config` endpoint. + * + * Returns the webhook configuration for an organization. To get more information about the webhook, including the `active` state and `events`, use "[Get an organization webhook ](/rest/orgs/webhooks#get-an-organization-webhook)." + * + * You must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit + * webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + */ + pub async fn get_webhook_config_for_org( + &self, + org: &str, + hook_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/hooks/{}/config", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a webhook configuration for an organization. + * + * This function performs a `PATCH` to the `/orgs/{org}/hooks/{hook_id}/config` endpoint. + * + * Updates the webhook configuration for an organization. To update more information about the webhook, including the `active` state and `events`, use "[Update an organization webhook ](/rest/orgs/webhooks#update-an-organization-webhook)." + * + * You must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit + * webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + */ + pub async fn update_webhook_config_for_org( + &self, + org: &str, + hook_id: i64, + body: &crate::types::AppsUpdateWebhookConfigAppRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/hooks/{}/config", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List deliveries for an organization webhook. + * + * This function performs a `GET` to the `/orgs/{org}/hooks/{hook_id}/deliveries` endpoint. + * + * Returns a list of webhook deliveries for a webhook configured in an organization. + * + * You must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit + * webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `cursor: &str` -- Used for pagination: the starting delivery from which the page of deliveries is fetched. Refer to the `link` header for the next and previous page cursors. + */ + pub async fn list_webhook_deliveries( + &self, + org: &str, + hook_id: i64, + per_page: i64, + cursor: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !cursor.is_empty() { + query_args.push(("cursor".to_string(), cursor.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/hooks/{}/deliveries?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List deliveries for an organization webhook. + * + * This function performs a `GET` to the `/orgs/{org}/hooks/{hook_id}/deliveries` endpoint. + * + * As opposed to `list_webhook_deliveries`, this function returns all the pages of the request at once. + * + * Returns a list of webhook deliveries for a webhook configured in an organization. + * + * You must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit + * webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + */ + pub async fn list_all_webhook_deliveries( + &self, + org: &str, + hook_id: i64, + cursor: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !cursor.is_empty() { + query_args.push(("cursor".to_string(), cursor.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/hooks/{}/deliveries?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a webhook delivery for an organization webhook. + * + * This function performs a `GET` to the `/orgs/{org}/hooks/{hook_id}/deliveries/{delivery_id}` endpoint. + * + * Returns a delivery for a webhook configured in an organization. + * + * You must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit + * webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + * * `delivery_id: i64` + */ + pub async fn get_webhook_delivery( + &self, + org: &str, + hook_id: i64, + delivery_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/hooks/{}/deliveries/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + crate::progenitor_support::encode_path(&delivery_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Redeliver a delivery for an organization webhook. + * + * This function performs a `POST` to the `/orgs/{org}/hooks/{hook_id}/deliveries/{delivery_id}/attempts` endpoint. + * + * Redeliver a delivery for a webhook configured in an organization. + * + * You must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit + * webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + * * `delivery_id: i64` + */ + pub async fn redeliver_webhook_delivery( + &self, + org: &str, + hook_id: i64, + delivery_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/hooks/{}/deliveries/{}/attempts", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + crate::progenitor_support::encode_path(&delivery_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Ping an organization webhook. + * + * This function performs a `POST` to the `/orgs/{org}/hooks/{hook_id}/pings` endpoint. + * + * This will trigger a [ping event](https://docs.github.com/webhooks/#ping-event) + * to be sent to the hook. + * + * You must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit + * webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + */ + pub async fn ping_webhook(&self, org: &str, hook_id: i64) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/hooks/{}/pings", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get route stats by actor. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/route-stats/{actor_type}/{actor_id}` endpoint. + * + * Get API request count statistics for an actor broken down by route within a specified time frame. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `actor_type: crate::types::ApiInsightsActorType` -- The type of the actor. + * * `actor_id: i64` -- The ID of the actor. + * * `min_timestamp: &str` -- The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `max_timestamp: &str` -- The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `sort: &[String]` -- The property to sort the results by. + * * `api_route_substring: &str` -- Providing a substring will filter results where the API route contains the substring. This is a case-insensitive search. + */ + pub async fn api_insights_get_route_stats_by_actor( + &self, + org: &str, + actor_type: crate::types::ApiInsightsActorType, + actor_id: i64, + min_timestamp: &str, + max_timestamp: &str, + page: i64, + per_page: i64, + direction: crate::types::Order, + sort: &[String], + api_route_substring: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !api_route_substring.is_empty() { + query_args.push(( + "api_route_substring".to_string(), + api_route_substring.to_string(), + )); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !sort.is_empty() { + query_args.push(("sort".to_string(), sort.join(" "))); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/route-stats/{}/{}?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&actor_type.to_string()), + crate::progenitor_support::encode_path(&actor_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get route stats by actor. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/route-stats/{actor_type}/{actor_id}` endpoint. + * + * As opposed to `api_insights_get_route_stats_by_actor`, this function returns all the pages of the request at once. + * + * Get API request count statistics for an actor broken down by route within a specified time frame. + * + * FROM: + */ + pub async fn api_insights_get_all_route_stats_by_actor( + &self, + org: &str, + actor_type: crate::types::ApiInsightsActorType, + actor_id: i64, + min_timestamp: &str, + max_timestamp: &str, + direction: crate::types::Order, + sort: &[String], + api_route_substring: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !api_route_substring.is_empty() { + query_args.push(( + "api_route_substring".to_string(), + api_route_substring.to_string(), + )); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + if !sort.is_empty() { + query_args.push(("sort".to_string(), sort.join(" "))); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/route-stats/{}/{}?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&actor_type.to_string()), + crate::progenitor_support::encode_path(&actor_id.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get subject stats. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/subject-stats` endpoint. + * + * Get API request statistics for all subjects within an organization within a specified time frame. Subjects can be users or GitHub Apps. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `min_timestamp: &str` -- The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `max_timestamp: &str` -- The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `sort: &[String]` -- The property to sort the results by. + * * `subject_name_substring: &str` -- Providing a substring will filter results where the subject name contains the substring. This is a case-insensitive search. + */ + pub async fn api_insights_get_subject_stats( + &self, + org: &str, + min_timestamp: &str, + max_timestamp: &str, + page: i64, + per_page: i64, + direction: crate::types::Order, + sort: &[String], + subject_name_substring: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !sort.is_empty() { + query_args.push(("sort".to_string(), sort.join(" "))); + } + if !subject_name_substring.is_empty() { + query_args.push(( + "subject_name_substring".to_string(), + subject_name_substring.to_string(), + )); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/subject-stats?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get subject stats. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/subject-stats` endpoint. + * + * As opposed to `api_insights_get_subject_stats`, this function returns all the pages of the request at once. + * + * Get API request statistics for all subjects within an organization within a specified time frame. Subjects can be users or GitHub Apps. + * + * FROM: + */ + pub async fn api_insights_get_all_subject_stats( + &self, + org: &str, + min_timestamp: &str, + max_timestamp: &str, + direction: crate::types::Order, + sort: &[String], + subject_name_substring: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + if !sort.is_empty() { + query_args.push(("sort".to_string(), sort.join(" "))); + } + if !subject_name_substring.is_empty() { + query_args.push(( + "subject_name_substring".to_string(), + subject_name_substring.to_string(), + )); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/subject-stats?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get summary stats. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/summary-stats` endpoint. + * + * Get overall statistics of API requests made within an organization by all users and apps within a specified time frame. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `min_timestamp: &str` -- The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `max_timestamp: &str` -- The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + */ + pub async fn api_insights_get_summary_stats( + &self, + org: &str, + min_timestamp: &str, + max_timestamp: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/summary-stats?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get summary stats by user. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/summary-stats/users/{user_id}` endpoint. + * + * Get overall statistics of API requests within the organization for a user. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `user_id: &str` -- The ID of the user to query for stats. + * * `min_timestamp: &str` -- The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `max_timestamp: &str` -- The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + */ + pub async fn api_insights_get_summary_stats_by_user( + &self, + org: &str, + user_id: &str, + min_timestamp: &str, + max_timestamp: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/summary-stats/users/{}?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&user_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get summary stats by actor. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/summary-stats/{actor_type}/{actor_id}` endpoint. + * + * Get overall statistics of API requests within the organization made by a specific actor. Actors can be GitHub App installations, OAuth apps or other tokens on behalf of a user. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `min_timestamp: &str` -- The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `max_timestamp: &str` -- The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `actor_type: crate::types::ApiInsightsActorType` -- The type of the actor. + * * `actor_id: i64` -- The ID of the actor. + */ + pub async fn api_insights_get_summary_stats_by_actor( + &self, + org: &str, + min_timestamp: &str, + max_timestamp: &str, + actor_type: crate::types::ApiInsightsActorType, + actor_id: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/summary-stats/{}/{}?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&actor_type.to_string()), + crate::progenitor_support::encode_path(&actor_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get time stats. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/time-stats` endpoint. + * + * Get the number of API requests and rate-limited requests made within an organization over a specified time period. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `min_timestamp: &str` -- The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `max_timestamp: &str` -- The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `timestamp_increment: &str` -- The increment of time used to breakdown the query results (5m, 10m, 1h, etc.). + */ + pub async fn api_insights_get_time_stats( + &self, + org: &str, + min_timestamp: &str, + max_timestamp: &str, + timestamp_increment: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + if !timestamp_increment.is_empty() { + query_args.push(( + "timestamp_increment".to_string(), + timestamp_increment.to_string(), + )); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/time-stats?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get time stats. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/time-stats` endpoint. + * + * As opposed to `api_insights_get_time_stats`, this function returns all the pages of the request at once. + * + * Get the number of API requests and rate-limited requests made within an organization over a specified time period. + * + * FROM: + */ + pub async fn api_insights_get_all_time_stats( + &self, + org: &str, + min_timestamp: &str, + max_timestamp: &str, + timestamp_increment: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + if !timestamp_increment.is_empty() { + query_args.push(( + "timestamp_increment".to_string(), + timestamp_increment.to_string(), + )); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/time-stats?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get time stats by user. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/time-stats/users/{user_id}` endpoint. + * + * Get the number of API requests and rate-limited requests made within an organization by a specific user over a specified time period. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `user_id: &str` -- The ID of the user to query for stats. + * * `min_timestamp: &str` -- The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `max_timestamp: &str` -- The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `timestamp_increment: &str` -- The increment of time used to breakdown the query results (5m, 10m, 1h, etc.). + */ + pub async fn api_insights_get_time_stats_by_user( + &self, + org: &str, + user_id: &str, + min_timestamp: &str, + max_timestamp: &str, + timestamp_increment: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + if !timestamp_increment.is_empty() { + query_args.push(( + "timestamp_increment".to_string(), + timestamp_increment.to_string(), + )); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/time-stats/users/{}?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&user_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get time stats by user. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/time-stats/users/{user_id}` endpoint. + * + * As opposed to `api_insights_get_time_stats_by_user`, this function returns all the pages of the request at once. + * + * Get the number of API requests and rate-limited requests made within an organization by a specific user over a specified time period. + * + * FROM: + */ + pub async fn api_insights_get_all_time_stats_by_user( + &self, + org: &str, + user_id: &str, + min_timestamp: &str, + max_timestamp: &str, + timestamp_increment: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + if !timestamp_increment.is_empty() { + query_args.push(( + "timestamp_increment".to_string(), + timestamp_increment.to_string(), + )); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/time-stats/users/{}?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&user_id.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get time stats by actor. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/time-stats/{actor_type}/{actor_id}` endpoint. + * + * Get the number of API requests and rate-limited requests made within an organization by a specific actor within a specified time period. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `actor_type: crate::types::ApiInsightsActorType` -- The type of the actor. + * * `actor_id: i64` -- The ID of the actor. + * * `min_timestamp: &str` -- The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `max_timestamp: &str` -- The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `timestamp_increment: &str` -- The increment of time used to breakdown the query results (5m, 10m, 1h, etc.). + */ + pub async fn api_insights_get_time_stats_by_actor( + &self, + org: &str, + actor_type: crate::types::ApiInsightsActorType, + actor_id: i64, + min_timestamp: &str, + max_timestamp: &str, + timestamp_increment: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + if !timestamp_increment.is_empty() { + query_args.push(( + "timestamp_increment".to_string(), + timestamp_increment.to_string(), + )); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/time-stats/{}/{}?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&actor_type.to_string()), + crate::progenitor_support::encode_path(&actor_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get time stats by actor. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/time-stats/{actor_type}/{actor_id}` endpoint. + * + * As opposed to `api_insights_get_time_stats_by_actor`, this function returns all the pages of the request at once. + * + * Get the number of API requests and rate-limited requests made within an organization by a specific actor within a specified time period. + * + * FROM: + */ + pub async fn api_insights_get_all_time_stats_by_actor( + &self, + org: &str, + actor_type: crate::types::ApiInsightsActorType, + actor_id: i64, + min_timestamp: &str, + max_timestamp: &str, + timestamp_increment: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + if !timestamp_increment.is_empty() { + query_args.push(( + "timestamp_increment".to_string(), + timestamp_increment.to_string(), + )); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/time-stats/{}/{}?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&actor_type.to_string()), + crate::progenitor_support::encode_path(&actor_id.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get user stats. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/user-stats/{user_id}` endpoint. + * + * Get API usage statistics within an organization for a user broken down by the type of access. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `user_id: &str` -- The ID of the user to query for stats. + * * `min_timestamp: &str` -- The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `max_timestamp: &str` -- The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `sort: &[String]` -- The property to sort the results by. + * * `actor_name_substring: &str` -- Providing a substring will filter results where the actor name contains the substring. This is a case-insensitive search. + */ + pub async fn api_insights_get_user_stats( + &self, + org: &str, + user_id: &str, + min_timestamp: &str, + max_timestamp: &str, + page: i64, + per_page: i64, + direction: crate::types::Order, + sort: &[String], + actor_name_substring: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !actor_name_substring.is_empty() { + query_args.push(( + "actor_name_substring".to_string(), + actor_name_substring.to_string(), + )); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !sort.is_empty() { + query_args.push(("sort".to_string(), sort.join(" "))); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/user-stats/{}?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&user_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get user stats. + * + * This function performs a `GET` to the `/orgs/{org}/insights/api/user-stats/{user_id}` endpoint. + * + * As opposed to `api_insights_get_user_stats`, this function returns all the pages of the request at once. + * + * Get API usage statistics within an organization for a user broken down by the type of access. + * + * FROM: + */ + pub async fn api_insights_get_all_user_stats( + &self, + org: &str, + user_id: &str, + min_timestamp: &str, + max_timestamp: &str, + direction: crate::types::Order, + sort: &[String], + actor_name_substring: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !actor_name_substring.is_empty() { + query_args.push(( + "actor_name_substring".to_string(), + actor_name_substring.to_string(), + )); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !max_timestamp.is_empty() { + query_args.push(("max_timestamp".to_string(), max_timestamp.to_string())); + } + if !min_timestamp.is_empty() { + query_args.push(("min_timestamp".to_string(), min_timestamp.to_string())); + } + if !sort.is_empty() { + query_args.push(("sort".to_string(), sort.join(" "))); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/insights/api/user-stats/{}?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&user_id.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List app installations for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/installations` endpoint. + * + * Lists all GitHub Apps in an organization. The installation count includes + * all GitHub Apps installed on repositories in the organization. + * + * The authenticated user must be an organization owner to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:read` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_app_installations( + &self, + org: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/installations?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List pending organization invitations. + * + * This function performs a `GET` to the `/orgs/{org}/invitations` endpoint. + * + * The return hash contains a `role` field which refers to the Organization + * Invitation role and will be one of the following values: `direct_member`, `admin`, + * `billing_manager`, or `hiring_manager`. If the invitee is not a GitHub + * member, the `login` field in the return hash will be `null`. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `role: crate::types::OrgsListPendingInvitationsRole` -- Filter invitations by their member role. + * * `invitation_source: crate::types::InvitationSource` -- Filter invitations by their invitation source. + */ + pub async fn list_pending_invitations( + &self, + org: &str, + per_page: i64, + page: i64, + role: crate::types::OrgsListPendingInvitationsRole, + invitation_source: crate::types::InvitationSource, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !invitation_source.to_string().is_empty() { + query_args.push(( + "invitation_source".to_string(), + invitation_source.to_string(), + )); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !role.to_string().is_empty() { + query_args.push(("role".to_string(), role.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/invitations?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List pending organization invitations. + * + * This function performs a `GET` to the `/orgs/{org}/invitations` endpoint. + * + * As opposed to `list_pending_invitations`, this function returns all the pages of the request at once. + * + * The return hash contains a `role` field which refers to the Organization + * Invitation role and will be one of the following values: `direct_member`, `admin`, + * `billing_manager`, or `hiring_manager`. If the invitee is not a GitHub + * member, the `login` field in the return hash will be `null`. + * + * FROM: + */ + pub async fn list_all_pending_invitations( + &self, + org: &str, + role: crate::types::OrgsListPendingInvitationsRole, + invitation_source: crate::types::InvitationSource, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !invitation_source.to_string().is_empty() { + query_args.push(( + "invitation_source".to_string(), + invitation_source.to_string(), + )); + } + if !role.to_string().is_empty() { + query_args.push(("role".to_string(), role.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/invitations?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create an organization invitation. + * + * This function performs a `POST` to the `/orgs/{org}/invitations` endpoint. + * + * Invite people to an organization by using their GitHub user ID or their email address. In order to create invitations in an organization, the authenticated user must be an organization owner. + * + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" + * and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_invitation( + &self, + org: &str, + body: &crate::types::OrgsCreateInvitationRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/invitations", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Cancel an organization invitation. + * + * This function performs a `DELETE` to the `/orgs/{org}/invitations/{invitation_id}` endpoint. + * + * Cancel an organization invitation. In order to cancel an organization invitation, the authenticated user must be an organization owner. + * + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `invitation_id: i64` -- The unique identifier of the invitation. + */ + pub async fn cancel_invitation( + &self, + org: &str, + invitation_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/invitations/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&invitation_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List organization invitation teams. + * + * This function performs a `GET` to the `/orgs/{org}/invitations/{invitation_id}/teams` endpoint. + * + * List all teams associated with an invitation. In order to see invitations in an organization, the authenticated user must be an organization owner. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `invitation_id: i64` -- The unique identifier of the invitation. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_invitation_teams( + &self, + org: &str, + invitation_id: i64, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/invitations/{}/teams?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&invitation_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List organization invitation teams. + * + * This function performs a `GET` to the `/orgs/{org}/invitations/{invitation_id}/teams` endpoint. + * + * As opposed to `list_invitation_teams`, this function returns all the pages of the request at once. + * + * List all teams associated with an invitation. In order to see invitations in an organization, the authenticated user must be an organization owner. + * + * FROM: + */ + pub async fn list_all_invitation_teams( + &self, + org: &str, + invitation_id: i64, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/orgs/{}/invitations/{}/teams", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&invitation_id.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List issue types for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/issue-types` endpoint. + * + * Lists all issue types for an organization. OAuth app tokens and personal access tokens (classic) need the read:org scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn list_issue_types( + &self, + org: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/orgs/{}/issue-types", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List issue types for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/issue-types` endpoint. + * + * As opposed to `list_issue_types`, this function returns all the pages of the request at once. + * + * Lists all issue types for an organization. OAuth app tokens and personal access tokens (classic) need the read:org scope to use this endpoint. + * + * FROM: + */ + pub async fn list_all_issue_types( + &self, + org: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/orgs/{}/issue-types", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create issue type for an organization. + * + * This function performs a `POST` to the `/orgs/{org}/issue-types` endpoint. + * + * Create a new issue type for an organization. + * + * You can find out more about issue types in [Managing issue types in an organization](https://docs.github.com/issues/tracking-your-work-with-issues/configuring-issues/managing-issue-types-in-an-organization). + * + * To use this endpoint, the authenticated user must be an administrator for the organization. OAuth app tokens and + * personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_issue_type( + &self, + org: &str, + body: &crate::types::OrganizationCreateIssueType, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/issue-types", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Update issue type for an organization. + * + * This function performs a `PUT` to the `/orgs/{org}/issue-types/{issue_type_id}` endpoint. + * + * Updates an issue type for an organization. + * + * You can find out more about issue types in [Managing issue types in an organization](https://docs.github.com/issues/tracking-your-work-with-issues/configuring-issues/managing-issue-types-in-an-organization). + * + * To use this endpoint, the authenticated user must be an administrator for the organization. OAuth app tokens and + * personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `issue_type_id: i64` -- The unique identifier of the issue type. + */ + pub async fn update_issue_type( + &self, + org: &str, + issue_type_id: i64, + body: &crate::types::OrganizationCreateIssueType, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/issue-types/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&issue_type_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete issue type for an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/issue-types/{issue_type_id}` endpoint. + * + * Deletes an issue type for an organization. + * + * You can find out more about issue types in [Managing issue types in an organization](https://docs.github.com/issues/tracking-your-work-with-issues/configuring-issues/managing-issue-types-in-an-organization). + * + * To use this endpoint, the authenticated user must be an administrator for the organization. OAuth app tokens and + * personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `issue_type_id: i64` -- The unique identifier of the issue type. + */ + pub async fn delete_issue_type( + &self, + org: &str, + issue_type_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/issue-types/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&issue_type_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List organization members. + * + * This function performs a `GET` to the `/orgs/{org}/members` endpoint. + * + * List all users who are members of an organization. If the authenticated user is also a member of this organization then both concealed and public members will be returned. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `filter: crate::types::OrgsListMembersFilter` -- Filter members returned in the list. `2fa_disabled` means that only members without [two-factor authentication](https://github.com/blog/1614-two-factor-authentication) enabled will be returned. `2fa_insecure` means that only members with [insecure 2FA methods](https://docs.github.com/organizations/keeping-your-organization-secure/managing-two-factor-authentication-for-your-organization/requiring-two-factor-authentication-in-your-organization#requiring-secure-methods-of-two-factor-authentication-in-your-organization) will be returned. These options are only available for organization owners. + * * `role: crate::types::OrgsListMembersRole` -- Filter members returned by their role. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_members( + &self, + org: &str, + filter: crate::types::OrgsListMembersFilter, + role: crate::types::OrgsListMembersRole, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !filter.to_string().is_empty() { + query_args.push(("filter".to_string(), filter.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !role.to_string().is_empty() { + query_args.push(("role".to_string(), role.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/members?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List organization members. + * + * This function performs a `GET` to the `/orgs/{org}/members` endpoint. + * + * As opposed to `list_members`, this function returns all the pages of the request at once. + * + * List all users who are members of an organization. If the authenticated user is also a member of this organization then both concealed and public members will be returned. + * + * FROM: + */ + pub async fn list_all_members( + &self, + org: &str, + filter: crate::types::OrgsListMembersFilter, + role: crate::types::OrgsListMembersRole, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !filter.to_string().is_empty() { + query_args.push(("filter".to_string(), filter.to_string())); + } + if !role.to_string().is_empty() { + query_args.push(("role".to_string(), role.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/members?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Check organization membership for a user. + * + * This function performs a `GET` to the `/orgs/{org}/members/{username}` endpoint. + * + * Check if a user is, publicly or privately, a member of the organization. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn check_membership_for_user( + &self, + org: &str, + username: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/members/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove an organization member. + * + * This function performs a `DELETE` to the `/orgs/{org}/members/{username}` endpoint. + * + * Removing a user from this list will remove them from all teams and they will no longer have any access to the organization's repositories. + * + * > [!NOTE] + * > If a user has both direct membership in the organization as well as indirect membership via an enterprise team, only their direct membership will be removed. Their indirect membership via an enterprise team remains until the user is removed from the enterprise team. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn remove_member( + &self, + org: &str, + username: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/members/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get organization membership for a user. + * + * This function performs a `GET` to the `/orgs/{org}/memberships/{username}` endpoint. + * + * In order to get a user's membership with an organization, the authenticated user must be an organization member. The `state` parameter in the response can be used to identify the user's membership status. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn get_membership_for_user( + &self, + org: &str, + username: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/memberships/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Set organization membership for a user. + * + * This function performs a `PUT` to the `/orgs/{org}/memberships/{username}` endpoint. + * + * Only authenticated organization owners can add a member to the organization or update the member's role. + * + * * If the authenticated user is _adding_ a member to the organization, the invited user will receive an email inviting them to the organization. The user's [membership status](https://docs.github.com/rest/orgs/members#get-organization-membership-for-a-user) will be `pending` until they accept the invitation. + * + * * Authenticated users can _update_ a user's membership by passing the `role` parameter. If the authenticated user changes a member's role to `admin`, the affected user will receive an email notifying them that they've been made an organization owner. If the authenticated user changes an owner's role to `member`, no email will be sent. + * + * **Rate limits** + * + * To prevent abuse, organization owners are limited to creating 50 organization invitations for an organization within a 24 hour period. If the organization is more than one month old or on a paid plan, the limit is 500 invitations per 24 hour period. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn set_membership_for_user( + &self, + org: &str, + username: &str, + body: &crate::types::OrgsSetMembershipUserRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/memberships/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Remove organization membership for a user. + * + * This function performs a `DELETE` to the `/orgs/{org}/memberships/{username}` endpoint. + * + * In order to remove a user's membership with an organization, the authenticated user must be an organization owner. + * + * If the specified user is an active member of the organization, this will remove them from the organization. If the specified user has been invited to the organization, this will cancel their invitation. The specified user will receive an email notification in both cases. + * + * > [!NOTE] + * > If a user has both direct membership in the organization as well as indirect membership via an enterprise team, only their direct membership will be removed. Their indirect membership via an enterprise team remains until the user is removed from the enterprise team. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn remove_membership_for_user( + &self, + org: &str, + username: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/memberships/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get all organization roles for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/organization-roles` endpoint. + * + * Lists the organization roles available in this organization. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)." + * + * To use this endpoint, the authenticated user must be one of: + * + * - An administrator for the organization. + * - A user, or a user on a team, with the fine-grained permissions of `read_organization_custom_org_role` in the organization. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn list_org_roles( + &self, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/organization-roles", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove all organization roles for a team. + * + * This function performs a `DELETE` to the `/orgs/{org}/organization-roles/teams/{team_slug}` endpoint. + * + * Removes all assigned organization roles from a team. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)." + * + * The authenticated user must be an administrator for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + */ + pub async fn revoke_all_org_roles_team( + &self, + org: &str, + team_slug: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/organization-roles/teams/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Assign an organization role to a team. + * + * This function performs a `PUT` to the `/orgs/{org}/organization-roles/teams/{team_slug}/{role_id}` endpoint. + * + * Assigns an organization role to a team in an organization. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)." + * + * The authenticated user must be an administrator for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `role_id: i64` -- The unique identifier of the role. + */ + pub async fn assign_team_to_org_role( + &self, + org: &str, + team_slug: &str, + role_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/organization-roles/teams/{}/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + crate::progenitor_support::encode_path(&role_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove an organization role from a team. + * + * This function performs a `DELETE` to the `/orgs/{org}/organization-roles/teams/{team_slug}/{role_id}` endpoint. + * + * Removes an organization role from a team. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)." + * + * The authenticated user must be an administrator for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `role_id: i64` -- The unique identifier of the role. + */ + pub async fn revoke_org_role_team( + &self, + org: &str, + team_slug: &str, + role_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/organization-roles/teams/{}/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + crate::progenitor_support::encode_path(&role_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Remove all organization roles for a user. + * + * This function performs a `DELETE` to the `/orgs/{org}/organization-roles/users/{username}` endpoint. + * + * Revokes all assigned organization roles from a user. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)." + * + * The authenticated user must be an administrator for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn revoke_all_org_roles_user( + &self, + org: &str, + username: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/organization-roles/users/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Assign an organization role to a user. + * + * This function performs a `PUT` to the `/orgs/{org}/organization-roles/users/{username}/{role_id}` endpoint. + * + * Assigns an organization role to a member of an organization. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)." + * + * The authenticated user must be an administrator for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + * * `role_id: i64` -- The unique identifier of the role. + */ + pub async fn assign_user_to_org_role( + &self, + org: &str, + username: &str, + role_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/organization-roles/users/{}/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&role_id.to_string()), ), None, ); self.client - .get_all_pages( + .put( &url, crate::Message { body: None, @@ -291,31 +3558,41 @@ impl Orgs { .await } /** - * List users blocked by an organization. + * Remove an organization role from a user. * - * This function performs a `GET` to the `/orgs/{org}/blocks` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/organization-roles/users/{username}/{role_id}` endpoint. * - * List the users blocked by an organization. + * Remove an organization role from a user. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)." + * + * The authenticated user must be an administrator for the organization to use this endpoint. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. + * * `role_id: i64` -- The unique identifier of the role. */ - pub async fn list_blocked_users( + pub async fn revoke_org_role_user( &self, org: &str, - ) -> ClientResult>> { + username: &str, + role_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/blocks", - crate::progenitor_support::encode_path(org), + "/orgs/{}/organization-roles/users/{}/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&role_id.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -325,29 +3602,41 @@ impl Orgs { .await } /** - * List users blocked by an organization. + * Get an organization role. * - * This function performs a `GET` to the `/orgs/{org}/blocks` endpoint. + * This function performs a `GET` to the `/orgs/{org}/organization-roles/{role_id}` endpoint. * - * As opposed to `list_blocked_users`, this function returns all the pages of the request at once. + * Gets an organization role that is available to this organization. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)." * - * List the users blocked by an organization. + * To use this endpoint, the authenticated user must be one of: + * + * - An administrator for the organization. + * - A user, or a user on a team, with the fine-grained permissions of `read_organization_custom_org_role` in the organization. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `role_id: i64` -- The unique identifier of the role. */ - pub async fn list_all_blocked_users( + pub async fn get_org_role( &self, org: &str, - ) -> ClientResult>> { + role_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/blocks", - crate::progenitor_support::encode_path(org), + "/orgs/{}/organization-roles/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&role_id.to_string()), ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -357,29 +3646,46 @@ impl Orgs { .await } /** - * Check if a user is blocked by an organization. + * List teams that are assigned to an organization role. * - * This function performs a `GET` to the `/orgs/{org}/blocks/{username}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/organization-roles/{role_id}/teams` endpoint. * + * Lists the teams that are assigned to an organization role. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)." * + * To use this endpoint, you must be an administrator for the organization. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `username: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `role_id: i64` -- The unique identifier of the role. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn check_blocked_user( + pub async fn list_org_role_teams( &self, org: &str, - username: &str, - ) -> ClientResult> { + role_id: i64, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/blocks/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/organization-roles/{}/teams?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&role_id.to_string()), + query_ ), None, ); @@ -394,30 +3700,35 @@ impl Orgs { .await } /** - * Block a user from an organization. + * List teams that are assigned to an organization role. * - * This function performs a `PUT` to the `/orgs/{org}/blocks/{username}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/organization-roles/{role_id}/teams` endpoint. * + * As opposed to `list_org_role_teams`, this function returns all the pages of the request at once. * + * Lists the teams that are assigned to an organization role. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)." * - * FROM: + * To use this endpoint, you must be an administrator for the organization. * - * **Parameters:** + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * * `org: &str` - * * `username: &str` + * FROM: */ - pub async fn block_user(&self, org: &str, username: &str) -> ClientResult> { + pub async fn list_all_org_role_teams( + &self, + org: &str, + role_id: i64, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/orgs/{}/blocks/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/organization-roles/{}/teams", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&role_id.to_string()), ), None, ); self.client - .put( + .get_all_pages( &url, crate::Message { body: None, @@ -427,34 +3738,51 @@ impl Orgs { .await } /** - * Unblock a user from an organization. + * List users that are assigned to an organization role. * - * This function performs a `DELETE` to the `/orgs/{org}/blocks/{username}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/organization-roles/{role_id}/users` endpoint. + * + * Lists organization members that are assigned to an organization role. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)." * + * To use this endpoint, you must be an administrator for the organization. * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `username: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `role_id: i64` -- The unique identifier of the role. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn unblock_user( + pub async fn list_org_role_users( &self, org: &str, - username: &str, - ) -> ClientResult> { + role_id: i64, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/blocks/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/organization-roles/{}/users?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&role_id.to_string()), + query_ ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -464,33 +3792,35 @@ impl Orgs { .await } /** - * List SAML SSO authorizations for an organization. + * List users that are assigned to an organization role. * - * This function performs a `GET` to the `/orgs/{org}/credential-authorizations` endpoint. + * This function performs a `GET` to the `/orgs/{org}/organization-roles/{role_id}/users` endpoint. * - * Listing and deleting credential authorizations is available to organizations with GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products). + * As opposed to `list_org_role_users`, this function returns all the pages of the request at once. * - * An authenticated organization owner with the `read:org` scope can list all credential authorizations for an organization that uses SAML single sign-on (SSO). The credentials are either personal access tokens or SSH keys that organization members have authorized for the organization. For more information, see [About authentication with SAML single sign-on](https://help.github.com/en/articles/about-authentication-with-saml-single-sign-on). + * Lists organization members that are assigned to an organization role. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)." * - * FROM: + * To use this endpoint, you must be an administrator for the organization. * - * **Parameters:** + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * * `org: &str` + * FROM: */ - pub async fn list_saml_sso_authorizations( + pub async fn list_all_org_role_users( &self, org: &str, - ) -> ClientResult>> { + role_id: i64, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/orgs/{}/credential-authorizations", - crate::progenitor_support::encode_path(org), + "/orgs/{}/organization-roles/{}/users", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&role_id.to_string()), ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -500,31 +3830,49 @@ impl Orgs { .await } /** - * List SAML SSO authorizations for an organization. + * List outside collaborators for an organization. * - * This function performs a `GET` to the `/orgs/{org}/credential-authorizations` endpoint. + * This function performs a `GET` to the `/orgs/{org}/outside_collaborators` endpoint. * - * As opposed to `list_saml_sso_authorizations`, this function returns all the pages of the request at once. + * List all users who are outside collaborators of an organization. * - * Listing and deleting credential authorizations is available to organizations with GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products). + * FROM: * - * An authenticated organization owner with the `read:org` scope can list all credential authorizations for an organization that uses SAML single sign-on (SSO). The credentials are either personal access tokens or SSH keys that organization members have authorized for the organization. For more information, see [About authentication with SAML single sign-on](https://help.github.com/en/articles/about-authentication-with-saml-single-sign-on). + * **Parameters:** * - * FROM: + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `filter: crate::types::OrgsListMembersFilter` -- Filter members returned in the list. `2fa_disabled` means that only members without [two-factor authentication](https://github.com/blog/1614-two-factor-authentication) enabled will be returned. `2fa_insecure` means that only members with [insecure 2FA methods](https://docs.github.com/organizations/keeping-your-organization-secure/managing-two-factor-authentication-for-your-organization/requiring-two-factor-authentication-in-your-organization#requiring-secure-methods-of-two-factor-authentication-in-your-organization) will be returned. These options are only available for organization owners. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_all_saml_sso_authorizations( + pub async fn list_outside_collaborators( &self, org: &str, - ) -> ClientResult>> { + filter: crate::types::OrgsListMembersFilter, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !filter.to_string().is_empty() { + query_args.push(("filter".to_string(), filter.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/credential-authorizations", - crate::progenitor_support::encode_path(org), + "/orgs/{}/outside_collaborators?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -534,36 +3882,36 @@ impl Orgs { .await } /** - * Remove a SAML SSO authorization for an organization. - * - * This function performs a `DELETE` to the `/orgs/{org}/credential-authorizations/{credential_id}` endpoint. - * - * Listing and deleting credential authorizations is available to organizations with GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products). + * List outside collaborators for an organization. * - * An authenticated organization owner with the `admin:org` scope can remove a credential authorization for an organization that uses SAML SSO. Once you remove someone's credential authorization, they will need to create a new personal access token or SSH key and authorize it for the organization they want to access. + * This function performs a `GET` to the `/orgs/{org}/outside_collaborators` endpoint. * - * FROM: + * As opposed to `list_outside_collaborators`, this function returns all the pages of the request at once. * - * **Parameters:** + * List all users who are outside collaborators of an organization. * - * * `org: &str` - * * `credential_id: i64` + * FROM: */ - pub async fn remove_saml_sso_authorization( + pub async fn list_all_outside_collaborators( &self, org: &str, - credential_id: i64, - ) -> ClientResult> { + filter: crate::types::OrgsListMembersFilter, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !filter.to_string().is_empty() { + query_args.push(("filter".to_string(), filter.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/credential-authorizations/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&credential_id.to_string()), + "/orgs/{}/outside_collaborators?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ ), None, ); self.client - .delete( + .get_all_pages( &url, crate::Message { body: None, @@ -573,76 +3921,72 @@ impl Orgs { .await } /** - * List failed organization invitations. + * Convert an organization member to outside collaborator. * - * This function performs a `GET` to the `/orgs/{org}/failed_invitations` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/outside_collaborators/{username}` endpoint. * - * The return hash contains `failed_at` and `failed_reason` fields which represent the time at which the invitation failed and the reason for the failure. + * When an organization member is converted to an outside collaborator, they'll only have access to the repositories that their current team membership allows. The user will no longer be a member of the organization. For more information, see "[Converting an organization member to an outside collaborator](https://docs.github.com/articles/converting-an-organization-member-to-an-outside-collaborator/)". Converting an organization member to an outside collaborator may be restricted by enterprise administrators. For more information, see "[Enforcing repository management policies in your enterprise](https://docs.github.com/admin/policies/enforcing-policies-for-your-enterprise/enforcing-repository-management-policies-in-your-enterprise#enforcing-a-policy-for-inviting-outside-collaborators-to-repositories)." * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn list_failed_invitations( + pub async fn convert_member_to_outside_collaborator( &self, org: &str, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + username: &str, + body: &crate::types::OrgsConvertMemberOutsideCollaboratorRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/failed_invitations?{}", - crate::progenitor_support::encode_path(org), - query_ + "/orgs/{}/outside_collaborators/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List failed organization invitations. + * Remove outside collaborator from an organization. * - * This function performs a `GET` to the `/orgs/{org}/failed_invitations` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/outside_collaborators/{username}` endpoint. * - * As opposed to `list_failed_invitations`, this function returns all the pages of the request at once. + * Removing a user from this list will remove them from all the organization's repositories. * - * The return hash contains `failed_at` and `failed_reason` fields which represent the time at which the invitation failed and the reason for the failure. + * FROM: + * + * **Parameters:** * - * FROM: + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn list_all_failed_invitations( + pub async fn remove_outside_collaborator( &self, org: &str, - ) -> ClientResult>> { + username: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/failed_invitations", - crate::progenitor_support::encode_path(org), + "/orgs/{}/outside_collaborators/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); self.client - .get_all_pages( + .delete( &url, crate::Message { body: None, @@ -652,38 +3996,80 @@ impl Orgs { .await } /** - * List organization webhooks. + * List requests to access organization resources with fine-grained personal access tokens. * - * This function performs a `GET` to the `/orgs/{org}/hooks` endpoint. + * This function performs a `GET` to the `/orgs/{org}/personal-access-token-requests` endpoint. * + * Lists requests from organization members to access organization resources with a fine-grained personal access token. * + * Only GitHub Apps can use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `sort: crate::types::PersonalAccessTokenSort` -- The property by which to sort the results. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `owner: &[String]` -- The functions in the package that are affected by the vulnerability. + * * `repository: &str` -- The name of the repository to use to filter the results. + * * `permission: &str` -- The permission to use to filter the results. + * * `last_used_before: chrono::DateTime` -- Only show fine-grained personal access tokens used before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `last_used_after: chrono::DateTime` -- Only show fine-grained personal access tokens used after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `token_id: &[String]` -- The functions in the package that are affected by the vulnerability. */ - pub async fn list_webhooks( + pub async fn list_pat_grant_requests( &self, org: &str, per_page: i64, page: i64, - ) -> ClientResult>> { + sort: crate::types::PersonalAccessTokenSort, + direction: crate::types::Order, + owner: &[String], + repository: &str, + permission: &str, + last_used_before: Option>, + last_used_after: Option>, + token_id: &[String], + ) -> ClientResult> { let mut query_args: Vec<(String, String)> = Default::default(); + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if let Some(date) = last_used_after { + query_args.push(("last_used_after".to_string(), date.to_rfc3339())); + } + if let Some(date) = last_used_before { + query_args.push(("last_used_before".to_string(), date.to_rfc3339())); + } + if !owner.is_empty() { + query_args.push(("owner".to_string(), owner.join(" "))); + } if page > 0 { query_args.push(("page".to_string(), page.to_string())); } if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } + if !permission.is_empty() { + query_args.push(("permission".to_string(), permission.to_string())); + } + if !repository.is_empty() { + query_args.push(("repository".to_string(), repository.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !token_id.is_empty() { + query_args.push(("token_id".to_string(), token_id.join(" "))); + } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/hooks?{}", - crate::progenitor_support::encode_path(org), + "/orgs/{}/personal-access-token-requests?{}", + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -699,59 +4085,69 @@ impl Orgs { .await } /** - * List organization webhooks. + * Review requests to access organization resources with fine-grained personal access tokens. * - * This function performs a `GET` to the `/orgs/{org}/hooks` endpoint. + * This function performs a `POST` to the `/orgs/{org}/personal-access-token-requests` endpoint. * - * As opposed to `list_webhooks`, this function returns all the pages of the request at once. + * Approves or denies multiple pending requests to access organization resources via a fine-grained personal access token. * + * Only GitHub Apps can use this endpoint. * + * FROM: * - * FROM: + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn list_all_webhooks( + pub async fn review_pat_grant_requests_in_bulk( &self, org: &str, - ) -> ClientResult>> { + body: &crate::types::OrgsReviewPatGrantRequestsInBulkRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/hooks", - crate::progenitor_support::encode_path(org), + "/orgs/{}/personal-access-token-requests", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .get_all_pages( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Create an organization webhook. + * Review a request to access organization resources with a fine-grained personal access token. * - * This function performs a `POST` to the `/orgs/{org}/hooks` endpoint. + * This function performs a `POST` to the `/orgs/{org}/personal-access-token-requests/{pat_request_id}` endpoint. + * + * Approves or denies a pending request to access organization resources via a fine-grained personal access token. * - * Here's how you can create a hook that posts payloads in JSON format: + * Only GitHub Apps can use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `pat_request_id: i64` -- Unique identifier of the request for access via fine-grained personal access token. */ - pub async fn create_webhook( + pub async fn review_pat_grant_request( &self, org: &str, - body: &crate::types::OrgsCreateWebhookRequest, - ) -> ClientResult> { + pat_request_id: i64, + body: &crate::types::OrgsReviewPatGrantRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/hooks", - crate::progenitor_support::encode_path(org), + "/orgs/{}/personal-access-token-requests/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&pat_request_id.to_string()), ), None, ); @@ -766,29 +4162,44 @@ impl Orgs { .await } /** - * Get an organization webhook. + * List repositories requested to be accessed by a fine-grained personal access token. * - * This function performs a `GET` to the `/orgs/{org}/hooks/{hook_id}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/personal-access-token-requests/{pat_request_id}/repositories` endpoint. * - * Returns a webhook configured in an organization. To get only the webhook `config` properties, see "[Get a webhook configuration for an organization](/rest/reference/orgs#get-a-webhook-configuration-for-an-organization)." + * Lists the repositories a fine-grained personal access token request is requesting access to. * - * FROM: + * Only GitHub Apps can use this endpoint. + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `hook_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `pat_request_id: i64` -- Unique identifier of the request for access via fine-grained personal access token. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn get_webhook( + pub async fn list_pat_grant_request_repositories( &self, org: &str, - hook_id: i64, - ) -> ClientResult> { + pat_request_id: i64, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/hooks/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/orgs/{}/personal-access-token-requests/{}/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&pat_request_id.to_string()), + query_ ), None, ); @@ -803,34 +4214,86 @@ impl Orgs { .await } /** - * Delete an organization webhook. + * List fine-grained personal access tokens with access to organization resources. * - * This function performs a `DELETE` to the `/orgs/{org}/hooks/{hook_id}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/personal-access-tokens` endpoint. * + * Lists approved fine-grained personal access tokens owned by organization members that can access organization resources. * + * Only GitHub Apps can use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `hook_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `sort: crate::types::PersonalAccessTokenSort` -- The property by which to sort the results. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `owner: &[String]` -- The functions in the package that are affected by the vulnerability. + * * `repository: &str` -- The name of the repository to use to filter the results. + * * `permission: &str` -- The permission to use to filter the results. + * * `last_used_before: chrono::DateTime` -- Only show fine-grained personal access tokens used before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `last_used_after: chrono::DateTime` -- Only show fine-grained personal access tokens used after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `token_id: &[String]` -- The functions in the package that are affected by the vulnerability. */ - pub async fn delete_webhook( + pub async fn list_pat_grants( &self, org: &str, - hook_id: i64, - ) -> ClientResult> { + per_page: i64, + page: i64, + sort: crate::types::PersonalAccessTokenSort, + direction: crate::types::Order, + owner: &[String], + repository: &str, + permission: &str, + last_used_before: Option>, + last_used_after: Option>, + token_id: &[String], + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if let Some(date) = last_used_after { + query_args.push(("last_used_after".to_string(), date.to_rfc3339())); + } + if let Some(date) = last_used_before { + query_args.push(("last_used_before".to_string(), date.to_rfc3339())); + } + if !owner.is_empty() { + query_args.push(("owner".to_string(), owner.join(" "))); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !permission.is_empty() { + query_args.push(("permission".to_string(), permission.to_string())); + } + if !repository.is_empty() { + query_args.push(("repository".to_string(), repository.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !token_id.is_empty() { + query_args.push(("token_id".to_string(), token_id.join(" "))); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/hooks/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/orgs/{}/personal-access-tokens?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -840,35 +4303,34 @@ impl Orgs { .await } /** - * Update an organization webhook. + * Update the access to organization resources via fine-grained personal access tokens. * - * This function performs a `PATCH` to the `/orgs/{org}/hooks/{hook_id}` endpoint. + * This function performs a `POST` to the `/orgs/{org}/personal-access-tokens` endpoint. + * + * Updates the access organization members have to organization resources via fine-grained personal access tokens. Limited to revoking a token's existing access. * - * Updates a webhook configured in an organization. When you update a webhook, the `secret` will be overwritten. If you previously had a `secret` set, you must provide the same `secret` or set a new `secret` or the secret will be removed. If you are only updating individual webhook `config` properties, use "[Update a webhook configuration for an organization](/rest/reference/orgs#update-a-webhook-configuration-for-an-organization)." + * Only GitHub Apps can use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `hook_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn update_webhook( + pub async fn update_pat_accesses( &self, org: &str, - hook_id: i64, - body: &crate::types::OrgsUpdateWebhookRequest, - ) -> ClientResult> { + body: &crate::types::OrgsUpdatePatAccessesRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/hooks/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/orgs/{}/personal-access-tokens", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .patch( + .post( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -878,121 +4340,119 @@ impl Orgs { .await } /** - * Get a webhook configuration for an organization. + * Update the access a fine-grained personal access token has to organization resources. * - * This function performs a `GET` to the `/orgs/{org}/hooks/{hook_id}/config` endpoint. + * This function performs a `POST` to the `/orgs/{org}/personal-access-tokens/{pat_id}` endpoint. * - * Returns the webhook configuration for an organization. To get more information about the webhook, including the `active` state and `events`, use "[Get an organization webhook ](/rest/reference/orgs#get-an-organization-webhook)." + * Updates the access an organization member has to organization resources via a fine-grained personal access token. Limited to revoking the token's existing access. Limited to revoking a token's existing access. * - * Access tokens must have the `admin:org_hook` scope, and GitHub Apps must have the `organization_hooks:read` permission. + * Only GitHub Apps can use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `hook_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `pat_id: i64` -- The unique identifier of the fine-grained personal access token. */ - pub async fn get_webhook_config_for_org( + pub async fn update_pat_access( &self, org: &str, - hook_id: i64, - ) -> ClientResult> { + pat_id: i64, + body: &crate::types::OrgsUpdatePatAccessRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/hooks/{}/config", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/orgs/{}/personal-access-tokens/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&pat_id.to_string()), ), None, ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Update a webhook configuration for an organization. + * List repositories a fine-grained personal access token has access to. * - * This function performs a `PATCH` to the `/orgs/{org}/hooks/{hook_id}/config` endpoint. + * This function performs a `GET` to the `/orgs/{org}/personal-access-tokens/{pat_id}/repositories` endpoint. * - * Updates the webhook configuration for an organization. To update more information about the webhook, including the `active` state and `events`, use "[Update an organization webhook ](/rest/reference/orgs#update-an-organization-webhook)." + * Lists the repositories a fine-grained personal access token has access to. * - * Access tokens must have the `admin:org_hook` scope, and GitHub Apps must have the `organization_hooks:write` permission. + * Only GitHub Apps can use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `hook_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `pat_id: i64` -- Unique identifier of the fine-grained personal access token. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn update_webhook_config_for_org( + pub async fn list_pat_grant_repositories( &self, org: &str, - hook_id: i64, - body: &crate::types::AppsUpdateWebhookConfigAppRequest, - ) -> ClientResult> { + pat_id: i64, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/hooks/{}/config", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/orgs/{}/personal-access-tokens/{}/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&pat_id.to_string()), + query_ ), None, ); self.client - .patch( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * List deliveries for an organization webhook. + * Get all custom properties for an organization. * - * This function performs a `GET` to the `/orgs/{org}/hooks/{hook_id}/deliveries` endpoint. + * This function performs a `GET` to the `/orgs/{org}/properties/schema` endpoint. * - * Returns a list of webhook deliveries for a webhook configured in an organization. + * Gets all custom properties defined for an organization. + * Organization members can read these properties. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `hook_id: i64` - * * `per_page: i64` -- Results per page (max 100). - * * `cursor: &str` -- Used for pagination: the starting delivery from which the page of deliveries is fetched. Refer to the `link` header for the next and previous page cursors. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn list_webhook_deliveries( + pub async fn custom_properties_for_repos_get_organization_definitions( &self, org: &str, - hook_id: i64, - per_page: i64, - cursor: &str, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !cursor.is_empty() { - query_args.push(("cursor".to_string(), cursor.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult>> { let url = self.client.url( &format!( - "/orgs/{}/hooks/{}/deliveries?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&hook_id.to_string()), - query_ + "/orgs/{}/properties/schema", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -1007,33 +4467,25 @@ impl Orgs { .await } /** - * List deliveries for an organization webhook. + * Get all custom properties for an organization. * - * This function performs a `GET` to the `/orgs/{org}/hooks/{hook_id}/deliveries` endpoint. + * This function performs a `GET` to the `/orgs/{org}/properties/schema` endpoint. * - * As opposed to `list_webhook_deliveries`, this function returns all the pages of the request at once. + * As opposed to `custom_properties_for_repos_get_organization_definitions`, this function returns all the pages of the request at once. * - * Returns a list of webhook deliveries for a webhook configured in an organization. + * Gets all custom properties defined for an organization. + * Organization members can read these properties. * - * FROM: + * FROM: */ - pub async fn list_all_webhook_deliveries( + pub async fn custom_properties_for_repos_get_all_organization_definitions( &self, org: &str, - hook_id: i64, - cursor: &str, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !cursor.is_empty() { - query_args.push(("cursor".to_string(), cursor.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult>> { let url = self.client.url( &format!( - "/orgs/{}/hooks/{}/deliveries?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&hook_id.to_string()), - query_ + "/orgs/{}/properties/schema", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -1048,77 +4500,78 @@ impl Orgs { .await } /** - * Get a webhook delivery for an organization webhook. + * Create or update custom properties for an organization. * - * This function performs a `GET` to the `/orgs/{org}/hooks/{hook_id}/deliveries/{delivery_id}` endpoint. + * This function performs a `PATCH` to the `/orgs/{org}/properties/schema` endpoint. * - * Returns a delivery for a webhook configured in an organization. + * Creates new or updates existing custom properties defined for an organization in a batch. + * + * If the property already exists, the existing property will be replaced with the new values. + * Missing optional values will fall back to default values, previous values will be overwritten. + * E.g. if a property exists with `values_editable_by: org_and_repo_actors` and it's updated without specifying `values_editable_by`, it will be updated to default value `org_actors`. * - * FROM: + * To use this endpoint, the authenticated user must be one of: + * - An administrator for the organization. + * - A user, or a user on a team, with the fine-grained permission of `custom_properties_org_definitions_manager` in the organization. + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `hook_id: i64` - * * `delivery_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn get_webhook_delivery( + pub async fn custom_properties_for_repos_create_or_update_organization_definitions( &self, org: &str, - hook_id: i64, - delivery_id: i64, - ) -> ClientResult> { + body: &crate::types::OrgsCustomPropertiesReposCreateUpdateOrganizationDefinitionsRequest, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/orgs/{}/hooks/{}/deliveries/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&hook_id.to_string()), - crate::progenitor_support::encode_path(&delivery_id.to_string()), + "/orgs/{}/properties/schema", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .get( + .patch( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Redeliver a delivery for an organization webhook. + * Get a custom property for an organization. * - * This function performs a `POST` to the `/orgs/{org}/hooks/{hook_id}/deliveries/{delivery_id}/attempts` endpoint. + * This function performs a `GET` to the `/orgs/{org}/properties/schema/{custom_property_name}` endpoint. * - * Redeliver a delivery for a webhook configured in an organization. + * Gets a custom property that is defined for an organization. + * Organization members can read these properties. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `hook_id: i64` - * * `delivery_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `custom_property_name: &str` -- The custom property name. */ - pub async fn redeliver_webhook_delivery( + pub async fn custom_properties_for_repos_get_organization_definition( &self, org: &str, - hook_id: i64, - delivery_id: i64, - ) -> ClientResult> { + custom_property_name: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/hooks/{}/deliveries/{}/attempts", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&hook_id.to_string()), - crate::progenitor_support::encode_path(&delivery_id.to_string()), + "/orgs/{}/properties/schema/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&custom_property_name.to_string()), ), None, ); self.client - .post( + .get( &url, crate::Message { body: None, @@ -1128,77 +4581,80 @@ impl Orgs { .await } /** - * Ping an organization webhook. + * Create or update a custom property for an organization. * - * This function performs a `POST` to the `/orgs/{org}/hooks/{hook_id}/pings` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/properties/schema/{custom_property_name}` endpoint. * - * This will trigger a [ping event](https://docs.github.com/webhooks/#ping-event) to be sent to the hook. + * Creates a new or updates an existing custom property that is defined for an organization. * - * FROM: + * To use this endpoint, the authenticated user must be one of: + * - An administrator for the organization. + * - A user, or a user on a team, with the fine-grained permission of `custom_properties_org_definitions_manager` in the organization. + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `hook_id: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `custom_property_name: &str` -- The custom property name. */ - pub async fn ping_webhook(&self, org: &str, hook_id: i64) -> ClientResult> { + pub async fn custom_properties_for_repos_create_or_update_organization_definition( + &self, + org: &str, + custom_property_name: &str, + body: &crate::types::CustomPropertySetPayload, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/hooks/{}/pings", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/orgs/{}/properties/schema/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&custom_property_name.to_string()), ), None, ); self.client - .post( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List app installations for an organization. + * Remove a custom property for an organization. * - * This function performs a `GET` to the `/orgs/{org}/installations` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/properties/schema/{custom_property_name}` endpoint. * - * Lists all GitHub Apps in an organization. The installation count includes all GitHub Apps installed on repositories in the organization. You must be an organization owner with `admin:read` scope to use this endpoint. + * Removes a custom property that is defined for an organization. * - * FROM: + * To use this endpoint, the authenticated user must be one of: + * - An administrator for the organization. + * - A user, or a user on a team, with the fine-grained permission of `custom_properties_org_definitions_manager` in the organization. + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `custom_property_name: &str` -- The custom property name. */ - pub async fn list_app_installations( + pub async fn custom_properties_for_repos_delete_organization_definition( &self, org: &str, - per_page: i64, - page: i64, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + custom_property_name: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/installations?{}", - crate::progenitor_support::encode_path(org), - query_ + "/orgs/{}/properties/schema/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&custom_property_name.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -1208,26 +4664,29 @@ impl Orgs { .await } /** - * List pending organization invitations. + * List custom property values for organization repositories. * - * This function performs a `GET` to the `/orgs/{org}/invitations` endpoint. + * This function performs a `GET` to the `/orgs/{org}/properties/values` endpoint. * - * The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, `hiring_manager`, or `reinstate`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`. + * Lists organization repositories with all of their custom property values. + * Organization members can read these properties. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `repository_query: &str` -- Finds repositories in the organization with a query containing one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as the web interface for GitHub. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/search/search#constructing-a-search-query). See "[Searching for repositories](https://docs.github.com/articles/searching-for-repositories/)" for a detailed list of qualifiers. */ - pub async fn list_pending_invitations( + pub async fn custom_properties_for_repos_get_organization_values( &self, org: &str, per_page: i64, page: i64, - ) -> ClientResult>> { + repository_query: &str, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if page > 0 { query_args.push(("page".to_string(), page.to_string())); @@ -1235,11 +4694,14 @@ impl Orgs { if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } + if !repository_query.is_empty() { + query_args.push(("repository_query".to_string(), repository_query.to_string())); + } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/invitations?{}", - crate::progenitor_support::encode_path(org), + "/orgs/{}/properties/values?{}", + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -1255,24 +4717,32 @@ impl Orgs { .await } /** - * List pending organization invitations. + * List custom property values for organization repositories. * - * This function performs a `GET` to the `/orgs/{org}/invitations` endpoint. + * This function performs a `GET` to the `/orgs/{org}/properties/values` endpoint. * - * As opposed to `list_pending_invitations`, this function returns all the pages of the request at once. + * As opposed to `custom_properties_for_repos_get_organization_values`, this function returns all the pages of the request at once. * - * The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, `hiring_manager`, or `reinstate`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`. + * Lists organization repositories with all of their custom property values. + * Organization members can read these properties. * - * FROM: + * FROM: */ - pub async fn list_all_pending_invitations( + pub async fn custom_properties_for_repos_get_all_organization_values( &self, org: &str, - ) -> ClientResult>> { + repository_query: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !repository_query.is_empty() { + query_args.push(("repository_query".to_string(), repository_query.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/invitations", - crate::progenitor_support::encode_path(org), + "/orgs/{}/properties/values?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ ), None, ); @@ -1287,34 +4757,41 @@ impl Orgs { .await } /** - * Create an organization invitation. + * Create or update custom property values for organization repositories. * - * This function performs a `POST` to the `/orgs/{org}/invitations` endpoint. + * This function performs a `PATCH` to the `/orgs/{org}/properties/values` endpoint. * - * Invite people to an organization by using their GitHub user ID or their email address. In order to create invitations in an organization, the authenticated user must be an organization owner. + * Create new or update existing custom property values for repositories in a batch that belong to an organization. + * Each target repository will have its custom property values updated to match the values provided in the request. + * + * A maximum of 30 repositories can be updated in a single request. + * + * Using a value of `null` for a custom property will remove or 'unset' the property value from the repository. * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * To use this endpoint, the authenticated user must be one of: + * - An administrator for the organization. + * - A user, or a user on a team, with the fine-grained permission of `custom_properties_org_values_editor` in the organization. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn create_invitation( + pub async fn custom_properties_for_repos_create_or_update_organization_values( &self, org: &str, - body: &crate::types::OrgsCreateInvitationRequest, - ) -> ClientResult> { + body: &crate::types::OrgsCustomPropertiesReposCreateUpdateOrganizationValuesRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/invitations", - crate::progenitor_support::encode_path(org), + "/orgs/{}/properties/values", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .post( + .patch( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -1324,36 +4801,44 @@ impl Orgs { .await } /** - * Cancel an organization invitation. - * - * This function performs a `DELETE` to the `/orgs/{org}/invitations/{invitation_id}` endpoint. + * List public organization members. * - * Cancel an organization invitation. In order to cancel an organization invitation, the authenticated user must be an organization owner. + * This function performs a `GET` to the `/orgs/{org}/public_members` endpoint. * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). + * Members of an organization can choose to have their membership publicized or not. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `invitation_id: i64` -- invitation_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn cancel_invitation( + pub async fn list_public_members( &self, org: &str, - invitation_id: i64, - ) -> ClientResult> { + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/invitations/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&invitation_id.to_string()), + "/orgs/{}/public_members?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -1363,47 +4848,29 @@ impl Orgs { .await } /** - * List organization invitation teams. - * - * This function performs a `GET` to the `/orgs/{org}/invitations/{invitation_id}/teams` endpoint. + * List public organization members. * - * List all teams associated with an invitation. In order to see invitations in an organization, the authenticated user must be an organization owner. + * This function performs a `GET` to the `/orgs/{org}/public_members` endpoint. * - * FROM: + * As opposed to `list_public_members`, this function returns all the pages of the request at once. * - * **Parameters:** + * Members of an organization can choose to have their membership publicized or not. * - * * `org: &str` - * * `invitation_id: i64` -- invitation_id parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * FROM: */ - pub async fn list_invitation_teams( + pub async fn list_all_public_members( &self, org: &str, - invitation_id: i64, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult>> { let url = self.client.url( &format!( - "/orgs/{}/invitations/{}/teams?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&invitation_id.to_string()), - query_ + "/orgs/{}/public_members", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -1413,31 +4880,34 @@ impl Orgs { .await } /** - * List organization invitation teams. + * Check public organization membership for a user. * - * This function performs a `GET` to the `/orgs/{org}/invitations/{invitation_id}/teams` endpoint. + * This function performs a `GET` to the `/orgs/{org}/public_members/{username}` endpoint. * - * As opposed to `list_invitation_teams`, this function returns all the pages of the request at once. + * Check if the provided user is a public member of the organization. * - * List all teams associated with an invitation. In order to see invitations in an organization, the authenticated user must be an organization owner. + * FROM: + * + * **Parameters:** * - * FROM: + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn list_all_invitation_teams( + pub async fn check_public_membership_for_user( &self, org: &str, - invitation_id: i64, - ) -> ClientResult>> { + username: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/invitations/{}/teams", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(&invitation_id.to_string()), + "/orgs/{}/public_members/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -1447,59 +4917,36 @@ impl Orgs { .await } /** - * List organization members. + * Set public organization membership for the authenticated user. * - * This function performs a `GET` to the `/orgs/{org}/members` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/public_members/{username}` endpoint. * - * List all users who are members of an organization. If the authenticated user is also a member of this organization then both concealed and public members will be returned. + * The user can publicize their own membership. (A user cannot publicize the membership for another user.) * - * FROM: + * Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)." + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `filter: crate::types::OrgsListMembersFilter` -- Filter members returned in the list. Can be one of: - * \\* `2fa_disabled` - Members without [two-factor authentication](https://github.com/blog/1614-two-factor-authentication) enabled. Available for organization owners. - * \\* `all` - All members the authenticated user can see. - * * `role: crate::types::OrgsListMembersRole` -- Filter members returned by their role. Can be one of: - * \\* `all` - All members of the organization, regardless of role. - * \\* `admin` - Organization owners. - * \\* `member` - Non-owner organization members. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn list_members( + pub async fn set_public_membership_for_authenticated_user( &self, org: &str, - filter: crate::types::OrgsListMembersFilter, - role: crate::types::OrgsListMembersRole, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !filter.to_string().is_empty() { - query_args.push(("filter".to_string(), filter.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - if !role.to_string().is_empty() { - query_args.push(("role".to_string(), role.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + username: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/members?{}", - crate::progenitor_support::encode_path(org), - query_ + "/orgs/{}/public_members/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { body: None, @@ -1509,40 +4956,34 @@ impl Orgs { .await } /** - * List organization members. + * Remove public organization membership for the authenticated user. * - * This function performs a `GET` to the `/orgs/{org}/members` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/public_members/{username}` endpoint. * - * As opposed to `list_members`, this function returns all the pages of the request at once. + * Removes the public membership for the authenticated user from the specified organization, unless public visibility is enforced by default. * - * List all users who are members of an organization. If the authenticated user is also a member of this organization then both concealed and public members will be returned. + * FROM: + * + * **Parameters:** * - * FROM: + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn list_all_members( + pub async fn remove_public_membership_for_authenticated_user( &self, org: &str, - filter: crate::types::OrgsListMembersFilter, - role: crate::types::OrgsListMembersRole, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !filter.to_string().is_empty() { - query_args.push(("filter".to_string(), filter.to_string())); - } - if !role.to_string().is_empty() { - query_args.push(("role".to_string(), role.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + username: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/members?{}", - crate::progenitor_support::encode_path(org), - query_ + "/orgs/{}/public_members/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); self.client - .get_all_pages( + .delete( &url, crate::Message { body: None, @@ -1552,29 +4993,42 @@ impl Orgs { .await } /** - * Check organization membership for a user. + * Get organization ruleset history. * - * This function performs a `GET` to the `/orgs/{org}/members/{username}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/rulesets/{ruleset_id}/history` endpoint. * - * Check if a user is, publicly or privately, a member of the organization. + * Get the history of an organization ruleset. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `username: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `ruleset_id: i64` -- The ID of the ruleset. */ - pub async fn check_membership_for_user( + pub async fn get_org_ruleset_history( &self, org: &str, - username: &str, - ) -> ClientResult> { + per_page: i64, + page: i64, + ruleset_id: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/members/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/rulesets/{}/history?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&ruleset_id.to_string()), + query_ ), None, ); @@ -1589,34 +5043,31 @@ impl Orgs { .await } /** - * Remove an organization member. - * - * This function performs a `DELETE` to the `/orgs/{org}/members/{username}` endpoint. + * Get organization ruleset history. * - * Removing a user from this list will remove them from all teams and they will no longer have any access to the organization's repositories. + * This function performs a `GET` to the `/orgs/{org}/rulesets/{ruleset_id}/history` endpoint. * - * FROM: + * As opposed to `get_org_ruleset_history`, this function returns all the pages of the request at once. * - * **Parameters:** + * Get the history of an organization ruleset. * - * * `org: &str` - * * `username: &str` + * FROM: */ - pub async fn remove_member( + pub async fn get_all_org_ruleset_history( &self, org: &str, - username: &str, - ) -> ClientResult> { + ruleset_id: i64, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/orgs/{}/members/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/rulesets/{}/history", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&ruleset_id.to_string()), ), None, ); self.client - .delete( + .get_all_pages( &url, crate::Message { body: None, @@ -1626,29 +5077,32 @@ impl Orgs { .await } /** - * Get organization membership for a user. + * Get organization ruleset version. * - * This function performs a `GET` to the `/orgs/{org}/memberships/{username}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/rulesets/{ruleset_id}/history/{version_id}` endpoint. * - * In order to get a user's membership with an organization, the authenticated user must be an organization member. The `state` parameter in the response can be used to identify the user's membership status. + * Get a version of an organization ruleset. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `username: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `ruleset_id: i64` -- The ID of the ruleset. + * * `version_id: i64` -- The ID of the version. */ - pub async fn get_membership_for_user( + pub async fn get_org_ruleset_version( &self, org: &str, - username: &str, - ) -> ClientResult> { + ruleset_id: i64, + version_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/memberships/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/rulesets/{}/history/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&ruleset_id.to_string()), + crate::progenitor_support::encode_path(&version_id.to_string()), ), None, ); @@ -1663,82 +5117,65 @@ impl Orgs { .await } /** - * Set organization membership for a user. - * - * This function performs a `PUT` to the `/orgs/{org}/memberships/{username}` endpoint. - * - * Only authenticated organization owners can add a member to the organization or update the member's role. + * List security manager teams. * - * * If the authenticated user is _adding_ a member to the organization, the invited user will receive an email inviting them to the organization. The user's [membership status](https://docs.github.com/rest/reference/orgs#get-organization-membership-for-a-user) will be `pending` until they accept the invitation. - * - * * Authenticated users can _update_ a user's membership by passing the `role` parameter. If the authenticated user changes a member's role to `admin`, the affected user will receive an email notifying them that they've been made an organization owner. If the authenticated user changes an owner's role to `member`, no email will be sent. - * - * **Rate limits** + * This function performs a `GET` to the `/orgs/{org}/security-managers` endpoint. * - * To prevent abuse, the authenticated user is limited to 50 organization invitations per 24 hour period. If the organization is more than one month old or on a paid plan, the limit is 500 invitations per 24 hour period. + * > [!WARNING] + * > **Closing down notice:** This operation is closing down and will be removed starting January 1, 2026. Please use the "[Organization Roles](https://docs.github.com/rest/orgs/organization-roles)" endpoints instead. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `username: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn set_membership_for_user( + pub async fn list_security_manager_teams( &self, org: &str, - username: &str, - body: &crate::types::OrgsSetMembershipUserRequest, - ) -> ClientResult> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/orgs/{}/memberships/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/security-managers", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Remove organization membership for a user. + * List security manager teams. * - * This function performs a `DELETE` to the `/orgs/{org}/memberships/{username}` endpoint. - * - * In order to remove a user's membership with an organization, the authenticated user must be an organization owner. - * - * If the specified user is an active member of the organization, this will remove them from the organization. If the specified user has been invited to the organization, this will cancel their invitation. The specified user will receive an email notification in both cases. + * This function performs a `GET` to the `/orgs/{org}/security-managers` endpoint. * - * FROM: + * As opposed to `list_security_manager_teams`, this function returns all the pages of the request at once. * - * **Parameters:** + * > [!WARNING] + * > **Closing down notice:** This operation is closing down and will be removed starting January 1, 2026. Please use the "[Organization Roles](https://docs.github.com/rest/orgs/organization-roles)" endpoints instead. * - * * `org: &str` - * * `username: &str` + * FROM: */ - pub async fn remove_membership_for_user( + pub async fn list_all_security_manager_teams( &self, org: &str, - username: &str, - ) -> ClientResult> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/orgs/{}/memberships/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/security-managers", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .delete( + .get_all_pages( &url, crate::Message { body: None, @@ -1748,51 +5185,35 @@ impl Orgs { .await } /** - * List outside collaborators for an organization. + * Add a security manager team. * - * This function performs a `GET` to the `/orgs/{org}/outside_collaborators` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/security-managers/teams/{team_slug}` endpoint. * - * List all users who are outside collaborators of an organization. + * > [!WARNING] + * > **Closing down notice:** This operation is closing down and will be removed starting January 1, 2026. Please use the "[Organization Roles](https://docs.github.com/rest/orgs/organization-roles)" endpoints instead. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `filter: crate::types::OrgsListMembersFilter` -- Filter members returned in the list. Can be one of: - * \\* `2fa_disabled` - Members without [two-factor authentication](https://github.com/blog/1614-two-factor-authentication) enabled. Available for organization owners. - * \\* `all` - All members the authenticated user can see. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. */ - pub async fn list_outside_collaborators( + pub async fn add_security_manager_team( &self, org: &str, - filter: crate::types::OrgsListMembersFilter, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !filter.to_string().is_empty() { - query_args.push(("filter".to_string(), filter.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + team_slug: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/outside_collaborators?{}", - crate::progenitor_support::encode_path(org), - query_ + "/orgs/{}/security-managers/teams/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { body: None, @@ -1802,36 +5223,35 @@ impl Orgs { .await } /** - * List outside collaborators for an organization. + * Remove a security manager team. * - * This function performs a `GET` to the `/orgs/{org}/outside_collaborators` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/security-managers/teams/{team_slug}` endpoint. * - * As opposed to `list_outside_collaborators`, this function returns all the pages of the request at once. + * > [!WARNING] + * > **Closing down notice:** This operation is closing down and will be removed starting January 1, 2026. Please use the "[Organization Roles](https://docs.github.com/rest/orgs/organization-roles)" endpoints instead. * - * List all users who are outside collaborators of an organization. + * FROM: * - * FROM: + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. */ - pub async fn list_all_outside_collaborators( + pub async fn remove_security_manager_team( &self, org: &str, - filter: crate::types::OrgsListMembersFilter, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !filter.to_string().is_empty() { - query_args.push(("filter".to_string(), filter.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + team_slug: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/outside_collaborators?{}", - crate::progenitor_support::encode_path(org), - query_ + "/orgs/{}/security-managers/teams/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), ), None, ); self.client - .get_all_pages( + .delete( &url, crate::Message { body: None, @@ -1841,34 +5261,33 @@ impl Orgs { .await } /** - * Convert an organization member to outside collaborator. + * Get immutable releases settings for an organization. * - * This function performs a `PUT` to the `/orgs/{org}/outside_collaborators/{username}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/settings/immutable-releases` endpoint. + * + * Gets the immutable releases policy for repositories in an organization. * - * When an organization member is converted to an outside collaborator, they'll only have access to the repositories that their current team membership allows. The user will no longer be a member of the organization. For more information, see "[Converting an organization member to an outside collaborator](https://help.github.com/articles/converting-an-organization-member-to-an-outside-collaborator/)". + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `username: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn convert_member_to_outside_collaborator( + pub async fn get_immutable_releases_settings( &self, org: &str, - username: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/outside_collaborators/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/settings/immutable-releases", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { body: None, @@ -1878,63 +5297,65 @@ impl Orgs { .await } /** - * Remove outside collaborator from an organization. + * Set immutable releases settings for an organization. * - * This function performs a `DELETE` to the `/orgs/{org}/outside_collaborators/{username}` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/settings/immutable-releases` endpoint. * - * Removing a user from this list will remove them from all the organization's repositories. + * Sets the immutable releases policy for repositories in an organization. + * + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `username: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn remove_outside_collaborator( + pub async fn set_immutable_releases_settings( &self, org: &str, - username: &str, + body: &crate::types::OrgsSetImmutableReleasesSettingsRequest, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/outside_collaborators/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/settings/immutable-releases", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .delete( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List public organization members. + * List selected repositories for immutable releases enforcement. * - * This function performs a `GET` to the `/orgs/{org}/public_members` endpoint. + * This function performs a `GET` to the `/orgs/{org}/settings/immutable-releases/repositories` endpoint. * - * Members of an organization can choose to have their membership publicized or not. + * List all of the repositories that have been selected for immutable releases enforcement in an organization. * - * FROM: + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_public_members( + pub async fn get_immutable_releases_settings_repositories( &self, org: &str, - per_page: i64, page: i64, - ) -> ClientResult>> { + per_page: i64, + ) -> ClientResult> { let mut query_args: Vec<(String, String)> = Default::default(); if page > 0 { query_args.push(("page".to_string(), page.to_string())); @@ -1945,8 +5366,8 @@ impl Orgs { let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/public_members?{}", - crate::progenitor_support::encode_path(org), + "/orgs/{}/settings/immutable-releases/repositories?{}", + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -1962,66 +5383,73 @@ impl Orgs { .await } /** - * List public organization members. + * Set selected repositories for immutable releases enforcement. * - * This function performs a `GET` to the `/orgs/{org}/public_members` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/settings/immutable-releases/repositories` endpoint. * - * As opposed to `list_public_members`, this function returns all the pages of the request at once. + * Replaces all repositories that have been selected for immutable releases enforcement in an organization. To use this endpoint, the organization immutable releases policy for `enforced_repositories` must be configured to `selected`. * - * Members of an organization can choose to have their membership publicized or not. + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** * - * FROM: + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn list_all_public_members( + pub async fn set_immutable_releases_settings_repositories( &self, org: &str, - ) -> ClientResult>> { + body: &crate::types::CodespacesSetRepositoriesSecretRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/public_members", - crate::progenitor_support::encode_path(org), + "/orgs/{}/settings/immutable-releases/repositories", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .get_all_pages( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Check public organization membership for a user. + * Enable a selected repository for immutable releases in an organization. * - * This function performs a `GET` to the `/orgs/{org}/public_members/{username}` endpoint. + * This function performs a `PUT` to the `/orgs/{org}/settings/immutable-releases/repositories/{repository_id}` endpoint. * + * Adds a repository to the list of selected repositories that are enforced for immutable releases in an organization. To use this endpoint, the organization immutable releases policy for `enforced_repositories` must be configured to `selected`. * + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `username: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `repository_id: i64` -- The unique identifier of the repository. */ - pub async fn check_public_membership_for_user( + pub async fn enable_selected_repository_immutable_releases_organization( &self, org: &str, - username: &str, + repository_id: i64, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/public_members/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/settings/immutable-releases/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { body: None, @@ -2031,36 +5459,36 @@ impl Orgs { .await } /** - * Set public organization membership for the authenticated user. + * Disable a selected repository for immutable releases in an organization. * - * This function performs a `PUT` to the `/orgs/{org}/public_members/{username}` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/settings/immutable-releases/repositories/{repository_id}` endpoint. * - * The user can publicize their own membership. (A user cannot publicize the membership for another user.) + * Removes a repository from the list of selected repositories that are enforced for immutable releases in an organization. To use this endpoint, the organization immutable releases policy for `enforced_repositories` must be configured to `selected`. * - * Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://docs.github.com/rest/overview/resources-in-the-rest-api#http-verbs)." + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `username: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `repository_id: i64` -- The unique identifier of the repository. */ - pub async fn set_public_membership_for_authenticated_user( + pub async fn disable_selected_repository_immutable_releases_organization( &self, org: &str, - username: &str, + repository_id: i64, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/public_members/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/settings/immutable-releases/repositories/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&repository_id.to_string()), ), None, ); self.client - .put( + .delete( &url, crate::Message { body: None, @@ -2070,38 +5498,52 @@ impl Orgs { .await } /** - * Remove public organization membership for the authenticated user. + * Enable or disable a security feature for an organization. * - * This function performs a `DELETE` to the `/orgs/{org}/public_members/{username}` endpoint. + * This function performs a `POST` to the `/orgs/{org}/{security_product}/{enablement}` endpoint. * + * > [!WARNING] + * > **Closing down notice:** The ability to enable or disable a security feature for all eligible repositories in an organization is closing down. Please use [code security configurations](https://docs.github.com/rest/code-security/configurations) instead. For more information, see the [changelog](https://github.blog/changelog/2024-07-22-deprecation-of-api-endpoint-to-enable-or-disable-a-security-feature-for-an-organization/). * + * Enables or disables the specified security feature for all eligible repositories in an organization. For more information, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)." * - * FROM: + * The authenticated user must be an organization owner or be member of a team with the security manager role to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org`, `write:org`, or `repo` scopes to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `username: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `security_product: crate::types::SecurityProduct` -- The security feature to enable or disable. + * * `enablement: crate::types::Enablement` -- The action to take. + * + * `enable_all` means to enable the specified security feature for all repositories in the organization. + * `disable_all` means to disable the specified security feature for all repositories in the organization. */ - pub async fn remove_public_membership_for_authenticated_user( + pub async fn enable_or_disable_security_product_on_all_org_repos( &self, org: &str, - username: &str, + security_product: crate::types::SecurityProduct, + enablement: crate::types::Enablement, + body: &crate::types::OrgsEnableDisableSecurityProductOnAllOrgReposRequest, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/public_members/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(username), + "/orgs/{}/{}/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&security_product.to_string()), + crate::progenitor_support::encode_path(&enablement.to_string()), ), None, ); self.client - .delete( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await @@ -2111,15 +5553,15 @@ impl Orgs { * * This function performs a `GET` to the `/user/memberships/orgs` endpoint. * + * Lists all of the authenticated user's organization memberships. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `state: crate::types::OrgMembershipState` -- Indicates the state of the memberships to return. Can be either `active` or `pending`. If not specified, the API returns both active and pending memberships. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `state: crate::types::OrgMembershipState` -- The state of the member in the organization. The `pending` state indicates the user has not yet accepted an invitation. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_memberships_for_authenticated_user( &self, @@ -2158,9 +5600,9 @@ impl Orgs { * * As opposed to `list_memberships_for_authenticated_user`, this function returns all the pages of the request at once. * + * Lists all of the authenticated user's organization memberships. * - * - * FROM: + * FROM: */ pub async fn list_all_memberships_for_authenticated_user( &self, @@ -2189,13 +5631,13 @@ impl Orgs { * * This function performs a `GET` to the `/user/memberships/orgs/{org}` endpoint. * + * If the authenticated user is an active or pending member of the organization, this endpoint will return the user's membership. If the authenticated user is not affiliated with the organization, a `404` is returned. This endpoint will return a `403` if the request is made by a GitHub App that is blocked by the organization. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn get_membership_for_authenticated_user( &self, @@ -2204,7 +5646,7 @@ impl Orgs { let url = self.client.url( &format!( "/user/memberships/orgs/{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -2223,13 +5665,13 @@ impl Orgs { * * This function performs a `PATCH` to the `/user/memberships/orgs/{org}` endpoint. * + * Converts the authenticated user to an active member of the organization, if that user has a pending invitation from the organization. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn update_membership_for_authenticated_user( &self, @@ -2239,7 +5681,7 @@ impl Orgs { let url = self.client.url( &format!( "/user/memberships/orgs/{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -2260,16 +5702,17 @@ impl Orgs { * * List organizations for the authenticated user. * - * **OAuth scope requirements** + * For OAuth app tokens and personal access tokens (classic), this endpoint only lists organizations that your authorization allows you to operate on in some way (e.g., you can list teams with `read:org` scope, you can publicize your organization membership with `user` scope, etc.). Therefore, this API requires at least `user` or `read:org` scope for OAuth app tokens and personal access tokens (classic). Requests with insufficient scope will receive a `403 Forbidden` response. * - * This only lists organizations that your authorization allows you to operate on in some way (e.g., you can list teams with `read:org` scope, you can publicize your organization membership with `user` scope, etc.). Therefore, this API requires at least `user` or `read:org` scope. OAuth requests with insufficient scope receive a `403 Forbidden` response. + * > [!NOTE] + * > Requests using a fine-grained access token will receive a `200 Success` response with an empty list. * - * FROM: + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_authenticated_user( &self, @@ -2304,16 +5747,17 @@ impl Orgs { * * List organizations for the authenticated user. * - * **OAuth scope requirements** + * For OAuth app tokens and personal access tokens (classic), this endpoint only lists organizations that your authorization allows you to operate on in some way (e.g., you can list teams with `read:org` scope, you can publicize your organization membership with `user` scope, etc.). Therefore, this API requires at least `user` or `read:org` scope for OAuth app tokens and personal access tokens (classic). Requests with insufficient scope will receive a `403 Forbidden` response. * - * This only lists organizations that your authorization allows you to operate on in some way (e.g., you can list teams with `read:org` scope, you can publicize your organization membership with `user` scope, etc.). Therefore, this API requires at least `user` or `read:org` scope. OAuth requests with insufficient scope receive a `403 Forbidden` response. + * > [!NOTE] + * > Requests using a fine-grained access token will receive a `200 Success` response with an empty list. * - * FROM: + * FROM: */ pub async fn list_all_for_authenticated_user( &self, ) -> ClientResult>> { - let url = self.client.url("/user/orgs", None); + let url = self.client.url(&"/user/orgs".to_string(), None); self.client .get_all_pages( &url, @@ -2329,17 +5773,17 @@ impl Orgs { * * This function performs a `GET` to the `/users/{username}/orgs` endpoint. * - * List [public organization memberships](https://help.github.com/articles/publicizing-or-concealing-organization-membership) for the specified user. + * List [public organization memberships](https://docs.github.com/articles/publicizing-or-concealing-organization-membership) for the specified user. * - * This method only lists _public_ memberships, regardless of authentication. If you need to fetch all of the organization memberships (public and private) for the authenticated user, use the [List organizations for the authenticated user](https://docs.github.com/rest/reference/orgs#list-organizations-for-the-authenticated-user) API instead. + * This method only lists _public_ memberships, regardless of authentication. If you need to fetch all of the organization memberships (public and private) for the authenticated user, use the [List organizations for the authenticated user](https://docs.github.com/rest/orgs/orgs#list-organizations-for-the-authenticated-user) API instead. * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `username: &str` -- The handle for the GitHub user account. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_user( &self, @@ -2358,7 +5802,7 @@ impl Orgs { let url = self.client.url( &format!( "/users/{}/orgs?{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), query_ ), None, @@ -2380,11 +5824,11 @@ impl Orgs { * * As opposed to `list_for_user`, this function returns all the pages of the request at once. * - * List [public organization memberships](https://help.github.com/articles/publicizing-or-concealing-organization-membership) for the specified user. + * List [public organization memberships](https://docs.github.com/articles/publicizing-or-concealing-organization-membership) for the specified user. * - * This method only lists _public_ memberships, regardless of authentication. If you need to fetch all of the organization memberships (public and private) for the authenticated user, use the [List organizations for the authenticated user](https://docs.github.com/rest/reference/orgs#list-organizations-for-the-authenticated-user) API instead. + * This method only lists _public_ memberships, regardless of authentication. If you need to fetch all of the organization memberships (public and private) for the authenticated user, use the [List organizations for the authenticated user](https://docs.github.com/rest/orgs/orgs#list-organizations-for-the-authenticated-user) API instead. * - * FROM: + * FROM: */ pub async fn list_all_for_user( &self, @@ -2393,7 +5837,7 @@ impl Orgs { let url = self.client.url( &format!( "/users/{}/orgs", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); diff --git a/github/src/packages.rs b/github/src/packages.rs index 90f57d36..44d90096 100644 --- a/github/src/packages.rs +++ b/github/src/packages.rs @@ -11,6 +11,183 @@ impl Packages { Packages { client } } + /** + * Get list of conflicting packages during Docker migration for organization. + * + * This function performs a `GET` to the `/orgs/{org}/docker/conflicts` endpoint. + * + * Lists all packages that are in a specific organization, are readable by the requesting user, and that encountered a conflict during a Docker migration. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn list_docker_migration_conflicting_packages_for_organization( + &self, + org: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/orgs/{}/docker/conflicts", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get list of conflicting packages during Docker migration for organization. + * + * This function performs a `GET` to the `/orgs/{org}/docker/conflicts` endpoint. + * + * As opposed to `list_docker_migration_conflicting_packages_for_organization`, this function returns all the pages of the request at once. + * + * Lists all packages that are in a specific organization, are readable by the requesting user, and that encountered a conflict during a Docker migration. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. + * + * FROM: + */ + pub async fn list_all_docker_migration_conflicting_packages_for_organization( + &self, + org: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/orgs/{}/docker/conflicts", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List packages for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/packages` endpoint. + * + * Lists packages in an organization readable by the user. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." + * + * FROM: + * + * **Parameters:** + * + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `visibility: crate::types::PackageVisibilityData` -- The selected visibility of the packages. This parameter is optional and only filters an existing result set. + * + * The `internal` visibility is only supported for GitHub Packages registries that allow for granular permissions. For other ecosystems `internal` is synonymous with `private`. + * For the list of GitHub Packages registries that support granular permissions, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_packages_for_organization( + &self, + package_type: crate::types::PackageType, + org: &str, + visibility: crate::types::PackageVisibilityData, + page: i64, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !package_type.to_string().is_empty() { + query_args.push(("package_type".to_string(), package_type.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !visibility.to_string().is_empty() { + query_args.push(("visibility".to_string(), visibility.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/packages?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List packages for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/packages` endpoint. + * + * As opposed to `list_packages_for_organization`, this function returns all the pages of the request at once. + * + * Lists packages in an organization readable by the user. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." + * + * FROM: + */ + pub async fn list_all_packages_for_organization( + &self, + package_type: crate::types::PackageType, + org: &str, + visibility: crate::types::PackageVisibilityData, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !package_type.to_string().is_empty() { + query_args.push(("package_type".to_string(), package_type.to_string())); + } + if !visibility.to_string().is_empty() { + query_args.push(("visibility".to_string(), visibility.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/packages?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } /** * Get a package for an organization. * @@ -18,29 +195,28 @@ impl Packages { * * Gets a specific package in an organization. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` scope. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn get_package_for_organization( &self, package_type: crate::types::PackageType, package_name: &str, org: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( "/orgs/{}/packages/{}/{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), ), None, ); @@ -61,17 +237,17 @@ impl Packages { * * Deletes an entire package in an organization. You cannot delete a public package if any version of the package has more than 5,000 downloads. In this scenario, contact GitHub support for further assistance. * - * To use this endpoint, you must have admin permissions in the organization and authenticate using an access token with the `packages:read` and `packages:delete` scopes. In addition: - * - If `package_type` is not `container`, your token must also include the `repo` scope. - * - If `package_type` is `container`, you must also have admin permissions to the container you want to delete. + * The authenticated user must have admin permissions in the organization to use this endpoint. If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)." + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn delete_package_for_org( &self, @@ -82,9 +258,9 @@ impl Packages { let url = self.client.url( &format!( "/orgs/{}/packages/{}/{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), ), None, ); @@ -109,17 +285,17 @@ impl Packages { * - The package was deleted within the last 30 days. * - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first. * - * To use this endpoint, you must have admin permissions in the organization and authenticate using an access token with the `packages:read` and `packages:write` scopes. In addition: - * - If `package_type` is not `container`, your token must also include the `repo` scope. - * - If `package_type` is `container`, you must also have admin permissions to the container that you want to restore. + * The authenticated user must have admin permissions in the organization to use this endpoint. If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)." + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. * * `token: &str` -- package token. */ pub async fn restore_package_for_org( @@ -137,9 +313,9 @@ impl Packages { let url = self.client.url( &format!( "/orgs/{}/packages/{}/{}/restore?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), query_ ), None, @@ -155,24 +331,23 @@ impl Packages { .await } /** - * Get all package versions for a package owned by an organization. + * List package versions for a package owned by an organization. * * This function performs a `GET` to the `/orgs/{org}/packages/{package_type}/{package_name}/versions` endpoint. * - * Returns all package versions for a package owned by an organization. + * Lists package versions for a package owned by an organization. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` scope. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. - * * `org: &str` - * * `page: i64` -- Page number of the results to fetch. - * * `per_page: i64` -- Results per page (max 100). + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". * * `state: crate::types::PackagesGetAllPackageVersionsOwnedByOrgState` -- The state of the package, either active or deleted. */ pub async fn get_all_package_versions_for_package_owned_by_org( @@ -198,9 +373,9 @@ impl Packages { let url = self.client.url( &format!( "/orgs/{}/packages/{}/{}/versions?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), query_ ), None, @@ -216,18 +391,17 @@ impl Packages { .await } /** - * Get all package versions for a package owned by an organization. + * List package versions for a package owned by an organization. * * This function performs a `GET` to the `/orgs/{org}/packages/{package_type}/{package_name}/versions` endpoint. * * As opposed to `get_all_package_versions_for_package_owned_by_org`, this function returns all the pages of the request at once. * - * Returns all package versions for a package owned by an organization. + * Lists package versions for a package owned by an organization. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` scope. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: */ pub async fn get_all_all_package_versions_for_package_owned_by_org( &self, @@ -244,9 +418,9 @@ impl Packages { let url = self.client.url( &format!( "/orgs/{}/packages/{}/{}/versions?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), query_ ), None, @@ -268,16 +442,15 @@ impl Packages { * * Gets a specific package version in an organization. * - * You must authenticate using an access token with the `packages:read` scope. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. * * `package_version_id: i64` -- Unique identifier of the package version. */ pub async fn get_package_version_for_organization( @@ -290,9 +463,9 @@ impl Packages { let url = self.client.url( &format!( "/orgs/{}/packages/{}/{}/versions/{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), crate::progenitor_support::encode_path(&package_version_id.to_string()), ), None, @@ -314,17 +487,17 @@ impl Packages { * * Deletes a specific package version in an organization. If the package is public and the package version has more than 5,000 downloads, you cannot delete the package version. In this scenario, contact GitHub support for further assistance. * - * To use this endpoint, you must have admin permissions in the organization and authenticate using an access token with the `packages:read` and `packages:delete` scopes. In addition: - * - If `package_type` is not `container`, your token must also include the `repo` scope. - * - If `package_type` is `container`, you must also have admin permissions to the container you want to delete. + * The authenticated user must have admin permissions in the organization to use this endpoint. If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)." * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." + * + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. * * `package_version_id: i64` -- Unique identifier of the package version. */ pub async fn delete_package_version_for_org( @@ -337,9 +510,9 @@ impl Packages { let url = self.client.url( &format!( "/orgs/{}/packages/{}/{}/versions/{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), crate::progenitor_support::encode_path(&package_version_id.to_string()), ), None, @@ -365,17 +538,17 @@ impl Packages { * - The package was deleted within the last 30 days. * - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first. * - * To use this endpoint, you must have admin permissions in the organization and authenticate using an access token with the `packages:read` and `packages:write` scopes. In addition: - * - If `package_type` is not `container`, your token must also include the `repo` scope. - * - If `package_type` is `container`, you must also have admin permissions to the container that you want to restore. + * The authenticated user must have admin permissions in the organization to use this endpoint. If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)." + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. * * `package_version_id: i64` -- Unique identifier of the package version. */ pub async fn restore_package_version_for_org( @@ -388,9 +561,9 @@ impl Packages { let url = self.client.url( &format!( "/orgs/{}/packages/{}/{}/versions/{}/restore", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), crate::progenitor_support::encode_path(&package_version_id.to_string()), ), None, @@ -405,6 +578,148 @@ impl Packages { ) .await } + /** + * Get list of conflicting packages during Docker migration for authenticated-user. + * + * This function performs a `GET` to the `/user/docker/conflicts` endpoint. + * + * Lists all packages that are owned by the authenticated user within the user's namespace, and that encountered a conflict during a Docker migration. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. + * + * FROM: + */ + pub async fn list_docker_migration_conflicting_packages_for_authenticated_user( + &self, + ) -> ClientResult>> { + let url = self.client.url(&"/user/docker/conflicts".to_string(), None); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get list of conflicting packages during Docker migration for authenticated-user. + * + * This function performs a `GET` to the `/user/docker/conflicts` endpoint. + * + * As opposed to `list_docker_migration_conflicting_packages_for_authenticated_user`, this function returns all the pages of the request at once. + * + * Lists all packages that are owned by the authenticated user within the user's namespace, and that encountered a conflict during a Docker migration. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. + * + * FROM: + */ + pub async fn list_all_docker_migration_conflicting_packages_for_authenticated_user( + &self, + ) -> ClientResult>> { + let url = self.client.url(&"/user/docker/conflicts".to_string(), None); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List packages for the authenticated user's namespace. + * + * This function performs a `GET` to the `/user/packages` endpoint. + * + * Lists packages owned by the authenticated user within the user's namespace. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." + * + * FROM: + * + * **Parameters:** + * + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `visibility: crate::types::PackageVisibilityData` -- The selected visibility of the packages. This parameter is optional and only filters an existing result set. + * + * The `internal` visibility is only supported for GitHub Packages registries that allow for granular permissions. For other ecosystems `internal` is synonymous with `private`. + * For the list of GitHub Packages registries that support granular permissions, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_packages_for_authenticated_user( + &self, + package_type: crate::types::PackageType, + visibility: crate::types::PackageVisibilityData, + page: i64, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !package_type.to_string().is_empty() { + query_args.push(("package_type".to_string(), package_type.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !visibility.to_string().is_empty() { + query_args.push(("visibility".to_string(), visibility.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url(&format!("/user/packages?{}", query_), None); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List packages for the authenticated user's namespace. + * + * This function performs a `GET` to the `/user/packages` endpoint. + * + * As opposed to `list_packages_for_authenticated_user`, this function returns all the pages of the request at once. + * + * Lists packages owned by the authenticated user within the user's namespace. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." + * + * FROM: + */ + pub async fn list_all_packages_for_authenticated_user( + &self, + package_type: crate::types::PackageType, + visibility: crate::types::PackageVisibilityData, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !package_type.to_string().is_empty() { + query_args.push(("package_type".to_string(), package_type.to_string())); + } + if !visibility.to_string().is_empty() { + query_args.push(("visibility".to_string(), visibility.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url(&format!("/user/packages?{}", query_), None); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } /** * Get a package for the authenticated user. * @@ -412,26 +727,25 @@ impl Packages { * * Gets a specific package for a package owned by the authenticated user. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` scope. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. */ pub async fn get_package_for_authenticated_user( &self, package_type: crate::types::PackageType, package_name: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( "/user/packages/{}/{}", crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), ), None, ); @@ -452,14 +766,13 @@ impl Packages { * * Deletes a package owned by the authenticated user. You cannot delete a public package if any version of the package has more than 5,000 downloads. In this scenario, contact GitHub support for further assistance. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` and `packages:delete` scopes. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. */ pub async fn delete_package_for_authenticated_user( @@ -471,7 +784,7 @@ impl Packages { &format!( "/user/packages/{}/{}", crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), ), None, ); @@ -496,13 +809,13 @@ impl Packages { * - The package was deleted within the last 30 days. * - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` and `packages:write` scopes. If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. * * `token: &str` -- package token. */ @@ -521,7 +834,7 @@ impl Packages { &format!( "/user/packages/{}/{}/restore?{}", crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), query_ ), None, @@ -537,23 +850,22 @@ impl Packages { .await } /** - * Get all package versions for a package owned by the authenticated user. + * List package versions for a package owned by the authenticated user. * * This function performs a `GET` to the `/user/packages/{package_type}/{package_name}/versions` endpoint. * - * Returns all package versions for a package owned by the authenticated user. + * Lists package versions for a package owned by the authenticated user. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` scope. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. - * * `page: i64` -- Page number of the results to fetch. - * * `per_page: i64` -- Results per page (max 100). + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". * * `state: crate::types::PackagesGetAllPackageVersionsOwnedByOrgState` -- The state of the package, either active or deleted. */ pub async fn get_all_package_versions_for_package_owned_by_authenticated_user( @@ -579,7 +891,7 @@ impl Packages { &format!( "/user/packages/{}/{}/versions?{}", crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), query_ ), None, @@ -595,18 +907,17 @@ impl Packages { .await } /** - * Get all package versions for a package owned by the authenticated user. + * List package versions for a package owned by the authenticated user. * * This function performs a `GET` to the `/user/packages/{package_type}/{package_name}/versions` endpoint. * * As opposed to `get_all_package_versions_for_package_owned_by_authenticated_user`, this function returns all the pages of the request at once. * - * Returns all package versions for a package owned by the authenticated user. + * Lists package versions for a package owned by the authenticated user. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` scope. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: */ pub async fn get_all_all_package_versions_for_package_owned_by_authenticated_user( &self, @@ -623,7 +934,7 @@ impl Packages { &format!( "/user/packages/{}/{}/versions?{}", crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), query_ ), None, @@ -645,14 +956,13 @@ impl Packages { * * Gets a specific package version for a package owned by the authenticated user. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` scope. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. * * `package_version_id: i64` -- Unique identifier of the package version. */ @@ -666,7 +976,7 @@ impl Packages { &format!( "/user/packages/{}/{}/versions/{}", crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), crate::progenitor_support::encode_path(&package_version_id.to_string()), ), None, @@ -688,14 +998,15 @@ impl Packages { * * Deletes a specific package version for a package owned by the authenticated user. If the package is public and the package version has more than 5,000 downloads, you cannot delete the package version. In this scenario, contact GitHub support for further assistance. * - * To use this endpoint, you must have admin permissions in the organization and authenticate using an access token with the `packages:read` and `packages:delete` scopes. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * The authenticated user must have admin permissions in the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. * * `package_version_id: i64` -- Unique identifier of the package version. */ @@ -709,7 +1020,7 @@ impl Packages { &format!( "/user/packages/{}/{}/versions/{}", crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), crate::progenitor_support::encode_path(&package_version_id.to_string()), ), None, @@ -735,13 +1046,13 @@ impl Packages { * - The package was deleted within the last 30 days. * - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` and `packages:write` scopes. If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. * * `package_version_id: i64` -- Unique identifier of the package version. */ @@ -755,7 +1066,7 @@ impl Packages { &format!( "/user/packages/{}/{}/versions/{}/restore", crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), crate::progenitor_support::encode_path(&package_version_id.to_string()), ), None, @@ -770,6 +1081,183 @@ impl Packages { ) .await } + /** + * Get list of conflicting packages during Docker migration for user. + * + * This function performs a `GET` to the `/users/{username}/docker/conflicts` endpoint. + * + * Lists all packages that are in a specific user's namespace, that the requesting user has access to, and that encountered a conflict during Docker migration. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn list_docker_migration_conflicting_packages_for_user( + &self, + username: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/users/{}/docker/conflicts", + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get list of conflicting packages during Docker migration for user. + * + * This function performs a `GET` to the `/users/{username}/docker/conflicts` endpoint. + * + * As opposed to `list_docker_migration_conflicting_packages_for_user`, this function returns all the pages of the request at once. + * + * Lists all packages that are in a specific user's namespace, that the requesting user has access to, and that encountered a conflict during Docker migration. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. + * + * FROM: + */ + pub async fn list_all_docker_migration_conflicting_packages_for_user( + &self, + username: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/users/{}/docker/conflicts", + crate::progenitor_support::encode_path(&username.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List packages for a user. + * + * This function performs a `GET` to the `/users/{username}/packages` endpoint. + * + * Lists all packages in a user's namespace for which the requesting user has access. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." + * + * FROM: + * + * **Parameters:** + * + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `visibility: crate::types::PackageVisibilityData` -- The selected visibility of the packages. This parameter is optional and only filters an existing result set. + * + * The `internal` visibility is only supported for GitHub Packages registries that allow for granular permissions. For other ecosystems `internal` is synonymous with `private`. + * For the list of GitHub Packages registries that support granular permissions, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages).". + * * `username: &str` -- The handle for the GitHub user account. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_packages_for_user( + &self, + package_type: crate::types::PackageType, + visibility: crate::types::PackageVisibilityData, + username: &str, + page: i64, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !package_type.to_string().is_empty() { + query_args.push(("package_type".to_string(), package_type.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !visibility.to_string().is_empty() { + query_args.push(("visibility".to_string(), visibility.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/users/{}/packages?{}", + crate::progenitor_support::encode_path(&username.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List packages for a user. + * + * This function performs a `GET` to the `/users/{username}/packages` endpoint. + * + * As opposed to `list_packages_for_user`, this function returns all the pages of the request at once. + * + * Lists all packages in a user's namespace for which the requesting user has access. + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." + * + * FROM: + */ + pub async fn list_all_packages_for_user( + &self, + package_type: crate::types::PackageType, + visibility: crate::types::PackageVisibilityData, + username: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !package_type.to_string().is_empty() { + query_args.push(("package_type".to_string(), package_type.to_string())); + } + if !visibility.to_string().is_empty() { + query_args.push(("visibility".to_string(), visibility.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/users/{}/packages?{}", + crate::progenitor_support::encode_path(&username.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } /** * Get a package for a user. * @@ -777,29 +1265,28 @@ impl Packages { * * Gets a specific package metadata for a public package owned by a user. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` scope. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. - * * `username: &str` + * * `username: &str` -- The handle for the GitHub user account. */ pub async fn get_package_for_user( &self, package_type: crate::types::PackageType, package_name: &str, username: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( "/users/{}/packages/{}/{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), ), None, ); @@ -814,22 +1301,121 @@ impl Packages { .await } /** - * Get all package versions for a package owned by a user. + * Delete a package for a user. + * + * This function performs a `DELETE` to the `/users/{username}/packages/{package_type}/{package_name}` endpoint. + * + * Deletes an entire package for a user. You cannot delete a public package if any version of the package has more than 5,000 downloads. In this scenario, contact GitHub support for further assistance. + * + * If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)." + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." + * + * FROM: + * + * **Parameters:** + * + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_name: &str` -- The name of the package. + * * `username: &str` -- The handle for the GitHub user account. + */ + pub async fn delete_package_for_user( + &self, + package_type: crate::types::PackageType, + package_name: &str, + username: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/users/{}/packages/{}/{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&package_type.to_string()), + crate::progenitor_support::encode_path(&package_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Restore a package for a user. + * + * This function performs a `POST` to the `/users/{username}/packages/{package_type}/{package_name}/restore` endpoint. + * + * Restores an entire package for a user. + * + * You can restore a deleted package under the following conditions: + * - The package was deleted within the last 30 days. + * - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first. + * + * If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)." + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." + * + * FROM: + * + * **Parameters:** + * + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_name: &str` -- The name of the package. + * * `username: &str` -- The handle for the GitHub user account. + * * `token: &str` -- package token. + */ + pub async fn restore_package_for_user( + &self, + package_type: crate::types::PackageType, + package_name: &str, + username: &str, + token: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !token.is_empty() { + query_args.push(("token".to_string(), token.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/users/{}/packages/{}/{}/restore?{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&package_type.to_string()), + crate::progenitor_support::encode_path(&package_name.to_string()), + query_ + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List package versions for a package owned by a user. * * This function performs a `GET` to the `/users/{username}/packages/{package_type}/{package_name}/versions` endpoint. * - * Returns all package versions for a public package owned by a specified user. + * Lists package versions for a public package owned by a specified user. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` scope. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. - * * `username: &str` + * * `username: &str` -- The handle for the GitHub user account. */ pub async fn get_all_package_versions_for_package_owned_by_user( &self, @@ -840,9 +1426,9 @@ impl Packages { let url = self.client.url( &format!( "/users/{}/packages/{}/{}/versions", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), ), None, ); @@ -857,18 +1443,17 @@ impl Packages { .await } /** - * Get all package versions for a package owned by a user. + * List package versions for a package owned by a user. * * This function performs a `GET` to the `/users/{username}/packages/{package_type}/{package_name}/versions` endpoint. * * As opposed to `get_all_package_versions_for_package_owned_by_user`, this function returns all the pages of the request at once. * - * Returns all package versions for a public package owned by a specified user. + * Lists package versions for a public package owned by a specified user. * - * To use this endpoint, you must authenticate using an access token with the `packages:read` scope. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: */ pub async fn get_all_all_package_versions_for_package_owned_by_user( &self, @@ -879,9 +1464,9 @@ impl Packages { let url = self.client.url( &format!( "/users/{}/packages/{}/{}/versions", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), ), None, ); @@ -902,17 +1487,16 @@ impl Packages { * * Gets a specific package version for a public package owned by a specified user. * - * At this time, to use this endpoint, you must authenticate using an access token with the `packages:read` scope. - * If `package_type` is not `container`, your token must also include the `repo` scope. + * OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." * - * FROM: + * FROM: * * **Parameters:** * - * * `package_type: crate::types::PackageType` -- The type of supported package. Can be one of `npm`, `maven`, `rubygems`, `nuget`, `docker`, or `container`. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. * * `package_name: &str` -- The name of the package. * * `package_version_id: i64` -- Unique identifier of the package version. - * * `username: &str` + * * `username: &str` -- The handle for the GitHub user account. */ pub async fn get_package_version_for_user( &self, @@ -924,9 +1508,9 @@ impl Packages { let url = self.client.url( &format!( "/users/{}/packages/{}/{}/versions/{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), crate::progenitor_support::encode_path(&package_type.to_string()), - crate::progenitor_support::encode_path(package_name), + crate::progenitor_support::encode_path(&package_name.to_string()), crate::progenitor_support::encode_path(&package_version_id.to_string()), ), None, @@ -941,4 +1525,102 @@ impl Packages { ) .await } + /** + * Delete package version for a user. + * + * This function performs a `DELETE` to the `/users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}` endpoint. + * + * Deletes a specific package version for a user. If the package is public and the package version has more than 5,000 downloads, you cannot delete the package version. In this scenario, contact GitHub support for further assistance. + * + * If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)." + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." + * + * FROM: + * + * **Parameters:** + * + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_name: &str` -- The name of the package. + * * `username: &str` -- The handle for the GitHub user account. + * * `package_version_id: i64` -- Unique identifier of the package version. + */ + pub async fn delete_package_version_for_user( + &self, + package_type: crate::types::PackageType, + package_name: &str, + username: &str, + package_version_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/users/{}/packages/{}/{}/versions/{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&package_type.to_string()), + crate::progenitor_support::encode_path(&package_name.to_string()), + crate::progenitor_support::encode_path(&package_version_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Restore package version for a user. + * + * This function performs a `POST` to the `/users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore` endpoint. + * + * Restores a specific package version for a user. + * + * You can restore a deleted package under the following conditions: + * - The package was deleted within the last 30 days. + * - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first. + * + * If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)." + * + * OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)." + * + * FROM: + * + * **Parameters:** + * + * * `package_type: crate::types::PackageType` -- The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry. + * * `package_name: &str` -- The name of the package. + * * `username: &str` -- The handle for the GitHub user account. + * * `package_version_id: i64` -- Unique identifier of the package version. + */ + pub async fn restore_package_version_for_user( + &self, + package_type: crate::types::PackageType, + package_name: &str, + username: &str, + package_version_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/users/{}/packages/{}/{}/versions/{}/restore", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&package_type.to_string()), + crate::progenitor_support::encode_path(&package_name.to_string()), + crate::progenitor_support::encode_path(&package_version_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } } diff --git a/github/src/private_registries.rs b/github/src/private_registries.rs new file mode 100644 index 00000000..7fd01ab2 --- /dev/null +++ b/github/src/private_registries.rs @@ -0,0 +1,263 @@ +use crate::Client; +use crate::ClientResult; + +pub struct PrivateRegistries { + pub client: Client, +} + +impl PrivateRegistries { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + PrivateRegistries { client } + } + + /** + * List private registries for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/private-registries` endpoint. + * + * + * Lists all private registry configurations available at the organization-level without revealing their encrypted + * values. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_org_private_registries( + &self, + org: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/private-registries?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a private registry for an organization. + * + * This function performs a `POST` to the `/orgs/{org}/private-registries` endpoint. + * + * + * Creates a private registry configuration with an encrypted value for an organization. Encrypt your secret using [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api)." + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn create_org_private_registry( + &self, + org: &str, + body: &crate::types::PrivateRegistriesCreateOrgRegistryRequest, + ) -> ClientResult< + crate::Response, + > { + let url = self.client.url( + &format!( + "/orgs/{}/private-registries", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get private registries public key for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/private-registries/public-key` endpoint. + * + * + * Gets the org public key, which is needed to encrypt private registry secrets. You need to encrypt a secret before you can create or update secrets. + * + * OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn get_org_public_key( + &self, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/private-registries/public-key", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a private registry for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/private-registries/{secret_name}` endpoint. + * + * + * Get the configuration of a single private registry defined for an organization, omitting its encrypted value. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn get_org_private_registry( + &self, + org: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/private-registries/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a private registry for an organization. + * + * This function performs a `DELETE` to the `/orgs/{org}/private-registries/{secret_name}` endpoint. + * + * + * Delete a private registry configuration at the organization-level. + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn delete_org_private_registry( + &self, + org: &str, + secret_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/private-registries/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a private registry for an organization. + * + * This function performs a `PATCH` to the `/orgs/{org}/private-registries/{secret_name}` endpoint. + * + * + * Updates a private registry configuration with an encrypted value for an organization. Encrypt your secret using [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api)." + * + * OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `secret_name: &str` -- The name of the secret. + */ + pub async fn update_org_private_registry( + &self, + org: &str, + secret_name: &str, + body: &crate::types::PrivateRegistriesUpdateOrgRegistryRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/private-registries/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&secret_name.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } +} diff --git a/github/src/projects.rs b/github/src/projects.rs index 08a241ca..7bb369cd 100644 --- a/github/src/projects.rs +++ b/github/src/projects.rs @@ -12,43 +12,48 @@ impl Projects { } /** - * List organization projects. + * List projects for organization. * - * This function performs a `GET` to the `/orgs/{org}/projects` endpoint. + * This function performs a `GET` to the `/orgs/{org}/projectsV2` endpoint. * - * Lists the projects in an organization. Returns a `404 Not Found` status if projects are disabled in the organization. If you do not have sufficient privileges to perform this action, a `401 Unauthorized` or `410 Gone` status is returned. + * List all projects owned by a specific organization accessible by the authenticated user. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. Can be either `open`, `closed`, or `all`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `q: &str` -- Limit results to projects of the specified type. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_org( &self, org: &str, - state: crate::types::IssuesListState, + q: &str, + before: &str, + after: &str, per_page: i64, - page: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); } if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } - if !state.to_string().is_empty() { - query_args.push(("state".to_string(), state.to_string())); + if !q.is_empty() { + query_args.push(("q".to_string(), q.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/projects?{}", - crate::progenitor_support::encode_path(org), + "/orgs/{}/projectsV2?{}", + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -64,30 +69,38 @@ impl Projects { .await } /** - * List organization projects. + * List projects for organization. * - * This function performs a `GET` to the `/orgs/{org}/projects` endpoint. + * This function performs a `GET` to the `/orgs/{org}/projectsV2` endpoint. * * As opposed to `list_for_org`, this function returns all the pages of the request at once. * - * Lists the projects in an organization. Returns a `404 Not Found` status if projects are disabled in the organization. If you do not have sufficient privileges to perform this action, a `401 Unauthorized` or `410 Gone` status is returned. + * List all projects owned by a specific organization accessible by the authenticated user. * - * FROM: + * FROM: */ pub async fn list_all_for_org( &self, org: &str, - state: crate::types::IssuesListState, - ) -> ClientResult>> { + q: &str, + before: &str, + after: &str, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if !state.to_string().is_empty() { - query_args.push(("state".to_string(), state.to_string())); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !q.is_empty() { + query_args.push(("q".to_string(), q.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/projects?{}", - crate::progenitor_support::encode_path(org), + "/orgs/{}/projectsV2?{}", + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -103,27 +116,67 @@ impl Projects { .await } /** - * Create an organization project. + * Get project for organization. * - * This function performs a `POST` to the `/orgs/{org}/projects` endpoint. + * This function performs a `GET` to the `/orgs/{org}/projectsV2/{project_number}` endpoint. * - * Creates an organization project board. Returns a `404 Not Found` status if projects are disabled in the organization. If you do not have sufficient privileges to perform this action, a `401 Unauthorized` or `410 Gone` status is returned. + * Get a specific organization-owned project. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `project_number: i64` -- The project's number. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn create_for_org( + pub async fn get_for_org( &self, + project_number: i64, org: &str, - body: &crate::types::ProjectsCreateRequest, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/projects", - crate::progenitor_support::encode_path(org), + "/orgs/{}/projectsV2/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create draft item for organization owned project. + * + * This function performs a `POST` to the `/orgs/{org}/projectsV2/{project_number}/drafts` endpoint. + * + * Create draft issue item for the specified organization owned project. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `project_number: i64` -- The project's number. + */ + pub async fn create_draft_item_for_org( + &self, + org: &str, + project_number: i64, + body: &crate::types::ProjectsCreateDraftItemRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/projectsV2/{}/drafts", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), ), None, ); @@ -138,26 +191,47 @@ impl Projects { .await } /** - * Get a project card. + * List project fields for organization. * - * This function performs a `GET` to the `/projects/columns/cards/{card_id}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/projectsV2/{project_number}/fields` endpoint. * + * List all fields for a specific organization-owned project. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `card_id: i64` -- card_id parameter. + * * `project_number: i64` -- The project's number. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn get_card( + pub async fn list_fields_for_org( &self, - card_id: i64, - ) -> ClientResult> { + project_number: i64, + org: &str, + per_page: i64, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/projects/columns/cards/{}", - crate::progenitor_support::encode_path(&card_id.to_string()), + "/orgs/{}/projectsV2/{}/fields?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + query_ ), None, ); @@ -172,28 +246,42 @@ impl Projects { .await } /** - * Delete a project card. + * List project fields for organization. * - * This function performs a `DELETE` to the `/projects/columns/cards/{card_id}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/projectsV2/{project_number}/fields` endpoint. * + * As opposed to `list_fields_for_org`, this function returns all the pages of the request at once. * + * List all fields for a specific organization-owned project. * - * FROM: - * - * **Parameters:** - * - * * `card_id: i64` -- card_id parameter. + * FROM: */ - pub async fn delete_card(&self, card_id: i64) -> ClientResult> { + pub async fn list_all_fields_for_org( + &self, + project_number: i64, + org: &str, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/projects/columns/cards/{}", - crate::progenitor_support::encode_path(&card_id.to_string()), + "/orgs/{}/projectsV2/{}/fields?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + query_ ), None, ); self.client - .delete( + .get_all_pages( &url, crate::Message { body: None, @@ -203,32 +291,35 @@ impl Projects { .await } /** - * Update an existing project card. - * - * This function performs a `PATCH` to the `/projects/columns/cards/{card_id}` endpoint. + * Add a field to an organization-owned project. * + * This function performs a `POST` to the `/orgs/{org}/projectsV2/{project_number}/fields` endpoint. * + * Add a field to an organization-owned project. * - * FROM: + * FROM: * * **Parameters:** * - * * `card_id: i64` -- card_id parameter. + * * `project_number: i64` -- The project's number. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn update_card( + pub async fn add_field_for_org( &self, - card_id: i64, - body: &crate::types::ProjectsUpdateCardRequest, - ) -> ClientResult> { + project_number: i64, + org: &str, + body: &crate::types::ProjectsAddFieldOrgRequestOneOf, + ) -> ClientResult> { let url = self.client.url( &format!( - "/projects/columns/cards/{}", - crate::progenitor_support::encode_path(&card_id.to_string()), + "/orgs/{}/projectsV2/{}/fields", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), ), None, ); self.client - .patch( + .post( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -238,61 +329,99 @@ impl Projects { .await } /** - * Move a project card. - * - * This function performs a `POST` to the `/projects/columns/cards/{card_id}/moves` endpoint. + * Get project field for organization. * + * This function performs a `GET` to the `/orgs/{org}/projectsV2/{project_number}/fields/{field_id}` endpoint. * + * Get a specific field for an organization-owned project. * - * FROM: + * FROM: * * **Parameters:** * - * * `card_id: i64` -- card_id parameter. + * * `project_number: i64` -- The project's number. + * * `field_id: i64` -- The unique identifier of the field. + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn move_card( + pub async fn get_field_for_org( &self, - card_id: i64, - body: &crate::types::ProjectsMoveCardRequest, - ) -> ClientResult> { + project_number: i64, + field_id: i64, + org: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/projects/columns/cards/{}/moves", - crate::progenitor_support::encode_path(&card_id.to_string()), + "/orgs/{}/projectsV2/{}/fields/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + crate::progenitor_support::encode_path(&field_id.to_string()), ), None, ); self.client - .post( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get a project column. - * - * This function performs a `GET` to the `/projects/columns/{column_id}` endpoint. + * List items for an organization owned project. * + * This function performs a `GET` to the `/orgs/{org}/projectsV2/{project_number}/items` endpoint. * + * List all items for a specific organization-owned project accessible by the authenticated user. * - * FROM: + * FROM: * * **Parameters:** * - * * `column_id: i64` -- column_id parameter. + * * `project_number: i64` -- The project's number. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `q: &str` -- Search query to filter items, see [Filtering projects](https://docs.github.com/issues/planning-and-tracking-with-projects/customizing-views-in-your-project/filtering-projects) for more information. + * * `fields: &str` -- Limit results to specific fields, by their IDs. If not specified, the title field will be returned. + * + * Example: `fields[]=123&fields[]=456&fields[]=789` or `fields=123,456,789`. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn get_column( + pub async fn list_items_for_org( &self, - column_id: i64, - ) -> ClientResult> { + project_number: i64, + org: &str, + q: &str, + fields: &str, + before: &str, + after: &str, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !fields.is_empty() { + query_args.push(("fields".to_string(), fields.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !q.is_empty() { + query_args.push(("q".to_string(), q.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/projects/columns/{}", - crate::progenitor_support::encode_path(&column_id.to_string()), + "/orgs/{}/projectsV2/{}/items?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + query_ ), None, ); @@ -307,28 +436,50 @@ impl Projects { .await } /** - * Delete a project column. + * List items for an organization owned project. * - * This function performs a `DELETE` to the `/projects/columns/{column_id}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/projectsV2/{project_number}/items` endpoint. * + * As opposed to `list_items_for_org`, this function returns all the pages of the request at once. * + * List all items for a specific organization-owned project accessible by the authenticated user. * - * FROM: - * - * **Parameters:** - * - * * `column_id: i64` -- column_id parameter. + * FROM: */ - pub async fn delete_column(&self, column_id: i64) -> ClientResult> { + pub async fn list_all_items_for_org( + &self, + project_number: i64, + org: &str, + q: &str, + fields: &str, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !fields.is_empty() { + query_args.push(("fields".to_string(), fields.to_string())); + } + if !q.is_empty() { + query_args.push(("q".to_string(), q.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/projects/columns/{}", - crate::progenitor_support::encode_path(&column_id.to_string()), + "/orgs/{}/projectsV2/{}/items?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + query_ ), None, ); self.client - .delete( + .get_all_pages( &url, crate::Message { body: None, @@ -338,32 +489,35 @@ impl Projects { .await } /** - * Update an existing project column. - * - * This function performs a `PATCH` to the `/projects/columns/{column_id}` endpoint. + * Add item to organization owned project. * + * This function performs a `POST` to the `/orgs/{org}/projectsV2/{project_number}/items` endpoint. * + * Add an issue or pull request item to the specified organization owned project. * - * FROM: + * FROM: * * **Parameters:** * - * * `column_id: i64` -- column_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `project_number: i64` -- The project's number. */ - pub async fn update_column( + pub async fn add_item_for_org( &self, - column_id: i64, - body: &crate::types::ProjectsUpdateColumnRequest, - ) -> ClientResult> { + org: &str, + project_number: i64, + body: &crate::types::ProjectsAddItemOrgRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/projects/columns/{}", - crate::progenitor_support::encode_path(&column_id.to_string()), + "/orgs/{}/projectsV2/{}/items", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), ), None, ); self.client - .patch( + .post( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -373,43 +527,41 @@ impl Projects { .await } /** - * List project cards. - * - * This function performs a `GET` to the `/projects/columns/{column_id}/cards` endpoint. + * Get an item for an organization owned project. * + * This function performs a `GET` to the `/orgs/{org}/projectsV2/{project_number}/items/{item_id}` endpoint. * + * Get a specific item from an organization-owned project. * - * FROM: + * FROM: * * **Parameters:** * - * * `column_id: i64` -- column_id parameter. - * * `archived_state: crate::types::ArchivedState` -- Filters the project cards that are returned by the card's state. Can be one of `all`,`archived`, or `not_archived`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `project_number: i64` -- The project's number. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `item_id: i64` -- The unique identifier of the project item. + * * `fields: &str` -- Limit results to specific fields, by their IDs. If not specified, the title field will be returned. + * + * Example: fields[]=123&fields[]=456&fields[]=789 or fields=123,456,789. */ - pub async fn list_cards( + pub async fn get_org_item( &self, - column_id: i64, - archived_state: crate::types::ArchivedState, - per_page: i64, - page: i64, - ) -> ClientResult>> { + project_number: i64, + org: &str, + item_id: i64, + fields: &str, + ) -> ClientResult> { let mut query_args: Vec<(String, String)> = Default::default(); - if !archived_state.to_string().is_empty() { - query_args.push(("archived_state".to_string(), archived_state.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); + if !fields.is_empty() { + query_args.push(("fields".to_string(), fields.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/projects/columns/{}/cards?{}", - crate::progenitor_support::encode_path(&column_id.to_string()), + "/orgs/{}/projectsV2/{}/items/{}?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + crate::progenitor_support::encode_path(&item_id.to_string()), query_ ), None, @@ -425,36 +577,37 @@ impl Projects { .await } /** - * List project cards. + * Delete project item for organization. * - * This function performs a `GET` to the `/projects/columns/{column_id}/cards` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/projectsV2/{project_number}/items/{item_id}` endpoint. * - * As opposed to `list_cards`, this function returns all the pages of the request at once. + * Delete a specific item from an organization-owned project. * + * FROM: * + * **Parameters:** * - * FROM: + * * `project_number: i64` -- The project's number. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `item_id: i64` -- The unique identifier of the project item. */ - pub async fn list_all_cards( + pub async fn delete_item_for_org( &self, - column_id: i64, - archived_state: crate::types::ArchivedState, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !archived_state.to_string().is_empty() { - query_args.push(("archived_state".to_string(), archived_state.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + project_number: i64, + org: &str, + item_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/projects/columns/{}/cards?{}", - crate::progenitor_support::encode_path(&column_id.to_string()), - query_ + "/orgs/{}/projectsV2/{}/items/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + crate::progenitor_support::encode_path(&item_id.to_string()), ), None, ); self.client - .get_all_pages( + .delete( &url, crate::Message { body: None, @@ -464,32 +617,38 @@ impl Projects { .await } /** - * Create a project card. + * Update project item for organization. * - * This function performs a `POST` to the `/projects/columns/{column_id}/cards` endpoint. + * This function performs a `PATCH` to the `/orgs/{org}/projectsV2/{project_number}/items/{item_id}` endpoint. * + * Update a specific item in an organization-owned project. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `column_id: i64` -- column_id parameter. + * * `project_number: i64` -- The project's number. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `item_id: i64` -- The unique identifier of the project item. */ - pub async fn create_card( + pub async fn update_item_for_org( &self, - column_id: i64, - body: &crate::types::ProjectsCreateCardRequestOneOf, - ) -> ClientResult> { + project_number: i64, + org: &str, + item_id: i64, + body: &crate::types::ProjectsUpdateItemOrgRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/projects/columns/{}/cards", - crate::progenitor_support::encode_path(&column_id.to_string()), + "/orgs/{}/projectsV2/{}/items/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + crate::progenitor_support::encode_path(&item_id.to_string()), ), None, ); self.client - .post( + .patch( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -499,27 +658,30 @@ impl Projects { .await } /** - * Move a project column. + * Create a view for an organization-owned project. * - * This function performs a `POST` to the `/projects/columns/{column_id}/moves` endpoint. + * This function performs a `POST` to the `/orgs/{org}/projectsV2/{project_number}/views` endpoint. * + * Create a new view in an organization-owned project. Views allow you to customize how items in a project are displayed and filtered. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `column_id: i64` -- column_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `project_number: i64` -- The project's number. */ - pub async fn move_column( + pub async fn create_view_for_org( &self, - column_id: i64, - body: &crate::types::ProjectsMoveColumnRequest, - ) -> ClientResult> { + org: &str, + project_number: i64, + body: &crate::types::ProjectsCreateViewOrgRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/projects/columns/{}/moves", - crate::progenitor_support::encode_path(&column_id.to_string()), + "/orgs/{}/projectsV2/{}/views", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), ), None, ); @@ -534,26 +696,58 @@ impl Projects { .await } /** - * Get a project. + * List items for an organization project view. * - * This function performs a `GET` to the `/projects/{project_id}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/projectsV2/{project_number}/views/{view_number}/items` endpoint. * - * Gets a project by its `id`. Returns a `404 Not Found` status if projects are disabled. If you do not have sufficient privileges to perform this action, a `401 Unauthorized` or `410 Gone` status is returned. + * List items in an organization project with the saved view's filter applied. * - * FROM: + * FROM: * * **Parameters:** * - * * `project_id: i64` + * * `project_number: i64` -- The project's number. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `view_number: i64` -- The number that identifies the project view. + * * `fields: &str` -- Limit results to specific fields, by their IDs. If not specified, the + * title field will be returned. + * + * Example: `fields[]=123&fields[]=456&fields[]=789` or `fields=123,456,789`. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn get( + pub async fn list_view_items_for_org( &self, - project_id: i64, - ) -> ClientResult> { + project_number: i64, + org: &str, + view_number: i64, + fields: &str, + before: &str, + after: &str, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !fields.is_empty() { + query_args.push(("fields".to_string(), fields.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/projects/{}", - crate::progenitor_support::encode_path(&project_id.to_string()), + "/orgs/{}/projectsV2/{}/views/{}/items?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + crate::progenitor_support::encode_path(&view_number.to_string()), + query_ ), None, ); @@ -568,28 +762,48 @@ impl Projects { .await } /** - * Delete a project. + * List items for an organization project view. * - * This function performs a `DELETE` to the `/projects/{project_id}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/projectsV2/{project_number}/views/{view_number}/items` endpoint. * - * Deletes a project board. Returns a `404 Not Found` status if projects are disabled. + * As opposed to `list_view_items_for_org`, this function returns all the pages of the request at once. * - * FROM: + * List items in an organization project with the saved view's filter applied. * - * **Parameters:** - * - * * `project_id: i64` + * FROM: */ - pub async fn delete(&self, project_id: i64) -> ClientResult> { + pub async fn list_all_view_items_for_org( + &self, + project_number: i64, + org: &str, + view_number: i64, + fields: &str, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !fields.is_empty() { + query_args.push(("fields".to_string(), fields.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/projects/{}", - crate::progenitor_support::encode_path(&project_id.to_string()), + "/orgs/{}/projectsV2/{}/views/{}/items?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + crate::progenitor_support::encode_path(&view_number.to_string()), + query_ ), None, ); self.client - .delete( + .get_all_pages( &url, crate::Message { body: None, @@ -599,32 +813,35 @@ impl Projects { .await } /** - * Update a project. + * Create draft item for user owned project. * - * This function performs a `PATCH` to the `/projects/{project_id}` endpoint. + * This function performs a `POST` to the `/user/{user_id}/projectsV2/{project_number}/drafts` endpoint. * - * Updates a project board's information. Returns a `404 Not Found` status if projects are disabled. If you do not have sufficient privileges to perform this action, a `401 Unauthorized` or `410 Gone` status is returned. + * Create draft issue item for the specified user owned project. * - * FROM: + * FROM: * * **Parameters:** * - * * `project_id: i64` + * * `user_id: &str` -- The unique identifier of the user. + * * `project_number: i64` -- The project's number. */ - pub async fn update( + pub async fn create_draft_item_for_authenticated_user( &self, - project_id: i64, - body: &crate::types::ProjectsUpdateRequest, - ) -> ClientResult> { + user_id: &str, + project_number: i64, + body: &crate::types::ProjectsCreateDraftItemRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/projects/{}", - crate::progenitor_support::encode_path(&project_id.to_string()), + "/user/{}/projectsV2/{}/drafts", + crate::progenitor_support::encode_path(&user_id.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), ), None, ); self.client - .patch( + .post( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -634,91 +851,92 @@ impl Projects { .await } /** - * List project collaborators. + * Create a view for a user-owned project. * - * This function performs a `GET` to the `/projects/{project_id}/collaborators` endpoint. + * This function performs a `POST` to the `/users/{user_id}/projectsV2/{project_number}/views` endpoint. * - * Lists the collaborators for an organization project. For a project, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners. You must be an organization owner or a project `admin` to list collaborators. + * Create a new view in a user-owned project. Views allow you to customize how items in a project are displayed and filtered. * - * FROM: + * FROM: * * **Parameters:** * - * * `project_id: i64` - * * `affiliation: crate::types::Affiliation` -- Filters the collaborators by their affiliation. Can be one of: - * \\* `outside`: Outside collaborators of a project that are not a member of the project's organization. - * \\* `direct`: Collaborators with permissions to a project, regardless of organization membership status. - * \\* `all`: All collaborators the authenticated user can see. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `user_id: &str` -- The unique identifier of the user. + * * `project_number: i64` -- The project's number. */ - pub async fn list_collaborators( + pub async fn create_view_for_user( &self, - project_id: i64, - affiliation: crate::types::Affiliation, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !affiliation.to_string().is_empty() { - query_args.push(("affiliation".to_string(), affiliation.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + user_id: &str, + project_number: i64, + body: &crate::types::ProjectsCreateViewOrgRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/projects/{}/collaborators?{}", - crate::progenitor_support::encode_path(&project_id.to_string()), - query_ + "/users/{}/projectsV2/{}/views", + crate::progenitor_support::encode_path(&user_id.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), ), None, ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List project collaborators. + * List projects for user. * - * This function performs a `GET` to the `/projects/{project_id}/collaborators` endpoint. + * This function performs a `GET` to the `/users/{username}/projectsV2` endpoint. * - * As opposed to `list_collaborators`, this function returns all the pages of the request at once. + * List all projects owned by a specific user accessible by the authenticated user. * - * Lists the collaborators for an organization project. For a project, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners. You must be an organization owner or a project `admin` to list collaborators. + * FROM: * - * FROM: + * **Parameters:** + * + * * `username: &str` -- The handle for the GitHub user account. + * * `q: &str` -- Limit results to projects of the specified type. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_all_collaborators( + pub async fn list_for_user( &self, - project_id: i64, - affiliation: crate::types::Affiliation, - ) -> ClientResult>> { + username: &str, + q: &str, + before: &str, + after: &str, + per_page: i64, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if !affiliation.to_string().is_empty() { - query_args.push(("affiliation".to_string(), affiliation.to_string())); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !q.is_empty() { + query_args.push(("q".to_string(), q.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/projects/{}/collaborators?{}", - crate::progenitor_support::encode_path(&project_id.to_string()), + "/users/{}/projectsV2?{}", + crate::progenitor_support::encode_path(&username.to_string()), query_ ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -728,72 +946,81 @@ impl Projects { .await } /** - * Add project collaborator. - * - * This function performs a `PUT` to the `/projects/{project_id}/collaborators/{username}` endpoint. + * List projects for user. * - * Adds a collaborator to an organization project and sets their permission level. You must be an organization owner or a project `admin` to add a collaborator. + * This function performs a `GET` to the `/users/{username}/projectsV2` endpoint. * - * FROM: + * As opposed to `list_for_user`, this function returns all the pages of the request at once. * - * **Parameters:** + * List all projects owned by a specific user accessible by the authenticated user. * - * * `project_id: i64` - * * `username: &str` + * FROM: */ - pub async fn add_collaborator( + pub async fn list_all_for_user( &self, - project_id: i64, username: &str, - body: &crate::types::ProjectsAddCollaboratorRequest, - ) -> ClientResult> { + q: &str, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !q.is_empty() { + query_args.push(("q".to_string(), q.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/projects/{}/collaborators/{}", - crate::progenitor_support::encode_path(&project_id.to_string()), - crate::progenitor_support::encode_path(username), + "/users/{}/projectsV2?{}", + crate::progenitor_support::encode_path(&username.to_string()), + query_ ), None, ); self.client - .put( + .get_all_pages( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Remove user as a collaborator. + * Get project for user. * - * This function performs a `DELETE` to the `/projects/{project_id}/collaborators/{username}` endpoint. + * This function performs a `GET` to the `/users/{username}/projectsV2/{project_number}` endpoint. * - * Removes a collaborator from an organization project. You must be an organization owner or a project `admin` to remove a collaborator. + * Get a specific user-owned project. * - * FROM: + * FROM: * * **Parameters:** * - * * `project_id: i64` - * * `username: &str` + * * `project_number: i64` -- The project's number. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn remove_collaborator( + pub async fn get_for_user( &self, - project_id: i64, + project_number: i64, username: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/projects/{}/collaborators/{}", - crate::progenitor_support::encode_path(&project_id.to_string()), - crate::progenitor_support::encode_path(username), + "/users/{}/projectsV2/{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -803,29 +1030,47 @@ impl Projects { .await } /** - * Get project permission for a user. + * List project fields for user. * - * This function performs a `GET` to the `/projects/{project_id}/collaborators/{username}/permission` endpoint. + * This function performs a `GET` to the `/users/{username}/projectsV2/{project_number}/fields` endpoint. * - * Returns the collaborator's permission level for an organization project. Possible values for the `permission` key: `admin`, `write`, `read`, `none`. You must be an organization owner or a project `admin` to review a user's permission level. + * List all fields for a specific user-owned project. * - * FROM: + * FROM: * * **Parameters:** * - * * `project_id: i64` - * * `username: &str` + * * `project_number: i64` -- The project's number. + * * `username: &str` -- The handle for the GitHub user account. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn get_permission_for_user( + pub async fn list_fields_for_user( &self, - project_id: i64, + project_number: i64, username: &str, - ) -> ClientResult> { + per_page: i64, + before: &str, + after: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/projects/{}/collaborators/{}/permission", - crate::progenitor_support::encode_path(&project_id.to_string()), - crate::progenitor_support::encode_path(username), + "/users/{}/projectsV2/{}/fields?{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + query_ ), None, ); @@ -840,44 +1085,42 @@ impl Projects { .await } /** - * List project columns. - * - * This function performs a `GET` to the `/projects/{project_id}/columns` endpoint. + * List project fields for user. * + * This function performs a `GET` to the `/users/{username}/projectsV2/{project_number}/fields` endpoint. * + * As opposed to `list_fields_for_user`, this function returns all the pages of the request at once. * - * FROM: + * List all fields for a specific user-owned project. * - * **Parameters:** - * - * * `project_id: i64` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * FROM: */ - pub async fn list_columns( + pub async fn list_all_fields_for_user( &self, - project_id: i64, - per_page: i64, - page: i64, - ) -> ClientResult>> { + project_number: i64, + username: &str, + before: &str, + after: &str, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/projects/{}/columns?{}", - crate::progenitor_support::encode_path(&project_id.to_string()), + "/users/{}/projectsV2/{}/fields?{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), query_ ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -887,113 +1130,136 @@ impl Projects { .await } /** - * List project columns. + * Add field to user owned project. * - * This function performs a `GET` to the `/projects/{project_id}/columns` endpoint. + * This function performs a `POST` to the `/users/{username}/projectsV2/{project_number}/fields` endpoint. * - * As opposed to `list_columns`, this function returns all the pages of the request at once. + * Add a field to a specified user owned project. * + * FROM: * + * **Parameters:** * - * FROM: + * * `username: &str` -- The handle for the GitHub user account. + * * `project_number: i64` -- The project's number. */ - pub async fn list_all_columns( + pub async fn add_field_for_user( &self, - project_id: i64, - ) -> ClientResult>> { + username: &str, + project_number: i64, + body: &crate::types::ProjectsAddFieldUserRequestOneOf, + ) -> ClientResult> { let url = self.client.url( &format!( - "/projects/{}/columns", - crate::progenitor_support::encode_path(&project_id.to_string()), + "/users/{}/projectsV2/{}/fields", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), ), None, ); self.client - .get_all_pages( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Create a project column. - * - * This function performs a `POST` to the `/projects/{project_id}/columns` endpoint. + * Get project field for user. * + * This function performs a `GET` to the `/users/{username}/projectsV2/{project_number}/fields/{field_id}` endpoint. * + * Get a specific field for a user-owned project. * - * FROM: + * FROM: * * **Parameters:** * - * * `project_id: i64` + * * `project_number: i64` -- The project's number. + * * `field_id: i64` -- The unique identifier of the field. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn create_column( + pub async fn get_field_for_user( &self, - project_id: i64, - body: &crate::types::ProjectsUpdateColumnRequest, - ) -> ClientResult> { + project_number: i64, + field_id: i64, + username: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/projects/{}/columns", - crate::progenitor_support::encode_path(&project_id.to_string()), + "/users/{}/projectsV2/{}/fields/{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + crate::progenitor_support::encode_path(&field_id.to_string()), ), None, ); self.client - .post( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * List repository projects. + * List items for a user owned project. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/projects` endpoint. + * This function performs a `GET` to the `/users/{username}/projectsV2/{project_number}/items` endpoint. * - * Lists the projects in a repository. Returns a `404 Not Found` status if projects are disabled in the repository. If you do not have sufficient privileges to perform this action, a `401 Unauthorized` or `410 Gone` status is returned. + * List all items for a specific user-owned project accessible by the authenticated user. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. Can be either `open`, `closed`, or `all`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `project_number: i64` -- The project's number. + * * `username: &str` -- The handle for the GitHub user account. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `q: &str` -- Search query to filter items, see [Filtering projects](https://docs.github.com/issues/planning-and-tracking-with-projects/customizing-views-in-your-project/filtering-projects) for more information. + * * `fields: &str` -- Limit results to specific fields, by their IDs. If not specified, the title field will be returned. + * + * Example: `fields[]=123&fields[]=456&fields[]=789` or `fields=123,456,789`. */ - pub async fn list_for_repo( + pub async fn list_items_for_user( &self, - owner: &str, - repo: &str, - state: crate::types::IssuesListState, + project_number: i64, + username: &str, + before: &str, + after: &str, per_page: i64, - page: i64, - ) -> ClientResult>> { + q: &str, + fields: &str, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !fields.is_empty() { + query_args.push(("fields".to_string(), fields.to_string())); } if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } - if !state.to_string().is_empty() { - query_args.push(("state".to_string(), state.to_string())); + if !q.is_empty() { + query_args.push(("q".to_string(), q.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/projects?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/users/{}/projectsV2/{}/items?{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), query_ ), None, @@ -1009,32 +1275,44 @@ impl Projects { .await } /** - * List repository projects. + * List items for a user owned project. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/projects` endpoint. + * This function performs a `GET` to the `/users/{username}/projectsV2/{project_number}/items` endpoint. * - * As opposed to `list_for_repo`, this function returns all the pages of the request at once. + * As opposed to `list_items_for_user`, this function returns all the pages of the request at once. * - * Lists the projects in a repository. Returns a `404 Not Found` status if projects are disabled in the repository. If you do not have sufficient privileges to perform this action, a `401 Unauthorized` or `410 Gone` status is returned. + * List all items for a specific user-owned project accessible by the authenticated user. * - * FROM: + * FROM: */ - pub async fn list_all_for_repo( + pub async fn list_all_items_for_user( &self, - owner: &str, - repo: &str, - state: crate::types::IssuesListState, - ) -> ClientResult>> { + project_number: i64, + username: &str, + before: &str, + after: &str, + q: &str, + fields: &str, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if !state.to_string().is_empty() { - query_args.push(("state".to_string(), state.to_string())); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !fields.is_empty() { + query_args.push(("fields".to_string(), fields.to_string())); + } + if !q.is_empty() { + query_args.push(("q".to_string(), q.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/projects?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/users/{}/projectsV2/{}/items?{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), query_ ), None, @@ -1050,30 +1328,30 @@ impl Projects { .await } /** - * Create a repository project. + * Add item to user owned project. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/projects` endpoint. + * This function performs a `POST` to the `/users/{username}/projectsV2/{project_number}/items` endpoint. * - * Creates a repository project board. Returns a `404 Not Found` status if projects are disabled in the repository. If you do not have sufficient privileges to perform this action, a `401 Unauthorized` or `410 Gone` status is returned. + * Add an issue or pull request item to the specified user owned project. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `username: &str` -- The handle for the GitHub user account. + * * `project_number: i64` -- The project's number. */ - pub async fn create_for_repo( + pub async fn add_item_for_user( &self, - owner: &str, - repo: &str, - body: &crate::types::ProjectsCreateRequest, - ) -> ClientResult> { + username: &str, + project_number: i64, + body: &crate::types::ProjectsAddItemOrgRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/projects", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/users/{}/projectsV2/{}/items", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), ), None, ); @@ -1088,21 +1366,128 @@ impl Projects { .await } /** - * Create a user project. + * Get an item for a user owned project. + * + * This function performs a `GET` to the `/users/{username}/projectsV2/{project_number}/items/{item_id}` endpoint. * - * This function performs a `POST` to the `/user/projects` endpoint. + * Get a specific item from a user-owned project. * + * FROM: * + * **Parameters:** * - * FROM: + * * `project_number: i64` -- The project's number. + * * `username: &str` -- The handle for the GitHub user account. + * * `item_id: i64` -- The unique identifier of the project item. + * * `fields: &str` -- Limit results to specific fields, by their IDs. If not specified, the title field will be returned. + * + * Example: fields[]=123&fields[]=456&fields[]=789 or fields=123,456,789. */ - pub async fn create_for_authenticated_user( + pub async fn get_user_item( &self, - body: &crate::types::ProjectsCreateRequest, - ) -> ClientResult> { - let url = self.client.url("/user/projects", None); + project_number: i64, + username: &str, + item_id: i64, + fields: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !fields.is_empty() { + query_args.push(("fields".to_string(), fields.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/users/{}/projectsV2/{}/items/{}?{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + crate::progenitor_support::encode_path(&item_id.to_string()), + query_ + ), + None, + ); self.client - .post( + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete project item for user. + * + * This function performs a `DELETE` to the `/users/{username}/projectsV2/{project_number}/items/{item_id}` endpoint. + * + * Delete a specific item from a user-owned project. + * + * FROM: + * + * **Parameters:** + * + * * `project_number: i64` -- The project's number. + * * `username: &str` -- The handle for the GitHub user account. + * * `item_id: i64` -- The unique identifier of the project item. + */ + pub async fn delete_item_for_user( + &self, + project_number: i64, + username: &str, + item_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/users/{}/projectsV2/{}/items/{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + crate::progenitor_support::encode_path(&item_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update project item for user. + * + * This function performs a `PATCH` to the `/users/{username}/projectsV2/{project_number}/items/{item_id}` endpoint. + * + * Update a specific item in a user-owned project. + * + * FROM: + * + * **Parameters:** + * + * * `project_number: i64` -- The project's number. + * * `username: &str` -- The handle for the GitHub user account. + * * `item_id: i64` -- The unique identifier of the project item. + */ + pub async fn update_item_for_user( + &self, + project_number: i64, + username: &str, + item_id: i64, + body: &crate::types::ProjectsUpdateItemOrgRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/users/{}/projectsV2/{}/items/{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + crate::progenitor_support::encode_path(&item_id.to_string()), + ), + None, + ); + self.client + .patch( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -1112,43 +1497,57 @@ impl Projects { .await } /** - * List user projects. - * - * This function performs a `GET` to the `/users/{username}/projects` endpoint. + * List items for a user project view. * + * This function performs a `GET` to the `/users/{username}/projectsV2/{project_number}/views/{view_number}/items` endpoint. * + * List items in a user project with the saved view's filter applied. * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` - * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. Can be either `open`, `closed`, or `all`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `project_number: i64` -- The project's number. + * * `username: &str` -- The handle for the GitHub user account. + * * `view_number: i64` -- The number that identifies the project view. + * * `fields: &str` -- Limit results to specific fields, by their IDs. If not specified, the + * title field will be returned. + * + * Example: `fields[]=123&fields[]=456&fields[]=789` or `fields=123,456,789`. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_for_user( + pub async fn list_view_items_for_user( &self, + project_number: i64, username: &str, - state: crate::types::IssuesListState, + view_number: i64, + fields: &str, + before: &str, + after: &str, per_page: i64, - page: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !fields.is_empty() { + query_args.push(("fields".to_string(), fields.to_string())); } if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } - if !state.to_string().is_empty() { - query_args.push(("state".to_string(), state.to_string())); - } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/users/{}/projects?{}", - crate::progenitor_support::encode_path(username), + "/users/{}/projectsV2/{}/views/{}/items?{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + crate::progenitor_support::encode_path(&view_number.to_string()), query_ ), None, @@ -1164,30 +1563,42 @@ impl Projects { .await } /** - * List user projects. + * List items for a user project view. * - * This function performs a `GET` to the `/users/{username}/projects` endpoint. + * This function performs a `GET` to the `/users/{username}/projectsV2/{project_number}/views/{view_number}/items` endpoint. * - * As opposed to `list_for_user`, this function returns all the pages of the request at once. + * As opposed to `list_view_items_for_user`, this function returns all the pages of the request at once. * + * List items in a user project with the saved view's filter applied. * - * - * FROM: + * FROM: */ - pub async fn list_all_for_user( + pub async fn list_all_view_items_for_user( &self, + project_number: i64, username: &str, - state: crate::types::IssuesListState, - ) -> ClientResult>> { + view_number: i64, + fields: &str, + before: &str, + after: &str, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if !state.to_string().is_empty() { - query_args.push(("state".to_string(), state.to_string())); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !fields.is_empty() { + query_args.push(("fields".to_string(), fields.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/users/{}/projects?{}", - crate::progenitor_support::encode_path(username), + "/users/{}/projectsV2/{}/views/{}/items?{}", + crate::progenitor_support::encode_path(&username.to_string()), + crate::progenitor_support::encode_path(&project_number.to_string()), + crate::progenitor_support::encode_path(&view_number.to_string()), query_ ), None, diff --git a/github/src/pulls.rs b/github/src/pulls.rs index 184e7f5e..331aa744 100644 --- a/github/src/pulls.rs +++ b/github/src/pulls.rs @@ -16,23 +16,34 @@ impl Pulls { * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls` endpoint. * - * Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Lists pull requests in a specified repository. * - * FROM: + * Draft pull requests are available in public repositories with GitHub + * Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing + * plans, and in public and private repositories with GitHub Team and GitHub Enterprise + * Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) + * in the GitHub Help documentation. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `state: crate::types::IssuesListState` -- Indicates the state of the issues to return. Can be either `open`, `closed`, or `all`. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `state: crate::types::IssuesListState` -- Either `open`, `closed`, or `all` to filter by state. * * `head: &str` -- Filter pulls by head user or head organization and branch name in the format of `user:ref-name` or `organization:ref-name`. For example: `github:new-script-format` or `octocat:test-branch`. * * `base: &str` -- Filter pulls by base branch name. Example: `gh-pages`. - * * `sort: crate::types::PullsListSort` -- What to sort results by. Can be either `created`, `updated`, `popularity` (comment count) or `long-running` (age, filtering by pulls updated in the last month). - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `sort: crate::types::PullsListSort` -- What to sort results by. `popularity` will sort by the number of comments. `long-running` will sort by date created and will limit the results to pull requests that have been open for more than a month and have had activity within the past month. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list( &self, @@ -72,8 +83,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -95,9 +106,22 @@ impl Pulls { * * As opposed to `list`, this function returns all the pages of the request at once. * - * Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Lists pull requests in a specified repository. + * + * Draft pull requests are available in public repositories with GitHub + * Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing + * plans, and in public and private repositories with GitHub Team and GitHub Enterprise + * Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) + * in the GitHub Help documentation. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: */ pub async fn list_all( &self, @@ -129,8 +153,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -150,32 +174,37 @@ impl Pulls { * * This function performs a `POST` to the `/repos/{owner}/{repo}/pulls` endpoint. * - * Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * * To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request. * - * You can create a new pull request. + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-rate-limits)" for details. + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn create( &self, owner: &str, repo: &str, body: &crate::types::PullsCreateRequest, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( "/repos/{}/{}/pulls", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -194,21 +223,27 @@ impl Pulls { * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls/comments` endpoint. * - * Lists review comments for all pull requests in a repository. By default, review comments are in ascending order by ID. + * Lists review comments for all pull requests in a repository. By default, + * review comments are in ascending order by ID. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `sort: crate::types::PullsListReviewCommentsRepoSort` - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_review_comments_for_repo( &self, @@ -240,8 +275,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/comments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -263,9 +298,17 @@ impl Pulls { * * As opposed to `list_review_comments_for_repo`, this function returns all the pages of the request at once. * - * Lists review comments for all pull requests in a repository. By default, review comments are in ascending order by ID. + * Lists review comments for all pull requests in a repository. By default, + * review comments are in ascending order by ID. * - * FROM: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: */ pub async fn list_all_review_comments_for_repo( &self, @@ -289,8 +332,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/comments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -310,15 +353,22 @@ impl Pulls { * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls/comments/{comment_id}` endpoint. * - * Provides details for a review comment. + * Provides details for a specified review comment. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn get_review_comment( &self, @@ -329,8 +379,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/comments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, @@ -352,13 +402,13 @@ impl Pulls { * * Deletes a review comment. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn delete_review_comment( &self, @@ -369,8 +419,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/comments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, @@ -390,15 +440,22 @@ impl Pulls { * * This function performs a `PATCH` to the `/repos/{owner}/{repo}/pulls/comments/{comment_id}` endpoint. * - * Enables you to edit a review comment. + * Edits the content of a specified review comment. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn update_review_comment( &self, @@ -410,8 +467,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/comments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, @@ -431,41 +488,49 @@ impl Pulls { * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls/{pull_number}` endpoint. * - * Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * * Lists details of a pull request by providing its number. * - * When you get, [create](https://docs.github.com/rest/reference/pulls/#create-a-pull-request), or [edit](https://docs.github.com/rest/reference/pulls#update-a-pull-request) a pull request, GitHub creates a merge commit to test whether the pull request can be automatically merged into the base branch. This test commit is not added to the base branch or the head branch. You can review the status of the test commit using the `mergeable` key. For more information, see "[Checking mergeability of pull requests](https://docs.github.com/rest/guides/getting-started-with-the-git-database-api#checking-mergeability-of-pull-requests)". + * When you get, [create](https://docs.github.com/rest/pulls/pulls/#create-a-pull-request), or [edit](https://docs.github.com/rest/pulls/pulls#update-a-pull-request) a pull request, GitHub creates a merge commit to test whether the pull request can be automatically merged into the base branch. This test commit is not added to the base branch or the head branch. You can review the status of the test commit using the `mergeable` key. For more information, see "[Checking mergeability of pull requests](https://docs.github.com/rest/guides/getting-started-with-the-git-database-api#checking-mergeability-of-pull-requests)". * * The value of the `mergeable` attribute can be `true`, `false`, or `null`. If the value is `null`, then GitHub has started a background job to compute the mergeability. After giving the job time to complete, resubmit the request. When the job finishes, you will see a non-`null` value for the `mergeable` attribute in the response. If `mergeable` is `true`, then `merge_commit_sha` will be the SHA of the _test_ merge commit. * * The value of the `merge_commit_sha` attribute changes depending on the state of the pull request. Before merging a pull request, the `merge_commit_sha` attribute holds the SHA of the _test_ merge commit. After merging a pull request, the `merge_commit_sha` attribute changes depending on how you merged the pull request: * - * * If merged as a [merge commit](https://help.github.com/articles/about-merge-methods-on-github/), `merge_commit_sha` represents the SHA of the merge commit. - * * If merged via a [squash](https://help.github.com/articles/about-merge-methods-on-github/#squashing-your-merge-commits), `merge_commit_sha` represents the SHA of the squashed commit on the base branch. - * * If [rebased](https://help.github.com/articles/about-merge-methods-on-github/#rebasing-and-merging-your-commits), `merge_commit_sha` represents the commit that the base branch was updated to. + * * If merged as a [merge commit](https://docs.github.com/articles/about-merge-methods-on-github/), `merge_commit_sha` represents the SHA of the merge commit. + * * If merged via a [squash](https://docs.github.com/articles/about-merge-methods-on-github/#squashing-your-merge-commits), `merge_commit_sha` represents the SHA of the squashed commit on the base branch. + * * If [rebased](https://docs.github.com/articles/about-merge-methods-on-github/#rebasing-and-merging-your-commits), `merge_commit_sha` represents the commit that the base branch was updated to. + * + * Pass the appropriate [media type](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types) to fetch diff and patch formats. * - * Pass the appropriate [media type](https://docs.github.com/rest/overview/media-types/#commits-commit-comparison-and-pull-requests) to fetch diff and patch formats. + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * - **`application/vnd.github.diff`**: For more information, see "[git-diff](https://git-scm.com/docs/git-diff)" in the Git documentation. If a diff is corrupt, contact us through the [GitHub Support portal](https://support.github.com/). Include the repository name and pull request ID in your message. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. */ pub async fn get( &self, owner: &str, repo: &str, pull_number: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), ), None, @@ -485,17 +550,24 @@ impl Pulls { * * This function performs a `PATCH` to the `/repos/{owner}/{repo}/pulls/{pull_number}` endpoint. * - * Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * * To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request. * - * FROM: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. */ pub async fn update( &self, @@ -503,12 +575,12 @@ impl Pulls { repo: &str, pull_number: i64, body: &crate::types::PullsUpdateRequest, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), ), None, @@ -528,29 +600,35 @@ impl Pulls { * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls/{pull_number}/comments` endpoint. * - * Lists all review comments for a pull request. By default, review comments are in ascending order by ID. + * Lists all review comments for a specified pull request. By default, review comments + * are in ascending order by ID. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` - * * `sort: crate::types::Sort` -- One of `created` (when the repository was starred) or `updated` (when it was last pushed to). - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. + * * `sort: crate::types::SortData` -- The property to sort the results by. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_review_comments( &self, owner: &str, repo: &str, pull_number: i64, - sort: crate::types::Sort, + sort: crate::types::SortData, direction: crate::types::Order, since: Option>, per_page: i64, @@ -576,8 +654,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/comments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), query_ ), @@ -600,16 +678,24 @@ impl Pulls { * * As opposed to `list_review_comments`, this function returns all the pages of the request at once. * - * Lists all review comments for a pull request. By default, review comments are in ascending order by ID. + * Lists all review comments for a specified pull request. By default, review comments + * are in ascending order by ID. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: */ pub async fn list_all_review_comments( &self, owner: &str, repo: &str, pull_number: i64, - sort: crate::types::Sort, + sort: crate::types::SortData, direction: crate::types::Order, since: Option>, ) -> ClientResult>> { @@ -627,8 +713,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/comments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), query_ ), @@ -649,22 +735,29 @@ impl Pulls { * * This function performs a `POST` to the `/repos/{owner}/{repo}/pulls/{pull_number}/comments` endpoint. * + * Creates a review comment on the diff of a specified pull request. To add a regular comment to a pull request timeline, see "[Create an issue comment](https://docs.github.com/rest/issues/comments#create-an-issue-comment)." * - * Creates a review comment in the pull request diff. To add a regular comment to a pull request timeline, see "[Create an issue comment](https://docs.github.com/rest/reference/issues#create-an-issue-comment)." We recommend creating a review comment using `line`, `side`, and optionally `start_line` and `start_side` if your comment applies to more than one line in the pull request diff. + * If your comment applies to more than one line in the pull request diff, you should use the parameters `line`, `side`, and optionally `start_line` and `start_side` in your request. * - * You can still create a review comment using the `position` parameter. When you use `position`, the `line`, `side`, `start_line`, and `start_side` parameters are not required. For more information, see the [`comfort-fade` preview notice](https://docs.github.com/rest/reference/pulls#create-a-review-comment-for-a-pull-request-preview-notices). + * The `position` parameter is closing down. If you use `position`, the `line`, `side`, `start_line`, and `start_side` parameters are not required. * - * **Note:** The position value equals the number of lines down from the first "@@" hunk header in the file you want to add a comment. The line just below the "@@" line is position 1, the next line is position 2, and so on. The position in the diff continues to increase through lines of whitespace and additional hunks until the beginning of a new file. + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" + * and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. */ pub async fn create_review_comment( &self, @@ -676,8 +769,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/comments", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), ), None, @@ -699,16 +792,24 @@ impl Pulls { * * Creates a reply to a review comment for a pull request. For the `comment_id`, provide the ID of the review comment you are replying to. This must be the ID of a _top-level review comment_, not a reply to that comment. Replies to replies are not supported. * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" + * and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` - * * `comment_id: i64` -- comment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn create_reply_for_review_comment( &self, @@ -721,8 +822,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/comments/{}/replies", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), @@ -743,17 +844,26 @@ impl Pulls { * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls/{pull_number}/commits` endpoint. * - * Lists a maximum of 250 commits for a pull request. To receive a complete commit list for pull requests with more than 250 commits, use the [List commits](https://docs.github.com/rest/reference/repos#list-commits) endpoint. + * Lists a maximum of 250 commits for a pull request. To receive a complete + * commit list for pull requests with more than 250 commits, use the [List commits](https://docs.github.com/rest/commits/commits#list-commits) + * endpoint. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_commits( &self, @@ -774,8 +884,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/commits?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), query_ ), @@ -798,9 +908,18 @@ impl Pulls { * * As opposed to `list_commits`, this function returns all the pages of the request at once. * - * Lists a maximum of 250 commits for a pull request. To receive a complete commit list for pull requests with more than 250 commits, use the [List commits](https://docs.github.com/rest/reference/repos#list-commits) endpoint. + * Lists a maximum of 250 commits for a pull request. To receive a complete + * commit list for pull requests with more than 250 commits, use the [List commits](https://docs.github.com/rest/commits/commits#list-commits) + * endpoint. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: */ pub async fn list_all_commits( &self, @@ -811,8 +930,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/commits", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), ), None, @@ -832,17 +951,27 @@ impl Pulls { * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls/{pull_number}/files` endpoint. * - * **Note:** Responses include a maximum of 3000 files. The paginated response returns 30 files per page by default. + * Lists the files in a specified pull request. + * + * > [!NOTE] + * > Responses include a maximum of 3000 files. The paginated response returns 30 files per page by default. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_files( &self, @@ -863,8 +992,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/files?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), query_ ), @@ -887,9 +1016,19 @@ impl Pulls { * * As opposed to `list_files`, this function returns all the pages of the request at once. * - * **Note:** Responses include a maximum of 3000 files. The paginated response returns 30 files per page by default. + * Lists the files in a specified pull request. + * + * > [!NOTE] + * > Responses include a maximum of 3000 files. The paginated response returns 30 files per page by default. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: */ pub async fn list_all_files( &self, @@ -900,8 +1039,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/files", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), ), None, @@ -921,15 +1060,15 @@ impl Pulls { * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls/{pull_number}/merge` endpoint. * + * Checks if a pull request has been merged into the base branch. The HTTP status of the response indicates whether or not the pull request has been merged; the response body is empty. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. */ pub async fn check_if_merged( &self, @@ -940,8 +1079,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/merge", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), ), None, @@ -961,15 +1100,16 @@ impl Pulls { * * This function performs a `PUT` to the `/repos/{owner}/{repo}/pulls/{pull_number}/merge` endpoint. * - * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * Merges a pull request into the base branch. + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. */ pub async fn merge( &self, @@ -981,8 +1121,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/merge", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), ), None, @@ -998,45 +1138,32 @@ impl Pulls { .await } /** - * List requested reviewers for a pull request. + * Get all requested reviewers for a pull request. * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers` endpoint. * + * Gets the users or teams whose review is requested for a pull request. Once a requested reviewer submits a review, they are no longer considered a requested reviewer. Their review will instead be returned by the [List reviews for a pull request](https://docs.github.com/rest/pulls/reviews#list-reviews-for-a-pull-request) operation. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. */ pub async fn list_requested_reviewers( &self, owner: &str, repo: &str, pull_number: i64, - per_page: i64, - page: i64, ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/pulls/{}/requested_reviewers?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/pulls/{}/requested_reviewers", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), - query_ ), None, ); @@ -1055,15 +1182,16 @@ impl Pulls { * * This function performs a `POST` to the `/repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers` endpoint. * - * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * Requests reviews for a pull request from a given set of users and/or teams. + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. */ pub async fn request_reviewers( &self, @@ -1075,8 +1203,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/requested_reviewers", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), ), None, @@ -1096,28 +1224,28 @@ impl Pulls { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers` endpoint. * + * Removes review requests from a pull request for a given set of users and/or teams. * - * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. */ pub async fn remove_requested_reviewers( &self, owner: &str, repo: &str, pull_number: i64, - body: &crate::types::PullsRemoveRequestedReviewersRequest, + body: &crate::types::PullsRequestReviewers, ) -> ClientResult> { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/requested_reviewers", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), ), None, @@ -1137,17 +1265,24 @@ impl Pulls { * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls/{pull_number}/reviews` endpoint. * - * The list of reviews returns in chronological order. + * Lists all reviews for a specified pull request. The list of reviews returns in chronological order. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_reviews( &self, @@ -1168,8 +1303,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/reviews?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), query_ ), @@ -1192,9 +1327,16 @@ impl Pulls { * * As opposed to `list_reviews`, this function returns all the pages of the request at once. * - * The list of reviews returns in chronological order. + * Lists all reviews for a specified pull request. The list of reviews returns in chronological order. * - * FROM: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: */ pub async fn list_all_reviews( &self, @@ -1205,8 +1347,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/reviews", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), ), None, @@ -1226,21 +1368,31 @@ impl Pulls { * * This function performs a `POST` to the `/repos/{owner}/{repo}/pulls/{pull_number}/reviews` endpoint. * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * Creates a review on a specified pull request. + * + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." * - * Pull request reviews created in the `PENDING` state do not include the `submitted_at` property in the response. + * Pull request reviews created in the `PENDING` state are not submitted and therefore do not include the `submitted_at` property in the response. To create a pending review for a pull request, leave the `event` parameter blank. For more information about submitting a `PENDING` review, see "[Submit a review for a pull request](https://docs.github.com/rest/pulls/reviews#submit-a-review-for-a-pull-request)." * - * **Note:** To comment on a specific line in a file, you need to first determine the _position_ of that line in the diff. The GitHub REST API v3 offers the `application/vnd.github.v3.diff` [media type](https://docs.github.com/rest/overview/media-types#commits-commit-comparison-and-pull-requests). To see a pull request diff, add this media type to the `Accept` header of a call to the [single pull request](https://docs.github.com/rest/reference/pulls#get-a-pull-request) endpoint. + * > [!NOTE] + * > To comment on a specific line in a file, you need to first determine the position of that line in the diff. To see a pull request diff, add the `application/vnd.github.v3.diff` media type to the `Accept` header of a call to the [Get a pull request](https://docs.github.com/rest/pulls/pulls#get-a-pull-request) endpoint. * * The `position` value equals the number of lines down from the first "@@" hunk header in the file you want to add a comment. The line just below the "@@" line is position 1, the next line is position 2, and so on. The position in the diff continues to increase through lines of whitespace and additional hunks until the beginning of a new file. * - * FROM: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. */ pub async fn create_review( &self, @@ -1252,8 +1404,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/reviews", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), ), None, @@ -1273,16 +1425,23 @@ impl Pulls { * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}` endpoint. * + * Retrieves a pull request review by its ID. * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` - * * `review_id: i64` -- review_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. + * * `review_id: i64` -- The unique identifier of the review. */ pub async fn get_review( &self, @@ -1294,8 +1453,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/reviews/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), crate::progenitor_support::encode_path(&review_id.to_string()), ), @@ -1316,16 +1475,23 @@ impl Pulls { * * This function performs a `PUT` to the `/repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}` endpoint. * - * Update the review summary comment with new text. + * Updates the contents of a specified review summary comment. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` - * * `review_id: i64` -- review_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. + * * `review_id: i64` -- The unique identifier of the review. */ pub async fn update_review( &self, @@ -1338,8 +1504,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/reviews/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), crate::progenitor_support::encode_path(&review_id.to_string()), ), @@ -1360,16 +1526,23 @@ impl Pulls { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}` endpoint. * + * Deletes a pull request review that has not been submitted. Submitted reviews cannot be deleted. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` - * * `review_id: i64` -- review_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. + * * `review_id: i64` -- The unique identifier of the review. */ pub async fn delete_pending_review( &self, @@ -1381,8 +1554,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/reviews/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), crate::progenitor_support::encode_path(&review_id.to_string()), ), @@ -1403,18 +1576,25 @@ impl Pulls { * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments` endpoint. * - * List comments for a specific pull request review. + * Lists comments for a specific pull request review. * - * FROM: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` - * * `review_id: i64` -- review_id parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. + * * `review_id: i64` -- The unique identifier of the review. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_comments_for_review( &self, @@ -1436,8 +1616,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/reviews/{}/comments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), crate::progenitor_support::encode_path(&review_id.to_string()), query_ @@ -1461,9 +1641,16 @@ impl Pulls { * * As opposed to `list_comments_for_review`, this function returns all the pages of the request at once. * - * List comments for a specific pull request review. + * Lists comments for a specific pull request review. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: */ pub async fn list_all_comments_for_review( &self, @@ -1475,8 +1662,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/reviews/{}/comments", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), crate::progenitor_support::encode_path(&review_id.to_string()), ), @@ -1497,16 +1684,26 @@ impl Pulls { * * This function performs a `PUT` to the `/repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/dismissals` endpoint. * - * **Note:** To dismiss a pull request review on a [protected branch](https://docs.github.com/rest/reference/repos#branches), you must be a repository administrator or be included in the list of people or teams who can dismiss pull request reviews. + * Dismisses a specified review on a pull request. * - * FROM: + * > [!NOTE] + * > To dismiss a pull request review on a [protected branch](https://docs.github.com/rest/branches/branch-protection), you must be a repository administrator or be included in the list of people or teams who can dismiss pull request reviews. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` - * * `review_id: i64` -- review_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. + * * `review_id: i64` -- The unique identifier of the review. */ pub async fn dismiss_review( &self, @@ -1519,8 +1716,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/reviews/{}/dismissals", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), crate::progenitor_support::encode_path(&review_id.to_string()), ), @@ -1541,16 +1738,23 @@ impl Pulls { * * This function performs a `POST` to the `/repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/events` endpoint. * + * Submits a pending review for a pull request. For more information about creating a pending review for a pull request, see "[Create a review for a pull request](https://docs.github.com/rest/pulls/reviews#create-a-review-for-a-pull-request)." + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` - * * `review_id: i64` -- review_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. + * * `review_id: i64` -- The unique identifier of the review. */ pub async fn submit_review( &self, @@ -1563,8 +1767,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/reviews/{}/events", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), crate::progenitor_support::encode_path(&review_id.to_string()), ), @@ -1586,14 +1790,15 @@ impl Pulls { * This function performs a `PUT` to the `/repos/{owner}/{repo}/pulls/{pull_number}/update-branch` endpoint. * * Updates the pull request branch with the latest upstream changes by merging HEAD from the base branch into the pull request branch. + * Note: If making a request on behalf of a GitHub App you must also have permissions to write the contents of the head repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `pull_number: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pull_number: i64` -- The number that identifies the pull request. */ pub async fn update_branch( &self, @@ -1605,8 +1810,8 @@ impl Pulls { let url = self.client.url( &format!( "/repos/{}/{}/pulls/{}/update-branch", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&pull_number.to_string()), ), None, diff --git a/github/src/rate_limit.rs b/github/src/rate_limit.rs index 918cdc2a..ab866d3a 100644 --- a/github/src/rate_limit.rs +++ b/github/src/rate_limit.rs @@ -16,14 +16,28 @@ impl RateLimit { * * This function performs a `GET` to the `/rate_limit` endpoint. * - * **Note:** Accessing this endpoint does not count against your REST API rate limit. + * > [!NOTE] + * > Accessing this endpoint does not count against your REST API rate limit. * - * **Note:** The `rate` object is deprecated. If you're writing new API client code or updating existing code, you should use the `core` object instead of the `rate` object. The `core` object contains the same information that is present in the `rate` object. + * Some categories of endpoints have custom rate limits that are separate from the rate limit governing the other REST API endpoints. For this reason, the API response categorizes your rate limit. Under `resources`, you'll see objects relating to different categories: + * * The `core` object provides your rate limit status for all non-search-related resources in the REST API. + * * The `search` object provides your rate limit status for the REST API for searching (excluding code searches). For more information, see "[Search](https://docs.github.com/rest/search/search)." + * * The `code_search` object provides your rate limit status for the REST API for searching code. For more information, see "[Search code](https://docs.github.com/rest/search/search#search-code)." + * * The `graphql` object provides your rate limit status for the GraphQL API. For more information, see "[Resource limitations](https://docs.github.com/graphql/overview/resource-limitations#rate-limit)." + * * The `integration_manifest` object provides your rate limit status for the `POST /app-manifests/{code}/conversions` operation. For more information, see "[Creating a GitHub App from a manifest](https://docs.github.com/apps/creating-github-apps/setting-up-a-github-app/creating-a-github-app-from-a-manifest#3-you-exchange-the-temporary-code-to-retrieve-the-app-configuration)." + * * The `dependency_snapshots` object provides your rate limit status for submitting snapshots to the dependency graph. For more information, see "[Dependency graph](https://docs.github.com/rest/dependency-graph)." + * * The `dependency_sbom` object provides your rate limit status for requesting SBOMs from the dependency graph. For more information, see "[Dependency graph](https://docs.github.com/rest/dependency-graph)." + * * The `code_scanning_upload` object provides your rate limit status for uploading SARIF results to code scanning. For more information, see "[Uploading a SARIF file to GitHub](https://docs.github.com/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github)." + * * The `actions_runner_registration` object provides your rate limit status for registering self-hosted runners in GitHub Actions. For more information, see "[Self-hosted runners](https://docs.github.com/rest/actions/self-hosted-runners)." + * * The `source_import` object is no longer in use for any API endpoints, and it will be removed in the next API version. For more information about API versions, see "[API Versions](https://docs.github.com/rest/about-the-rest-api/api-versions)." * - * FROM: + * > [!NOTE] + * > The `rate` object is closing down. If you're writing new API client code or updating existing code, you should use the `core` object instead of the `rate` object. The `core` object contains the same information that is present in the `rate` object. + * + * FROM: */ pub async fn get(&self) -> ClientResult> { - let url = self.client.url("/rate_limit", None); + let url = self.client.url(&"/rate_limit".to_string(), None); self.client .get( &url, diff --git a/github/src/reactions.rs b/github/src/reactions.rs index b94dd1f5..43f501a8 100644 --- a/github/src/reactions.rs +++ b/github/src/reactions.rs @@ -11,453 +11,23 @@ impl Reactions { Reactions { client } } - /** - * List reactions for a team discussion comment. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions` endpoint. - * - * List the reactions to a [team discussion comment](https://docs.github.com/rest/reference/teams#discussion-comments/). OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/:org_id/team/:team_id/discussions/:discussion_number/comments/:comment_number/reactions`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` - * * `comment_number: i64` - * * `content: crate::types::Content` -- Returns a single [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types). Omit this parameter to list all reactions to a team discussion comment. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - */ - pub async fn list_for_team_discussion_comment_in_org( - &self, - org: &str, - team_slug: &str, - discussion_number: i64, - comment_number: i64, - content: crate::types::Content, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !content.to_string().is_empty() { - query_args.push(("content".to_string(), content.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/discussions/{}/comments/{}/reactions?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), - query_ - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List reactions for a team discussion comment. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions` endpoint. - * - * As opposed to `list_for_team_discussion_comment_in_org`, this function returns all the pages of the request at once. - * - * List the reactions to a [team discussion comment](https://docs.github.com/rest/reference/teams#discussion-comments/). OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/:org_id/team/:team_id/discussions/:discussion_number/comments/:comment_number/reactions`. - * - * FROM: - */ - pub async fn list_all_for_team_discussion_comment_in_org( - &self, - org: &str, - team_slug: &str, - discussion_number: i64, - comment_number: i64, - content: crate::types::Content, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !content.to_string().is_empty() { - query_args.push(("content".to_string(), content.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/discussions/{}/comments/{}/reactions?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), - query_ - ), - None, - ); - self.client - .get_all_pages( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Create reaction for a team discussion comment. - * - * This function performs a `POST` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions` endpoint. - * - * Create a reaction to a [team discussion comment](https://docs.github.com/rest/reference/teams#discussion-comments). OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). A response with an HTTP `200` status means that you already added the reaction type to this team discussion comment. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `POST /organizations/:org_id/team/:team_id/discussions/:discussion_number/comments/:comment_number/reactions`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` - * * `comment_number: i64` - */ - pub async fn create_for_team_discussion_comment_in_org( - &self, - org: &str, - team_slug: &str, - discussion_number: i64, - comment_number: i64, - body: &crate::types::ReactionsCreateIssueRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/discussions/{}/comments/{}/reactions", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), - ), - None, - ); - self.client - .post( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } - /** - * Delete team discussion comment reaction. - * - * This function performs a `DELETE` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions/{reaction_id}` endpoint. - * - * **Note:** You can also specify a team or organization with `team_id` and `org_id` using the route `DELETE /organizations/:org_id/team/:team_id/discussions/:discussion_number/comments/:comment_number/reactions/:reaction_id`. - * - * Delete a reaction to a [team discussion comment](https://docs.github.com/rest/reference/teams#discussion-comments). OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` - * * `comment_number: i64` - * * `reaction_id: i64` - */ - pub async fn delete_for_team_discussion_comment( - &self, - org: &str, - team_slug: &str, - discussion_number: i64, - comment_number: i64, - reaction_id: i64, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/discussions/{}/comments/{}/reactions/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), - crate::progenitor_support::encode_path(&reaction_id.to_string()), - ), - None, - ); - self.client - .delete( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List reactions for a team discussion. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions` endpoint. - * - * List the reactions to a [team discussion](https://docs.github.com/rest/reference/teams#discussions). OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/:org_id/team/:team_id/discussions/:discussion_number/reactions`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` - * * `content: crate::types::Content` -- Returns a single [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types). Omit this parameter to list all reactions to a team discussion. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - */ - pub async fn list_for_team_discussion_in_org( - &self, - org: &str, - team_slug: &str, - discussion_number: i64, - content: crate::types::Content, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !content.to_string().is_empty() { - query_args.push(("content".to_string(), content.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/discussions/{}/reactions?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - query_ - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List reactions for a team discussion. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions` endpoint. - * - * As opposed to `list_for_team_discussion_in_org`, this function returns all the pages of the request at once. - * - * List the reactions to a [team discussion](https://docs.github.com/rest/reference/teams#discussions). OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/:org_id/team/:team_id/discussions/:discussion_number/reactions`. - * - * FROM: - */ - pub async fn list_all_for_team_discussion_in_org( - &self, - org: &str, - team_slug: &str, - discussion_number: i64, - content: crate::types::Content, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !content.to_string().is_empty() { - query_args.push(("content".to_string(), content.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/discussions/{}/reactions?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - query_ - ), - None, - ); - self.client - .get_all_pages( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Create reaction for a team discussion. - * - * This function performs a `POST` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions` endpoint. - * - * Create a reaction to a [team discussion](https://docs.github.com/rest/reference/teams#discussions). OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). A response with an HTTP `200` status means that you already added the reaction type to this team discussion. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `POST /organizations/:org_id/team/:team_id/discussions/:discussion_number/reactions`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` - */ - pub async fn create_for_team_discussion_in_org( - &self, - org: &str, - team_slug: &str, - discussion_number: i64, - body: &crate::types::ReactionsCreateIssueRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/discussions/{}/reactions", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - ), - None, - ); - self.client - .post( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } - /** - * Delete team discussion reaction. - * - * This function performs a `DELETE` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions/{reaction_id}` endpoint. - * - * **Note:** You can also specify a team or organization with `team_id` and `org_id` using the route `DELETE /organizations/:org_id/team/:team_id/discussions/:discussion_number/reactions/:reaction_id`. - * - * Delete a reaction to a [team discussion](https://docs.github.com/rest/reference/teams#discussions). OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` - * * `reaction_id: i64` - */ - pub async fn delete_for_team_discussion( - &self, - org: &str, - team_slug: &str, - discussion_number: i64, - reaction_id: i64, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/discussions/{}/reactions/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&reaction_id.to_string()), - ), - None, - ); - self.client - .delete( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Delete a reaction (Legacy). - * - * This function performs a `DELETE` to the `/reactions/{reaction_id}` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Reactions API. We recommend migrating your existing code to use the new delete reactions endpoints. For more information, see this [blog post](https://developer.github.com/changes/2020-02-26-new-delete-reactions-endpoints/). - * - * OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/), when deleting a [team discussion](https://docs.github.com/rest/reference/teams#discussions) or [team discussion comment](https://docs.github.com/rest/reference/teams#discussion-comments). - * - * FROM: - * - * **Parameters:** - * - * * `reaction_id: i64` - */ - pub async fn delete_legacy(&self, reaction_id: i64) -> ClientResult> { - let url = self.client.url( - &format!( - "/reactions/{}", - crate::progenitor_support::encode_path(&reaction_id.to_string()), - ), - None, - ); - self.client - .delete( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } /** * List reactions for a commit comment. * * This function performs a `GET` to the `/repos/{owner}/{repo}/comments/{comment_id}/reactions` endpoint. * - * List the reactions to a [commit comment](https://docs.github.com/rest/reference/repos#comments). + * List the reactions to a [commit comment](https://docs.github.com/rest/commits/comments#get-a-commit-comment). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. - * * `content: crate::types::Content` -- Returns a single [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types). Omit this parameter to list all reactions to a commit comment. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. + * * `content: crate::types::Content` -- Returns a single [reaction type](https://docs.github.com/rest/reactions/reactions#about-reactions). Omit this parameter to list all reactions to a commit comment. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_commit_comment( &self, @@ -482,8 +52,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/comments/{}/reactions?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), query_ ), @@ -506,9 +76,9 @@ impl Reactions { * * As opposed to `list_for_commit_comment`, this function returns all the pages of the request at once. * - * List the reactions to a [commit comment](https://docs.github.com/rest/reference/repos#comments). + * List the reactions to a [commit comment](https://docs.github.com/rest/commits/comments#get-a-commit-comment). * - * FROM: + * FROM: */ pub async fn list_all_for_commit_comment( &self, @@ -525,8 +95,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/comments/{}/reactions?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), query_ ), @@ -547,15 +117,15 @@ impl Reactions { * * This function performs a `POST` to the `/repos/{owner}/{repo}/comments/{comment_id}/reactions` endpoint. * - * Create a reaction to a [commit comment](https://docs.github.com/rest/reference/repos#comments). A response with an HTTP `200` status means that you already added the reaction type to this commit comment. + * Create a reaction to a [commit comment](https://docs.github.com/rest/commits/comments#get-a-commit-comment). A response with an HTTP `200` status means that you already added the reaction type to this commit comment. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn create_for_commit_comment( &self, @@ -567,8 +137,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/comments/{}/reactions", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, @@ -588,18 +158,19 @@ impl Reactions { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/comments/{comment_id}/reactions/{reaction_id}` endpoint. * - * **Note:** You can also specify a repository by `repository_id` using the route `DELETE /repositories/:repository_id/comments/:comment_id/reactions/:reaction_id`. + * > [!NOTE] + * > You can also specify a repository by `repository_id` using the route `DELETE /repositories/:repository_id/comments/:comment_id/reactions/:reaction_id`. * - * Delete a reaction to a [commit comment](https://docs.github.com/rest/reference/repos#comments). + * Delete a reaction to a [commit comment](https://docs.github.com/rest/commits/comments#get-a-commit-comment). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. - * * `reaction_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. + * * `reaction_id: i64` -- The unique identifier of the reaction. */ pub async fn delete_for_commit_comment( &self, @@ -611,8 +182,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/comments/{}/reactions/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), crate::progenitor_support::encode_path(&reaction_id.to_string()), ), @@ -633,18 +204,18 @@ impl Reactions { * * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/comments/{comment_id}/reactions` endpoint. * - * List the reactions to an [issue comment](https://docs.github.com/rest/reference/issues#comments). + * List the reactions to an [issue comment](https://docs.github.com/rest/issues/comments#get-an-issue-comment). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. - * * `content: crate::types::Content` -- Returns a single [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types). Omit this parameter to list all reactions to an issue comment. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. + * * `content: crate::types::Content` -- Returns a single [reaction type](https://docs.github.com/rest/reactions/reactions#about-reactions). Omit this parameter to list all reactions to an issue comment. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_issue_comment( &self, @@ -669,8 +240,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/issues/comments/{}/reactions?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), query_ ), @@ -693,9 +264,9 @@ impl Reactions { * * As opposed to `list_for_issue_comment`, this function returns all the pages of the request at once. * - * List the reactions to an [issue comment](https://docs.github.com/rest/reference/issues#comments). + * List the reactions to an [issue comment](https://docs.github.com/rest/issues/comments#get-an-issue-comment). * - * FROM: + * FROM: */ pub async fn list_all_for_issue_comment( &self, @@ -712,8 +283,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/issues/comments/{}/reactions?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), query_ ), @@ -734,15 +305,15 @@ impl Reactions { * * This function performs a `POST` to the `/repos/{owner}/{repo}/issues/comments/{comment_id}/reactions` endpoint. * - * Create a reaction to an [issue comment](https://docs.github.com/rest/reference/issues#comments). A response with an HTTP `200` status means that you already added the reaction type to this issue comment. + * Create a reaction to an [issue comment](https://docs.github.com/rest/issues/comments#get-an-issue-comment). A response with an HTTP `200` status means that you already added the reaction type to this issue comment. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn create_for_issue_comment( &self, @@ -754,8 +325,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/issues/comments/{}/reactions", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, @@ -775,18 +346,19 @@ impl Reactions { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id}` endpoint. * - * **Note:** You can also specify a repository by `repository_id` using the route `DELETE delete /repositories/:repository_id/issues/comments/:comment_id/reactions/:reaction_id`. + * > [!NOTE] + * > You can also specify a repository by `repository_id` using the route `DELETE delete /repositories/:repository_id/issues/comments/:comment_id/reactions/:reaction_id`. * - * Delete a reaction to an [issue comment](https://docs.github.com/rest/reference/issues#comments). + * Delete a reaction to an [issue comment](https://docs.github.com/rest/issues/comments#get-an-issue-comment). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. - * * `reaction_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. + * * `reaction_id: i64` -- The unique identifier of the reaction. */ pub async fn delete_for_issue_comment( &self, @@ -798,8 +370,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/issues/comments/{}/reactions/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), crate::progenitor_support::encode_path(&reaction_id.to_string()), ), @@ -820,18 +392,18 @@ impl Reactions { * * This function performs a `GET` to the `/repos/{owner}/{repo}/issues/{issue_number}/reactions` endpoint. * - * List the reactions to an [issue](https://docs.github.com/rest/reference/issues). + * List the reactions to an [issue](https://docs.github.com/rest/issues/issues#get-an-issue). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. - * * `content: crate::types::Content` -- Returns a single [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types). Omit this parameter to list all reactions to an issue. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + * * `content: crate::types::Content` -- Returns a single [reaction type](https://docs.github.com/rest/reactions/reactions#about-reactions). Omit this parameter to list all reactions to an issue. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_issue( &self, @@ -856,8 +428,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/reactions?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), query_ ), @@ -880,9 +452,9 @@ impl Reactions { * * As opposed to `list_for_issue`, this function returns all the pages of the request at once. * - * List the reactions to an [issue](https://docs.github.com/rest/reference/issues). + * List the reactions to an [issue](https://docs.github.com/rest/issues/issues#get-an-issue). * - * FROM: + * FROM: */ pub async fn list_all_for_issue( &self, @@ -899,8 +471,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/reactions?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), query_ ), @@ -921,15 +493,15 @@ impl Reactions { * * This function performs a `POST` to the `/repos/{owner}/{repo}/issues/{issue_number}/reactions` endpoint. * - * Create a reaction to an [issue](https://docs.github.com/rest/reference/issues/). A response with an HTTP `200` status means that you already added the reaction type to this issue. + * Create a reaction to an [issue](https://docs.github.com/rest/issues/issues#get-an-issue). A response with an HTTP `200` status means that you already added the reaction type to this issue. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. */ pub async fn create_for_issue( &self, @@ -941,8 +513,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/reactions", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), ), None, @@ -962,18 +534,19 @@ impl Reactions { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/issues/{issue_number}/reactions/{reaction_id}` endpoint. * - * **Note:** You can also specify a repository by `repository_id` using the route `DELETE /repositories/:repository_id/issues/:issue_number/reactions/:reaction_id`. + * > [!NOTE] + * > You can also specify a repository by `repository_id` using the route `DELETE /repositories/:repository_id/issues/:issue_number/reactions/:reaction_id`. * - * Delete a reaction to an [issue](https://docs.github.com/rest/reference/issues/). + * Delete a reaction to an [issue](https://docs.github.com/rest/issues/issues#get-an-issue). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `issue_number: i64` -- issue_number parameter. - * * `reaction_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `issue_number: i64` -- The number that identifies the issue. + * * `reaction_id: i64` -- The unique identifier of the reaction. */ pub async fn delete_for_issue( &self, @@ -985,8 +558,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/issues/{}/reactions/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&issue_number.to_string()), crate::progenitor_support::encode_path(&reaction_id.to_string()), ), @@ -1007,18 +580,18 @@ impl Reactions { * * This function performs a `GET` to the `/repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions` endpoint. * - * List the reactions to a [pull request review comment](https://docs.github.com/rest/reference/pulls#review-comments). + * List the reactions to a [pull request review comment](https://docs.github.com/rest/pulls/comments#get-a-review-comment-for-a-pull-request). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. - * * `content: crate::types::Content` -- Returns a single [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types). Omit this parameter to list all reactions to a pull request review comment. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. + * * `content: crate::types::Content` -- Returns a single [reaction type](https://docs.github.com/rest/reactions/reactions#about-reactions). Omit this parameter to list all reactions to a pull request review comment. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_pull_request_review_comment( &self, @@ -1043,8 +616,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/pulls/comments/{}/reactions?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), query_ ), @@ -1067,9 +640,9 @@ impl Reactions { * * As opposed to `list_for_pull_request_review_comment`, this function returns all the pages of the request at once. * - * List the reactions to a [pull request review comment](https://docs.github.com/rest/reference/pulls#review-comments). + * List the reactions to a [pull request review comment](https://docs.github.com/rest/pulls/comments#get-a-review-comment-for-a-pull-request). * - * FROM: + * FROM: */ pub async fn list_all_for_pull_request_review_comment( &self, @@ -1086,8 +659,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/pulls/comments/{}/reactions?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), query_ ), @@ -1108,15 +681,15 @@ impl Reactions { * * This function performs a `POST` to the `/repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions` endpoint. * - * Create a reaction to a [pull request review comment](https://docs.github.com/rest/reference/pulls#comments). A response with an HTTP `200` status means that you already added the reaction type to this pull request review comment. + * Create a reaction to a [pull request review comment](https://docs.github.com/rest/pulls/comments#get-a-review-comment-for-a-pull-request). A response with an HTTP `200` status means that you already added the reaction type to this pull request review comment. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. */ pub async fn create_for_pull_request_review_comment( &self, @@ -1128,8 +701,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/pulls/comments/{}/reactions", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, @@ -1149,18 +722,19 @@ impl Reactions { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id}` endpoint. * - * **Note:** You can also specify a repository by `repository_id` using the route `DELETE /repositories/:repository_id/pulls/comments/:comment_id/reactions/:reaction_id.` + * > [!NOTE] + * > You can also specify a repository by `repository_id` using the route `DELETE /repositories/:repository_id/pulls/comments/:comment_id/reactions/:reaction_id.` * - * Delete a reaction to a [pull request review comment](https://docs.github.com/rest/reference/pulls#review-comments). + * Delete a reaction to a [pull request review comment](https://docs.github.com/rest/pulls/comments#get-a-review-comment-for-a-pull-request). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. - * * `reaction_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. + * * `reaction_id: i64` -- The unique identifier of the reaction. */ pub async fn delete_for_pull_request_comment( &self, @@ -1172,8 +746,8 @@ impl Reactions { let url = self.client.url( &format!( "/repos/{}/{}/pulls/comments/{}/reactions/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&comment_id.to_string()), crate::progenitor_support::encode_path(&reaction_id.to_string()), ), @@ -1190,72 +764,29 @@ impl Reactions { .await } /** - * Create reaction for a release. + * List reactions for a release. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/releases/{release_id}/reactions` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/{release_id}/reactions` endpoint. * - * Create a reaction to a [release](https://docs.github.com/rest/reference/repos#releases). A response with a `Status: 200 OK` means that you already added the reaction type to this release. + * List the reactions to a [release](https://docs.github.com/rest/releases/releases#get-a-release). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `release_id: i64` -- release_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `release_id: i64` -- The unique identifier of the release. + * * `content: crate::types::ReactionsListReleaseContent` -- Returns a single [reaction type](https://docs.github.com/rest/reactions/reactions#about-reactions). Omit this parameter to list all reactions to a release. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn create_for_release( + pub async fn list_for_release( &self, owner: &str, repo: &str, release_id: i64, - body: &crate::types::ReactionsCreateReleaseRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/repos/{}/{}/releases/{}/reactions", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&release_id.to_string()), - ), - None, - ); - self.client - .post( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } - /** - * List reactions for a team discussion comment (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List reactions for a team discussion comment`](https://docs.github.com/rest/reference/reactions#list-reactions-for-a-team-discussion-comment) endpoint. - * - * List the reactions to a [team discussion comment](https://docs.github.com/rest/reference/teams#discussion-comments). OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - * * `discussion_number: i64` - * * `comment_number: i64` - * * `content: crate::types::Content` -- Returns a single [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types). Omit this parameter to list all reactions to a team discussion comment. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - */ - pub async fn list_for_team_discussion_comment_legacy( - &self, - team_id: i64, - discussion_number: i64, - comment_number: i64, - content: crate::types::Content, + content: crate::types::ReactionsListReleaseContent, per_page: i64, page: i64, ) -> ClientResult>> { @@ -1272,10 +803,10 @@ impl Reactions { let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/teams/{}/discussions/{}/comments/{}/reactions?{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), + "/repos/{}/{}/releases/{}/reactions?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&release_id.to_string()), query_ ), None, @@ -1291,24 +822,22 @@ impl Reactions { .await } /** - * List reactions for a team discussion comment (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions` endpoint. + * List reactions for a release. * - * As opposed to `list_for_team_discussion_comment_legacy`, this function returns all the pages of the request at once. + * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/{release_id}/reactions` endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List reactions for a team discussion comment`](https://docs.github.com/rest/reference/reactions#list-reactions-for-a-team-discussion-comment) endpoint. + * As opposed to `list_for_release`, this function returns all the pages of the request at once. * - * List the reactions to a [team discussion comment](https://docs.github.com/rest/reference/teams#discussion-comments). OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * List the reactions to a [release](https://docs.github.com/rest/releases/releases#get-a-release). * - * FROM: + * FROM: */ - pub async fn list_all_for_team_discussion_comment_legacy( + pub async fn list_all_for_release( &self, - team_id: i64, - discussion_number: i64, - comment_number: i64, - content: crate::types::Content, + owner: &str, + repo: &str, + release_id: i64, + content: crate::types::ReactionsListReleaseContent, ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if !content.to_string().is_empty() { @@ -1317,10 +846,10 @@ impl Reactions { let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/teams/{}/discussions/{}/comments/{}/reactions?{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), + "/repos/{}/{}/releases/{}/reactions?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&release_id.to_string()), query_ ), None, @@ -1336,35 +865,33 @@ impl Reactions { .await } /** - * Create reaction for a team discussion comment (Legacy). - * - * This function performs a `POST` to the `/teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions` endpoint. + * Create reaction for a release. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new "[Create reaction for a team discussion comment](https://docs.github.com/rest/reference/reactions#create-reaction-for-a-team-discussion-comment)" endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/releases/{release_id}/reactions` endpoint. * - * Create a reaction to a [team discussion comment](https://docs.github.com/rest/reference/teams#discussion-comments). OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). A response with an HTTP `200` status means that you already added the reaction type to this team discussion comment. + * Create a reaction to a [release](https://docs.github.com/rest/releases/releases#get-a-release). A response with a `Status: 200 OK` means that you already added the reaction type to this release. * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `discussion_number: i64` - * * `comment_number: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `release_id: i64` -- The unique identifier of the release. */ - pub async fn create_for_team_discussion_comment_legacy( + pub async fn create_for_release( &self, - team_id: i64, - discussion_number: i64, - comment_number: i64, - body: &crate::types::ReactionsCreateIssueRequest, + owner: &str, + repo: &str, + release_id: i64, + body: &crate::types::ReactionsCreateReleaseRequest, ) -> ClientResult> { let url = self.client.url( &format!( - "/teams/{}/discussions/{}/comments/{}/reactions", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), + "/repos/{}/{}/releases/{}/reactions", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&release_id.to_string()), ), None, ); @@ -1379,97 +906,43 @@ impl Reactions { .await } /** - * List reactions for a team discussion (Legacy). + * Delete a release reaction. * - * This function performs a `GET` to the `/teams/{team_id}/discussions/{discussion_number}/reactions` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/releases/{release_id}/reactions/{reaction_id}` endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List reactions for a team discussion`](https://docs.github.com/rest/reference/reactions#list-reactions-for-a-team-discussion) endpoint. + * > [!NOTE] + * > You can also specify a repository by `repository_id` using the route `DELETE delete /repositories/:repository_id/releases/:release_id/reactions/:reaction_id`. * - * List the reactions to a [team discussion](https://docs.github.com/rest/reference/teams#discussions). OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * Delete a reaction to a [release](https://docs.github.com/rest/releases/releases#get-a-release). * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `discussion_number: i64` - * * `content: crate::types::Content` -- Returns a single [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types). Omit this parameter to list all reactions to a team discussion. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `release_id: i64` -- The unique identifier of the release. + * * `reaction_id: i64` -- The unique identifier of the reaction. */ - pub async fn list_for_team_discussion_legacy( + pub async fn delete_for_release( &self, - team_id: i64, - discussion_number: i64, - content: crate::types::Content, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !content.to_string().is_empty() { - query_args.push(("content".to_string(), content.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/teams/{}/discussions/{}/reactions?{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - query_ - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List reactions for a team discussion (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/discussions/{discussion_number}/reactions` endpoint. - * - * As opposed to `list_for_team_discussion_legacy`, this function returns all the pages of the request at once. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List reactions for a team discussion`](https://docs.github.com/rest/reference/reactions#list-reactions-for-a-team-discussion) endpoint. - * - * List the reactions to a [team discussion](https://docs.github.com/rest/reference/teams#discussions). OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * FROM: - */ - pub async fn list_all_for_team_discussion_legacy( - &self, - team_id: i64, - discussion_number: i64, - content: crate::types::Content, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !content.to_string().is_empty() { - query_args.push(("content".to_string(), content.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + owner: &str, + repo: &str, + release_id: i64, + reaction_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/teams/{}/discussions/{}/reactions?{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - query_ + "/repos/{}/{}/releases/{}/reactions/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&release_id.to_string()), + crate::progenitor_support::encode_path(&reaction_id.to_string()), ), None, ); self.client - .get_all_pages( + .delete( &url, crate::Message { body: None, @@ -1478,44 +951,4 @@ impl Reactions { ) .await } - /** - * Create reaction for a team discussion (Legacy). - * - * This function performs a `POST` to the `/teams/{team_id}/discussions/{discussion_number}/reactions` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`Create reaction for a team discussion`](https://docs.github.com/rest/reference/reactions#create-reaction-for-a-team-discussion) endpoint. - * - * Create a reaction to a [team discussion](https://docs.github.com/rest/reference/teams#discussions). OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). A response with an HTTP `200` status means that you already added the reaction type to this team discussion. - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - * * `discussion_number: i64` - */ - pub async fn create_for_team_discussion_legacy( - &self, - team_id: i64, - discussion_number: i64, - body: &crate::types::ReactionsCreateIssueRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}/discussions/{}/reactions", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - ), - None, - ); - self.client - .post( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } } diff --git a/github/src/repos.rs b/github/src/repos.rs index 483d2927..6e03ae60 100644 --- a/github/src/repos.rs +++ b/github/src/repos.rs @@ -27,18 +27,19 @@ impl Repos { * * Lists repositories for the specified organization. * - * FROM: + * > [!NOTE] + * > In order to see the `security_and_analysis` block for a repository you must have admin permissions for the repository or be an owner or security manager for the organization that owns the repository. For more information, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)." + * + * FROM: * * **Parameters:** * - * * `org: &str` - * * `type_: crate::types::ReposListOrgType` -- Specifies the types of repositories you want returned. Can be one of `all`, `public`, `private`, `forks`, `sources`, `member`, `internal`. Note: For GitHub AE, can be one of `all`, `private`, `forks`, `sources`, `member`, `internal`. Default: `all`. If your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+, `type` can also be `internal`. However, the `internal` value is not yet supported when a GitHub App calls this API with an installation access token. - * * `sort: crate::types::ReposListOrgSort` -- Can be one of `created`, `updated`, `pushed`, `full_name`. - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `type_: crate::types::ReposListOrgType` -- Specifies the types of repositories you want returned. + * * `sort: crate::types::ReposListOrgSort` -- The property to sort the results by. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_org( &self, @@ -69,7 +70,7 @@ impl Repos { let url = self.client.url( &format!( "/orgs/{}/repos?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -93,7 +94,10 @@ impl Repos { * * Lists repositories for the specified organization. * - * FROM: + * > [!NOTE] + * > In order to see the `security_and_analysis` block for a repository you must have admin permissions for the repository or be an owner or security manager for the organization that owns the repository. For more information, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)." + * + * FROM: */ pub async fn list_all_for_org( &self, @@ -116,7 +120,7 @@ impl Repos { let url = self.client.url( &format!( "/orgs/{}/repos?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -138,28 +142,23 @@ impl Repos { * * Creates a new repository in the specified organization. The authenticated user must be a member of the organization. * - * **OAuth scope requirements** - * - * When using [OAuth](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/), authorizations must include: + * OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to create a public repository, and `repo` scope to create a private repository. * - * * `public_repo` scope or `repo` scope to create a public repository. Note: For GitHub AE, use `repo` scope to create an internal repository. - * * `repo` scope to create a private repository - * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn create_in_org( &self, org: &str, body: &crate::types::ReposCreateInOrgRequest, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( "/orgs/{}/repos", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -174,31 +173,47 @@ impl Repos { .await } /** - * Get a repository. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}` endpoint. + * Get all organization repository rulesets. * - * When you pass the `scarlet-witch-preview` media type, requests to get a repository will also return the repository's code of conduct if it can be detected from the repository's code of conduct file. + * This function performs a `GET` to the `/orgs/{org}/rulesets` endpoint. * - * The `parent` and `source` objects are present when the repository is a fork. `parent` is the repository this repository was forked from, `source` is the ultimate source for the network. + * Get all the repository rulesets for an organization. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `targets: &str` -- A comma-separated list of rule targets to filter by. + * If provided, only rulesets that apply to the specified targets will be returned. + * For example, `branch,tag,push`. + * . */ - pub async fn get( + pub async fn get_org_rulesets( &self, - owner: &str, - repo: &str, - ) -> ClientResult> { + org: &str, + per_page: i64, + page: i64, + targets: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !targets.is_empty() { + query_args.push(("targets".to_string(), targets.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/orgs/{}/rulesets?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ ), None, ); @@ -213,33 +228,36 @@ impl Repos { .await } /** - * Delete a repository. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}` endpoint. - * - * Deleting a repository requires admin access. If OAuth is used, the `delete_repo` scope is required. + * Get all organization repository rulesets. * - * If an organization owner has configured the organization to prevent members from deleting organization-owned - * repositories, you will get a `403 Forbidden` response. + * This function performs a `GET` to the `/orgs/{org}/rulesets` endpoint. * - * FROM: + * As opposed to `get_org_rulesets`, this function returns all the pages of the request at once. * - * **Parameters:** + * Get all the repository rulesets for an organization. * - * * `owner: &str` - * * `repo: &str` + * FROM: */ - pub async fn delete(&self, owner: &str, repo: &str) -> ClientResult> { + pub async fn get_all_org_rulesets( + &self, + org: &str, + targets: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !targets.is_empty() { + query_args.push(("targets".to_string(), targets.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/orgs/{}/rulesets?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ ), None, ); self.client - .delete( + .get_all_pages( &url, crate::Message { body: None, @@ -249,35 +267,32 @@ impl Repos { .await } /** - * Update a repository. + * Create an organization repository ruleset. * - * This function performs a `PATCH` to the `/repos/{owner}/{repo}` endpoint. + * This function performs a `POST` to the `/orgs/{org}/rulesets` endpoint. * - * **Note**: To edit a repository's topics, use the [Replace all repository topics](https://docs.github.com/rest/reference/repos#replace-all-repository-topics) endpoint. + * Create a repository ruleset for an organization. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ - pub async fn update( + pub async fn create_org_ruleset( &self, - owner: &str, - repo: &str, - body: &crate::types::ReposUpdateRequest, - ) -> ClientResult> { + org: &str, + body: &crate::types::ReposCreateOrgRulesetRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/orgs/{}/rulesets", + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); self.client - .patch( + .post( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -287,38 +302,69 @@ impl Repos { .await } /** - * List all autolinks of a repository. + * List organization rule suites. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/autolinks` endpoint. - * - * This returns a list of autolinks configured for the given repository. + * This function performs a `GET` to the `/orgs/{org}/rulesets/rule-suites` endpoint. * - * Information about autolinks are only available to repository administrators. + * Lists suites of rule evaluations at the organization level. + * For more information, see "[Managing rulesets for repositories in your organization](https://docs.github.com/organizations/managing-organization-settings/managing-rulesets-for-repositories-in-your-organization#viewing-insights-for-rulesets)." * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `ref_: &str` -- The name of the ref. Cannot contain wildcard characters. Optionally prefix with `refs/heads/` to limit to branches or `refs/tags/` to limit to tags. Omit the prefix to search across all refs. When specified, only rule evaluations triggered for this ref will be returned. + * * `repository_name: &str` -- The name of the repository to filter on. + * * `time_period: crate::types::TimePeriodData` -- The time period to filter by. + * + * For example, `day` will filter for rule suites that occurred in the past 24 hours, and `week` will filter for rule suites that occurred in the past 7 days (168 hours). + * * `actor_name: &str` -- The handle for the GitHub user account to filter on. When specified, only rule evaluations triggered by this actor will be returned. + * * `rule_suite_result: crate::types::RuleSuiteResult` -- The rule suite results to filter on. When specified, only suites with this result will be returned. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_autolinks( + pub async fn get_org_rule_suites( &self, - owner: &str, - repo: &str, + org: &str, + ref_: &str, + repository_name: &str, + time_period: crate::types::TimePeriodData, + actor_name: &str, + rule_suite_result: crate::types::RuleSuiteResult, + per_page: i64, page: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); + if !actor_name.is_empty() { + query_args.push(("actor_name".to_string(), actor_name.to_string())); + } if page > 0 { query_args.push(("page".to_string(), page.to_string())); } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + if !repository_name.is_empty() { + query_args.push(("repository_name".to_string(), repository_name.to_string())); + } + if !rule_suite_result.to_string().is_empty() { + query_args.push(( + "rule_suite_result".to_string(), + rule_suite_result.to_string(), + )); + } + if !time_period.to_string().is_empty() { + query_args.push(("time_period".to_string(), time_period.to_string())); + } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/autolinks?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/orgs/{}/rulesets/rule-suites?{}", + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -334,28 +380,51 @@ impl Repos { .await } /** - * List all autolinks of a repository. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/autolinks` endpoint. + * List organization rule suites. * - * As opposed to `list_autolinks`, this function returns all the pages of the request at once. + * This function performs a `GET` to the `/orgs/{org}/rulesets/rule-suites` endpoint. * - * This returns a list of autolinks configured for the given repository. + * As opposed to `get_org_rule_suites`, this function returns all the pages of the request at once. * - * Information about autolinks are only available to repository administrators. + * Lists suites of rule evaluations at the organization level. + * For more information, see "[Managing rulesets for repositories in your organization](https://docs.github.com/organizations/managing-organization-settings/managing-rulesets-for-repositories-in-your-organization#viewing-insights-for-rulesets)." * - * FROM: + * FROM: */ - pub async fn list_all_autolinks( + pub async fn get_all_org_rule_suites( &self, - owner: &str, - repo: &str, - ) -> ClientResult>> { + org: &str, + ref_: &str, + repository_name: &str, + time_period: crate::types::TimePeriodData, + actor_name: &str, + rule_suite_result: crate::types::RuleSuiteResult, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !actor_name.is_empty() { + query_args.push(("actor_name".to_string(), actor_name.to_string())); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + if !repository_name.is_empty() { + query_args.push(("repository_name".to_string(), repository_name.to_string())); + } + if !rule_suite_result.to_string().is_empty() { + query_args.push(( + "rule_suite_result".to_string(), + rule_suite_result.to_string(), + )); + } + if !time_period.to_string().is_empty() { + query_args.push(("time_period".to_string(), time_period.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/autolinks", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/orgs/{}/rulesets/rule-suites?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ ), None, ); @@ -370,72 +439,73 @@ impl Repos { .await } /** - * Create an autolink reference for a repository. + * Get an organization rule suite. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/autolinks` endpoint. + * This function performs a `GET` to the `/orgs/{org}/rulesets/rule-suites/{rule_suite_id}` endpoint. * - * Users with admin access to the repository can create an autolink. + * Gets information about a suite of rule evaluations from within an organization. + * For more information, see "[Managing rulesets for repositories in your organization](https://docs.github.com/organizations/managing-organization-settings/managing-rulesets-for-repositories-in-your-organization#viewing-insights-for-rulesets)." * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `rule_suite_id: i64` -- The unique identifier of the rule suite result. + * To get this ID, you can use [GET /repos/{owner}/{repo}/rulesets/rule-suites](https://docs.github.com/rest/repos/rule-suites#list-repository-rule-suites) + * for repositories and [GET /orgs/{org}/rulesets/rule-suites](https://docs.github.com/rest/orgs/rule-suites#list-organization-rule-suites) + * for organizations. */ - pub async fn create_autolink( + pub async fn get_org_rule_suite( &self, - owner: &str, - repo: &str, - body: &crate::types::ReposCreateAutolinkRequest, - ) -> ClientResult> { + org: &str, + rule_suite_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/autolinks", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/orgs/{}/rulesets/rule-suites/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&rule_suite_id.to_string()), ), None, ); self.client - .post( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get an autolink reference of a repository. + * Get an organization repository ruleset. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/autolinks/{autolink_id}` endpoint. + * This function performs a `GET` to the `/orgs/{org}/rulesets/{ruleset_id}` endpoint. * - * This returns a single autolink reference by ID that was configured for the given repository. + * Get a repository ruleset for an organization. * - * Information about autolinks are only available to repository administrators. + * **Note:** To prevent leaking sensitive information, the `bypass_actors` property is only returned if the user + * making the API request has write access to the ruleset. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `autolink_id: i64` -- autolink_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `ruleset_id: i64` -- The ID of the ruleset. */ - pub async fn get_autolink( + pub async fn get_org_ruleset( &self, - owner: &str, - repo: &str, - autolink_id: i64, - ) -> ClientResult> { + org: &str, + ruleset_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/autolinks/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&autolink_id.to_string()), + "/orgs/{}/rulesets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&ruleset_id.to_string()), ), None, ); @@ -450,76 +520,72 @@ impl Repos { .await } /** - * Delete an autolink reference from a repository. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/autolinks/{autolink_id}` endpoint. + * Update an organization repository ruleset. * - * This deletes a single autolink reference by ID that was configured for the given repository. + * This function performs a `PUT` to the `/orgs/{org}/rulesets/{ruleset_id}` endpoint. * - * Information about autolinks are only available to repository administrators. + * Update a ruleset for an organization. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `autolink_id: i64` -- autolink_id parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `ruleset_id: i64` -- The ID of the ruleset. */ - pub async fn delete_autolink( + pub async fn update_org_ruleset( &self, - owner: &str, - repo: &str, - autolink_id: i64, - ) -> ClientResult> { + org: &str, + ruleset_id: i64, + body: &crate::types::ReposUpdateOrgRulesetRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/autolinks/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&autolink_id.to_string()), + "/orgs/{}/rulesets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&ruleset_id.to_string()), ), None, ); self.client - .delete( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Enable automated security fixes. + * Delete an organization repository ruleset. * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/automated-security-fixes` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/rulesets/{ruleset_id}` endpoint. * - * Enables automated security fixes for a repository. The authenticated user must have admin access to the repository. For more information, see "[Configuring automated security fixes](https://help.github.com/en/articles/configuring-automated-security-fixes)". + * Delete a ruleset for an organization. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `ruleset_id: i64` -- The ID of the ruleset. */ - pub async fn enable_automated_security_fixes( + pub async fn delete_org_ruleset( &self, - owner: &str, - repo: &str, + org: &str, + ruleset_id: i64, ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/automated-security-fixes", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/orgs/{}/rulesets/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&ruleset_id.to_string()), ), None, ); self.client - .put( + .delete( &url, crate::Message { body: None, @@ -529,34 +595,38 @@ impl Repos { .await } /** - * Disable automated security fixes. + * Get a repository. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/automated-security-fixes` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}` endpoint. * - * Disables automated security fixes for a repository. The authenticated user must have admin access to the repository. For more information, see "[Configuring automated security fixes](https://help.github.com/en/articles/configuring-automated-security-fixes)". + * The `parent` and `source` objects are present when the repository is a fork. `parent` is the repository this repository was forked from, `source` is the ultimate source for the network. + * + * > [!NOTE] + * > - In order to see the `security_and_analysis` block for a repository you must have admin permissions for the repository or be an owner or security manager for the organization that owns the repository. For more information, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)." + * > - To view merge-related settings, you must have the `contents:read` and `contents:write` permissions. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn disable_automated_security_fixes( + pub async fn get( &self, owner: &str, repo: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/automated-security-fixes", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -566,52 +636,35 @@ impl Repos { .await } /** - * List branches. + * Delete a repository. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}` endpoint. * + * Deleting a repository requires admin access. + * + * If an organization owner has configured the organization to prevent members from deleting organization-owned + * repositories, you will get a `403 Forbidden` response. * + * OAuth app tokens and personal access tokens (classic) need the `delete_repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `protected: bool` -- Setting to `true` returns only protected branches. When set to `false`, only unprotected branches are returned. Omitting this parameter returns all branches. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn list_branches( - &self, - owner: &str, - repo: &str, - protected: bool, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - if protected { - query_args.push(("protected".to_string(), protected.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + pub async fn delete(&self, owner: &str, repo: &str) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -621,73 +674,119 @@ impl Repos { .await } /** - * List branches. + * Update a repository. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches` endpoint. + * This function performs a `PATCH` to the `/repos/{owner}/{repo}` endpoint. * - * As opposed to `list_branches`, this function returns all the pages of the request at once. + * **Note**: To edit a repository's topics, use the [Replace all repository topics](https://docs.github.com/rest/repos/repos#replace-all-repository-topics) endpoint. * + * FROM: * + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn list_all_branches( + pub async fn update( &self, owner: &str, repo: &str, - protected: bool, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if protected { - query_args.push(("protected".to_string(), protected.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + body: &crate::types::ReposUpdateRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get_all_pages( + .patch( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Get a branch. + * List repository activities. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/activity` endpoint. * + * Lists a detailed history of changes to a repository, such as pushes, merges, force pushes, and branch changes, and associates these changes with commits and users. * + * For more information about viewing repository activity, + * see "[Viewing activity and data for your repository](https://docs.github.com/repositories/viewing-activity-and-data-for-your-repository)." * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `ref_: &str` -- The Git reference for the activities you want to list. + * + * The `ref` for a branch can be formatted either as `refs/heads/BRANCH_NAME` or `BRANCH_NAME`, where `BRANCH_NAME` is the name of your branch. + * * `actor: &str` -- The GitHub username to use to filter by the actor who performed the activity. + * * `time_period: crate::types::ReposListActivitiesTimePeriod` -- The time period to filter by. + * + * For example, `day` will filter for activity that occurred in the past 24 hours, and `week` will filter for activity that occurred in the past 7 days (168 hours). + * * `activity_type: crate::types::ActivityType` -- The activity type to filter by. + * + * For example, you can choose to filter by "force_push", to see all force pushes to the repository. */ - pub async fn get_branch( + pub async fn list_activities( &self, owner: &str, repo: &str, - branch: &str, - ) -> ClientResult> { + direction: crate::types::Order, + per_page: i64, + before: &str, + after: &str, + ref_: &str, + actor: &str, + time_period: crate::types::ReposListActivitiesTimePeriod, + activity_type: crate::types::ActivityType, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !activity_type.to_string().is_empty() { + query_args.push(("activity_type".to_string(), activity_type.to_string())); + } + if !actor.is_empty() { + query_args.push(("actor".to_string(), actor.to_string())); + } + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + if !time_period.to_string().is_empty() { + query_args.push(("time_period".to_string(), time_period.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/activity?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); @@ -702,37 +801,65 @@ impl Repos { .await } /** - * Get branch protection. + * List repository activities. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/activity` endpoint. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * As opposed to `list_activities`, this function returns all the pages of the request at once. * - * FROM: + * Lists a detailed history of changes to a repository, such as pushes, merges, force pushes, and branch changes, and associates these changes with commits and users. * - * **Parameters:** + * For more information about viewing repository activity, + * see "[Viewing activity and data for your repository](https://docs.github.com/repositories/viewing-activity-and-data-for-your-repository)." * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * FROM: */ - pub async fn get_branch_protection( + pub async fn list_all_activities( &self, owner: &str, repo: &str, - branch: &str, - ) -> ClientResult> { + direction: crate::types::Order, + before: &str, + after: &str, + ref_: &str, + actor: &str, + time_period: crate::types::ReposListActivitiesTimePeriod, + activity_type: crate::types::ActivityType, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !activity_type.to_string().is_empty() { + query_args.push(("activity_type".to_string(), activity_type.to_string())); + } + if !actor.is_empty() { + query_args.push(("actor".to_string(), actor.to_string())); + } + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + if !time_period.to_string().is_empty() { + query_args.push(("time_period".to_string(), time_period.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/activity?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -742,44 +869,39 @@ impl Repos { .await } /** - * Update branch protection. - * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/branches/{branch}/protection` endpoint. + * Create an attestation. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This function performs a `POST` to the `/repos/{owner}/{repo}/attestations` endpoint. * - * Protecting a branch requires admin or owner permissions to the repository. + * Store an artifact attestation and associate it with a repository. * - * **Note**: Passing new arrays of `users` and `teams` replaces their previous values. + * The authenticated user must have write permission to the repository and, if using a fine-grained access token, the `attestations:write` permission is required. * - * **Note**: The list of users, apps, and teams in total is limited to 100 items. + * Artifact attestations are meant to be created using the [attest action](https://github.com/actions/attest). For more information, see our guide on [using artifact attestations to establish a build's provenance](https://docs.github.com/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn update_branch_protection( + pub async fn create_attestation( &self, owner: &str, repo: &str, - branch: &str, - body: &crate::types::ReposUpdateBranchProtectionRequest, - ) -> ClientResult> { + body: &crate::types::ReposCreateAttestationRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/attestations", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .put( + .post( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -789,37 +911,66 @@ impl Repos { .await } /** - * Delete branch protection. + * List attestations. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/attestations/{subject_digest}` endpoint. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * List a collection of artifact attestations with a given subject digest that are associated with a repository. * - * FROM: + * The authenticated user making the request must have read access to the repository. In addition, when using a fine-grained access token the `attestations:read` permission is required. + * + * **Please note:** in order to offer meaningful security benefits, an attestation's signature and timestamps **must** be cryptographically verified, and the identity of the attestation signer **must** be validated. Attestations can be verified using the [GitHub CLI `attestation verify` command](https://cli.github.com/manual/gh_attestation_verify). For more information, see [our guide on how to use artifact attestations to establish a build's provenance](https://docs.github.com/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds). + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `subject_digest: &str` -- The parameter should be set to the attestation's subject's SHA256 digest, in the form `sha256:HEX_DIGEST`. + * * `predicate_type: &str` -- Optional filter for fetching attestations with a given predicate type. + * This option accepts `provenance`, `sbom`, `release`, or freeform text + * for custom predicate types. */ - pub async fn delete_branch_protection( + pub async fn list_attestations( &self, owner: &str, repo: &str, - branch: &str, - ) -> ClientResult> { + per_page: i64, + before: &str, + after: &str, + subject_digest: &str, + predicate_type: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !predicate_type.is_empty() { + query_args.push(("predicate_type".to_string(), predicate_type.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/attestations/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&subject_digest.to_string()), + query_ ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -829,32 +980,31 @@ impl Repos { .await } /** - * Get admin branch protection. + * Get all autolinks of a repository. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/autolinks` endpoint. + * + * Gets all autolinks that are configured for a repository. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Information about autolinks are only available to repository administrators. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn get_admin_branch_protection( + pub async fn list_autolinks( &self, owner: &str, repo: &str, - branch: &str, - ) -> ClientResult> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/enforce_admins", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/autolinks", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -869,39 +1019,33 @@ impl Repos { .await } /** - * Set admin branch protection. - * - * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins` endpoint. + * Get all autolinks of a repository. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This function performs a `GET` to the `/repos/{owner}/{repo}/autolinks` endpoint. * - * Adding admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled. + * As opposed to `list_autolinks`, this function returns all the pages of the request at once. * - * FROM: + * Gets all autolinks that are configured for a repository. * - * **Parameters:** + * Information about autolinks are only available to repository administrators. * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * FROM: */ - pub async fn set_admin_branch_protection( + pub async fn list_all_autolinks( &self, owner: &str, repo: &str, - branch: &str, - ) -> ClientResult> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/enforce_admins", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/autolinks", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .post( + .get_all_pages( &url, crate::Message { body: None, @@ -911,74 +1055,72 @@ impl Repos { .await } /** - * Delete admin branch protection. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins` endpoint. + * Create an autolink reference for a repository. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This function performs a `POST` to the `/repos/{owner}/{repo}/autolinks` endpoint. * - * Removing admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled. + * Users with admin access to the repository can create an autolink. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn delete_admin_branch_protection( + pub async fn create_autolink( &self, owner: &str, repo: &str, - branch: &str, - ) -> ClientResult> { + body: &crate::types::ReposCreateAutolinkRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/enforce_admins", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/autolinks", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .delete( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Get pull request review protection. + * Get an autolink reference of a repository. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/autolinks/{autolink_id}` endpoint. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This returns a single autolink reference by ID that was configured for the given repository. + * + * Information about autolinks are only available to repository administrators. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `autolink_id: i64` -- The unique identifier of the autolink. */ - pub async fn get_pull_request_review_protection( + pub async fn get_autolink( &self, owner: &str, repo: &str, - branch: &str, - ) -> ClientResult> { + autolink_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/autolinks/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&autolink_id.to_string()), ), None, ); @@ -993,32 +1135,34 @@ impl Repos { .await } /** - * Delete pull request review protection. + * Delete an autolink reference from a repository. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/autolinks/{autolink_id}` endpoint. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This deletes a single autolink reference by ID that was configured for the given repository. + * + * Information about autolinks are only available to repository administrators. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `autolink_id: i64` -- The unique identifier of the autolink. */ - pub async fn delete_pull_request_review_protection( + pub async fn delete_autolink( &self, owner: &str, repo: &str, - branch: &str, + autolink_id: i64, ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/autolinks/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&autolink_id.to_string()), ), None, ); @@ -1033,86 +1177,71 @@ impl Repos { .await } /** - * Update pull request review protection. - * - * This function performs a `PATCH` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews` endpoint. - * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Check if Dependabot security updates are enabled for a repository. * - * Updating pull request review enforcement requires admin or owner permissions to the repository and branch protection to be enabled. + * This function performs a `GET` to the `/repos/{owner}/{repo}/automated-security-fixes` endpoint. * - * **Note**: Passing new arrays of `users` and `teams` replaces their previous values. + * Shows whether Dependabot security updates are enabled, disabled or paused for a repository. The authenticated user must have admin read access to the repository. For more information, see "[Configuring Dependabot security updates](https://docs.github.com/articles/configuring-automated-security-fixes)". * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn update_pull_request_review_protection( + pub async fn check_automated_security_fixes( &self, owner: &str, repo: &str, - branch: &str, - body: &crate::types::ReposUpdatePullRequestReviewProtection, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/automated-security-fixes", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .patch( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get commit signature protection. + * Enable Dependabot security updates. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_signatures` endpoint. - * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. - * - * When authenticated with admin or owner permissions to the repository, you can use this endpoint to check whether a branch requires signed commits. An enabled status of `true` indicates you must sign commits on this branch. For more information, see [Signing commits with GPG](https://help.github.com/articles/signing-commits-with-gpg) in GitHub Help. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/automated-security-fixes` endpoint. * - * **Note**: You must enable branch protection to require signed commits. + * Enables Dependabot security updates for a repository. The authenticated user must have admin access to the repository. For more information, see "[Configuring Dependabot security updates](https://docs.github.com/articles/configuring-automated-security-fixes)". * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn get_commit_signature_protection( + pub async fn enable_automated_security_fixes( &self, owner: &str, repo: &str, - branch: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_signatures", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/automated-security-fixes", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { body: None, @@ -1122,39 +1251,34 @@ impl Repos { .await } /** - * Create commit signature protection. - * - * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_signatures` endpoint. + * Disable Dependabot security updates. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/automated-security-fixes` endpoint. * - * When authenticated with admin or owner permissions to the repository, you can use this endpoint to require signed commits on a branch. You must enable branch protection to require signed commits. + * Disables Dependabot security updates for a repository. The authenticated user must have admin access to the repository. For more information, see "[Configuring Dependabot security updates](https://docs.github.com/articles/configuring-automated-security-fixes)". * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn create_commit_signature_protection( + pub async fn disable_automated_security_fixes( &self, owner: &str, repo: &str, - branch: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_signatures", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/automated-security-fixes", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .post( + .delete( &url, crate::Message { body: None, @@ -1164,39 +1288,52 @@ impl Repos { .await } /** - * Delete commit signature protection. + * List branches. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_signatures` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches` endpoint. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * When authenticated with admin or owner permissions to the repository, you can use this endpoint to disable required signed commits on a branch. You must enable branch protection to require signed commits. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `protected: bool` -- Setting to `true` returns only branches protected by branch protections or rulesets. When set to `false`, only unprotected branches are returned. Omitting this parameter returns all branches. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn delete_commit_signature_protection( + pub async fn list_branches( &self, owner: &str, repo: &str, - branch: &str, - ) -> ClientResult> { + protected: bool, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if protected { + query_args.push(("protected".to_string(), protected.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_signatures", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -1206,37 +1343,38 @@ impl Repos { .await } /** - * Get status checks protection. + * List branches. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches` endpoint. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * As opposed to `list_branches`, this function returns all the pages of the request at once. * - * FROM: * - * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * FROM: */ - pub async fn get_status_checks_protection( + pub async fn list_all_branches( &self, owner: &str, repo: &str, - branch: &str, - ) -> ClientResult> { + protected: bool, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if protected { + query_args.push(("protected".to_string(), protected.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_status_checks", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -1246,37 +1384,37 @@ impl Repos { .await } /** - * Remove status check protection. + * Get a branch. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}` endpoint. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * FROM: + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn remove_status_check_protection( + pub async fn get_branch( &self, owner: &str, repo: &str, branch: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_status_checks", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -1286,116 +1424,126 @@ impl Repos { .await } /** - * Update status check protection. - * - * This function performs a `PATCH` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks` endpoint. + * Get branch protection. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection` endpoint. * - * Updating required status checks requires admin or owner permissions to the repository and branch protection to be enabled. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn update_status_check_protection( + pub async fn get_branch_protection( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposUpdateStatusCheckProtectionRequest, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_status_checks", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .patch( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get all status check contexts. + * Update branch protection. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts` endpoint. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/branches/{branch}/protection` endpoint. + * + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * + * Protecting a branch requires admin or owner permissions to the repository. + * + * > [!NOTE] + * > Passing new arrays of `users` and `teams` replaces their previous values. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * > [!NOTE] + * > The list of users, apps, and teams in total is limited to 100 items. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn get_all_status_check_contexts( + pub async fn update_branch_protection( &self, owner: &str, repo: &str, branch: &str, - ) -> ClientResult>> { + body: &crate::types::ReposUpdateBranchProtectionRequestData, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Get all status check contexts. + * Delete branch protection. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection` endpoint. * - * As opposed to `get_all_status_check_contexts`, this function returns all the pages of the request at once. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * + * FROM: * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn get_all_all_status_check_contexts( + pub async fn delete_branch_protection( &self, owner: &str, repo: &str, branch: &str, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get_all_pages( + .delete( &url, crate::Message { body: None, @@ -1405,74 +1553,74 @@ impl Repos { .await } /** - * Set status check contexts. + * Get admin branch protection. * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins` endpoint. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn set_status_check_contexts( + pub async fn get_admin_branch_protection( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposAddStatusCheckContextsRequestOneOf, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/enforce_admins", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Add status check contexts. + * Set admin branch protection. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins` endpoint. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * + * Adding admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn add_status_check_contexts( + pub async fn set_admin_branch_protection( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposAddStatusCheckContextsRequestOneOf, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/enforce_admins", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); @@ -1480,40 +1628,41 @@ impl Repos { .post( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Remove status check contexts. + * Delete admin branch protection. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins` endpoint. + * + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Removing admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn remove_status_check_contexts( + pub async fn delete_admin_branch_protection( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposAddStatusCheckContextsRequestOneOf, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/enforce_admins", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); @@ -1521,43 +1670,39 @@ impl Repos { .delete( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get access restrictions. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions` endpoint. - * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Get pull request review protection. * - * Lists who has access to this protected branch. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews` endpoint. * - * **Note**: Users, apps, and teams `restrictions` are only available for organization-owned repositories. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn get_access_restrictions( + pub async fn get_pull_request_review_protection( &self, owner: &str, repo: &str, branch: &str, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); @@ -1572,23 +1717,21 @@ impl Repos { .await } /** - * Delete access restrictions. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions` endpoint. + * Delete pull request review protection. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews` endpoint. * - * Disables the ability to restrict who can push to this branch. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn delete_access_restrictions( + pub async fn delete_pull_request_review_protection( &self, owner: &str, repo: &str, @@ -1596,10 +1739,10 @@ impl Repos { ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); @@ -1614,77 +1757,88 @@ impl Repos { .await } /** - * Get apps with access to the protected branch. + * Update pull request review protection. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps` endpoint. + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews` endpoint. + * + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Updating pull request review enforcement requires admin or owner permissions to the repository and branch protection to be enabled. * - * Lists the GitHub Apps that have push access to this branch. Only installed GitHub Apps with `write` access to the `contents` permission can be added as authorized actors on a protected branch. + * > [!NOTE] + * > Passing new arrays of `users` and `teams` replaces their previous values. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn get_apps_with_access_to_protected_branch( + pub async fn update_pull_request_review_protection( &self, owner: &str, repo: &str, branch: &str, - ) -> ClientResult>> { + body: &crate::types::ReposUpdatePullRequestReviewProtection, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/apps", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get( + .patch( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Get apps with access to the protected branch. + * Get commit signature protection. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_signatures` endpoint. * - * As opposed to `get_apps_with_access_to_protected_branch`, this function returns all the pages of the request at once. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * + * When authenticated with admin or owner permissions to the repository, you can use this endpoint to check whether a branch requires signed commits. An enabled status of `true` indicates you must sign commits on this branch. For more information, see [Signing commits with GPG](https://docs.github.com/articles/signing-commits-with-gpg) in GitHub Help. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * > [!NOTE] + * > You must enable branch protection to require signed commits. * - * Lists the GitHub Apps that have push access to this branch. Only installed GitHub Apps with `write` access to the `contents` permission can be added as authorized actors on a protected branch. + * FROM: * - * FROM: + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn get_all_apps_with_access_to_protected_branch( + pub async fn get_commit_signature_protection( &self, owner: &str, repo: &str, branch: &str, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/apps", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_signatures", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -1694,180 +1848,161 @@ impl Repos { .await } /** - * Set app access restrictions. - * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps` endpoint. + * Create commit signature protection. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_signatures` endpoint. * - * Replaces the list of apps that have push access to this branch. This removes all apps that previously had push access and grants push access to the new list of apps. Only installed GitHub Apps with `write` access to the `contents` permission can be added as authorized actors on a protected branch. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * | Type | Description | - * | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | - * | `array` | The GitHub Apps that have push access to this branch. Use the app's `slug`. **Note**: The list of users, apps, and teams in total is limited to 100 items. | + * When authenticated with admin or owner permissions to the repository, you can use this endpoint to require signed commits on a branch. You must enable branch protection to require signed commits. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn set_app_access_restrictions( + pub async fn create_commit_signature_protection( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposAddAppAccessRestrictionsRequestOneOf, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/apps", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_signatures", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .put( + .post( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Add app access restrictions. - * - * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps` endpoint. + * Delete commit signature protection. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_signatures` endpoint. * - * Grants the specified apps push access for this branch. Only installed GitHub Apps with `write` access to the `contents` permission can be added as authorized actors on a protected branch. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * | Type | Description | - * | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | - * | `array` | The GitHub Apps that have push access to this branch. Use the app's `slug`. **Note**: The list of users, apps, and teams in total is limited to 100 items. | + * When authenticated with admin or owner permissions to the repository, you can use this endpoint to disable required signed commits on a branch. You must enable branch protection to require signed commits. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn add_app_access_restrictions( + pub async fn delete_commit_signature_protection( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposAddAppAccessRestrictionsRequestOneOf, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/apps", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_signatures", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .post( + .delete( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Remove app access restrictions. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps` endpoint. - * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Get status checks protection. * - * Removes the ability of an app to push to this branch. Only installed GitHub Apps with `write` access to the `contents` permission can be added as authorized actors on a protected branch. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks` endpoint. * - * | Type | Description | - * | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | - * | `array` | The GitHub Apps that have push access to this branch. Use the app's `slug`. **Note**: The list of users, apps, and teams in total is limited to 100 items. | + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn remove_app_access_restrictions( + pub async fn get_status_checks_protection( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposAddAppAccessRestrictionsRequestOneOf, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/apps", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_status_checks", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .delete( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get teams with access to the protected branch. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams` endpoint. + * Remove status check protection. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks` endpoint. * - * Lists the teams who have push access to this branch. The list includes child teams. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn get_teams_with_access_to_protected_branch( + pub async fn remove_status_check_protection( &self, owner: &str, repo: &str, branch: &str, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/teams", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_status_checks", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -1877,176 +2012,157 @@ impl Repos { .await } /** - * Get teams with access to the protected branch. + * Update status check protection. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams` endpoint. + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks` endpoint. * - * As opposed to `get_teams_with_access_to_protected_branch`, this function returns all the pages of the request at once. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * + * Updating required status checks requires admin or owner permissions to the repository and branch protection to be enabled. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * FROM: * - * Lists the teams who have push access to this branch. The list includes child teams. + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn get_all_teams_with_access_to_protected_branch( + pub async fn update_status_check_protection( &self, owner: &str, repo: &str, branch: &str, - ) -> ClientResult>> { + body: &crate::types::ReposUpdateStatusCheckProtectionRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/teams", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_status_checks", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get_all_pages( + .patch( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Set team access restrictions. - * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams` endpoint. - * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Get all status check contexts. * - * Replaces the list of teams that have push access to this branch. This removes all teams that previously had push access and grants push access to the new list of teams. Team restrictions include child teams. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts` endpoint. * - * | Type | Description | - * | ------- | ------------------------------------------------------------------------------------------------------------------------------------------ | - * | `array` | The teams that can have push access. Use the team's `slug`. **Note**: The list of users, apps, and teams in total is limited to 100 items. | + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn set_team_access_restrictions( + pub async fn get_all_status_check_contexts( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposAddTeamAccessRestrictionsRequestOneOf, - ) -> ClientResult>> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/teams", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Add team access restrictions. - * - * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams` endpoint. - * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. - * - * Grants the specified teams push access for this branch. You can also give push access to child teams. + * Get all status check contexts. * - * | Type | Description | - * | ------- | ------------------------------------------------------------------------------------------------------------------------------------------ | - * | `array` | The teams that can have push access. Use the team's `slug`. **Note**: The list of users, apps, and teams in total is limited to 100 items. | + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts` endpoint. * - * FROM: + * As opposed to `get_all_status_check_contexts`, this function returns all the pages of the request at once. * - * **Parameters:** + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * FROM: */ - pub async fn add_team_access_restrictions( + pub async fn get_all_all_status_check_contexts( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposAddTeamAccessRestrictionsRequestOneOf, - ) -> ClientResult>> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/teams", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .post( + .get_all_pages( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Remove team access restrictions. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams` endpoint. - * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Set status check contexts. * - * Removes the ability of a team to push to this branch. You can also remove push access for child teams. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts` endpoint. * - * | Type | Description | - * | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | - * | `array` | Teams that should no longer have push access. Use the team's `slug`. **Note**: The list of users, apps, and teams in total is limited to 100 items. | + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn remove_team_access_restrictions( + pub async fn set_status_check_contexts( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposAddTeamAccessRestrictionsRequestOneOf, - ) -> ClientResult>> { + body: &crate::types::ReposAddStatusCheckContextsRequestOneOf, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/teams", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .delete( + .put( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -2056,509 +2172,455 @@ impl Repos { .await } /** - * Get users with access to the protected branch. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users` endpoint. + * Add status check contexts. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts` endpoint. * - * Lists the people who have push access to this branch. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn get_users_with_access_to_protected_branch( + pub async fn add_status_check_contexts( &self, owner: &str, repo: &str, branch: &str, - ) -> ClientResult>> { + body: &crate::types::ReposAddStatusCheckContextsRequestOneOf, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/users", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Get users with access to the protected branch. + * Remove status check contexts. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts` endpoint. * - * As opposed to `get_users_with_access_to_protected_branch`, this function returns all the pages of the request at once. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * FROM: * - * Lists the people who have push access to this branch. + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn get_all_users_with_access_to_protected_branch( + pub async fn remove_status_check_contexts( &self, owner: &str, repo: &str, branch: &str, - ) -> ClientResult>> { + body: &crate::types::ReposAddStatusCheckContextsRequestOneOf, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/users", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get_all_pages( + .delete( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Set user access restrictions. + * Get access restrictions. * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions` endpoint. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * Replaces the list of people that have push access to this branch. This removes all people that previously had push access and grants push access to the new list of people. + * Lists who has access to this protected branch. * - * | Type | Description | - * | ------- | ----------------------------------------------------------------------------------------------------------------------------- | - * | `array` | Usernames for people who can have push access. **Note**: The list of users, apps, and teams in total is limited to 100 items. | + * > [!NOTE] + * > Users, apps, and teams `restrictions` are only available for organization-owned repositories. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn set_user_access_restrictions( + pub async fn get_access_restrictions( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposAddUserAccessRestrictionsRequestOneOf, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/users", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/restrictions", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Add user access restrictions. - * - * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users` endpoint. + * Delete access restrictions. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions` endpoint. * - * Grants the specified people push access for this branch. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * | Type | Description | - * | ------- | ----------------------------------------------------------------------------------------------------------------------------- | - * | `array` | Usernames for people who can have push access. **Note**: The list of users, apps, and teams in total is limited to 100 items. | + * Disables the ability to restrict who can push to this branch. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn add_user_access_restrictions( + pub async fn delete_access_restrictions( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposAddUserAccessRestrictionsRequestOneOf, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/users", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/restrictions", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .post( + .delete( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Remove user access restrictions. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users` endpoint. + * Get apps with access to the protected branch. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps` endpoint. * - * Removes the ability of a user to push to this branch. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * | Type | Description | - * | ------- | --------------------------------------------------------------------------------------------------------------------------------------------- | - * | `array` | Usernames of the people who should no longer have push access. **Note**: The list of users, apps, and teams in total is limited to 100 items. | + * Lists the GitHub Apps that have push access to this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn remove_user_access_restrictions( + pub async fn get_apps_with_access_to_protected_branch( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposAddUserAccessRestrictionsRequestOneOf, - ) -> ClientResult>> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/protection/restrictions/users", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/restrictions/apps", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .delete( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Rename a branch. - * - * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/rename` endpoint. - * - * Renames a branch in a repository. - * - * **Note:** Although the API responds immediately, the branch rename process might take some extra time to complete in the background. You won't be able to push to the old branch name while the rename process is in progress. For more information, see "[Renaming a branch](https://docs.github.com/github/administering-a-repository/renaming-a-branch)". - * - * The permissions required to use this endpoint depends on whether you are renaming the default branch. - * - * To rename a non-default branch: - * - * * Users must have push access. - * * GitHub Apps must have the `contents:write` repository permission. + * Get apps with access to the protected branch. * - * To rename the default branch: + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps` endpoint. * - * * Users must have admin or owner permissions. - * * GitHub Apps must have the `administration:write` repository permission. + * As opposed to `get_apps_with_access_to_protected_branch`, this function returns all the pages of the request at once. * - * FROM: + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * **Parameters:** + * Lists the GitHub Apps that have push access to this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch. * - * * `owner: &str` - * * `repo: &str` - * * `branch: &str` -- The name of the branch. + * FROM: */ - pub async fn rename_branch( + pub async fn get_all_apps_with_access_to_protected_branch( &self, owner: &str, repo: &str, branch: &str, - body: &crate::types::ReposRenameBranchRequest, - ) -> ClientResult> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/branches/{}/rename", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(branch), + "/repos/{}/{}/branches/{}/protection/restrictions/apps", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .post( + .get_all_pages( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * List repository collaborators. + * Set app access restrictions. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/collaborators` endpoint. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps` endpoint. * - * For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * Team members will include the members of child teams. + * Replaces the list of apps that have push access to this branch. This removes all apps that previously had push access and grants push access to the new list of apps. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `affiliation: crate::types::Affiliation` -- Filters the collaborators by their affiliation. Can be one of: - * \\* `outside`: Outside collaborators of a project that are not a member of the project's organization. - * \\* `direct`: Collaborators with permissions to a project, regardless of organization membership status. - * \\* `all`: All collaborators the authenticated user can see. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn list_collaborators( + pub async fn set_app_access_restrictions( &self, owner: &str, repo: &str, - affiliation: crate::types::Affiliation, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !affiliation.to_string().is_empty() { - query_args.push(("affiliation".to_string(), affiliation.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + branch: &str, + body: &crate::types::ReposAddAppAccessRestrictionsRequest, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/collaborators?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/branches/{}/protection/restrictions/apps", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List repository collaborators. + * Add app access restrictions. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/collaborators` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps` endpoint. * - * As opposed to `list_collaborators`, this function returns all the pages of the request at once. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners. + * Grants the specified apps push access for this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch. * - * Team members will include the members of child teams. + * FROM: + * + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn list_all_collaborators( + pub async fn add_app_access_restrictions( &self, owner: &str, repo: &str, - affiliation: crate::types::Affiliation, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !affiliation.to_string().is_empty() { - query_args.push(("affiliation".to_string(), affiliation.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + branch: &str, + body: &crate::types::ReposAddAppAccessRestrictionsRequest, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/collaborators?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/branches/{}/protection/restrictions/apps", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get_all_pages( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Check if a user is a repository collaborator. + * Remove app access restrictions. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/collaborators/{username}` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps` endpoint. * - * For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * Team members will include the members of child teams. + * Removes the ability of an app to push to this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `username: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn check_collaborator( + pub async fn remove_app_access_restrictions( &self, owner: &str, repo: &str, - username: &str, - ) -> ClientResult> { + branch: &str, + body: &crate::types::ReposAddAppAccessRestrictionsRequest, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/collaborators/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(username), + "/repos/{}/{}/branches/{}/protection/restrictions/apps", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Add a repository collaborator. + * Get teams with access to the protected branch. * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/collaborators/{username}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams` endpoint. * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * For more information the permission levels, see "[Repository permission levels for an organization](https://help.github.com/en/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization#permission-levels-for-repositories-owned-by-an-organization)". - * - * Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://docs.github.com/rest/overview/resources-in-the-rest-api#http-verbs)." - * - * The invitee will receive a notification that they have been invited to the repository, which they must accept or decline. They may do this via the notifications page, the email they receive, or by using the [repository invitations API endpoints](https://docs.github.com/rest/reference/repos#invitations). - * - * **Rate limits** - * - * You are limited to sending 50 invitations to a repository per 24 hour period. Note there is no limit if you are inviting organization members to an organization repository. + * Lists the teams who have push access to this branch. The list includes child teams. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `username: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn add_collaborator( + pub async fn get_teams_with_access_to_protected_branch( &self, owner: &str, repo: &str, - username: &str, - body: &crate::types::ReposAddCollaboratorRequest, - ) -> ClientResult> { + branch: &str, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/collaborators/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(username), + "/repos/{}/{}/branches/{}/protection/restrictions/teams", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .put( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Remove a repository collaborator. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/collaborators/{username}` endpoint. + * Get teams with access to the protected branch. * + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams` endpoint. * + * As opposed to `get_teams_with_access_to_protected_branch`, this function returns all the pages of the request at once. * - * FROM: + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * **Parameters:** + * Lists the teams who have push access to this branch. The list includes child teams. * - * * `owner: &str` - * * `repo: &str` - * * `username: &str` + * FROM: */ - pub async fn remove_collaborator( + pub async fn get_all_teams_with_access_to_protected_branch( &self, owner: &str, repo: &str, - username: &str, - ) -> ClientResult> { + branch: &str, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/collaborators/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(username), + "/repos/{}/{}/branches/{}/protection/restrictions/teams", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .delete( + .get_all_pages( &url, crate::Message { body: None, @@ -2568,160 +2630,163 @@ impl Repos { .await } /** - * Get repository permissions for a user. + * Set team access restrictions. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/collaborators/{username}/permission` endpoint. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams` endpoint. * - * Checks the repository permission of a collaborator. The possible repository permissions are `admin`, `write`, `read`, and `none`. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * FROM: + * Replaces the list of teams that have push access to this branch. This removes all teams that previously had push access and grants push access to the new list of teams. Team restrictions include child teams. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `username: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn get_collaborator_permission_level( + pub async fn set_team_access_restrictions( &self, owner: &str, repo: &str, - username: &str, - ) -> ClientResult> { + branch: &str, + body: &crate::types::ReposAddTeamAccessRestrictionsRequestOneOf, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/collaborators/{}/permission", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(username), + "/repos/{}/{}/branches/{}/protection/restrictions/teams", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List commit comments for a repository. + * Add team access restrictions. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/comments` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams` endpoint. * - * Commit Comments use [these custom media types](https://docs.github.com/rest/reference/repos#custom-media-types). You can read more about the use of media types in the API [here](https://docs.github.com/rest/overview/media-types/). + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * Comments are ordered by ascending ID. + * Grants the specified teams push access for this branch. You can also give push access to child teams. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn list_commit_comments_for_repo( + pub async fn add_team_access_restrictions( &self, owner: &str, repo: &str, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + branch: &str, + body: &crate::types::ReposAddTeamAccessRestrictionsRequestOneOf, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/comments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/branches/{}/protection/restrictions/teams", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List commit comments for a repository. + * Remove team access restrictions. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/comments` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams` endpoint. * - * As opposed to `list_commit_comments_for_repo`, this function returns all the pages of the request at once. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * Commit Comments use [these custom media types](https://docs.github.com/rest/reference/repos#custom-media-types). You can read more about the use of media types in the API [here](https://docs.github.com/rest/overview/media-types/). + * Removes the ability of a team to push to this branch. You can also remove push access for child teams. + * + * FROM: * - * Comments are ordered by ascending ID. + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn list_all_commit_comments_for_repo( + pub async fn remove_team_access_restrictions( &self, owner: &str, repo: &str, - ) -> ClientResult>> { + branch: &str, + body: &crate::types::ReposAddTeamAccessRestrictionsRequestOneOf, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/comments", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/branches/{}/protection/restrictions/teams", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get_all_pages( + .delete( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Get a commit comment. + * Get users with access to the protected branch. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/comments/{comment_id}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users` endpoint. * + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * + * Lists the people who have push access to this branch. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn get_commit_comment( + pub async fn get_users_with_access_to_protected_branch( &self, owner: &str, repo: &str, - comment_id: i64, - ) -> ClientResult> { + branch: &str, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/comments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&comment_id.to_string()), + "/repos/{}/{}/branches/{}/protection/restrictions/users", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); @@ -2736,37 +2801,35 @@ impl Repos { .await } /** - * Delete a commit comment. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/comments/{comment_id}` endpoint. + * Get users with access to the protected branch. * + * This function performs a `GET` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users` endpoint. * + * As opposed to `get_users_with_access_to_protected_branch`, this function returns all the pages of the request at once. * - * FROM: + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * **Parameters:** + * Lists the people who have push access to this branch. * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. + * FROM: */ - pub async fn delete_commit_comment( + pub async fn get_all_users_with_access_to_protected_branch( &self, owner: &str, repo: &str, - comment_id: i64, - ) -> ClientResult> { + branch: &str, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/comments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&comment_id.to_string()), + "/repos/{}/{}/branches/{}/protection/restrictions/users", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .delete( + .get_all_pages( &url, crate::Message { body: None, @@ -2776,38 +2839,44 @@ impl Repos { .await } /** - * Update a commit comment. + * Set user access restrictions. * - * This function performs a `PATCH` to the `/repos/{owner}/{repo}/comments/{comment_id}` endpoint. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users` endpoint. * + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * + * Replaces the list of people that have push access to this branch. This removes all people that previously had push access and grants push access to the new list of people. * + * | Type | Description | + * | ------- | ----------------------------------------------------------------------------------------------------------------------------- | + * | `array` | Usernames for people who can have push access. **Note**: The list of users, apps, and teams in total is limited to 100 items. | * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `comment_id: i64` -- comment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn update_commit_comment( + pub async fn set_user_access_restrictions( &self, owner: &str, repo: &str, - comment_id: i64, - body: &crate::types::PullsUpdateReviewRequest, - ) -> ClientResult> { + branch: &str, + body: &crate::types::ReposAddUserAccessRestrictionsRequest, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/comments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&comment_id.to_string()), + "/repos/{}/{}/branches/{}/protection/restrictions/users", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .patch( + .put( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -2817,263 +2886,188 @@ impl Repos { .await } /** - * List commits. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/commits` endpoint. - * - * **Signature verification object** + * Add user access restrictions. * - * The response will include a `verification` object that describes the result of verifying the commit's signature. The following fields are included in the `verification` object: + * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users` endpoint. * - * | Name | Type | Description | - * | ---- | ---- | ----------- | - * | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. | - * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. | - * | `signature` | `string` | The signature that was extracted from the commit. | - * | `payload` | `string` | The value that was signed. | + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * These are the possible values for `reason` in the `verification` object: + * Grants the specified people push access for this branch. * - * | Value | Description | - * | ----- | ----------- | - * | `expired_key` | The key that made the signature is expired. | - * | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. | - * | `gpgverify_error` | There was an error communicating with the signature verification service. | - * | `gpgverify_unavailable` | The signature verification service is currently unavailable. | - * | `unsigned` | The object does not include a signature. | - * | `unknown_signature_type` | A non-PGP signature was found in the commit. | - * | `no_user` | No user was associated with the `committer` email address in the commit. | - * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on her/his account. | - * | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. | - * | `unknown_key` | The key that made the signature has not been registered with any user's account. | - * | `malformed_signature` | There was an error parsing the signature. | - * | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. | - * | `valid` | None of the above errors applied, so the signature is considered to be verified. | + * | Type | Description | + * | ------- | ----------------------------------------------------------------------------------------------------------------------------- | + * | `array` | Usernames for people who can have push access. **Note**: The list of users, apps, and teams in total is limited to 100 items. | * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `sha: &str` -- SHA or branch to start listing commits from. Default: the repository’s default branch (usually `master`). - * * `path: &str` -- Only commits containing this file path will be returned. - * * `author: &str` -- GitHub login or email address by which to filter by commit author. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `until: chrono::DateTime` -- Only commits before this date will be returned. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn list_commits( + pub async fn add_user_access_restrictions( &self, owner: &str, repo: &str, - sha: &str, - path: &str, - author: &str, - since: Option>, - until: Option>, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !author.is_empty() { - query_args.push(("author".to_string(), author.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if !path.is_empty() { - query_args.push(("path".to_string(), path.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - if !sha.is_empty() { - query_args.push(("sha".to_string(), sha.to_string())); - } - if let Some(date) = since { - query_args.push(("since".to_string(), date.to_rfc3339())); - } - if let Some(date) = until { - query_args.push(("until".to_string(), date.to_rfc3339())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + branch: &str, + body: &crate::types::ReposAddUserAccessRestrictionsRequest, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/commits?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/branches/{}/protection/restrictions/users", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List commits. + * Remove user access restrictions. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/commits` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users` endpoint. * - * As opposed to `list_commits`, this function returns all the pages of the request at once. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * **Signature verification object** + * Removes the ability of a user to push to this branch. * - * The response will include a `verification` object that describes the result of verifying the commit's signature. The following fields are included in the `verification` object: + * | Type | Description | + * | ------- | --------------------------------------------------------------------------------------------------------------------------------------------- | + * | `array` | Usernames of the people who should no longer have push access. **Note**: The list of users, apps, and teams in total is limited to 100 items. | * - * | Name | Type | Description | - * | ---- | ---- | ----------- | - * | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. | - * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. | - * | `signature` | `string` | The signature that was extracted from the commit. | - * | `payload` | `string` | The value that was signed. | - * - * These are the possible values for `reason` in the `verification` object: + * FROM: * - * | Value | Description | - * | ----- | ----------- | - * | `expired_key` | The key that made the signature is expired. | - * | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. | - * | `gpgverify_error` | There was an error communicating with the signature verification service. | - * | `gpgverify_unavailable` | The signature verification service is currently unavailable. | - * | `unsigned` | The object does not include a signature. | - * | `unknown_signature_type` | A non-PGP signature was found in the commit. | - * | `no_user` | No user was associated with the `committer` email address in the commit. | - * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on her/his account. | - * | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. | - * | `unknown_key` | The key that made the signature has not been registered with any user's account. | - * | `malformed_signature` | There was an error parsing the signature. | - * | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. | - * | `valid` | None of the above errors applied, so the signature is considered to be verified. | + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn list_all_commits( + pub async fn remove_user_access_restrictions( &self, owner: &str, repo: &str, - sha: &str, - path: &str, - author: &str, - since: Option>, - until: Option>, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !author.is_empty() { - query_args.push(("author".to_string(), author.to_string())); - } - if !path.is_empty() { - query_args.push(("path".to_string(), path.to_string())); - } - if !sha.is_empty() { - query_args.push(("sha".to_string(), sha.to_string())); - } - if let Some(date) = since { - query_args.push(("since".to_string(), date.to_rfc3339())); - } - if let Some(date) = until { - query_args.push(("until".to_string(), date.to_rfc3339())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + branch: &str, + body: &crate::types::ReposAddUserAccessRestrictionsRequest, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/commits?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/branches/{}/protection/restrictions/users", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get_all_pages( + .delete( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List branches for HEAD commit. + * Rename a branch. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/branches/{branch}/rename` endpoint. + * + * Renames a branch in a repository. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * > [!NOTE] + * > Although the API responds immediately, the branch rename process might take some extra time to complete in the background. You won't be able to push to the old branch name while the rename process is in progress. For more information, see "[Renaming a branch](https://docs.github.com/github/administering-a-repository/renaming-a-branch)". * - * Returns all branches where the given commit SHA is the HEAD, or latest commit for the branch. + * The authenticated user must have push access to the branch. If the branch is the default branch, the authenticated user must also have admin or owner permissions. * - * FROM: + * In order to rename the default branch, fine-grained access tokens also need the `administration:write` repository permission. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `commit_sha: &str` -- commit_sha parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). */ - pub async fn list_branches_for_head_commit( + pub async fn rename_branch( &self, owner: &str, repo: &str, - commit_sha: &str, - ) -> ClientResult>> { + branch: &str, + body: &crate::types::ReposRenameBranchRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/commits/{}/branches-where-head", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(commit_sha), + "/repos/{}/{}/branches/{}/rename", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List branches for HEAD commit. + * List CODEOWNERS errors. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/codeowners/errors` endpoint. * - * As opposed to `list_branches_for_head_commit`, this function returns all the pages of the request at once. + * List any syntax errors that are detected in the CODEOWNERS + * file. * - * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * For more information about the correct CODEOWNERS syntax, + * see "[About code owners](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners)." * - * Returns all branches where the given commit SHA is the HEAD, or latest commit for the branch. + * FROM: + * + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- A branch, tag or commit name used to determine which version of the CODEOWNERS file to use. Default: the repository's default branch (e.g. `main`). */ - pub async fn list_all_branches_for_head_commit( + pub async fn codeowners_errors( &self, owner: &str, repo: &str, - commit_sha: &str, - ) -> ClientResult>> { + ref_: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/commits/{}/branches-where-head", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(commit_sha), + "/repos/{}/{}/codeowners/errors?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -3083,44 +3077,58 @@ impl Repos { .await } /** - * List commit comments. + * List repository collaborators. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{commit_sha}/comments` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/collaborators` endpoint. + * + * For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners. + * The `permissions` hash returned in the response contains the base role permissions of the collaborator. The `role_name` is the highest role assigned to the collaborator after considering all sources of grants, including: repo, teams, organization, and enterprise. + * There is presently not a way to differentiate between an organization level grant and a repository level grant from this endpoint response. + * + * Team members will include the members of child teams. * - * Use the `:commit_sha` to specify the commit that will have its comments listed. + * The authenticated user must have write, maintain, or admin privileges on the repository to use this endpoint. For organization-owned repositories, the authenticated user needs to be a member of the organization. + * OAuth app tokens and personal access tokens (classic) need the `read:org` and `repo` scopes to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `commit_sha: &str` -- commit_sha parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `affiliation: crate::types::Affiliation` -- Filter collaborators returned by their affiliation. `outside` means all outside collaborators of an organization-owned repository. `direct` means all collaborators with permissions to an organization-owned repository, regardless of organization membership status. `all` means all collaborators the authenticated user can see. + * * `permission: crate::types::ReposListCollaboratorsPermission` -- Filter collaborators by the permissions they have on the repository. If not specified, all collaborators will be returned. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_comments_for_commit( + pub async fn list_collaborators( &self, owner: &str, repo: &str, - commit_sha: &str, + affiliation: crate::types::Affiliation, + permission: crate::types::ReposListCollaboratorsPermission, per_page: i64, page: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); + if !affiliation.to_string().is_empty() { + query_args.push(("affiliation".to_string(), affiliation.to_string())); + } if page > 0 { query_args.push(("page".to_string(), page.to_string())); } if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } + if !permission.to_string().is_empty() { + query_args.push(("permission".to_string(), permission.to_string())); + } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/commits/{}/comments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(commit_sha), + "/repos/{}/{}/collaborators?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -3136,28 +3144,44 @@ impl Repos { .await } /** - * List commit comments. + * List repository collaborators. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{commit_sha}/comments` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/collaborators` endpoint. * - * As opposed to `list_comments_for_commit`, this function returns all the pages of the request at once. + * As opposed to `list_collaborators`, this function returns all the pages of the request at once. + * + * For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners. + * The `permissions` hash returned in the response contains the base role permissions of the collaborator. The `role_name` is the highest role assigned to the collaborator after considering all sources of grants, including: repo, teams, organization, and enterprise. + * There is presently not a way to differentiate between an organization level grant and a repository level grant from this endpoint response. + * + * Team members will include the members of child teams. * - * Use the `:commit_sha` to specify the commit that will have its comments listed. + * The authenticated user must have write, maintain, or admin privileges on the repository to use this endpoint. For organization-owned repositories, the authenticated user needs to be a member of the organization. + * OAuth app tokens and personal access tokens (classic) need the `read:org` and `repo` scopes to use this endpoint. * - * FROM: + * FROM: */ - pub async fn list_all_comments_for_commit( + pub async fn list_all_collaborators( &self, owner: &str, repo: &str, - commit_sha: &str, - ) -> ClientResult>> { + affiliation: crate::types::Affiliation, + permission: crate::types::ReposListCollaboratorsPermission, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !affiliation.to_string().is_empty() { + query_args.push(("affiliation".to_string(), affiliation.to_string())); + } + if !permission.to_string().is_empty() { + query_args.push(("permission".to_string(), permission.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/commits/{}/comments", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(commit_sha), + "/repos/{}/{}/collaborators?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); @@ -3172,129 +3196,169 @@ impl Repos { .await } /** - * Create a commit comment. + * Check if a user is a repository collaborator. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/commits/{commit_sha}/comments` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/collaborators/{username}` endpoint. * - * Create a comment for a commit using its `:commit_sha`. + * For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners. * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * Team members will include the members of child teams. + * + * The authenticated user must have push access to the repository to use this endpoint. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `read:org` and `repo` scopes to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `commit_sha: &str` -- commit_sha parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn create_commit_comment( + pub async fn check_collaborator( &self, owner: &str, repo: &str, - commit_sha: &str, - body: &crate::types::ReposCreateCommitCommentRequest, - ) -> ClientResult> { + username: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/commits/{}/comments", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(commit_sha), + "/repos/{}/{}/collaborators/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); self.client - .post( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * List pull requests associated with a commit. + * Add a repository collaborator. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{commit_sha}/pulls` endpoint. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/collaborators/{username}` endpoint. + * + * Add a user to a repository with a specified level of access. If the repository is owned by an organization, this API does not add the user to the organization - a user that has repository access without being an organization member is called an "outside collaborator" (if they are not an Enterprise Managed User) or a "repository collaborator" if they are an Enterprise Managed User. These users are exempt from some organization policies - see "[Adding outside collaborators to repositories](https://docs.github.com/organizations/managing-user-access-to-your-organizations-repositories/managing-outside-collaborators/adding-outside-collaborators-to-repositories-in-your-organization)" to learn more about these collaborator types. + * + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). * - * Lists the merged pull request that introduced the commit to the repository. If the commit is not present in the default branch, additionally returns open pull requests associated with the commit. The results may include open and closed pull requests. Additional preview headers may be required to see certain details for associated pull requests, such as whether a pull request is in a draft state. For more information about previews that might affect this endpoint, see the [List pull requests](https://docs.github.com/rest/reference/pulls#list-pull-requests) endpoint. + * Adding an outside collaborator may be restricted by enterprise and organization administrators. For more information, see "[Enforcing repository management policies in your enterprise](https://docs.github.com/admin/policies/enforcing-policies-for-your-enterprise/enforcing-repository-management-policies-in-your-enterprise#enforcing-a-policy-for-inviting-outside-collaborators-to-repositories)" and "[Setting permissions for adding outside collaborators](https://docs.github.com/organizations/managing-organization-settings/setting-permissions-for-adding-outside-collaborators)" for organization settings. * - * FROM: + * For more information on permission levels, see "[Repository permission levels for an organization](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization#permission-levels-for-repositories-owned-by-an-organization)". There are restrictions on which permissions can be granted to organization members when an organization base role is in place. In this case, the role being given must be equal to or higher than the org base permission. Otherwise, the request will fail with: + * + * ``` + * Cannot assign {member} permission of {role name} + * ``` + * + * Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)." + * + * The invitee will receive a notification that they have been invited to the repository, which they must accept or decline. They may do this via the notifications page, the email they receive, or by using the [API](https://docs.github.com/rest/collaborators/invitations). + * + * For Enterprise Managed Users, this endpoint does not send invitations - these users are automatically added to organizations and repositories. Enterprise Managed Users can only be added to organizations and repositories within their enterprise. + * + * **Updating an existing collaborator's permission level** + * + * The endpoint can also be used to change the permissions of an existing collaborator without first removing and re-adding the collaborator. To change the permissions, use the same endpoint and pass a different `permission` parameter. The response will be a `204`, with no other indication that the permission level changed. + * + * **Rate limits** + * + * You are limited to sending 50 invitations to a repository per 24 hour period. Note there is no limit if you are inviting organization members to an organization repository. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `commit_sha: &str` -- commit_sha parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn list_pull_requests_associated_with_commit( + pub async fn add_collaborator( &self, owner: &str, repo: &str, - commit_sha: &str, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + username: &str, + body: &crate::types::ReposAddCollaboratorRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/commits/{}/pulls?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(commit_sha), - query_ + "/repos/{}/{}/collaborators/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); self.client - .get( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List pull requests associated with a commit. + * Remove a repository collaborator. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{commit_sha}/pulls` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/collaborators/{username}` endpoint. * - * As opposed to `list_pull_requests_associated_with_commit`, this function returns all the pages of the request at once. + * Removes a collaborator from a repository. + * + * To use this endpoint, the authenticated user must either be an administrator of the repository or target themselves for removal. + * + * This endpoint also: + * - Cancels any outstanding invitations sent by the collaborator + * - Unassigns the user from any issues + * - Removes access to organization projects if the user is not an organization member and is not a collaborator on any other organization repositories. + * - Unstars the repository + * - Updates access permissions to packages + * + * Removing a user as a collaborator has the following effects on forks: + * - If the user had access to a fork through their membership to this repository, the user will also be removed from the fork. + * - If the user had their own fork of the repository, the fork will be deleted. + * - If the user still has read access to the repository, open pull requests by this user from a fork will be denied. + * + * > [!NOTE] + * > A user can still have access to the repository through organization permissions like base repository permissions. + * + * Although the API responds immediately, the additional permission updates might take some extra time to complete in the background. + * + * For more information on fork permissions, see "[About permissions and visibility of forks](https://docs.github.com/pull-requests/collaborating-with-pull-requests/working-with-forks/about-permissions-and-visibility-of-forks)". * - * Lists the merged pull request that introduced the commit to the repository. If the commit is not present in the default branch, additionally returns open pull requests associated with the commit. The results may include open and closed pull requests. Additional preview headers may be required to see certain details for associated pull requests, such as whether a pull request is in a draft state. For more information about previews that might affect this endpoint, see the [List pull requests](https://docs.github.com/rest/reference/pulls#list-pull-requests) endpoint. + * FROM: * - * FROM: + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn list_all_pull_requests_associated_with_commit( + pub async fn remove_collaborator( &self, owner: &str, repo: &str, - commit_sha: &str, - ) -> ClientResult>> { + username: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/commits/{}/pulls", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(commit_sha), + "/repos/{}/{}/collaborators/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); self.client - .get_all_pages( + .delete( &url, crate::Message { body: None, @@ -3304,80 +3368,40 @@ impl Repos { .await } /** - * Get a commit. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{ref}` endpoint. - * - * Returns the contents of a single commit reference. You must have `read` access for the repository to use this endpoint. - * - * **Note:** If there are more than 300 files in the commit diff, the response will include pagination link headers for the remaining files, up to a limit of 3000 files. Each page contains the static commit information, and the only changes are to the file listing. + * Get repository permissions for a user. * - * You can pass the appropriate [media type](https://docs.github.com/rest/overview/media-types/#commits-commit-comparison-and-pull-requests) to fetch `diff` and `patch` formats. Diffs with binary data will have no `patch` property. + * This function performs a `GET` to the `/repos/{owner}/{repo}/collaborators/{username}/permission` endpoint. * - * To return only the SHA-1 hash of the commit reference, you can provide the `sha` custom [media type](https://docs.github.com/rest/overview/media-types/#commits-commit-comparison-and-pull-requests) in the `Accept` header. You can use this endpoint to check if a remote reference's SHA-1 hash is the same as your local reference's SHA-1 hash by providing the local SHA-1 reference as the ETag. + * Checks the repository permission and role of a collaborator. * - * **Signature verification object** + * The `permission` attribute provides the legacy base roles of `admin`, `write`, `read`, and `none`, where the + * `maintain` role is mapped to `write` and the `triage` role is mapped to `read`. + * The `role_name` attribute provides the name of the assigned role, including custom roles. The + * `permission` can also be used to determine which base level of access the collaborator has to the repository. * - * The response will include a `verification` object that describes the result of verifying the commit's signature. The following fields are included in the `verification` object: + * The calculated permissions are the highest role assigned to the collaborator after considering all sources of grants, including: repo, teams, organization, and enterprise. + * There is presently not a way to differentiate between an organization level grant and a repository level grant from this endpoint response. * - * | Name | Type | Description | - * | ---- | ---- | ----------- | - * | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. | - * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. | - * | `signature` | `string` | The signature that was extracted from the commit. | - * | `payload` | `string` | The value that was signed. | + * FROM: * - * These are the possible values for `reason` in the `verification` object: + * **Parameters:** * - * | Value | Description | - * | ----- | ----------- | - * | `expired_key` | The key that made the signature is expired. | - * | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. | - * | `gpgverify_error` | There was an error communicating with the signature verification service. | - * | `gpgverify_unavailable` | The signature verification service is currently unavailable. | - * | `unsigned` | The object does not include a signature. | - * | `unknown_signature_type` | A non-PGP signature was found in the commit. | - * | `no_user` | No user was associated with the `committer` email address in the commit. | - * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on her/his account. | - * | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. | - * | `unknown_key` | The key that made the signature has not been registered with any user's account. | - * | `malformed_signature` | There was an error parsing the signature. | - * | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. | - * | `valid` | None of the above errors applied, so the signature is considered to be verified. | - * - * FROM: - * - * **Parameters:** - * - * * `owner: &str` - * * `repo: &str` - * * `page: i64` -- Page number of the results to fetch. - * * `per_page: i64` -- Results per page (max 100). - * * `ref_: &str` -- ref parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn get_commit( + pub async fn get_collaborator_permission_level( &self, owner: &str, repo: &str, - page: i64, - per_page: i64, - ref_: &str, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + username: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/commits/{}?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), - query_ + "/repos/{}/{}/collaborators/{}/permission", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); @@ -3392,38 +3416,35 @@ impl Repos { .await } /** - * Get the combined status for a specific reference. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{ref}/status` endpoint. + * List commit comments for a repository. * - * Users with pull access in a repository can access a combined view of commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name. + * This function performs a `GET` to the `/repos/{owner}/{repo}/comments` endpoint. * - * The most recent status for each context is returned, up to 100. This field [paginates](https://docs.github.com/rest/overview/resources-in-the-rest-api#pagination) if there are over 100 contexts. + * Lists the commit comments for a specified repository. Comments are ordered by ascending ID. * - * Additionally, a combined `state` is returned. The `state` is one of: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * * **failure** if any of the contexts report as `error` or `failure` - * * **pending** if there are no statuses or a context is `pending` - * * **success** if the latest status for all contexts is `success` + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `ref_: &str` -- ref parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn get_combined_status_for_ref( + pub async fn list_commit_comments_for_repo( &self, owner: &str, repo: &str, - ref_: &str, per_page: i64, page: i64, - ) -> ClientResult> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if page > 0 { query_args.push(("page".to_string(), page.to_string())); @@ -3434,10 +3455,9 @@ impl Repos { let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/commits/{}/status?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), + "/repos/{}/{}/comments?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -3453,52 +3473,38 @@ impl Repos { .await } /** - * List commit statuses for a reference. + * List commit comments for a repository. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{ref}/statuses` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/comments` endpoint. * - * Users with pull access in a repository can view commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name. Statuses are returned in reverse chronological order. The first status in the list will be the latest one. + * As opposed to `list_commit_comments_for_repo`, this function returns all the pages of the request at once. * - * This resource is also available via a legacy route: `GET /repos/:owner/:repo/statuses/:ref`. + * Lists the commit comments for a specified repository. Comments are ordered by ascending ID. * - * FROM: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * **Parameters:** + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * * `owner: &str` - * * `repo: &str` - * * `ref_: &str` -- ref parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * FROM: */ - pub async fn list_commit_statuses_for_ref( + pub async fn list_all_commit_comments_for_repo( &self, owner: &str, repo: &str, - ref_: &str, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/commits/{}/statuses?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), - query_ + "/repos/{}/{}/comments", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -3508,35 +3514,44 @@ impl Repos { .await } /** - * List commit statuses for a reference. + * Get a commit comment. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{ref}/statuses` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/comments/{comment_id}` endpoint. * - * As opposed to `list_commit_statuses_for_ref`, this function returns all the pages of the request at once. + * Gets a specified commit comment. * - * Users with pull access in a repository can view commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name. Statuses are returned in reverse chronological order. The first status in the list will be the latest one. + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * This resource is also available via a legacy route: `GET /repos/:owner/:repo/statuses/:ref`. + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. + * + * FROM: * - * FROM: + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. */ - pub async fn list_all_commit_statuses_for_ref( + pub async fn get_commit_comment( &self, owner: &str, repo: &str, - ref_: &str, - ) -> ClientResult>> { + comment_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/commits/{}/statuses", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), + "/repos/{}/{}/comments/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -3546,45 +3561,37 @@ impl Repos { .await } /** - * Get community profile metrics. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/community/profile` endpoint. + * Delete a commit comment. * - * This endpoint will return all community profile metrics, including an - * overall health score, repository description, the presence of documentation, detected - * code of conduct, detected license, and the presence of ISSUE\_TEMPLATE, PULL\_REQUEST\_TEMPLATE, - * README, and CONTRIBUTING files. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/comments/{comment_id}` endpoint. * - * The `health_percentage` score is defined as a percentage of how many of - * these four documents are present: README, CONTRIBUTING, LICENSE, and - * CODE_OF_CONDUCT. For example, if all four documents are present, then - * the `health_percentage` is `100`. If only one is present, then the - * `health_percentage` is `25`. * - * `content_reports_enabled` is only returned for organization-owned repositories. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. */ - pub async fn get_community_profile_metrics( + pub async fn delete_commit_comment( &self, owner: &str, repo: &str, - ) -> ClientResult> { + comment_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/community/profile", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/comments/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&comment_id.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -3594,21 +3601,57 @@ impl Repos { .await } /** - * Compare two commits. + * Update a commit comment. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/compare/{basehead}` endpoint. + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/comments/{comment_id}` endpoint. * - * The `basehead` param is comprised of two parts: `base` and `head`. Both must be branch names in `repo`. To compare branches across other repositories in the same network as `repo`, use the format `:branch`. + * Updates the contents of a specified commit comment. * - * The response from the API is equivalent to running the `git log base..head` command; however, commits are returned in chronological order. Pass the appropriate [media type](https://docs.github.com/rest/overview/media-types/#commits-commit-comparison-and-pull-requests) to fetch diff and patch formats. + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * The response also includes details on the files that were changed between the two commits. This includes the status of the change (for example, if a file was added, removed, modified, or renamed), and details of the change itself. For example, files with a `renamed` status have a `previous_filename` field showing the previous filename of the file, and files with a `modified` status have a `patch` field showing the changes made to the file. + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * **Working with large comparisons** + * FROM: * - * To process a response with a large number of commits, you can use (`per_page` or `page`) to paginate the results. When using paging, the list of changed files is only returned with page 1, but includes all changed files for the entire comparison. For more information on working with pagination, see "[Traversing with pagination](/rest/guides/traversing-with-pagination)." + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `comment_id: i64` -- The unique identifier of the comment. + */ + pub async fn update_commit_comment( + &self, + owner: &str, + repo: &str, + comment_id: i64, + body: &crate::types::PullsUpdateReviewRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/comments/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&comment_id.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List commits. * - * When calling this API without any paging parameters (`per_page` or `page`), the returned list is limited to 250 commits and the last commit in the list is the most recent of the entire comparison. When a paging parameter is specified, the first commit in the returned list of each page is the earliest. + * This function performs a `GET` to the `/repos/{owner}/{repo}/commits` endpoint. * * **Signature verification object** * @@ -3620,6 +3663,7 @@ impl Repos { * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. | * | `signature` | `string` | The signature that was extracted from the commit. | * | `payload` | `string` | The value that was signed. | + * | `verified_at` | `string` | The date the signature was verified by GitHub. | * * These are the possible values for `reason` in the `verification` object: * @@ -3632,45 +3676,72 @@ impl Repos { * | `unsigned` | The object does not include a signature. | * | `unknown_signature_type` | A non-PGP signature was found in the commit. | * | `no_user` | No user was associated with the `committer` email address in the commit. | - * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on her/his account. | + * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. | * | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. | * | `unknown_key` | The key that made the signature has not been registered with any user's account. | * | `malformed_signature` | There was an error parsing the signature. | * | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. | * | `valid` | None of the above errors applied, so the signature is considered to be verified. | * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `page: i64` -- Page number of the results to fetch. - * * `per_page: i64` -- Results per page (max 100). - * * `basehead: &str` -- The base branch and head branch to compare. This parameter expects the format `{base}...{head}`. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `sha: &str` -- SHA or branch to start listing commits from. Default: the repository’s default branch (usually `main`). + * * `path: &str` -- Only commits containing this file path will be returned. + * * `author: &str` -- GitHub username or email address to use to filter by commit author. + * * `committer: &str` -- GitHub username or email address to use to filter by commit committer. + * * `since: chrono::DateTime` -- Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Due to limitations of Git, timestamps must be between 1970-01-01 and 2099-12-31 (inclusive) or unexpected results may be returned. + * * `until: chrono::DateTime` -- Only commits before this date will be returned. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Due to limitations of Git, timestamps must be between 1970-01-01 and 2099-12-31 (inclusive) or unexpected results may be returned. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn compare_commits( + pub async fn list_commits( &self, owner: &str, repo: &str, - page: i64, + sha: &str, + path: &str, + author: &str, + committer: &str, + since: Option>, + until: Option>, per_page: i64, - basehead: &str, - ) -> ClientResult> { + page: i64, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); + if !author.is_empty() { + query_args.push(("author".to_string(), author.to_string())); + } + if !committer.is_empty() { + query_args.push(("committer".to_string(), committer.to_string())); + } if page > 0 { query_args.push(("page".to_string(), page.to_string())); } + if !path.is_empty() { + query_args.push(("path".to_string(), path.to_string())); + } if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } + if !sha.is_empty() { + query_args.push(("sha".to_string(), sha.to_string())); + } + if let Some(date) = since { + query_args.push(("since".to_string(), date.to_rfc3339())); + } + if let Some(date) = until { + query_args.push(("until".to_string(), date.to_rfc3339())); + } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/compare/{}?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(basehead), + "/repos/{}/{}/commits?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -3686,76 +3757,86 @@ impl Repos { .await } /** - * Get repository content. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. - * - * Gets the contents of a file or directory in a repository. Specify the file path or directory in `:path`. If you omit - * `:path`, you will receive the contents of the repository's root directory. See the description below regarding what the API response includes for directories. - * - * Files and symlinks support [a custom media type](https://docs.github.com/rest/reference/repos#custom-media-types) for - * retrieving the raw content or rendered HTML (when supported). All content types support [a custom media - * type](https://docs.github.com/rest/reference/repos#custom-media-types) to ensure the content is returned in a consistent - * object format. + * List commits. * - * **Note**: - * * To get a repository's contents recursively, you can [recursively get the tree](https://docs.github.com/rest/reference/git#trees). - * * This API has an upper limit of 1,000 files for a directory. If you need to retrieve more files, use the [Git Trees - * API](https://docs.github.com/rest/reference/git#get-a-tree). - * * This API supports files up to 1 megabyte in size. + * This function performs a `GET` to the `/repos/{owner}/{repo}/commits` endpoint. * - * #### If the content is a directory - * The response will be an array of objects, one object for each item in the directory. - * When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value - * _should_ be "submodule". This behavior exists in API v3 [for backwards compatibility purposes](https://git.io/v1YCW). - * In the next major version of the API, the type will be returned as "submodule". + * As opposed to `list_commits`, this function returns all the pages of the request at once. * - * #### If the content is a symlink - * If the requested `:path` points to a symlink, and the symlink's target is a normal file in the repository, then the - * API responds with the content of the file (in the format shown in the example. Otherwise, the API responds with an object - * describing the symlink itself. + * **Signature verification object** * - * #### If the content is a submodule - * The `submodule_git_url` identifies the location of the submodule repository, and the `sha` identifies a specific - * commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out - * the submodule at that specific commit. + * The response will include a `verification` object that describes the result of verifying the commit's signature. The following fields are included in the `verification` object: * - * If the submodule repository is not hosted on github.com, the Git URLs (`git_url` and `_links["git"]`) and the - * github.com URLs (`html_url` and `_links["html"]`) will have null values. + * | Name | Type | Description | + * | ---- | ---- | ----------- | + * | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. | + * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. | + * | `signature` | `string` | The signature that was extracted from the commit. | + * | `payload` | `string` | The value that was signed. | + * | `verified_at` | `string` | The date the signature was verified by GitHub. | * - * FROM: + * These are the possible values for `reason` in the `verification` object: * - * **Parameters:** + * | Value | Description | + * | ----- | ----------- | + * | `expired_key` | The key that made the signature is expired. | + * | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. | + * | `gpgverify_error` | There was an error communicating with the signature verification service. | + * | `gpgverify_unavailable` | The signature verification service is currently unavailable. | + * | `unsigned` | The object does not include a signature. | + * | `unknown_signature_type` | A non-PGP signature was found in the commit. | + * | `no_user` | No user was associated with the `committer` email address in the commit. | + * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. | + * | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. | + * | `unknown_key` | The key that made the signature has not been registered with any user's account. | + * | `malformed_signature` | There was an error parsing the signature. | + * | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. | + * | `valid` | None of the above errors applied, so the signature is considered to be verified. | * - * * `owner: &str` - * * `repo: &str` - * * `path: &str` -- path parameter. - * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch (usually `master`). + * FROM: */ - pub async fn get_content_vec_entries( + pub async fn list_all_commits( &self, owner: &str, repo: &str, + sha: &str, path: &str, - ref_: &str, - ) -> ClientResult>> { + author: &str, + committer: &str, + since: Option>, + until: Option>, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if !ref_.is_empty() { - query_args.push(("ref".to_string(), ref_.to_string())); + if !author.is_empty() { + query_args.push(("author".to_string(), author.to_string())); + } + if !committer.is_empty() { + query_args.push(("committer".to_string(), committer.to_string())); + } + if !path.is_empty() { + query_args.push(("path".to_string(), path.to_string())); + } + if !sha.is_empty() { + query_args.push(("sha".to_string(), sha.to_string())); + } + if let Some(date) = since { + query_args.push(("since".to_string(), date.to_rfc3339())); + } + if let Some(date) = until { + query_args.push(("until".to_string(), date.to_rfc3339())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/contents/{}?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(path), + "/repos/{}/{}/commits?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -3765,71 +3846,34 @@ impl Repos { .await } /** - * Get repository content. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. - * - * Gets the contents of a file or directory in a repository. Specify the file path or directory in `:path`. If you omit - * `:path`, you will receive the contents of the repository's root directory. See the description below regarding what the API response includes for directories. - * - * Files and symlinks support [a custom media type](https://docs.github.com/rest/reference/repos#custom-media-types) for - * retrieving the raw content or rendered HTML (when supported). All content types support [a custom media - * type](https://docs.github.com/rest/reference/repos#custom-media-types) to ensure the content is returned in a consistent - * object format. - * - * **Note**: - * * To get a repository's contents recursively, you can [recursively get the tree](https://docs.github.com/rest/reference/git#trees). - * * This API has an upper limit of 1,000 files for a directory. If you need to retrieve more files, use the [Git Trees - * API](https://docs.github.com/rest/reference/git#get-a-tree). - * * This API supports files up to 1 megabyte in size. - * - * #### If the content is a directory - * The response will be an array of objects, one object for each item in the directory. - * When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value - * _should_ be "submodule". This behavior exists in API v3 [for backwards compatibility purposes](https://git.io/v1YCW). - * In the next major version of the API, the type will be returned as "submodule". + * List branches for HEAD commit. * - * #### If the content is a symlink - * If the requested `:path` points to a symlink, and the symlink's target is a normal file in the repository, then the - * API responds with the content of the file (in the format shown in the example. Otherwise, the API responds with an object - * describing the symlink itself. + * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head` endpoint. * - * #### If the content is a submodule - * The `submodule_git_url` identifies the location of the submodule repository, and the `sha` identifies a specific - * commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out - * the submodule at that specific commit. + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * If the submodule repository is not hosted on github.com, the Git URLs (`git_url` and `_links["git"]`) and the - * github.com URLs (`html_url` and `_links["html"]`) will have null values. + * Returns all branches where the given commit SHA is the HEAD, or latest commit for the branch. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `path: &str` -- path parameter. - * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch (usually `master`). + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `commit_sha: &str` -- The SHA of the commit. */ - pub async fn get_content_file( + pub async fn list_branches_for_head_commit( &self, owner: &str, repo: &str, - path: &str, - ref_: &str, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !ref_.is_empty() { - query_args.push(("ref".to_string(), ref_.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + commit_sha: &str, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/contents/{}?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(path), - query_ + "/repos/{}/{}/commits/{}/branches-where-head", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&commit_sha.to_string()), ), None, ); @@ -3844,76 +3888,35 @@ impl Repos { .await } /** - * Get repository content. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. - * - * Gets the contents of a file or directory in a repository. Specify the file path or directory in `:path`. If you omit - * `:path`, you will receive the contents of the repository's root directory. See the description below regarding what the API response includes for directories. - * - * Files and symlinks support [a custom media type](https://docs.github.com/rest/reference/repos#custom-media-types) for - * retrieving the raw content or rendered HTML (when supported). All content types support [a custom media - * type](https://docs.github.com/rest/reference/repos#custom-media-types) to ensure the content is returned in a consistent - * object format. - * - * **Note**: - * * To get a repository's contents recursively, you can [recursively get the tree](https://docs.github.com/rest/reference/git#trees). - * * This API has an upper limit of 1,000 files for a directory. If you need to retrieve more files, use the [Git Trees - * API](https://docs.github.com/rest/reference/git#get-a-tree). - * * This API supports files up to 1 megabyte in size. - * - * #### If the content is a directory - * The response will be an array of objects, one object for each item in the directory. - * When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value - * _should_ be "submodule". This behavior exists in API v3 [for backwards compatibility purposes](https://git.io/v1YCW). - * In the next major version of the API, the type will be returned as "submodule". - * - * #### If the content is a symlink - * If the requested `:path` points to a symlink, and the symlink's target is a normal file in the repository, then the - * API responds with the content of the file (in the format shown in the example. Otherwise, the API responds with an object - * describing the symlink itself. + * List branches for HEAD commit. * - * #### If the content is a submodule - * The `submodule_git_url` identifies the location of the submodule repository, and the `sha` identifies a specific - * commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out - * the submodule at that specific commit. + * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head` endpoint. * - * If the submodule repository is not hosted on github.com, the Git URLs (`git_url` and `_links["git"]`) and the - * github.com URLs (`html_url` and `_links["html"]`) will have null values. + * As opposed to `list_branches_for_head_commit`, this function returns all the pages of the request at once. * - * FROM: + * Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * **Parameters:** + * Returns all branches where the given commit SHA is the HEAD, or latest commit for the branch. * - * * `owner: &str` - * * `repo: &str` - * * `path: &str` -- path parameter. - * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch (usually `master`). + * FROM: */ - pub async fn get_content_symlink( + pub async fn list_all_branches_for_head_commit( &self, owner: &str, repo: &str, - path: &str, - ref_: &str, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !ref_.is_empty() { - query_args.push(("ref".to_string(), ref_.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + commit_sha: &str, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/contents/{}?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(path), - query_ + "/repos/{}/{}/commits/{}/branches-where-head", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&commit_sha.to_string()), ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -3923,70 +3926,51 @@ impl Repos { .await } /** - * Get repository content. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. - * - * Gets the contents of a file or directory in a repository. Specify the file path or directory in `:path`. If you omit - * `:path`, you will receive the contents of the repository's root directory. See the description below regarding what the API response includes for directories. - * - * Files and symlinks support [a custom media type](https://docs.github.com/rest/reference/repos#custom-media-types) for - * retrieving the raw content or rendered HTML (when supported). All content types support [a custom media - * type](https://docs.github.com/rest/reference/repos#custom-media-types) to ensure the content is returned in a consistent - * object format. - * - * **Note**: - * * To get a repository's contents recursively, you can [recursively get the tree](https://docs.github.com/rest/reference/git#trees). - * * This API has an upper limit of 1,000 files for a directory. If you need to retrieve more files, use the [Git Trees - * API](https://docs.github.com/rest/reference/git#get-a-tree). - * * This API supports files up to 1 megabyte in size. + * List commit comments. * - * #### If the content is a directory - * The response will be an array of objects, one object for each item in the directory. - * When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value - * _should_ be "submodule". This behavior exists in API v3 [for backwards compatibility purposes](https://git.io/v1YCW). - * In the next major version of the API, the type will be returned as "submodule". + * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{commit_sha}/comments` endpoint. * - * #### If the content is a symlink - * If the requested `:path` points to a symlink, and the symlink's target is a normal file in the repository, then the - * API responds with the content of the file (in the format shown in the example. Otherwise, the API responds with an object - * describing the symlink itself. + * Lists the comments for a specified commit. * - * #### If the content is a submodule - * The `submodule_git_url` identifies the location of the submodule repository, and the `sha` identifies a specific - * commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out - * the submodule at that specific commit. + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * If the submodule repository is not hosted on github.com, the Git URLs (`git_url` and `_links["git"]`) and the - * github.com URLs (`html_url` and `_links["html"]`) will have null values. + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `path: &str` -- path parameter. - * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch (usually `master`). + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `commit_sha: &str` -- The SHA of the commit. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn get_content_submodule( + pub async fn list_comments_for_commit( &self, owner: &str, repo: &str, - path: &str, - ref_: &str, - ) -> ClientResult> { + commit_sha: &str, + per_page: i64, + page: i64, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if !ref_.is_empty() { - query_args.push(("ref".to_string(), ref_.to_string())); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/contents/{}?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(path), + "/repos/{}/{}/commits/{}/comments?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&commit_sha.to_string()), query_ ), None, @@ -4002,76 +3986,40 @@ impl Repos { .await } /** - * Get repository content. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. - * - * Gets the contents of a file or directory in a repository. Specify the file path or directory in `:path`. If you omit - * `:path`, you will receive the contents of the repository's root directory. See the description below regarding what the API response includes for directories. - * - * Files and symlinks support [a custom media type](https://docs.github.com/rest/reference/repos#custom-media-types) for - * retrieving the raw content or rendered HTML (when supported). All content types support [a custom media - * type](https://docs.github.com/rest/reference/repos#custom-media-types) to ensure the content is returned in a consistent - * object format. - * - * **Note**: - * * To get a repository's contents recursively, you can [recursively get the tree](https://docs.github.com/rest/reference/git#trees). - * * This API has an upper limit of 1,000 files for a directory. If you need to retrieve more files, use the [Git Trees - * API](https://docs.github.com/rest/reference/git#get-a-tree). - * * This API supports files up to 1 megabyte in size. - * - * #### If the content is a directory - * The response will be an array of objects, one object for each item in the directory. - * When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value - * _should_ be "submodule". This behavior exists in API v3 [for backwards compatibility purposes](https://git.io/v1YCW). - * In the next major version of the API, the type will be returned as "submodule". + * List commit comments. * - * #### If the content is a symlink - * If the requested `:path` points to a symlink, and the symlink's target is a normal file in the repository, then the - * API responds with the content of the file (in the format shown in the example. Otherwise, the API responds with an object - * describing the symlink itself. + * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{commit_sha}/comments` endpoint. * - * #### If the content is a submodule - * The `submodule_git_url` identifies the location of the submodule repository, and the `sha` identifies a specific - * commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out - * the submodule at that specific commit. + * As opposed to `list_comments_for_commit`, this function returns all the pages of the request at once. * - * If the submodule repository is not hosted on github.com, the Git URLs (`git_url` and `_links["git"]`) and the - * github.com URLs (`html_url` and `_links["html"]`) will have null values. + * Lists the comments for a specified commit. * - * FROM: + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * **Parameters:** + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * * `owner: &str` - * * `repo: &str` - * * `path: &str` -- path parameter. - * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch (usually `master`). + * FROM: */ - pub async fn get_content( + pub async fn list_all_comments_for_commit( &self, owner: &str, repo: &str, - path: &str, - ref_: &str, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !ref_.is_empty() { - query_args.push(("ref".to_string(), ref_.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + commit_sha: &str, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/contents/{}?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(path), - query_ + "/repos/{}/{}/commits/{}/comments", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&commit_sha.to_string()), ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -4081,85 +4029,47 @@ impl Repos { .await } /** - * Create or update file contents. - * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. - * - * Creates a new file or replaces an existing file in a repository. - * - * FROM: - * - * **Parameters:** - * - * * `owner: &str` - * * `repo: &str` - * * `path: &str` -- path parameter. - */ - pub async fn create_or_update_file_contents( - &self, - owner: &str, - repo: &str, - path: &str, - body: &crate::types::ReposCreateUpdateFileContentsRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/repos/{}/{}/contents/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(path), - ), - None, - ); - self.client - .put( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } - /** - * Delete a file. + * Create a commit comment. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/commits/{commit_sha}/comments` endpoint. * - * Deletes a file in a repository. + * Create a comment for a commit using its `:commit_sha`. * - * You can provide an additional `committer` parameter, which is an object containing information about the committer. Or, you can provide an `author` parameter, which is an object containing information about the author. + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." * - * The `author` section is optional and is filled in with the `committer` information if omitted. If the `committer` information is omitted, the authenticated user's information is used. + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * You must provide values for both `name` and `email`, whether you choose to use `author` or `committer`. Otherwise, you'll receive a `422` status code. + * - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type. + * - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`. + * - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`. + * - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `path: &str` -- path parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `commit_sha: &str` -- The SHA of the commit. */ - pub async fn delete_file( + pub async fn create_commit_comment( &self, owner: &str, repo: &str, - path: &str, - body: &crate::types::ReposDeleteFileRequest, - ) -> ClientResult> { + commit_sha: &str, + body: &crate::types::ReposCreateCommitCommentRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/contents/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(path), + "/repos/{}/{}/commits/{}/comments", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&commit_sha.to_string()), ), None, ); self.client - .delete( + .post( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -4169,36 +4079,33 @@ impl Repos { .await } /** - * List repository contributors. + * List pull requests associated with a commit. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/contributors` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{commit_sha}/pulls` endpoint. * - * Lists contributors to the specified repository and sorts them by the number of commits per contributor in descending order. This endpoint may return information that is a few hours old because the GitHub REST API v3 caches contributor data to improve performance. + * Lists the merged pull request that introduced the commit to the repository. If the commit is not present in the default branch, it will return merged and open pull requests associated with the commit. * - * GitHub identifies contributors by author email address. This endpoint groups contribution counts by GitHub user, which includes all associated email addresses. To improve performance, only the first 500 author email addresses in the repository link to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information. + * To list the open or merged pull requests associated with a branch, you can set the `commit_sha` parameter to the branch name. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `anon: &str` -- Set to `1` or `true` to include anonymous contributors in results. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `commit_sha: &str` -- The SHA of the commit. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_contributors( + pub async fn list_pull_requests_associated_with_commit( &self, owner: &str, repo: &str, - anon: &str, + commit_sha: &str, per_page: i64, page: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if !anon.is_empty() { - query_args.push(("anon".to_string(), anon.to_string())); - } if page > 0 { query_args.push(("page".to_string(), page.to_string())); } @@ -4208,9 +4115,10 @@ impl Repos { let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/contributors?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/commits/{}/pulls?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&commit_sha.to_string()), query_ ), None, @@ -4226,35 +4134,30 @@ impl Repos { .await } /** - * List repository contributors. + * List pull requests associated with a commit. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/contributors` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{commit_sha}/pulls` endpoint. * - * As opposed to `list_contributors`, this function returns all the pages of the request at once. + * As opposed to `list_pull_requests_associated_with_commit`, this function returns all the pages of the request at once. * - * Lists contributors to the specified repository and sorts them by the number of commits per contributor in descending order. This endpoint may return information that is a few hours old because the GitHub REST API v3 caches contributor data to improve performance. + * Lists the merged pull request that introduced the commit to the repository. If the commit is not present in the default branch, it will return merged and open pull requests associated with the commit. * - * GitHub identifies contributors by author email address. This endpoint groups contribution counts by GitHub user, which includes all associated email addresses. To improve performance, only the first 500 author email addresses in the repository link to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information. + * To list the open or merged pull requests associated with a branch, you can set the `commit_sha` parameter to the branch name. * - * FROM: + * FROM: */ - pub async fn list_all_contributors( + pub async fn list_all_pull_requests_associated_with_commit( &self, owner: &str, repo: &str, - anon: &str, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !anon.is_empty() { - query_args.push(("anon".to_string(), anon.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + commit_sha: &str, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/contributors?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/commits/{}/pulls", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&commit_sha.to_string()), ), None, ); @@ -4269,67 +4172,2707 @@ impl Repos { .await } /** - * List deployments. + * Get a commit. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/deployments` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{ref}` endpoint. * - * Simple filtering of deployments is available via query parameters: + * Returns the contents of a single commit reference. You must have `read` access for the repository to use this endpoint. + * + * > [!NOTE] + * > If there are more than 300 files in the commit diff and the default JSON media type is requested, the response will include pagination link headers for the remaining files, up to a limit of 3000 files. Each page contains the static commit information, and the only changes are to the file listing. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." Pagination query parameters are not supported for these media types. + * + * - **`application/vnd.github.diff`**: Returns the diff of the commit. Larger diffs may time out and return a 5xx status code. + * - **`application/vnd.github.patch`**: Returns the patch of the commit. Diffs with binary data will have no `patch` property. Larger diffs may time out and return a 5xx status code. + * - **`application/vnd.github.sha`**: Returns the commit's SHA-1 hash. You can use this endpoint to check if a remote reference's SHA-1 hash is the same as your local reference's SHA-1 hash by providing the local SHA-1 reference as the ETag. + * + * **Signature verification object** + * + * The response will include a `verification` object that describes the result of verifying the commit's signature. The following fields are included in the `verification` object: + * + * | Name | Type | Description | + * | ---- | ---- | ----------- | + * | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. | + * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. | + * | `signature` | `string` | The signature that was extracted from the commit. | + * | `payload` | `string` | The value that was signed. | + * | `verified_at` | `string` | The date the signature was verified by GitHub. | + * + * These are the possible values for `reason` in the `verification` object: + * + * | Value | Description | + * | ----- | ----------- | + * | `expired_key` | The key that made the signature is expired. | + * | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. | + * | `gpgverify_error` | There was an error communicating with the signature verification service. | + * | `gpgverify_unavailable` | The signature verification service is currently unavailable. | + * | `unsigned` | The object does not include a signature. | + * | `unknown_signature_type` | A non-PGP signature was found in the commit. | + * | `no_user` | No user was associated with the `committer` email address in the commit. | + * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. | + * | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. | + * | `unknown_key` | The key that made the signature has not been registered with any user's account. | + * | `malformed_signature` | There was an error parsing the signature. | + * | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. | + * | `valid` | None of the above errors applied, so the signature is considered to be verified. | * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `sha: &str` -- The SHA recorded at creation time. - * * `ref_: &str` -- The name of the ref. This can be a branch, tag, or SHA. - * * `task: &str` -- The name of the task for the deployment (e.g., `deploy` or `deploy:migrations`). - * * `environment: &str` -- The name of the environment that was deployed to (e.g., `staging` or `production`). - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `ref_: &str` -- The commit reference. Can be a commit SHA, branch name (`heads/BRANCH_NAME`), or tag name (`tags/TAG_NAME`). For more information, see "[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)" in the Git documentation. */ - pub async fn list_deployments( + pub async fn get_commit( &self, owner: &str, repo: &str, - sha: &str, - ref_: &str, - task: &str, - environment: &str, - per_page: i64, page: i64, - ) -> ClientResult>> { + per_page: i64, + ref_: &str, + ) -> ClientResult> { let mut query_args: Vec<(String, String)> = Default::default(); - if !environment.is_empty() { - query_args.push(("environment".to_string(), environment.to_string())); - } if page > 0 { query_args.push(("page".to_string(), page.to_string())); } if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } - if !ref_.is_empty() { - query_args.push(("ref".to_string(), ref_.to_string())); - } - if !sha.is_empty() { + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/commits/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get the combined status for a specific reference. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{ref}/status` endpoint. + * + * Users with pull access in a repository can access a combined view of commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name. + * + * + * Additionally, a combined `state` is returned. The `state` is one of: + * + * * **failure** if any of the contexts report as `error` or `failure` + * * **pending** if there are no statuses or a context is `pending` + * * **success** if the latest status for all contexts is `success` + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The commit reference. Can be a commit SHA, branch name (`heads/BRANCH_NAME`), or tag name (`tags/TAG_NAME`). For more information, see "[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)" in the Git documentation. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn get_combined_status_for_ref( + &self, + owner: &str, + repo: &str, + ref_: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/commits/{}/status?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List commit statuses for a reference. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{ref}/statuses` endpoint. + * + * Users with pull access in a repository can view commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name. Statuses are returned in reverse chronological order. The first status in the list will be the latest one. + * + * This resource is also available via a legacy route: `GET /repos/:owner/:repo/statuses/:ref`. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The commit reference. Can be a commit SHA, branch name (`heads/BRANCH_NAME`), or tag name (`tags/TAG_NAME`). For more information, see "[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)" in the Git documentation. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_commit_statuses_for_ref( + &self, + owner: &str, + repo: &str, + ref_: &str, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/commits/{}/statuses?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List commit statuses for a reference. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/commits/{ref}/statuses` endpoint. + * + * As opposed to `list_commit_statuses_for_ref`, this function returns all the pages of the request at once. + * + * Users with pull access in a repository can view commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name. Statuses are returned in reverse chronological order. The first status in the list will be the latest one. + * + * This resource is also available via a legacy route: `GET /repos/:owner/:repo/statuses/:ref`. + * + * FROM: + */ + pub async fn list_all_commit_statuses_for_ref( + &self, + owner: &str, + repo: &str, + ref_: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/commits/{}/statuses", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get community profile metrics. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/community/profile` endpoint. + * + * Returns all community profile metrics for a repository. The repository cannot be a fork. + * + * The returned metrics include an overall health score, the repository description, the presence of documentation, the + * detected code of conduct, the detected license, and the presence of ISSUE\_TEMPLATE, PULL\_REQUEST\_TEMPLATE, + * README, and CONTRIBUTING files. + * + * The `health_percentage` score is defined as a percentage of how many of + * the recommended community health files are present. For more information, see + * "[About community profiles for public repositories](https://docs.github.com/communities/setting-up-your-project-for-healthy-contributions/about-community-profiles-for-public-repositories)." + * + * `content_reports_enabled` is only returned for organization-owned repositories. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_community_profile_metrics( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/community/profile", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Compare two commits. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/compare/{basehead}` endpoint. + * + * Compares two commits against one another. You can compare refs (branches or tags) and commit SHAs in the same repository, or you can compare refs and commit SHAs that exist in different repositories within the same repository network, including fork branches. For more information about how to view a repository's network, see "[Understanding connections between repositories](https://docs.github.com/repositories/viewing-activity-and-data-for-your-repository/understanding-connections-between-repositories)." + * + * This endpoint is equivalent to running the `git log BASE..HEAD` command, but it returns commits in a different order. The `git log BASE..HEAD` command returns commits in reverse chronological order, whereas the API returns commits in chronological order. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.diff`**: Returns the diff of the commit. + * - **`application/vnd.github.patch`**: Returns the patch of the commit. Diffs with binary data will have no `patch` property. + * + * The API response includes details about the files that were changed between the two commits. This includes the status of the change (if a file was added, removed, modified, or renamed), and details of the change itself. For example, files with a `renamed` status have a `previous_filename` field showing the previous filename of the file, and files with a `modified` status have a `patch` field showing the changes made to the file. + * + * When calling this endpoint without any paging parameter (`per_page` or `page`), the returned list is limited to 250 commits, and the last commit in the list is the most recent of the entire comparison. + * + * **Working with large comparisons** + * + * To process a response with a large number of commits, use a query parameter (`per_page` or `page`) to paginate the results. When using pagination: + * + * - The list of changed files is only shown on the first page of results, and it includes up to 300 changed files for the entire comparison. + * - The results are returned in chronological order, but the last commit in the returned list may not be the most recent one in the entire set if there are more pages of results. + * + * For more information on working with pagination, see "[Using pagination in the REST API](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api)." + * + * **Signature verification object** + * + * The response will include a `verification` object that describes the result of verifying the commit's signature. The `verification` object includes the following fields: + * + * | Name | Type | Description | + * | ---- | ---- | ----------- | + * | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. | + * | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. | + * | `signature` | `string` | The signature that was extracted from the commit. | + * | `payload` | `string` | The value that was signed. | + * | `verified_at` | `string` | The date the signature was verified by GitHub. | + * + * These are the possible values for `reason` in the `verification` object: + * + * | Value | Description | + * | ----- | ----------- | + * | `expired_key` | The key that made the signature is expired. | + * | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. | + * | `gpgverify_error` | There was an error communicating with the signature verification service. | + * | `gpgverify_unavailable` | The signature verification service is currently unavailable. | + * | `unsigned` | The object does not include a signature. | + * | `unknown_signature_type` | A non-PGP signature was found in the commit. | + * | `no_user` | No user was associated with the `committer` email address in the commit. | + * | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. | + * | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. | + * | `unknown_key` | The key that made the signature has not been registered with any user's account. | + * | `malformed_signature` | There was an error parsing the signature. | + * | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. | + * | `valid` | None of the above errors applied, so the signature is considered to be verified. | + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `basehead: &str` -- The base branch and head branch to compare. This parameter expects the format `BASE...HEAD`. Both must be branch names in `repo`. To compare with a branch that exists in a different repository in the same network as `repo`, the `basehead` parameter expects the format `USERNAME:BASE...USERNAME:HEAD`. + */ + pub async fn compare_commits( + &self, + owner: &str, + repo: &str, + page: i64, + per_page: i64, + basehead: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/compare/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&basehead.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get repository content. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. + * + * Gets the contents of a file or directory in a repository. Specify the file path or directory with the `path` parameter. If you omit the `path` parameter, you will receive the contents of the repository's root directory. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw file contents for files and symlinks. + * - **`application/vnd.github.html+json`**: Returns the file contents in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup). + * - **`application/vnd.github.object+json`**: Returns the contents in a consistent object format regardless of the content type. For example, instead of an array of objects for a directory, the response will be an object with an `entries` attribute containing the array of objects. + * + * If the content is a directory, the response will be an array of objects, one object for each item in the directory. When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value _should_ be "submodule". This behavior exists [for backwards compatibility purposes](https://git.io/v1YCW). In the next major version of the API, the type will be returned as "submodule". + * + * If the content is a symlink and the symlink's target is a normal file in the repository, then the API responds with the content of the file. Otherwise, the API responds with an object describing the symlink itself. + * + * If the content is a submodule, the `submodule_git_url` field identifies the location of the submodule repository, and the `sha` identifies a specific commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out the submodule at that specific commit. If the submodule repository is not hosted on github.com, the Git URLs (`git_url` and `_links["git"]`) and the github.com URLs (`html_url` and `_links["html"]`) will have null values. + * + * **Notes**: + * + * - To get a repository's contents recursively, you can [recursively get the tree](https://docs.github.com/rest/git/trees#get-a-tree). + * - This API has an upper limit of 1,000 files for a directory. If you need to retrieve + * more files, use the [Git Trees API](https://docs.github.com/rest/git/trees#get-a-tree). + * - Download URLs expire and are meant to be used just once. To ensure the download URL does not expire, please use the contents API to obtain a fresh download URL for each download. + * - If the requested file's size is: + * - 1 MB or smaller: All features of this endpoint are supported. + * - Between 1-100 MB: Only the `raw` or `object` custom media types are supported. Both will work as normal, except that when using the `object` media type, the `content` field will be an empty + * string and the `encoding` field will be `"none"`. To get the contents of these larger files, use the `raw` media type. + * - Greater than 100 MB: This endpoint is not supported. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `path: &str` -- path parameter. + * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch. + */ + pub async fn get_content_vec_directory( + &self, + owner: &str, + repo: &str, + path: &str, + ref_: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/contents/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&path.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get repository content. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. + * + * Gets the contents of a file or directory in a repository. Specify the file path or directory with the `path` parameter. If you omit the `path` parameter, you will receive the contents of the repository's root directory. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw file contents for files and symlinks. + * - **`application/vnd.github.html+json`**: Returns the file contents in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup). + * - **`application/vnd.github.object+json`**: Returns the contents in a consistent object format regardless of the content type. For example, instead of an array of objects for a directory, the response will be an object with an `entries` attribute containing the array of objects. + * + * If the content is a directory, the response will be an array of objects, one object for each item in the directory. When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value _should_ be "submodule". This behavior exists [for backwards compatibility purposes](https://git.io/v1YCW). In the next major version of the API, the type will be returned as "submodule". + * + * If the content is a symlink and the symlink's target is a normal file in the repository, then the API responds with the content of the file. Otherwise, the API responds with an object describing the symlink itself. + * + * If the content is a submodule, the `submodule_git_url` field identifies the location of the submodule repository, and the `sha` identifies a specific commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out the submodule at that specific commit. If the submodule repository is not hosted on github.com, the Git URLs (`git_url` and `_links["git"]`) and the github.com URLs (`html_url` and `_links["html"]`) will have null values. + * + * **Notes**: + * + * - To get a repository's contents recursively, you can [recursively get the tree](https://docs.github.com/rest/git/trees#get-a-tree). + * - This API has an upper limit of 1,000 files for a directory. If you need to retrieve + * more files, use the [Git Trees API](https://docs.github.com/rest/git/trees#get-a-tree). + * - Download URLs expire and are meant to be used just once. To ensure the download URL does not expire, please use the contents API to obtain a fresh download URL for each download. + * - If the requested file's size is: + * - 1 MB or smaller: All features of this endpoint are supported. + * - Between 1-100 MB: Only the `raw` or `object` custom media types are supported. Both will work as normal, except that when using the `object` media type, the `content` field will be an empty + * string and the `encoding` field will be `"none"`. To get the contents of these larger files, use the `raw` media type. + * - Greater than 100 MB: This endpoint is not supported. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `path: &str` -- path parameter. + * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch. + */ + pub async fn get_content_file( + &self, + owner: &str, + repo: &str, + path: &str, + ref_: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/contents/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&path.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get repository content. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. + * + * Gets the contents of a file or directory in a repository. Specify the file path or directory with the `path` parameter. If you omit the `path` parameter, you will receive the contents of the repository's root directory. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw file contents for files and symlinks. + * - **`application/vnd.github.html+json`**: Returns the file contents in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup). + * - **`application/vnd.github.object+json`**: Returns the contents in a consistent object format regardless of the content type. For example, instead of an array of objects for a directory, the response will be an object with an `entries` attribute containing the array of objects. + * + * If the content is a directory, the response will be an array of objects, one object for each item in the directory. When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value _should_ be "submodule". This behavior exists [for backwards compatibility purposes](https://git.io/v1YCW). In the next major version of the API, the type will be returned as "submodule". + * + * If the content is a symlink and the symlink's target is a normal file in the repository, then the API responds with the content of the file. Otherwise, the API responds with an object describing the symlink itself. + * + * If the content is a submodule, the `submodule_git_url` field identifies the location of the submodule repository, and the `sha` identifies a specific commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out the submodule at that specific commit. If the submodule repository is not hosted on github.com, the Git URLs (`git_url` and `_links["git"]`) and the github.com URLs (`html_url` and `_links["html"]`) will have null values. + * + * **Notes**: + * + * - To get a repository's contents recursively, you can [recursively get the tree](https://docs.github.com/rest/git/trees#get-a-tree). + * - This API has an upper limit of 1,000 files for a directory. If you need to retrieve + * more files, use the [Git Trees API](https://docs.github.com/rest/git/trees#get-a-tree). + * - Download URLs expire and are meant to be used just once. To ensure the download URL does not expire, please use the contents API to obtain a fresh download URL for each download. + * - If the requested file's size is: + * - 1 MB or smaller: All features of this endpoint are supported. + * - Between 1-100 MB: Only the `raw` or `object` custom media types are supported. Both will work as normal, except that when using the `object` media type, the `content` field will be an empty + * string and the `encoding` field will be `"none"`. To get the contents of these larger files, use the `raw` media type. + * - Greater than 100 MB: This endpoint is not supported. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `path: &str` -- path parameter. + * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch. + */ + pub async fn get_content_symlink( + &self, + owner: &str, + repo: &str, + path: &str, + ref_: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/contents/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&path.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get repository content. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. + * + * Gets the contents of a file or directory in a repository. Specify the file path or directory with the `path` parameter. If you omit the `path` parameter, you will receive the contents of the repository's root directory. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw file contents for files and symlinks. + * - **`application/vnd.github.html+json`**: Returns the file contents in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup). + * - **`application/vnd.github.object+json`**: Returns the contents in a consistent object format regardless of the content type. For example, instead of an array of objects for a directory, the response will be an object with an `entries` attribute containing the array of objects. + * + * If the content is a directory, the response will be an array of objects, one object for each item in the directory. When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value _should_ be "submodule". This behavior exists [for backwards compatibility purposes](https://git.io/v1YCW). In the next major version of the API, the type will be returned as "submodule". + * + * If the content is a symlink and the symlink's target is a normal file in the repository, then the API responds with the content of the file. Otherwise, the API responds with an object describing the symlink itself. + * + * If the content is a submodule, the `submodule_git_url` field identifies the location of the submodule repository, and the `sha` identifies a specific commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out the submodule at that specific commit. If the submodule repository is not hosted on github.com, the Git URLs (`git_url` and `_links["git"]`) and the github.com URLs (`html_url` and `_links["html"]`) will have null values. + * + * **Notes**: + * + * - To get a repository's contents recursively, you can [recursively get the tree](https://docs.github.com/rest/git/trees#get-a-tree). + * - This API has an upper limit of 1,000 files for a directory. If you need to retrieve + * more files, use the [Git Trees API](https://docs.github.com/rest/git/trees#get-a-tree). + * - Download URLs expire and are meant to be used just once. To ensure the download URL does not expire, please use the contents API to obtain a fresh download URL for each download. + * - If the requested file's size is: + * - 1 MB or smaller: All features of this endpoint are supported. + * - Between 1-100 MB: Only the `raw` or `object` custom media types are supported. Both will work as normal, except that when using the `object` media type, the `content` field will be an empty + * string and the `encoding` field will be `"none"`. To get the contents of these larger files, use the `raw` media type. + * - Greater than 100 MB: This endpoint is not supported. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `path: &str` -- path parameter. + * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch. + */ + pub async fn get_content_submodule( + &self, + owner: &str, + repo: &str, + path: &str, + ref_: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/contents/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&path.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get repository content. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. + * + * Gets the contents of a file or directory in a repository. Specify the file path or directory with the `path` parameter. If you omit the `path` parameter, you will receive the contents of the repository's root directory. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." + * + * - **`application/vnd.github.raw+json`**: Returns the raw file contents for files and symlinks. + * - **`application/vnd.github.html+json`**: Returns the file contents in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup). + * - **`application/vnd.github.object+json`**: Returns the contents in a consistent object format regardless of the content type. For example, instead of an array of objects for a directory, the response will be an object with an `entries` attribute containing the array of objects. + * + * If the content is a directory, the response will be an array of objects, one object for each item in the directory. When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value _should_ be "submodule". This behavior exists [for backwards compatibility purposes](https://git.io/v1YCW). In the next major version of the API, the type will be returned as "submodule". + * + * If the content is a symlink and the symlink's target is a normal file in the repository, then the API responds with the content of the file. Otherwise, the API responds with an object describing the symlink itself. + * + * If the content is a submodule, the `submodule_git_url` field identifies the location of the submodule repository, and the `sha` identifies a specific commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out the submodule at that specific commit. If the submodule repository is not hosted on github.com, the Git URLs (`git_url` and `_links["git"]`) and the github.com URLs (`html_url` and `_links["html"]`) will have null values. + * + * **Notes**: + * + * - To get a repository's contents recursively, you can [recursively get the tree](https://docs.github.com/rest/git/trees#get-a-tree). + * - This API has an upper limit of 1,000 files for a directory. If you need to retrieve + * more files, use the [Git Trees API](https://docs.github.com/rest/git/trees#get-a-tree). + * - Download URLs expire and are meant to be used just once. To ensure the download URL does not expire, please use the contents API to obtain a fresh download URL for each download. + * - If the requested file's size is: + * - 1 MB or smaller: All features of this endpoint are supported. + * - Between 1-100 MB: Only the `raw` or `object` custom media types are supported. Both will work as normal, except that when using the `object` media type, the `content` field will be an empty + * string and the `encoding` field will be `"none"`. To get the contents of these larger files, use the `raw` media type. + * - Greater than 100 MB: This endpoint is not supported. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `path: &str` -- path parameter. + * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch. + */ + pub async fn get_content( + &self, + owner: &str, + repo: &str, + path: &str, + ref_: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/contents/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&path.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create or update file contents. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. + * + * Creates a new file or replaces an existing file in a repository. + * + * > [!NOTE] + * > If you use this endpoint and the "[Delete a file](https://docs.github.com/rest/repos/contents/#delete-a-file)" endpoint in parallel, the concurrent requests will conflict and you will receive errors. You must use these endpoints serially instead. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. The `workflow` scope is also required in order to modify files in the `.github/workflows` directory. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `path: &str` -- path parameter. + */ + pub async fn create_or_update_file_contents( + &self, + owner: &str, + repo: &str, + path: &str, + body: &crate::types::ReposCreateUpdateFileContentsRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/contents/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&path.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete a file. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/contents/{path}` endpoint. + * + * Deletes a file in a repository. + * + * You can provide an additional `committer` parameter, which is an object containing information about the committer. Or, you can provide an `author` parameter, which is an object containing information about the author. + * + * The `author` section is optional and is filled in with the `committer` information if omitted. If the `committer` information is omitted, the authenticated user's information is used. + * + * You must provide values for both `name` and `email`, whether you choose to use `author` or `committer`. Otherwise, you'll receive a `422` status code. + * + * > [!NOTE] + * > If you use this endpoint and the "[Create or update file contents](https://docs.github.com/rest/repos/contents/#create-or-update-file-contents)" endpoint in parallel, the concurrent requests will conflict and you will receive errors. You must use these endpoints serially instead. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `path: &str` -- path parameter. + */ + pub async fn delete_file( + &self, + owner: &str, + repo: &str, + path: &str, + body: &crate::types::ReposDeleteFileRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/contents/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&path.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List repository contributors. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/contributors` endpoint. + * + * Lists contributors to the specified repository and sorts them by the number of commits per contributor in descending order. This endpoint may return information that is a few hours old because the GitHub REST API caches contributor data to improve performance. + * + * GitHub identifies contributors by author email address. This endpoint groups contribution counts by GitHub user, which includes all associated email addresses. To improve performance, only the first 500 author email addresses in the repository link to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `anon: &str` -- Set to `1` or `true` to include anonymous contributors in results. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_contributors( + &self, + owner: &str, + repo: &str, + anon: &str, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !anon.is_empty() { + query_args.push(("anon".to_string(), anon.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/contributors?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List repository contributors. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/contributors` endpoint. + * + * As opposed to `list_contributors`, this function returns all the pages of the request at once. + * + * Lists contributors to the specified repository and sorts them by the number of commits per contributor in descending order. This endpoint may return information that is a few hours old because the GitHub REST API caches contributor data to improve performance. + * + * GitHub identifies contributors by author email address. This endpoint groups contribution counts by GitHub user, which includes all associated email addresses. To improve performance, only the first 500 author email addresses in the repository link to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information. + * + * FROM: + */ + pub async fn list_all_contributors( + &self, + owner: &str, + repo: &str, + anon: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !anon.is_empty() { + query_args.push(("anon".to_string(), anon.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/contributors?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List deployments. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/deployments` endpoint. + * + * Simple filtering of deployments is available via query parameters: + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `sha: &str` -- The SHA recorded at creation time. + * * `ref_: &str` -- The name of the ref. This can be a branch, tag, or SHA. + * * `task: &str` -- The name of the task for the deployment (e.g., `deploy` or `deploy:migrations`). + * * `environment: &str` -- The name of the environment that was deployed to (e.g., `staging` or `production`). + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_deployments( + &self, + owner: &str, + repo: &str, + sha: &str, + ref_: &str, + task: &str, + environment: &str, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !environment.is_empty() { + query_args.push(("environment".to_string(), environment.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + if !sha.is_empty() { + query_args.push(("sha".to_string(), sha.to_string())); + } + if !task.is_empty() { + query_args.push(("task".to_string(), task.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/deployments?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List deployments. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/deployments` endpoint. + * + * As opposed to `list_deployments`, this function returns all the pages of the request at once. + * + * Simple filtering of deployments is available via query parameters: + * + * FROM: + */ + pub async fn list_all_deployments( + &self, + owner: &str, + repo: &str, + sha: &str, + ref_: &str, + task: &str, + environment: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !environment.is_empty() { + query_args.push(("environment".to_string(), environment.to_string())); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + if !sha.is_empty() { query_args.push(("sha".to_string(), sha.to_string())); } - if !task.is_empty() { - query_args.push(("task".to_string(), task.to_string())); + if !task.is_empty() { + query_args.push(("task".to_string(), task.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/deployments?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a deployment. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/deployments` endpoint. + * + * Deployments offer a few configurable parameters with certain defaults. + * + * The `ref` parameter can be any named branch, tag, or SHA. At GitHub we often deploy branches and verify them + * before we merge a pull request. + * + * The `environment` parameter allows deployments to be issued to different runtime environments. Teams often have + * multiple environments for verifying their applications, such as `production`, `staging`, and `qa`. This parameter + * makes it easier to track which environments have requested deployments. The default environment is `production`. + * + * The `auto_merge` parameter is used to ensure that the requested ref is not behind the repository's default branch. If + * the ref _is_ behind the default branch for the repository, we will attempt to merge it for you. If the merge succeeds, + * the API will return a successful merge commit. If merge conflicts prevent the merge from succeeding, the API will + * return a failure response. + * + * By default, [commit statuses](https://docs.github.com/rest/commits/statuses) for every submitted context must be in a `success` + * state. The `required_contexts` parameter allows you to specify a subset of contexts that must be `success`, or to + * specify contexts that have not yet been submitted. You are not required to use commit statuses to deploy. If you do + * not require any contexts or create any commit statuses, the deployment will always succeed. + * + * The `payload` parameter is available for any extra information that a deployment system might need. It is a JSON text + * field that will be passed on when a deployment event is dispatched. + * + * The `task` parameter is used by the deployment system to allow different execution paths. In the web world this might + * be `deploy:migrations` to run schema changes on the system. In the compiled world this could be a flag to compile an + * application with debugging enabled. + * + * Merged branch response: + * + * You will see this response when GitHub automatically merges the base branch into the topic branch instead of creating + * a deployment. This auto-merge happens when: + * * Auto-merge option is enabled in the repository + * * Topic branch does not include the latest changes on the base branch, which is `master` in the response example + * * There are no merge conflicts + * + * If there are no new commits in the base branch, a new request to create a deployment should give a successful + * response. + * + * Merge conflict response: + * + * This error happens when the `auto_merge` option is enabled and when the default branch (in this case `master`), can't + * be merged into the branch that's being deployed (in this case `topic-branch`), due to merge conflicts. + * + * Failed commit status checks: + * + * This error happens when the `required_contexts` parameter indicates that one or more contexts need to have a `success` + * status for the commit to be deployed, but one or more of the required contexts do not have a state of `success`. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `repo_deployment` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_deployment( + &self, + owner: &str, + repo: &str, + body: &crate::types::ReposCreateDeploymentRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/deployments", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a deployment. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/deployments/{deployment_id}` endpoint. + * + * + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `deployment_id: i64` -- deployment_id parameter. + */ + pub async fn get_deployment( + &self, + owner: &str, + repo: &str, + deployment_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/deployments/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&deployment_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a deployment. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/deployments/{deployment_id}` endpoint. + * + * If the repository only has one deployment, you can delete the deployment regardless of its status. If the repository has more than one deployment, you can only delete inactive deployments. This ensures that repositories with multiple deployments will always have an active deployment. + * + * To set a deployment as inactive, you must: + * + * * Create a new deployment that is active so that the system has a record of the current state, then delete the previously active deployment. + * * Mark the active deployment as inactive by adding any non-successful deployment status. + * + * For more information, see "[Create a deployment](https://docs.github.com/rest/deployments/deployments/#create-a-deployment)" and "[Create a deployment status](https://docs.github.com/rest/deployments/statuses#create-a-deployment-status)." + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `repo_deployment` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `deployment_id: i64` -- deployment_id parameter. + */ + pub async fn delete_deployment( + &self, + owner: &str, + repo: &str, + deployment_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/deployments/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&deployment_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List deployment statuses. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/deployments/{deployment_id}/statuses` endpoint. + * + * Users with pull access can view deployment statuses for a deployment: + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `deployment_id: i64` -- deployment_id parameter. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_deployment_statuses( + &self, + owner: &str, + repo: &str, + deployment_id: i64, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/deployments/{}/statuses?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&deployment_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List deployment statuses. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/deployments/{deployment_id}/statuses` endpoint. + * + * As opposed to `list_deployment_statuses`, this function returns all the pages of the request at once. + * + * Users with pull access can view deployment statuses for a deployment: + * + * FROM: + */ + pub async fn list_all_deployment_statuses( + &self, + owner: &str, + repo: &str, + deployment_id: i64, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/deployments/{}/statuses", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&deployment_id.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a deployment status. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/deployments/{deployment_id}/statuses` endpoint. + * + * Users with `push` access can create deployment statuses for a given deployment. + * + * OAuth app tokens and personal access tokens (classic) need the `repo_deployment` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `deployment_id: i64` -- deployment_id parameter. + */ + pub async fn create_deployment_status( + &self, + owner: &str, + repo: &str, + deployment_id: i64, + body: &crate::types::ReposCreateDeploymentStatusRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/deployments/{}/statuses", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&deployment_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a deployment status. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}` endpoint. + * + * Users with pull access can view a deployment status for a deployment: + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `deployment_id: i64` -- deployment_id parameter. + * * `status_id: i64` + */ + pub async fn get_deployment_status( + &self, + owner: &str, + repo: &str, + deployment_id: i64, + status_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/deployments/{}/statuses/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&deployment_id.to_string()), + crate::progenitor_support::encode_path(&status_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a repository dispatch event. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/dispatches` endpoint. + * + * You can use this endpoint to trigger a webhook event called `repository_dispatch` when you want activity that happens outside of GitHub to trigger a GitHub Actions workflow or GitHub App webhook. You must configure your GitHub Actions workflow or GitHub App to run when the `repository_dispatch` event occurs. For an example `repository_dispatch` webhook payload, see "[RepositoryDispatchEvent](https://docs.github.com/webhooks/event-payloads/#repository_dispatch)." + * + * The `client_payload` parameter is available for any extra information that your workflow might need. This parameter is a JSON payload that will be passed on when the webhook event is dispatched. For example, the `client_payload` can include a message that a user would like to send using a GitHub Actions workflow. Or the `client_payload` can be used as a test to debug your workflow. + * + * This input example shows how you can use the `client_payload` as a test to debug your workflow. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_dispatch_event( + &self, + owner: &str, + repo: &str, + body: &crate::types::ReposCreateDispatchEventRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/dispatches", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List environments. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/environments` endpoint. + * + * Lists the environments for a repository. + * + * Anyone with read access to the repository can use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn get_all_environments( + &self, + owner: &str, + repo: &str, + per_page: i64, + page: i64, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/environments?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get an environment. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/environments/{environment_name}` endpoint. + * + * > [!NOTE] + * > To get information about name patterns that branches must match in order to deploy to this environment, see "[Get a deployment branch policy](/rest/deployments/branch-policies#get-a-deployment-branch-policy)." + * + * Anyone with read access to the repository can use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + */ + pub async fn get_environment( + &self, + owner: &str, + repo: &str, + environment_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create or update an environment. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/environments/{environment_name}` endpoint. + * + * Create or update an environment with protection rules, such as required reviewers. For more information about environment protection rules, see "[Environments](/actions/reference/environments#environment-protection-rules)." + * + * > [!NOTE] + * > To create or update name patterns that branches must match in order to deploy to this environment, see "[Deployment branch policies](/rest/deployments/branch-policies)." + * + * > [!NOTE] + * > To create or update secrets for an environment, see "[GitHub Actions secrets](/rest/actions/secrets)." + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + */ + pub async fn create_or_update_environment( + &self, + owner: &str, + repo: &str, + environment_name: &str, + body: &crate::types::ReposCreateUpdateEnvironmentRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete an environment. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/environments/{environment_name}` endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + */ + pub async fn delete_an_environment( + &self, + owner: &str, + repo: &str, + environment_name: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List deployment branch policies. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies` endpoint. + * + * Lists the deployment branch policies for an environment. + * + * Anyone with read access to the repository can use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_deployment_branch_policies( + &self, + owner: &str, + repo: &str, + environment_name: &str, + per_page: i64, + page: i64, + ) -> ClientResult> + { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/deployment-branch-policies?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a deployment branch policy. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies` endpoint. + * + * Creates a deployment branch or tag policy for an environment. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + */ + pub async fn create_deployment_branch_policy( + &self, + owner: &str, + repo: &str, + environment_name: &str, + body: &crate::types::DeploymentBranchTagPolicyNamePattern, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/deployment-branch-policies", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a deployment branch policy. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}` endpoint. + * + * Gets a deployment branch or tag policy for an environment. + * + * Anyone with read access to the repository can use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `branch_policy_id: i64` -- The unique identifier of the branch policy. + */ + pub async fn get_deployment_branch_policy( + &self, + owner: &str, + repo: &str, + environment_name: &str, + branch_policy_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/deployment-branch-policies/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + crate::progenitor_support::encode_path(&branch_policy_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a deployment branch policy. + * + * This function performs a `PUT` to the `/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}` endpoint. + * + * Updates a deployment branch or tag policy for an environment. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `branch_policy_id: i64` -- The unique identifier of the branch policy. + */ + pub async fn update_deployment_branch_policy( + &self, + owner: &str, + repo: &str, + environment_name: &str, + branch_policy_id: i64, + body: &crate::types::DeploymentBranchPolicyNamePattern, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/deployment-branch-policies/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + crate::progenitor_support::encode_path(&branch_policy_id.to_string()), + ), + None, + ); + self.client + .put( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Delete a deployment branch policy. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}` endpoint. + * + * Deletes a deployment branch or tag policy for an environment. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `branch_policy_id: i64` -- The unique identifier of the branch policy. + */ + pub async fn delete_deployment_branch_policy( + &self, + owner: &str, + repo: &str, + environment_name: &str, + branch_policy_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/deployment-branch-policies/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + crate::progenitor_support::encode_path(&branch_policy_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get all deployment protection rules for an environment. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules` endpoint. + * + * Gets all custom deployment protection rules that are enabled for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see "[Using environments for deployment](https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment)." + * + * For more information about the app that is providing this custom deployment rule, see the [documentation for the `GET /apps/{app_slug}` endpoint](https://docs.github.com/rest/apps/apps#get-an-app). + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * FROM: + * + * **Parameters:** + * + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + */ + pub async fn get_all_deployment_protection_rules( + &self, + environment_name: &str, + repo: &str, + owner: &str, + ) -> ClientResult> + { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/deployment_protection_rules", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a custom deployment protection rule on an environment. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules` endpoint. + * + * Enable a custom deployment protection rule for an environment. + * + * The authenticated user must have admin or owner permissions to the repository to use this endpoint. + * + * For more information about the app that is providing this custom deployment rule, see the [documentation for the `GET /apps/{app_slug}` endpoint](https://docs.github.com/rest/apps/apps#get-an-app), as well as the [guide to creating custom deployment protection rules](https://docs.github.com/actions/managing-workflow-runs-and-deployments/managing-deployments/creating-custom-deployment-protection-rules). + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + */ + pub async fn create_deployment_protection_rule( + &self, + environment_name: &str, + repo: &str, + owner: &str, + body: &crate::types::ReposCreateDeploymentProtectionRuleRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/deployment_protection_rules", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List custom deployment rule integrations available for an environment. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/apps` endpoint. + * + * Gets all custom deployment protection rule integrations that are available for an environment. + * + * The authenticated user must have admin or owner permissions to the repository to use this endpoint. + * + * For more information about environments, see "[Using environments for deployment](https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment)." + * + * For more information about the app that is providing this custom deployment rule, see "[GET an app](https://docs.github.com/rest/apps/apps#get-an-app)". + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * FROM: + * + * **Parameters:** + * + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_custom_deployment_rule_integrations( + &self, + environment_name: &str, + repo: &str, + owner: &str, + page: i64, + per_page: i64, + ) -> ClientResult< + crate::Response, + > { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/deployment_protection_rules/apps?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a custom deployment protection rule. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/{protection_rule_id}` endpoint. + * + * Gets an enabled custom deployment protection rule for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see "[Using environments for deployment](https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment)." + * + * For more information about the app that is providing this custom deployment rule, see [`GET /apps/{app_slug}`](https://docs.github.com/rest/apps/apps#get-an-app). + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `protection_rule_id: i64` -- The unique identifier of the protection rule. + */ + pub async fn get_custom_deployment_protection_rule( + &self, + owner: &str, + repo: &str, + environment_name: &str, + protection_rule_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/deployment_protection_rules/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + crate::progenitor_support::encode_path(&protection_rule_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Disable a custom protection rule for an environment. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/{protection_rule_id}` endpoint. + * + * Disables a custom deployment protection rule for an environment. + * + * The authenticated user must have admin or owner permissions to the repository to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `environment_name: &str` -- The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `protection_rule_id: i64` -- The unique identifier of the protection rule. + */ + pub async fn disable_deployment_protection_rule( + &self, + environment_name: &str, + repo: &str, + owner: &str, + protection_rule_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/environments/{}/deployment_protection_rules/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&environment_name.to_string()), + crate::progenitor_support::encode_path(&protection_rule_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List forks. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/forks` endpoint. + * + * + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `sort: crate::types::ReposListForksSort` -- The sort order. `stargazers` will sort by star count. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_forks( + &self, + owner: &str, + repo: &str, + sort: crate::types::ReposListForksSort, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/forks?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List forks. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/forks` endpoint. + * + * As opposed to `list_forks`, this function returns all the pages of the request at once. + * + * + * + * FROM: + */ + pub async fn list_all_forks( + &self, + owner: &str, + repo: &str, + sort: crate::types::ReposListForksSort, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/forks?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a fork. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/forks` endpoint. + * + * Create a fork for the authenticated user. + * + * > [!NOTE] + * > Forking a Repository happens asynchronously. You may have to wait a short period of time before you can access the git objects. If this takes longer than 5 minutes, be sure to contact [GitHub Support](https://support.github.com/contact?tags=dotcom-rest-api). + * + * > [!NOTE] + * > Although this endpoint works with GitHub Apps, the GitHub App must be installed on the destination account with access to all repositories and on the source account with access to the source repository. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_fork( + &self, + owner: &str, + repo: &str, + body: &crate::types::ReposCreateForkRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/forks", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List repository webhooks. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks` endpoint. + * + * Lists webhooks for a repository. `last response` may return null if there have not been any deliveries within 30 days. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_webhooks( + &self, + owner: &str, + repo: &str, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/hooks?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List repository webhooks. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks` endpoint. + * + * As opposed to `list_webhooks`, this function returns all the pages of the request at once. + * + * Lists webhooks for a repository. `last response` may return null if there have not been any deliveries within 30 days. + * + * FROM: + */ + pub async fn list_all_webhooks( + &self, + owner: &str, + repo: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/hooks", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a repository webhook. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/hooks` endpoint. + * + * Repositories can have multiple webhooks installed. Each webhook should have a unique `config`. Multiple webhooks can + * share the same `config` as long as those webhooks do not have any `events` that overlap. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_webhook( + &self, + owner: &str, + repo: &str, + body: &crate::types::ReposCreateWebhookRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/hooks", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a repository webhook. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks/{hook_id}` endpoint. + * + * Returns a webhook configured in a repository. To get only the webhook `config` properties, see "[Get a webhook configuration for a repository](/rest/webhooks/repo-config#get-a-webhook-configuration-for-a-repository)." + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + */ + pub async fn get_webhook( + &self, + owner: &str, + repo: &str, + hook_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/hooks/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Delete a repository webhook. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/hooks/{hook_id}` endpoint. + * + * Delete a webhook for an organization. + * + * The authenticated user must be a repository owner, or have admin access in the repository, to delete the webhook. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + */ + pub async fn delete_webhook( + &self, + owner: &str, + repo: &str, + hook_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/hooks/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a repository webhook. + * + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/hooks/{hook_id}` endpoint. + * + * Updates a webhook configured in a repository. If you previously had a `secret` set, you must provide the same `secret` or set a new `secret` or the secret will be removed. If you are only updating individual webhook `config` properties, use "[Update a webhook configuration for a repository](/rest/webhooks/repo-config#update-a-webhook-configuration-for-a-repository)." + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + */ + pub async fn update_webhook( + &self, + owner: &str, + repo: &str, + hook_id: i64, + body: &crate::types::ReposUpdateWebhookRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/hooks/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a webhook configuration for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks/{hook_id}/config` endpoint. + * + * Returns the webhook configuration for a repository. To get more information about the webhook, including the `active` state and `events`, use "[Get a repository webhook](/rest/webhooks/repos#get-a-repository-webhook)." + * + * OAuth app tokens and personal access tokens (classic) need the `read:repo_hook` or `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + */ + pub async fn get_webhook_config_for_repo( + &self, + owner: &str, + repo: &str, + hook_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/hooks/{}/config", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a webhook configuration for a repository. + * + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/hooks/{hook_id}/config` endpoint. + * + * Updates the webhook configuration for a repository. To update more information about the webhook, including the `active` state and `events`, use "[Update a repository webhook](/rest/webhooks/repos#update-a-repository-webhook)." + * + * OAuth app tokens and personal access tokens (classic) need the `write:repo_hook` or `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + */ + pub async fn update_webhook_config_for_repo( + &self, + owner: &str, + repo: &str, + hook_id: i64, + body: &crate::types::AppsUpdateWebhookConfigAppRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/hooks/{}/config", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * List deliveries for a repository webhook. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks/{hook_id}/deliveries` endpoint. + * + * Returns a list of webhook deliveries for a webhook configured in a repository. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `cursor: &str` -- Used for pagination: the starting delivery from which the page of deliveries is fetched. Refer to the `link` header for the next and previous page cursors. + */ + pub async fn list_webhook_deliveries( + &self, + owner: &str, + repo: &str, + hook_id: i64, + per_page: i64, + cursor: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !cursor.is_empty() { + query_args.push(("cursor".to_string(), cursor.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/hooks/{}/deliveries?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List deliveries for a repository webhook. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks/{hook_id}/deliveries` endpoint. + * + * As opposed to `list_webhook_deliveries`, this function returns all the pages of the request at once. + * + * Returns a list of webhook deliveries for a webhook configured in a repository. + * + * FROM: + */ + pub async fn list_all_webhook_deliveries( + &self, + owner: &str, + repo: &str, + hook_id: i64, + cursor: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !cursor.is_empty() { + query_args.push(("cursor".to_string(), cursor.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/deployments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/hooks/{}/deliveries?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), query_ ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -4339,50 +6882,40 @@ impl Repos { .await } /** - * List deployments. + * Get a delivery for a repository webhook. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/deployments` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}` endpoint. * - * As opposed to `list_deployments`, this function returns all the pages of the request at once. + * Returns a delivery for a webhook configured in a repository. * - * Simple filtering of deployments is available via query parameters: + * FROM: + * + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + * * `delivery_id: i64` */ - pub async fn list_all_deployments( + pub async fn get_webhook_delivery( &self, owner: &str, repo: &str, - sha: &str, - ref_: &str, - task: &str, - environment: &str, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !environment.is_empty() { - query_args.push(("environment".to_string(), environment.to_string())); - } - if !ref_.is_empty() { - query_args.push(("ref".to_string(), ref_.to_string())); - } - if !sha.is_empty() { - query_args.push(("sha".to_string(), sha.to_string())); - } - if !task.is_empty() { - query_args.push(("task".to_string(), task.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + hook_id: i64, + delivery_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/deployments?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/hooks/{}/deliveries/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + crate::progenitor_support::encode_path(&delivery_id.to_string()), ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -4392,74 +6925,118 @@ impl Repos { .await } /** - * Create a deployment. + * Redeliver a delivery for a repository webhook. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/deployments` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}/attempts` endpoint. * - * Deployments offer a few configurable parameters with certain defaults. + * Redeliver a webhook delivery for a webhook configured in a repository. * - * The `ref` parameter can be any named branch, tag, or SHA. At GitHub we often deploy branches and verify them - * before we merge a pull request. + * FROM: * - * The `environment` parameter allows deployments to be issued to different runtime environments. Teams often have - * multiple environments for verifying their applications, such as `production`, `staging`, and `qa`. This parameter - * makes it easier to track which environments have requested deployments. The default environment is `production`. + * **Parameters:** * - * The `auto_merge` parameter is used to ensure that the requested ref is not behind the repository's default branch. If - * the ref _is_ behind the default branch for the repository, we will attempt to merge it for you. If the merge succeeds, - * the API will return a successful merge commit. If merge conflicts prevent the merge from succeeding, the API will - * return a failure response. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + * * `delivery_id: i64` + */ + pub async fn redeliver_webhook_delivery( + &self, + owner: &str, + repo: &str, + hook_id: i64, + delivery_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/hooks/{}/deliveries/{}/attempts", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + crate::progenitor_support::encode_path(&delivery_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Ping a repository webhook. * - * By default, [commit statuses](https://docs.github.com/rest/reference/repos#statuses) for every submitted context must be in a `success` - * state. The `required_contexts` parameter allows you to specify a subset of contexts that must be `success`, or to - * specify contexts that have not yet been submitted. You are not required to use commit statuses to deploy. If you do - * not require any contexts or create any commit statuses, the deployment will always succeed. + * This function performs a `POST` to the `/repos/{owner}/{repo}/hooks/{hook_id}/pings` endpoint. * - * The `payload` parameter is available for any extra information that a deployment system might need. It is a JSON text - * field that will be passed on when a deployment event is dispatched. + * This will trigger a [ping event](https://docs.github.com/webhooks/#ping-event) to be sent to the hook. * - * The `task` parameter is used by the deployment system to allow different execution paths. In the web world this might - * be `deploy:migrations` to run schema changes on the system. In the compiled world this could be a flag to compile an - * application with debugging enabled. + * FROM: * - * Users with `repo` or `repo_deployment` scopes can create a deployment for a given ref. + * **Parameters:** * - * #### Merged branch response - * You will see this response when GitHub automatically merges the base branch into the topic branch instead of creating - * a deployment. This auto-merge happens when: - * * Auto-merge option is enabled in the repository - * * Topic branch does not include the latest changes on the base branch, which is `master` in the response example - * * There are no merge conflicts + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. + */ + pub async fn ping_webhook( + &self, + owner: &str, + repo: &str, + hook_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/hooks/{}/pings", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Test the push repository webhook. * - * If there are no new commits in the base branch, a new request to create a deployment should give a successful - * response. + * This function performs a `POST` to the `/repos/{owner}/{repo}/hooks/{hook_id}/tests` endpoint. * - * #### Merge conflict response - * This error happens when the `auto_merge` option is enabled and when the default branch (in this case `master`), can't - * be merged into the branch that's being deployed (in this case `topic-branch`), due to merge conflicts. + * This will trigger the hook with the latest push to the current repository if the hook is subscribed to `push` events. If the hook is not subscribed to `push` events, the server will respond with 204 but no test POST will be generated. * - * #### Failed commit status checks - * This error happens when the `required_contexts` parameter indicates that one or more contexts need to have a `success` - * status for the commit to be deployed, but one or more of the required contexts do not have a state of `success`. + * > [!NOTE] + * > Previously `/repos/:owner/:repo/hooks/:hook_id/test` * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `hook_id: i64` -- The unique identifier of the hook. You can find this value in the `X-GitHub-Hook-ID` header of a webhook delivery. */ - pub async fn create_deployment( + pub async fn test_push_webhook( &self, owner: &str, repo: &str, - body: &crate::types::ReposCreateDeploymentRequest, - ) -> ClientResult> { + hook_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/deployments", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/hooks/{}/tests", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&hook_id.to_string()), ), None, ); @@ -4467,39 +7044,37 @@ impl Repos { .post( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get a deployment. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/deployments/{deployment_id}` endpoint. + * Check if immutable releases are enabled for a repository. * + * This function performs a `GET` to the `/repos/{owner}/{repo}/immutable-releases` endpoint. * + * Shows whether immutable releases are enabled or disabled. Also identifies whether immutability is being + * enforced by the repository owner. The authenticated user must have admin read access to the repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `deployment_id: i64` -- deployment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn get_deployment( + pub async fn check_immutable_releases( &self, owner: &str, repo: &str, - deployment_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/deployments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&deployment_id.to_string()), + "/repos/{}/{}/immutable-releases", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -4514,44 +7089,34 @@ impl Repos { .await } /** - * Delete a deployment. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/deployments/{deployment_id}` endpoint. - * - * To ensure there can always be an active deployment, you can only delete an _inactive_ deployment. Anyone with `repo` or `repo_deployment` scopes can delete an inactive deployment. + * Enable immutable releases. * - * To set a deployment as inactive, you must: - * - * * Create a new deployment that is active so that the system has a record of the current state, then delete the previously active deployment. - * * Mark the active deployment as inactive by adding any non-successful deployment status. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/immutable-releases` endpoint. * - * For more information, see "[Create a deployment](https://docs.github.com/rest/reference/repos/#create-a-deployment)" and "[Create a deployment status](https://docs.github.com/rest/reference/repos#create-a-deployment-status)." + * Enables immutable releases for a repository. The authenticated user must have admin access to the repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `deployment_id: i64` -- deployment_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn delete_deployment( + pub async fn enable_immutable_releases( &self, owner: &str, repo: &str, - deployment_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/deployments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&deployment_id.to_string()), + "/repos/{}/{}/immutable-releases", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .delete( + .put( &url, crate::Message { body: None, @@ -4561,50 +7126,34 @@ impl Repos { .await } /** - * List deployment statuses. + * Disable immutable releases. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/deployments/{deployment_id}/statuses` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/immutable-releases` endpoint. * - * Users with pull access can view deployment statuses for a deployment: + * Disables immutable releases for a repository. The authenticated user must have admin access to the repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `deployment_id: i64` -- deployment_id parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn list_deployment_statuses( + pub async fn disable_immutable_releases( &self, owner: &str, repo: &str, - deployment_id: i64, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/deployments/{}/statuses?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&deployment_id.to_string()), - query_ + "/repos/{}/{}/immutable-releases", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -4614,33 +7163,47 @@ impl Repos { .await } /** - * List deployment statuses. + * List repository invitations. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/deployments/{deployment_id}/statuses` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/invitations` endpoint. * - * As opposed to `list_deployment_statuses`, this function returns all the pages of the request at once. + * When authenticating as a user with admin rights to a repository, this endpoint will list all currently open repository invitations. * - * Users with pull access can view deployment statuses for a deployment: + * FROM: + * + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_all_deployment_statuses( + pub async fn list_invitations( &self, owner: &str, repo: &str, - deployment_id: i64, - ) -> ClientResult>> { + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/deployments/{}/statuses", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&deployment_id.to_string()), + "/repos/{}/{}/invitations?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -4650,83 +7213,71 @@ impl Repos { .await } /** - * Create a deployment status. - * - * This function performs a `POST` to the `/repos/{owner}/{repo}/deployments/{deployment_id}/statuses` endpoint. - * - * Users with `push` access can create deployment statuses for a given deployment. + * List repository invitations. * - * GitHub Apps require `read & write` access to "Deployments" and `read-only` access to "Repo contents" (for private repos). OAuth Apps require the `repo_deployment` scope. + * This function performs a `GET` to the `/repos/{owner}/{repo}/invitations` endpoint. * - * FROM: + * As opposed to `list_invitations`, this function returns all the pages of the request at once. * - * **Parameters:** + * When authenticating as a user with admin rights to a repository, this endpoint will list all currently open repository invitations. * - * * `owner: &str` - * * `repo: &str` - * * `deployment_id: i64` -- deployment_id parameter. + * FROM: */ - pub async fn create_deployment_status( + pub async fn list_all_invitations( &self, owner: &str, repo: &str, - deployment_id: i64, - body: &crate::types::ReposCreateDeploymentStatusRequest, - ) -> ClientResult> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/deployments/{}/statuses", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&deployment_id.to_string()), + "/repos/{}/{}/invitations", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .post( + .get_all_pages( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get a deployment status. + * Delete a repository invitation. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/invitations/{invitation_id}` endpoint. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}` endpoint. * - * Users with pull access can view a deployment status for a deployment: * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `deployment_id: i64` -- deployment_id parameter. - * * `status_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `invitation_id: i64` -- The unique identifier of the invitation. */ - pub async fn get_deployment_status( + pub async fn delete_invitation( &self, owner: &str, repo: &str, - deployment_id: i64, - status_id: i64, - ) -> ClientResult> { + invitation_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/deployments/{}/statuses/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&deployment_id.to_string()), - crate::progenitor_support::encode_path(&status_id.to_string()), + "/repos/{}/{}/invitations/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&invitation_id.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -4736,44 +7287,38 @@ impl Repos { .await } /** - * Create a repository dispatch event. - * - * This function performs a `POST` to the `/repos/{owner}/{repo}/dispatches` endpoint. - * - * You can use this endpoint to trigger a webhook event called `repository_dispatch` when you want activity that happens outside of GitHub to trigger a GitHub Actions workflow or GitHub App webhook. You must configure your GitHub Actions workflow or GitHub App to run when the `repository_dispatch` event occurs. For an example `repository_dispatch` webhook payload, see "[RepositoryDispatchEvent](https://docs.github.com/webhooks/event-payloads/#repository_dispatch)." - * - * The `client_payload` parameter is available for any extra information that your workflow might need. This parameter is a JSON payload that will be passed on when the webhook event is dispatched. For example, the `client_payload` can include a message that a user would like to send using a GitHub Actions workflow. Or the `client_payload` can be used as a test to debug your workflow. + * Update a repository invitation. * - * This endpoint requires write access to the repository by providing either: + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/invitations/{invitation_id}` endpoint. * - * - Personal access tokens with `repo` scope. For more information, see "[Creating a personal access token for the command line](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line)" in the GitHub Help documentation. - * - GitHub Apps with both `metadata:read` and `contents:read&write` permissions. * - * This input example shows how you can use the `client_payload` as a test to debug your workflow. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `invitation_id: i64` -- The unique identifier of the invitation. */ - pub async fn create_dispatch_event( + pub async fn update_invitation( &self, owner: &str, repo: &str, - body: &crate::types::ReposCreateDispatchEventRequest, - ) -> ClientResult> { + invitation_id: i64, + body: &crate::types::ReposUpdateInvitationRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/dispatches", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/invitations/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&invitation_id.to_string()), ), None, ); self.client - .post( + .patch( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -4783,31 +7328,42 @@ impl Repos { .await } /** - * Get all environments. + * List deploy keys. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/environments` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/keys` endpoint. * - * Get all environments for a repository. * - * Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn get_all_environments( + pub async fn list_deploy_keys( &self, owner: &str, repo: &str, - ) -> ClientResult> { + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/environments", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/keys?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); @@ -4822,37 +7378,31 @@ impl Repos { .await } /** - * Get an environment. + * List deploy keys. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/environments/{environment_name}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/keys` endpoint. * - * Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an access token with the `repo` scope. GitHub Apps must have the `actions:read` permission to use this endpoint. + * As opposed to `list_deploy_keys`, this function returns all the pages of the request at once. * - * FROM: * - * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `environment_name: &str` -- The name of the environment. + * FROM: */ - pub async fn get_environment( + pub async fn list_all_deploy_keys( &self, owner: &str, repo: &str, - environment_name: &str, - ) -> ClientResult> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/environments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(environment_name), + "/repos/{}/{}/keys", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -4862,44 +7412,35 @@ impl Repos { .await } /** - * Create or update an environment. - * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/environments/{environment_name}` endpoint. - * - * Create or update an environment with protection rules, such as required reviewers. For more information about environment protection rules, see "[Environments](/actions/reference/environments#environment-protection-rules)." - * - * **Note:** Although you can use this operation to specify that only branches that match specified name patterns can deploy to this environment, you must use the UI to set the name patterns. For more information, see "[Environments](/actions/reference/environments#deployment-branches)." + * Create a deploy key. * - * **Note:** To create or update secrets for an environment, see "[Secrets](/rest/reference/actions#secrets)." + * This function performs a `POST` to the `/repos/{owner}/{repo}/keys` endpoint. * - * You must authenticate using an access token with the repo scope to use this endpoint. + * You can create a read-only deploy key. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `environment_name: &str` -- The name of the environment. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn create_or_update_environment( + pub async fn create_deploy_key( &self, owner: &str, repo: &str, - environment_name: &str, - body: &crate::types::ReposCreateUpdateEnvironmentRequest, - ) -> ClientResult> { + body: &crate::types::ReposCreateDeployKeyRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/environments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(environment_name), + "/repos/{}/{}/keys", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .put( + .post( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -4909,37 +7450,37 @@ impl Repos { .await } /** - * Delete an environment. + * Get a deploy key. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/environments/{environment_name}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/keys/{key_id}` endpoint. * - * You must authenticate using an access token with the repo scope to use this endpoint. * - * FROM: + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `environment_name: &str` -- The name of the environment. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `key_id: i64` -- The unique identifier of the key. */ - pub async fn delete_an_environment( + pub async fn get_deploy_key( &self, owner: &str, repo: &str, - environment_name: &str, - ) -> ClientResult> { + key_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/environments/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(environment_name), + "/repos/{}/{}/keys/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&key_id.to_string()), ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -4949,52 +7490,37 @@ impl Repos { .await } /** - * List forks. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/forks` endpoint. + * Delete a deploy key. * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/keys/{key_id}` endpoint. * + * Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `sort: crate::types::ReposListForksSort` -- The sort order. Can be either `newest`, `oldest`, or `stargazers`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `key_id: i64` -- The unique identifier of the key. */ - pub async fn list_forks( + pub async fn delete_deploy_key( &self, owner: &str, repo: &str, - sort: crate::types::ReposListForksSort, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - if !sort.to_string().is_empty() { - query_args.push(("sort".to_string(), sort.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + key_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/forks?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/keys/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&key_id.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -5004,38 +7530,34 @@ impl Repos { .await } /** - * List forks. + * List repository languages. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/forks` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/languages` endpoint. * - * As opposed to `list_forks`, this function returns all the pages of the request at once. + * Lists languages for the specified repository. The value shown for each language is the number of bytes of code written in that language. * + * FROM: * + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn list_all_forks( + pub async fn list_languages( &self, owner: &str, repo: &str, - sort: crate::types::ReposListForksSort, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !sort.to_string().is_empty() { - query_args.push(("sort".to_string(), sort.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/forks?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/languages", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -5045,32 +7567,30 @@ impl Repos { .await } /** - * Create a fork. - * - * This function performs a `POST` to the `/repos/{owner}/{repo}/forks` endpoint. + * Sync a fork branch with the upstream repository. * - * Create a fork for the authenticated user. + * This function performs a `POST` to the `/repos/{owner}/{repo}/merge-upstream` endpoint. * - * **Note**: Forking a Repository happens asynchronously. You may have to wait a short period of time before you can access the git objects. If this takes longer than 5 minutes, be sure to contact [GitHub Support](https://support.github.com/contact?tags=rest-api). + * Sync a branch of a forked repository to keep it up-to-date with the upstream repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn create_fork( + pub async fn merge_upstream( &self, owner: &str, repo: &str, - body: &crate::types::ReposCreateForkRequest, - ) -> ClientResult> { + body: &crate::types::ReposMergeUpstreamRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/forks", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/merge-upstream", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -5085,81 +7605,74 @@ impl Repos { .await } /** - * List repository webhooks. + * Merge a branch. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/merges` endpoint. * * * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn list_webhooks( + pub async fn merge( &self, owner: &str, repo: &str, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + body: &crate::types::ReposMergeRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/merges", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List repository webhooks. + * Get a GitHub Pages site. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/pages` endpoint. * - * As opposed to `list_webhooks`, this function returns all the pages of the request at once. + * Gets information about a GitHub Pages site. * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * + * FROM: + * + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn list_all_webhooks( + pub async fn get_pages( &self, owner: &str, repo: &str, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/pages", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -5169,36 +7682,39 @@ impl Repos { .await } /** - * Create a repository webhook. + * Update information about a GitHub Pages site. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/hooks` endpoint. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/pages` endpoint. * - * Repositories can have multiple webhooks installed. Each webhook should have a unique `config`. Multiple webhooks can - * share the same `config` as long as those webhooks do not have any `events` that overlap. + * Updates information for a GitHub Pages site. For more information, see "[About GitHub Pages](/github/working-with-github-pages/about-github-pages). + * + * The authenticated user must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn create_webhook( + pub async fn update_information_about_pages_site( &self, owner: &str, repo: &str, - body: &crate::types::ReposCreateWebhookRequest, - ) -> ClientResult> { + body: &crate::types::ReposUpdateInformationAboutPagesSiteRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/pages", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .post( + .put( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -5208,72 +7724,75 @@ impl Repos { .await } /** - * Get a repository webhook. + * Create a GitHub Pages site. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks/{hook_id}` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/pages` endpoint. + * + * Configures a GitHub Pages site. For more information, see "[About GitHub Pages](/github/working-with-github-pages/about-github-pages)." + * + * The authenticated user must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission. * - * Returns a webhook configured in a repository. To get only the webhook `config` properties, see "[Get a webhook configuration for a repository](/rest/reference/repos#get-a-webhook-configuration-for-a-repository)." + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `hook_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn get_webhook( + pub async fn create_pages_site( &self, owner: &str, repo: &str, - hook_id: i64, - ) -> ClientResult> { + body: &crate::types::ReposCreatePagesSiteRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/repos/{}/{}/pages", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Delete a repository webhook. + * Delete a GitHub Pages site. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/hooks/{hook_id}` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/pages` endpoint. + * + * Deletes a GitHub Pages site. For more information, see "[About GitHub Pages](/github/working-with-github-pages/about-github-pages). * + * The authenticated user must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission. * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `hook_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn delete_webhook( + pub async fn delete_pages_site( &self, owner: &str, repo: &str, - hook_id: i64, ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/repos/{}/{}/pages", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -5288,80 +7807,85 @@ impl Repos { .await } /** - * Update a repository webhook. + * List GitHub Pages builds. * - * This function performs a `PATCH` to the `/repos/{owner}/{repo}/hooks/{hook_id}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/pages/builds` endpoint. * - * Updates a webhook configured in a repository. If you previously had a `secret` set, you must provide the same `secret` or set a new `secret` or the secret will be removed. If you are only updating individual webhook `config` properties, use "[Update a webhook configuration for a repository](/rest/reference/repos#update-a-webhook-configuration-for-a-repository)." + * Lists builts of a GitHub Pages site. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `hook_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn update_webhook( + pub async fn list_pages_builds( &self, owner: &str, repo: &str, - hook_id: i64, - body: &crate::types::ReposUpdateWebhookRequest, - ) -> ClientResult> { + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/hooks/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/repos/{}/{}/pages/builds?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .patch( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get a webhook configuration for a repository. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks/{hook_id}/config` endpoint. + * List GitHub Pages builds. * - * Returns the webhook configuration for a repository. To get more information about the webhook, including the `active` state and `events`, use "[Get a repository webhook](/rest/reference/orgs#get-a-repository-webhook)." + * This function performs a `GET` to the `/repos/{owner}/{repo}/pages/builds` endpoint. * - * Access tokens must have the `read:repo_hook` or `repo` scope, and GitHub Apps must have the `repository_hooks:read` permission. + * As opposed to `list_pages_builds`, this function returns all the pages of the request at once. * - * FROM: + * Lists builts of a GitHub Pages site. * - * **Parameters:** + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * * `owner: &str` - * * `repo: &str` - * * `hook_id: i64` + * FROM: */ - pub async fn get_webhook_config_for_repo( + pub async fn list_all_pages_builds( &self, owner: &str, repo: &str, - hook_id: i64, - ) -> ClientResult> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks/{}/config", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/repos/{}/{}/pages/builds", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -5371,88 +7895,70 @@ impl Repos { .await } /** - * Update a webhook configuration for a repository. + * Request a GitHub Pages build. * - * This function performs a `PATCH` to the `/repos/{owner}/{repo}/hooks/{hook_id}/config` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/pages/builds` endpoint. * - * Updates the webhook configuration for a repository. To update more information about the webhook, including the `active` state and `events`, use "[Update a repository webhook](/rest/reference/orgs#update-a-repository-webhook)." + * You can request that your site be built from the latest revision on the default branch. This has the same effect as pushing a commit to your default branch, but does not require an additional commit. Manually triggering page builds can be helpful when diagnosing build warnings and failures. * - * Access tokens must have the `write:repo_hook` or `repo` scope, and GitHub Apps must have the `repository_hooks:write` permission. + * Build requests are limited to one concurrent build per repository and one concurrent build per requester. If you request a build while another is still in progress, the second request will be queued until the first completes. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `hook_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn update_webhook_config_for_repo( + pub async fn request_pages_build( &self, owner: &str, repo: &str, - hook_id: i64, - body: &crate::types::AppsUpdateWebhookConfigAppRequest, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks/{}/config", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/repos/{}/{}/pages/builds", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .patch( + .post( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * List deliveries for a repository webhook. + * Get latest Pages build. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks/{hook_id}/deliveries` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/pages/builds/latest` endpoint. * - * Returns a list of webhook deliveries for a webhook configured in a repository. + * Gets information about the single most recent build of a GitHub Pages site. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `hook_id: i64` - * * `per_page: i64` -- Results per page (max 100). - * * `cursor: &str` -- Used for pagination: the starting delivery from which the page of deliveries is fetched. Refer to the `link` header for the next and previous page cursors. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn list_webhook_deliveries( + pub async fn get_latest_pages_build( &self, owner: &str, repo: &str, - hook_id: i64, - per_page: i64, - cursor: &str, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !cursor.is_empty() { - query_args.push(("cursor".to_string(), cursor.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks/{}/deliveries?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&hook_id.to_string()), - query_ + "/repos/{}/{}/pages/builds/latest", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -5467,40 +7973,39 @@ impl Repos { .await } /** - * List deliveries for a repository webhook. + * Get GitHub Pages build. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks/{hook_id}/deliveries` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/pages/builds/{build_id}` endpoint. * - * As opposed to `list_webhook_deliveries`, this function returns all the pages of the request at once. + * Gets information about a GitHub Pages build. * - * Returns a list of webhook deliveries for a webhook configured in a repository. + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `build_id: i64` */ - pub async fn list_all_webhook_deliveries( + pub async fn get_pages_build( &self, owner: &str, repo: &str, - hook_id: i64, - cursor: &str, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !cursor.is_empty() { - query_args.push(("cursor".to_string(), cursor.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + build_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks/{}/deliveries?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&hook_id.to_string()), - query_ + "/repos/{}/{}/pages/builds/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&build_id.to_string()), ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -5510,83 +8015,79 @@ impl Repos { .await } /** - * Get a delivery for a repository webhook. + * Create a GitHub Pages deployment. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/pages/deployments` endpoint. * - * Returns a delivery for a webhook configured in a repository. + * Create a GitHub Pages deployment for a repository. + * + * The authenticated user must have write permission to the repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `hook_id: i64` - * * `delivery_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn get_webhook_delivery( + pub async fn create_pages_deployment( &self, owner: &str, repo: &str, - hook_id: i64, - delivery_id: i64, - ) -> ClientResult> { + body: &crate::types::ReposCreatePagesDeploymentRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks/{}/deliveries/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&hook_id.to_string()), - crate::progenitor_support::encode_path(&delivery_id.to_string()), + "/repos/{}/{}/pages/deployments", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Redeliver a delivery for a repository webhook. + * Get the status of a GitHub Pages deployment. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}/attempts` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/pages/deployments/{pages_deployment_id}` endpoint. * - * Redeliver a webhook delivery for a webhook configured in a repository. + * Gets the current status of a GitHub Pages deployment. + * + * The authenticated user must have read permission for the GitHub Pages site. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `hook_id: i64` - * * `delivery_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pages_deployment_id: &str` -- The ID of the Pages deployment. You can also give the commit SHA of the deployment. */ - pub async fn redeliver_webhook_delivery( + pub async fn get_pages_deployment( &self, owner: &str, repo: &str, - hook_id: i64, - delivery_id: i64, - ) -> ClientResult> { + pages_deployment_id: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks/{}/deliveries/{}/attempts", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&hook_id.to_string()), - crate::progenitor_support::encode_path(&delivery_id.to_string()), + "/repos/{}/{}/pages/deployments/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&pages_deployment_id.to_string()), ), None, ); self.client - .post( + .get( &url, crate::Message { body: None, @@ -5596,32 +8097,34 @@ impl Repos { .await } /** - * Ping a repository webhook. + * Cancel a GitHub Pages deployment. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/hooks/{hook_id}/pings` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/pages/deployments/{pages_deployment_id}/cancel` endpoint. * - * This will trigger a [ping event](https://docs.github.com/webhooks/#ping-event) to be sent to the hook. + * Cancels a GitHub Pages deployment. + * + * The authenticated user must have write permissions for the GitHub Pages site. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `hook_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `pages_deployment_id: &str` -- The ID of the Pages deployment. You can also give the commit SHA of the deployment. */ - pub async fn ping_webhook( + pub async fn cancel_pages_deployment( &self, owner: &str, repo: &str, - hook_id: i64, - ) -> ClientResult> { + pages_deployment_id: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks/{}/pings", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/repos/{}/{}/pages/deployments/{}/cancel", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&pages_deployment_id.to_string()), ), None, ); @@ -5636,39 +8139,40 @@ impl Repos { .await } /** - * Test the push repository webhook. + * Get a DNS health check for GitHub Pages. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/hooks/{hook_id}/tests` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/pages/health` endpoint. * - * This will trigger the hook with the latest push to the current repository if the hook is subscribed to `push` events. If the hook is not subscribed to `push` events, the server will respond with 204 but no test POST will be generated. + * Gets a health check of the DNS settings for the `CNAME` record configured for a repository's GitHub Pages. + * + * The first request to this endpoint returns a `202 Accepted` status and starts an asynchronous background task to get the results for the domain. After the background task completes, subsequent requests to this endpoint return a `200 OK` status with the health check results in the response. + * + * The authenticated user must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission to use this endpoint. * - * **Note**: Previously `/repos/:owner/:repo/hooks/:hook_id/test` + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `hook_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn test_push_webhook( + pub async fn get_pages_health_check( &self, owner: &str, repo: &str, - hook_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/hooks/{}/tests", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&hook_id.to_string()), + "/repos/{}/{}/pages/health", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .post( + .get( &url, crate::Message { body: None, @@ -5678,42 +8182,29 @@ impl Repos { .await } /** - * List repository invitations. + * Check if private vulnerability reporting is enabled for a repository. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/invitations` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/private-vulnerability-reporting` endpoint. * - * When authenticating as a user with admin rights to a repository, this endpoint will list all currently open repository invitations. + * Returns a boolean indicating whether or not private vulnerability reporting is enabled for the repository. For more information, see "[Evaluating the security settings of a repository](https://docs.github.com/code-security/security-advisories/working-with-repository-security-advisories/evaluating-the-security-settings-of-a-repository)". * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn list_invitations( + pub async fn check_private_vulnerability_reporting( &self, owner: &str, repo: &str, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/invitations?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/private-vulnerability-reporting", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -5728,31 +8219,34 @@ impl Repos { .await } /** - * List repository invitations. + * Enable private vulnerability reporting for a repository. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/invitations` endpoint. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/private-vulnerability-reporting` endpoint. * - * As opposed to `list_invitations`, this function returns all the pages of the request at once. + * Enables private vulnerability reporting for a repository. The authenticated user must have admin access to the repository. For more information, see "[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)." * - * When authenticating as a user with admin rights to a repository, this endpoint will list all currently open repository invitations. + * FROM: + * + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn list_all_invitations( + pub async fn enable_private_vulnerability_reporting( &self, owner: &str, repo: &str, - ) -> ClientResult>> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/invitations", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/private-vulnerability-reporting", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get_all_pages( + .put( &url, crate::Message { body: None, @@ -5762,32 +8256,29 @@ impl Repos { .await } /** - * Delete a repository invitation. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/invitations/{invitation_id}` endpoint. + * Disable private vulnerability reporting for a repository. * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/private-vulnerability-reporting` endpoint. * + * Disables private vulnerability reporting for a repository. The authenticated user must have admin access to the repository. For more information, see "[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)". * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `invitation_id: i64` -- invitation_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn delete_invitation( + pub async fn disable_private_vulnerability_reporting( &self, owner: &str, repo: &str, - invitation_id: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/invitations/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&invitation_id.to_string()), + "/repos/{}/{}/private-vulnerability-reporting", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -5802,88 +8293,70 @@ impl Repos { .await } /** - * Update a repository invitation. - * - * This function performs a `PATCH` to the `/repos/{owner}/{repo}/invitations/{invitation_id}` endpoint. + * Get all custom property values for a repository. * + * This function performs a `GET` to the `/repos/{owner}/{repo}/properties/values` endpoint. * + * Gets all custom property values that are set for a repository. + * Users with read access to the repository can use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `invitation_id: i64` -- invitation_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn update_invitation( + pub async fn custom_properties_for_repos_get_repository_values( &self, owner: &str, repo: &str, - invitation_id: i64, - body: &crate::types::ReposUpdateInvitationRequest, - ) -> ClientResult> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/invitations/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&invitation_id.to_string()), + "/repos/{}/{}/properties/values", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .patch( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } - /** - * List deploy keys. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/keys` endpoint. - * + /** + * Get all custom property values for a repository. * + * This function performs a `GET` to the `/repos/{owner}/{repo}/properties/values` endpoint. * - * FROM: + * As opposed to `custom_properties_for_repos_get_repository_values`, this function returns all the pages of the request at once. * - * **Parameters:** + * Gets all custom property values that are set for a repository. + * Users with read access to the repository can use this endpoint. * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * FROM: */ - pub async fn list_deploy_keys( + pub async fn custom_properties_for_repos_get_all_repository_values( &self, owner: &str, repo: &str, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/keys?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/properties/values", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -5893,104 +8366,136 @@ impl Repos { .await } /** - * List deploy keys. + * Create or update custom property values for a repository. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/keys` endpoint. + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/properties/values` endpoint. * - * As opposed to `list_deploy_keys`, this function returns all the pages of the request at once. + * Create new or update existing custom property values for a repository. + * Using a value of `null` for a custom property will remove or 'unset' the property value from the repository. + * + * Repository admins and other users with the repository-level "edit custom property values" fine-grained permission can use this endpoint. * + * FROM: * + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn list_all_deploy_keys( + pub async fn custom_properties_for_repos_create_or_update_repository_values( &self, owner: &str, repo: &str, - ) -> ClientResult>> { + body: &crate::types::ReposCustomPropertiesCreateUpdateRepositoryValuesRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/keys", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/properties/values", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get_all_pages( + .patch( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Create a deploy key. + * Get a repository README. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/keys` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/readme` endpoint. * - * You can create a read-only deploy key. + * Gets the preferred README for a repository. + * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * - * FROM: + * - **`application/vnd.github.raw+json`**: Returns the raw file contents. This is the default if you do not specify a media type. + * - **`application/vnd.github.html+json`**: Returns the README in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup). + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch. */ - pub async fn create_deploy_key( + pub async fn get_readme( &self, owner: &str, repo: &str, - body: &crate::types::ReposCreateDeployKeyRequest, - ) -> ClientResult> { + ref_: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/keys", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/readme?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .post( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get a deploy key. + * Get a repository README for a directory. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/keys/{key_id}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/readme/{dir}` endpoint. + * + * Gets the README from a repository directory. * + * This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." * + * - **`application/vnd.github.raw+json`**: Returns the raw file contents. This is the default if you do not specify a media type. + * - **`application/vnd.github.html+json`**: Returns the README in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `key_id: i64` -- key_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `dir: &str` -- The alternate path to look for a README file. + * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch. */ - pub async fn get_deploy_key( + pub async fn get_readme_in_directory( &self, owner: &str, repo: &str, - key_id: i64, - ) -> ClientResult> { + dir: &str, + ref_: &str, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/keys/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&key_id.to_string()), + "/repos/{}/{}/readme/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&dir.to_string()), + query_ ), None, ); @@ -6005,37 +8510,49 @@ impl Repos { .await } /** - * Delete a deploy key. + * List releases. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/keys/{key_id}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/releases` endpoint. * - * Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead. + * This returns a list of releases, which does not include regular Git tags that have not been associated with a release. To get a list of Git tags, use the [Repository Tags API](https://docs.github.com/rest/repos/repos#list-repository-tags). + * + * Information about published releases are available to everyone. Only users with push access will receive listings for draft releases. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `key_id: i64` -- key_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn delete_deploy_key( + pub async fn list_releases( &self, owner: &str, repo: &str, - key_id: i64, - ) -> ClientResult> { + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/keys/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&key_id.to_string()), + "/repos/{}/{}/releases?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -6045,34 +8562,33 @@ impl Repos { .await } /** - * List repository languages. + * List releases. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/languages` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/releases` endpoint. * - * Lists languages for the specified repository. The value shown for each language is the number of bytes of code written in that language. + * As opposed to `list_releases`, this function returns all the pages of the request at once. * - * FROM: + * This returns a list of releases, which does not include regular Git tags that have not been associated with a release. To get a list of Git tags, use the [Repository Tags API](https://docs.github.com/rest/repos/repos#list-repository-tags). * - * **Parameters:** + * Information about published releases are available to everyone. Only users with push access will receive listings for draft releases. * - * * `owner: &str` - * * `repo: &str` + * FROM: */ - pub async fn list_languages( + pub async fn list_all_releases( &self, owner: &str, repo: &str, - ) -> ClientResult> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/languages", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/releases", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -6082,30 +8598,32 @@ impl Repos { .await } /** - * Merge a branch. + * Create a release. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/merges` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/releases` endpoint. * + * Users with push access to the repository can create a release. * + * This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn merge( + pub async fn create_release( &self, owner: &str, repo: &str, - body: &crate::types::ReposMergeRequest, - ) -> ClientResult> { + body: &crate::types::ReposCreateReleaseRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/merges", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/releases", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -6120,29 +8638,38 @@ impl Repos { .await } /** - * Get a GitHub Pages site. + * Get a release asset. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/pages` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/assets/{asset_id}` endpoint. * + * To download the asset's binary content: * + * - If within a browser, fetch the location specified in the `browser_download_url` key provided in the response. + * - Alternatively, set the `Accept` header of the request to + * [`application/octet-stream`](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types). + * The API will either redirect the client to the location, or stream it directly if possible. + * API clients should handle both a `200` or `302` response. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `asset_id: i64` -- The unique identifier of the asset. */ - pub async fn get_pages( + pub async fn get_release_asset( &self, owner: &str, repo: &str, - ) -> ClientResult> { + asset_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/pages", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/releases/assets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&asset_id.to_string()), ), None, ); @@ -6157,73 +8684,78 @@ impl Repos { .await } /** - * Update information about a GitHub Pages site. + * Delete a release asset. * - * This function performs a `PUT` to the `/repos/{owner}/{repo}/pages` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/releases/assets/{asset_id}` endpoint. * - * Updates information for a GitHub Pages site. For more information, see "[About GitHub Pages](/github/working-with-github-pages/about-github-pages). * - * FROM: + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `asset_id: i64` -- The unique identifier of the asset. */ - pub async fn update_information_about_pages_site( + pub async fn delete_release_asset( &self, owner: &str, repo: &str, - body: &crate::types::ReposUpdateInformationAboutPagesSiteRequest, + asset_id: i64, ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/pages", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/releases/assets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&asset_id.to_string()), ), None, ); self.client - .put( + .delete( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Create a GitHub Pages site. + * Update a release asset. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/pages` endpoint. + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/releases/assets/{asset_id}` endpoint. * - * Configures a GitHub Pages site. For more information, see "[About GitHub Pages](/github/working-with-github-pages/about-github-pages)." + * Users with push access to the repository can edit a release asset. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `asset_id: i64` -- The unique identifier of the asset. */ - pub async fn create_pages_site( + pub async fn update_release_asset( &self, owner: &str, repo: &str, - body: &crate::types::ReposCreatePagesSiteRequest, - ) -> ClientResult> { + asset_id: i64, + body: &crate::types::ReposUpdateReleaseAssetRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/pages", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/releases/assets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&asset_id.to_string()), ), None, ); self.client - .post( + .patch( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -6233,79 +8765,69 @@ impl Repos { .await } /** - * Delete a GitHub Pages site. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/pages` endpoint. + * Generate release notes content for a release. * + * This function performs a `POST` to the `/repos/{owner}/{repo}/releases/generate-notes` endpoint. * + * Generate a name and body describing a [release](https://docs.github.com/rest/releases/releases#get-a-release). The body content will be markdown formatted and contain information like the changes since last release and users who contributed. The generated release notes are not saved anywhere. They are intended to be generated and used when creating a new release. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn delete_pages_site( + pub async fn generate_release_notes( &self, owner: &str, repo: &str, - ) -> ClientResult> { + body: &crate::types::ReposGenerateReleaseNotesRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/pages", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/releases/generate-notes", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .delete( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * List GitHub Pages builds. + * Get the latest release. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/pages/builds` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/latest` endpoint. * + * View the latest published full release for the repository. * + * The latest release is the most recent non-prerelease, non-draft release, sorted by the `created_at` attribute. The `created_at` attribute is the date of the commit used for the release, and not the date when the release was drafted or published. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn list_pages_builds( + pub async fn get_latest_release( &self, owner: &str, repo: &str, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/pages/builds?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/releases/latest", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -6320,31 +8842,37 @@ impl Repos { .await } /** - * List GitHub Pages builds. + * Get a release by tag name. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/pages/builds` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/tags/{tag}` endpoint. * - * As opposed to `list_pages_builds`, this function returns all the pages of the request at once. + * Get a published release with the specified tag. * + * FROM: * + * **Parameters:** * - * FROM: + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `tag: &str` -- tag parameter. */ - pub async fn list_all_pages_builds( + pub async fn get_release_by_tag( &self, owner: &str, repo: &str, - ) -> ClientResult>> { + tag: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/pages/builds", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/releases/tags/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&tag.to_string()), ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -6354,36 +8882,40 @@ impl Repos { .await } /** - * Request a GitHub Pages build. + * Get a release. * - * This function performs a `POST` to the `/repos/{owner}/{repo}/pages/builds` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/{release_id}` endpoint. * - * You can request that your site be built from the latest revision on the default branch. This has the same effect as pushing a commit to your default branch, but does not require an additional commit. Manually triggering page builds can be helpful when diagnosing build warnings and failures. + * Gets a public release with the specified release ID. * - * Build requests are limited to one concurrent build per repository and one concurrent build per requester. If you request a build while another is still in progress, the second request will be queued until the first completes. + * > [!NOTE] + * > This returns an `upload_url` key corresponding to the endpoint for uploading release assets. This key is a hypermedia resource. For more information, see "[Getting started with the REST API](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#hypermedia)." * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `release_id: i64` -- The unique identifier of the release. */ - pub async fn request_pages_build( + pub async fn get_release( &self, owner: &str, repo: &str, - ) -> ClientResult> { + release_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/pages/builds", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/releases/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&release_id.to_string()), ), None, ); self.client - .post( + .get( &url, crate::Message { body: None, @@ -6393,34 +8925,37 @@ impl Repos { .await } /** - * Get latest Pages build. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/pages/builds/latest` endpoint. + * Delete a release. * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/releases/{release_id}` endpoint. * + * Users with push access to the repository can delete a release. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `release_id: i64` -- The unique identifier of the release. */ - pub async fn get_latest_pages_build( + pub async fn delete_release( &self, owner: &str, repo: &str, - ) -> ClientResult> { + release_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/pages/builds/latest", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/releases/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&release_id.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -6430,73 +8965,86 @@ impl Repos { .await } /** - * Get GitHub Pages build. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/pages/builds/{build_id}` endpoint. + * Update a release. * + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/releases/{release_id}` endpoint. * + * Users with push access to the repository can edit a release. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `build_id: i64` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `release_id: i64` -- The unique identifier of the release. */ - pub async fn get_pages_build( + pub async fn update_release( &self, owner: &str, repo: &str, - build_id: i64, - ) -> ClientResult> { + release_id: i64, + body: &crate::types::ReposUpdateReleaseRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/pages/builds/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&build_id.to_string()), + "/repos/{}/{}/releases/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&release_id.to_string()), ), None, ); self.client - .get( + .patch( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Get a DNS health check for GitHub Pages. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/pages/health` endpoint. + * List release assets. * - * Gets a health check of the DNS settings for the `CNAME` record configured for a repository's GitHub Pages. + * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/{release_id}/assets` endpoint. * - * The first request to this endpoint returns a `202 Accepted` status and starts an asynchronous background task to get the results for the domain. After the background task completes, subsequent requests to this endpoint return a `200 OK` status with the health check results in the response. * - * Users must have admin or owner permissions. GitHub Apps must have the `pages:write` and `administration:write` permission to use this endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `release_id: i64` -- The unique identifier of the release. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn get_pages_health_check( + pub async fn list_release_assets( &self, owner: &str, repo: &str, - ) -> ClientResult> { + release_id: i64, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/pages/health", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/releases/{}/assets?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&release_id.to_string()), + query_ ), None, ); @@ -6511,44 +9059,33 @@ impl Repos { .await } /** - * Get a repository README. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/readme` endpoint. + * List release assets. * - * Gets the preferred README for a repository. + * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/{release_id}/assets` endpoint. * - * READMEs support [custom media types](https://docs.github.com/rest/reference/repos#custom-media-types) for retrieving the raw content or rendered HTML. + * As opposed to `list_release_assets`, this function returns all the pages of the request at once. * - * FROM: * - * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch (usually `master`). + * FROM: */ - pub async fn get_readme( + pub async fn list_all_release_assets( &self, owner: &str, repo: &str, - ref_: &str, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !ref_.is_empty() { - query_args.push(("ref".to_string(), ref_.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + release_id: i64, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/readme?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - query_ + "/repos/{}/{}/releases/{}/assets", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&release_id.to_string()), ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -6558,80 +9095,105 @@ impl Repos { .await } /** - * Get a repository README for a directory. + * Upload a release asset. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/readme/{dir}` endpoint. + * This function performs a `POST` to the `/repos/{owner}/{repo}/releases/{release_id}/assets` endpoint. * - * Gets the README from a repository directory. + * This endpoint makes use of a [Hypermedia relation](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#hypermedia) to determine which URL to access. The endpoint you call to upload release assets is specific to your release. Use the `upload_url` returned in + * the response of the [Create a release endpoint](https://docs.github.com/rest/releases/releases#create-a-release) to upload a release asset. + * + * You need to use an HTTP client which supports [SNI](http://en.wikipedia.org/wiki/Server_Name_Indication) to make calls to this endpoint. + * + * Most libraries will set the required `Content-Length` header automatically. Use the required `Content-Type` header to provide the media type of the asset. For a list of media types, see [Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml). For example: + * + * `application/zip` + * + * GitHub expects the asset data in its raw binary form, rather than JSON. You will send the raw binary content of the asset as the request body. Everything else about the endpoint is the same as the rest of the API. For example, + * you'll still need to pass your authentication to be able to upload an asset. + * + * When an upstream failure occurs, you will receive a `502 Bad Gateway` status. This may leave an empty asset with a state of `starter`. It can be safely deleted. * - * READMEs support [custom media types](https://docs.github.com/rest/reference/repos#custom-media-types) for retrieving the raw content or rendered HTML. + * **Notes:** + * * GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The "[List release assets](https://docs.github.com/rest/releases/assets#list-release-assets)" + * endpoint lists the renamed filenames. For more information and help, contact [GitHub Support](https://support.github.com/contact?tags=dotcom-rest-api). + * * To find the `release_id` query the [`GET /repos/{owner}/{repo}/releases/latest` endpoint](https://docs.github.com/rest/releases/releases#get-the-latest-release). + * * If you upload an asset with the same filename as another uploaded asset, you'll receive an error and must delete the old file before you can re-upload the new asset. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `dir: &str` -- The alternate path to look for a README file. - * * `ref_: &str` -- The name of the commit/branch/tag. Default: the repository’s default branch (usually `master`). + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `release_id: i64` -- The unique identifier of the release. + * * `name: &str` + * * `label: &str` */ - pub async fn get_readme_in_directory( + pub async fn upload_release_asset>( &self, owner: &str, repo: &str, - dir: &str, - ref_: &str, - ) -> ClientResult> { + release_id: i64, + name: &str, + label: &str, + body: B, + ) -> ClientResult> { let mut query_args: Vec<(String, String)> = Default::default(); - if !ref_.is_empty() { - query_args.push(("ref".to_string(), ref_.to_string())); + if !label.is_empty() { + query_args.push(("label".to_string(), label.to_string())); + } + if !name.is_empty() { + query_args.push(("name".to_string(), name.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/readme/{}?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(dir), + "/repos/{}/{}/releases/{}/assets?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&release_id.to_string()), query_ ), - None, + Some(ReposUploadReleaseAssetDefaultServer::default().default_url()), ); self.client - .get( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(body.into()), + content_type: Some("application/octet-stream".to_string()), }, ) .await } /** - * List releases. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/releases` endpoint. + * Get rules for a branch. * - * This returns a list of releases, which does not include regular Git tags that have not been associated with a release. To get a list of Git tags, use the [Repository Tags API](https://docs.github.com/rest/reference/repos#list-repository-tags). + * This function performs a `GET` to the `/repos/{owner}/{repo}/rules/branches/{branch}` endpoint. * - * Information about published releases are available to everyone. Only users with push access will receive listings for draft releases. + * Returns all active rules that apply to the specified branch. The branch does not need to exist; rules that would apply + * to a branch with that name will be returned. All active rules that apply will be returned, regardless of the level + * at which they are configured (e.g. repository or organization). Rules in rulesets with "evaluate" or "disabled" + * enforcement statuses are not returned. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `branch: &str` -- The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_releases( + pub async fn get_branch_rules( &self, owner: &str, repo: &str, + branch: &str, per_page: i64, page: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if page > 0 { query_args.push(("page".to_string(), page.to_string())); @@ -6642,9 +9204,10 @@ impl Repos { let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/releases?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/rules/branches/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), query_ ), None, @@ -6660,28 +9223,31 @@ impl Repos { .await } /** - * List releases. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/releases` endpoint. + * Get rules for a branch. * - * As opposed to `list_releases`, this function returns all the pages of the request at once. + * This function performs a `GET` to the `/repos/{owner}/{repo}/rules/branches/{branch}` endpoint. * - * This returns a list of releases, which does not include regular Git tags that have not been associated with a release. To get a list of Git tags, use the [Repository Tags API](https://docs.github.com/rest/reference/repos#list-repository-tags). + * As opposed to `get_branch_rules`, this function returns all the pages of the request at once. * - * Information about published releases are available to everyone. Only users with push access will receive listings for draft releases. + * Returns all active rules that apply to the specified branch. The branch does not need to exist; rules that would apply + * to a branch with that name will be returned. All active rules that apply will be returned, regardless of the level + * at which they are configured (e.g. repository or organization). Rules in rulesets with "evaluate" or "disabled" + * enforcement statuses are not returned. * - * FROM: + * FROM: */ - pub async fn list_all_releases( + pub async fn get_all_branch_rules( &self, owner: &str, repo: &str, - ) -> ClientResult>> { + branch: &str, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/releases", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/rules/branches/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&branch.to_string()), ), None, ); @@ -6696,77 +9262,105 @@ impl Repos { .await } /** - * Create a release. - * - * This function performs a `POST` to the `/repos/{owner}/{repo}/releases` endpoint. + * Get all repository rulesets. * - * Users with push access to the repository can create a release. + * This function performs a `GET` to the `/repos/{owner}/{repo}/rulesets` endpoint. * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * Get all the rulesets for a repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `includes_parents: bool` -- Include rulesets configured at higher levels that apply to this repository. + * * `targets: &str` -- A comma-separated list of rule targets to filter by. + * If provided, only rulesets that apply to the specified targets will be returned. + * For example, `branch,tag,push`. + * . */ - pub async fn create_release( + pub async fn get_repo_rulesets( &self, owner: &str, repo: &str, - body: &crate::types::ReposCreateReleaseRequest, - ) -> ClientResult> { + per_page: i64, + page: i64, + includes_parents: bool, + targets: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if includes_parents { + query_args.push(("includes_parents".to_string(), includes_parents.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !targets.is_empty() { + query_args.push(("targets".to_string(), targets.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/releases", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/rulesets?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .post( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get a release asset. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/assets/{asset_id}` endpoint. + * Get all repository rulesets. * - * To download the asset's binary content, set the `Accept` header of the request to [`application/octet-stream`](https://docs.github.com/rest/overview/media-types). The API will either redirect the client to the location, or stream it directly if possible. API clients should handle both a `200` or `302` response. + * This function performs a `GET` to the `/repos/{owner}/{repo}/rulesets` endpoint. * - * FROM: + * As opposed to `get_repo_rulesets`, this function returns all the pages of the request at once. * - * **Parameters:** + * Get all the rulesets for a repository. * - * * `owner: &str` - * * `repo: &str` - * * `asset_id: i64` -- asset_id parameter. + * FROM: */ - pub async fn get_release_asset( + pub async fn get_all_repo_rulesets( &self, owner: &str, repo: &str, - asset_id: i64, - ) -> ClientResult> { + includes_parents: bool, + targets: &str, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if includes_parents { + query_args.push(("includes_parents".to_string(), includes_parents.to_string())); + } + if !targets.is_empty() { + query_args.push(("targets".to_string(), targets.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/releases/assets/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&asset_id.to_string()), + "/repos/{}/{}/rulesets?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -6776,117 +9370,168 @@ impl Repos { .await } /** - * Delete a release asset. - * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/releases/assets/{asset_id}` endpoint. + * Create a repository ruleset. * + * This function performs a `POST` to the `/repos/{owner}/{repo}/rulesets` endpoint. * + * Create a ruleset for a repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `asset_id: i64` -- asset_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn delete_release_asset( + pub async fn create_repo_ruleset( &self, owner: &str, repo: &str, - asset_id: i64, - ) -> ClientResult> { + body: &crate::types::ReposCreateRepoRulesetRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/releases/assets/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&asset_id.to_string()), + "/repos/{}/{}/rulesets", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .delete( + .post( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Update a release asset. + * List repository rule suites. * - * This function performs a `PATCH` to the `/repos/{owner}/{repo}/releases/assets/{asset_id}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/rulesets/rule-suites` endpoint. * - * Users with push access to the repository can edit a release asset. + * Lists suites of rule evaluations at the repository level. + * For more information, see "[Managing rulesets for a repository](https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/managing-rulesets-for-a-repository#viewing-insights-for-rulesets)." * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `asset_id: i64` -- asset_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ref_: &str` -- The name of the ref. Cannot contain wildcard characters. Optionally prefix with `refs/heads/` to limit to branches or `refs/tags/` to limit to tags. Omit the prefix to search across all refs. When specified, only rule evaluations triggered for this ref will be returned. + * * `time_period: crate::types::TimePeriodData` -- The time period to filter by. + * + * For example, `day` will filter for rule suites that occurred in the past 24 hours, and `week` will filter for rule suites that occurred in the past 7 days (168 hours). + * * `actor_name: &str` -- The handle for the GitHub user account to filter on. When specified, only rule evaluations triggered by this actor will be returned. + * * `rule_suite_result: crate::types::RuleSuiteResult` -- The rule suite results to filter on. When specified, only suites with this result will be returned. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn update_release_asset( + pub async fn get_repo_rule_suites( &self, owner: &str, repo: &str, - asset_id: i64, - body: &crate::types::ReposUpdateReleaseAssetRequest, - ) -> ClientResult> { + ref_: &str, + time_period: crate::types::TimePeriodData, + actor_name: &str, + rule_suite_result: crate::types::RuleSuiteResult, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !actor_name.is_empty() { + query_args.push(("actor_name".to_string(), actor_name.to_string())); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + if !rule_suite_result.to_string().is_empty() { + query_args.push(( + "rule_suite_result".to_string(), + rule_suite_result.to_string(), + )); + } + if !time_period.to_string().is_empty() { + query_args.push(("time_period".to_string(), time_period.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/releases/assets/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&asset_id.to_string()), + "/repos/{}/{}/rulesets/rule-suites?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .patch( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get the latest release. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/latest` endpoint. + * List repository rule suites. * - * View the latest published full release for the repository. - * - * The latest release is the most recent non-prerelease, non-draft release, sorted by the `created_at` attribute. The `created_at` attribute is the date of the commit used for the release, and not the date when the release was drafted or published. + * This function performs a `GET` to the `/repos/{owner}/{repo}/rulesets/rule-suites` endpoint. * - * FROM: + * As opposed to `get_repo_rule_suites`, this function returns all the pages of the request at once. * - * **Parameters:** + * Lists suites of rule evaluations at the repository level. + * For more information, see "[Managing rulesets for a repository](https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/managing-rulesets-for-a-repository#viewing-insights-for-rulesets)." * - * * `owner: &str` - * * `repo: &str` + * FROM: */ - pub async fn get_latest_release( + pub async fn get_all_repo_rule_suites( &self, owner: &str, repo: &str, - ) -> ClientResult> { + ref_: &str, + time_period: crate::types::TimePeriodData, + actor_name: &str, + rule_suite_result: crate::types::RuleSuiteResult, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !actor_name.is_empty() { + query_args.push(("actor_name".to_string(), actor_name.to_string())); + } + if !ref_.is_empty() { + query_args.push(("ref".to_string(), ref_.to_string())); + } + if !rule_suite_result.to_string().is_empty() { + query_args.push(( + "rule_suite_result".to_string(), + rule_suite_result.to_string(), + )); + } + if !time_period.to_string().is_empty() { + query_args.push(("time_period".to_string(), time_period.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/releases/latest", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/rulesets/rule-suites?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -6896,32 +9541,36 @@ impl Repos { .await } /** - * Get a release by tag name. + * Get a repository rule suite. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/tags/{tag}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/rulesets/rule-suites/{rule_suite_id}` endpoint. * - * Get a published release with the specified tag. + * Gets information about a suite of rule evaluations from within a repository. + * For more information, see "[Managing rulesets for a repository](https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/managing-rulesets-for-a-repository#viewing-insights-for-rulesets)." * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `tag: &str` -- tag parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `rule_suite_id: i64` -- The unique identifier of the rule suite result. + * To get this ID, you can use [GET /repos/{owner}/{repo}/rulesets/rule-suites](https://docs.github.com/rest/repos/rule-suites#list-repository-rule-suites) + * for repositories and [GET /orgs/{org}/rulesets/rule-suites](https://docs.github.com/rest/orgs/rule-suites#list-organization-rule-suites) + * for organizations. */ - pub async fn get_release_by_tag( + pub async fn get_repo_rule_suite( &self, owner: &str, repo: &str, - tag: &str, - ) -> ClientResult> { + rule_suite_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/releases/tags/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(tag), + "/repos/{}/{}/rulesets/rule-suites/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&rule_suite_id.to_string()), ), None, ); @@ -6936,32 +9585,43 @@ impl Repos { .await } /** - * Get a release. + * Get a repository ruleset. * - * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/{release_id}` endpoint. + * This function performs a `GET` to the `/repos/{owner}/{repo}/rulesets/{ruleset_id}` endpoint. + * + * Get a ruleset for a repository. * - * **Note:** This returns an `upload_url` key corresponding to the endpoint for uploading release assets. This key is a [hypermedia resource](https://docs.github.com/rest/overview/resources-in-the-rest-api#hypermedia). + * **Note:** To prevent leaking sensitive information, the `bypass_actors` property is only returned if the user + * making the API request has write access to the ruleset. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `release_id: i64` -- release_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ruleset_id: i64` -- The ID of the ruleset. + * * `includes_parents: bool` -- Include rulesets configured at higher levels that apply to this repository. */ - pub async fn get_release( + pub async fn get_repo_ruleset( &self, owner: &str, repo: &str, - release_id: i64, - ) -> ClientResult> { + ruleset_id: i64, + includes_parents: bool, + ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if includes_parents { + query_args.push(("includes_parents".to_string(), includes_parents.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/releases/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&release_id.to_string()), + "/repos/{}/{}/rulesets/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ruleset_id.to_string()), + query_ ), None, ); @@ -6976,111 +9636,111 @@ impl Repos { .await } /** - * Delete a release. + * Update a repository ruleset. * - * This function performs a `DELETE` to the `/repos/{owner}/{repo}/releases/{release_id}` endpoint. + * This function performs a `PUT` to the `/repos/{owner}/{repo}/rulesets/{ruleset_id}` endpoint. * - * Users with push access to the repository can delete a release. + * Update a ruleset for a repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `release_id: i64` -- release_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ruleset_id: i64` -- The ID of the ruleset. */ - pub async fn delete_release( + pub async fn update_repo_ruleset( &self, owner: &str, repo: &str, - release_id: i64, - ) -> ClientResult> { + ruleset_id: i64, + body: &crate::types::ReposUpdateRepoRulesetRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/releases/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&release_id.to_string()), + "/repos/{}/{}/rulesets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ruleset_id.to_string()), ), None, ); self.client - .delete( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Update a release. + * Delete a repository ruleset. * - * This function performs a `PATCH` to the `/repos/{owner}/{repo}/releases/{release_id}` endpoint. + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/rulesets/{ruleset_id}` endpoint. * - * Users with push access to the repository can edit a release. + * Delete a ruleset for a repository. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `release_id: i64` -- release_id parameter. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ruleset_id: i64` -- The ID of the ruleset. */ - pub async fn update_release( + pub async fn delete_repo_ruleset( &self, owner: &str, repo: &str, - release_id: i64, - body: &crate::types::ReposCreateReleaseRequest, - ) -> ClientResult> { + ruleset_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/releases/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&release_id.to_string()), + "/repos/{}/{}/rulesets/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ruleset_id.to_string()), ), None, ); self.client - .patch( + .delete( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * List release assets. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/{release_id}/assets` endpoint. + * Get repository ruleset history. * + * This function performs a `GET` to the `/repos/{owner}/{repo}/rulesets/{ruleset_id}/history` endpoint. * + * Get the history of a repository ruleset. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `release_id: i64` -- release_id parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `ruleset_id: i64` -- The ID of the ruleset. */ - pub async fn list_release_assets( + pub async fn get_repo_ruleset_history( &self, owner: &str, repo: &str, - release_id: i64, per_page: i64, page: i64, - ) -> ClientResult>> { + ruleset_id: i64, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if page > 0 { query_args.push(("page".to_string(), page.to_string())); @@ -7091,10 +9751,10 @@ impl Repos { let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/releases/{}/assets?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&release_id.to_string()), + "/repos/{}/{}/rulesets/{}/history?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ruleset_id.to_string()), query_ ), None, @@ -7110,28 +9770,28 @@ impl Repos { .await } /** - * List release assets. - * - * This function performs a `GET` to the `/repos/{owner}/{repo}/releases/{release_id}/assets` endpoint. + * Get repository ruleset history. * - * As opposed to `list_release_assets`, this function returns all the pages of the request at once. + * This function performs a `GET` to the `/repos/{owner}/{repo}/rulesets/{ruleset_id}/history` endpoint. * + * As opposed to `get_repo_ruleset_history`, this function returns all the pages of the request at once. * + * Get the history of a repository ruleset. * - * FROM: + * FROM: */ - pub async fn list_all_release_assets( + pub async fn get_all_repo_ruleset_history( &self, owner: &str, repo: &str, - release_id: i64, - ) -> ClientResult>> { + ruleset_id: i64, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/repos/{}/{}/releases/{}/assets", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&release_id.to_string()), + "/repos/{}/{}/rulesets/{}/history", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ruleset_id.to_string()), ), None, ); @@ -7146,72 +9806,44 @@ impl Repos { .await } /** - * Upload a release asset. - * - * This function performs a `POST` to the `/repos/{owner}/{repo}/releases/{release_id}/assets` endpoint. - * - * This endpoint makes use of [a Hypermedia relation](https://docs.github.com/rest/overview/resources-in-the-rest-api#hypermedia) to determine which URL to access. The endpoint you call to upload release assets is specific to your release. Use the `upload_url` returned in - * the response of the [Create a release endpoint](https://docs.github.com/rest/reference/repos#create-a-release) to upload a release asset. - * - * You need to use an HTTP client which supports [SNI](http://en.wikipedia.org/wiki/Server_Name_Indication) to make calls to this endpoint. + * Get repository ruleset version. * - * Most libraries will set the required `Content-Length` header automatically. Use the required `Content-Type` header to provide the media type of the asset. For a list of media types, see [Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml). For example: - * - * `application/zip` - * - * GitHub expects the asset data in its raw binary form, rather than JSON. You will send the raw binary content of the asset as the request body. Everything else about the endpoint is the same as the rest of the API. For example, - * you'll still need to pass your authentication to be able to upload an asset. - * - * When an upstream failure occurs, you will receive a `502 Bad Gateway` status. This may leave an empty asset with a state of `starter`. It can be safely deleted. + * This function performs a `GET` to the `/repos/{owner}/{repo}/rulesets/{ruleset_id}/history/{version_id}` endpoint. * - * **Notes:** - * * GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The "[List assets for a release](https://docs.github.com/rest/reference/repos#list-assets-for-a-release)" - * endpoint lists the renamed filenames. For more information and help, contact [GitHub Support](https://support.github.com/contact?tags=rest-api). - * * If you upload an asset with the same filename as another uploaded asset, you'll receive an error and must delete the old file before you can re-upload the new asset. + * Get a version of a repository ruleset. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `release_id: i64` -- release_id parameter. - * * `name: &str` - * * `label: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ruleset_id: i64` -- The ID of the ruleset. + * * `version_id: i64` -- The ID of the version. */ - pub async fn upload_release_asset>( + pub async fn get_repo_ruleset_version( &self, owner: &str, repo: &str, - release_id: i64, - name: &str, - label: &str, - body: B, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !label.is_empty() { - query_args.push(("label".to_string(), label.to_string())); - } - if !name.is_empty() { - query_args.push(("name".to_string(), name.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ruleset_id: i64, + version_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( - "/repos/{}/{}/releases/{}/assets?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(&release_id.to_string()), - query_ + "/repos/{}/{}/rulesets/{}/history/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ruleset_id.to_string()), + crate::progenitor_support::encode_path(&version_id.to_string()), ), - Some(ReposUploadReleaseAssetDefaultServer::default().default_url()), + None, ); self.client - .post( + .get( &url, crate::Message { - body: Some(body.into()), - content_type: Some("application/octet-stream".to_string()), + body: None, + content_type: None, }, ) .await @@ -7223,12 +9855,15 @@ impl Repos { * * Returns a weekly aggregate of the number of additions and deletions pushed to a repository. * - * FROM: + * > [!NOTE] + * > This endpoint can only be used for repositories with fewer than 10,000 commits. If the repository contains 10,000 or more commits, a 422 status code will be returned. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_code_frequency_stats( &self, @@ -7238,8 +9873,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/stats/code_frequency", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7262,7 +9897,10 @@ impl Repos { * * Returns a weekly aggregate of the number of additions and deletions pushed to a repository. * - * FROM: + * > [!NOTE] + * > This endpoint can only be used for repositories with fewer than 10,000 commits. If the repository contains 10,000 or more commits, a 422 status code will be returned. + * + * FROM: */ pub async fn get_all_code_frequency_stats( &self, @@ -7272,8 +9910,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/stats/code_frequency", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7294,12 +9932,12 @@ impl Repos { * * Returns the last year of commit activity grouped by week. The `days` array is a group of commits per day, starting on `Sunday`. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_commit_activity_stats( &self, @@ -7309,8 +9947,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/stats/commit_activity", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7333,7 +9971,7 @@ impl Repos { * * Returns the last year of commit activity grouped by week. The `days` array is a group of commits per day, starting on `Sunday`. * - * FROM: + * FROM: */ pub async fn get_all_commit_activity_stats( &self, @@ -7343,8 +9981,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/stats/commit_activity", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7366,17 +10004,20 @@ impl Repos { * * Returns the `total` number of commits authored by the contributor. In addition, the response includes a Weekly Hash (`weeks` array) with the following information: * - * * `w` - Start of the week, given as a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time). + * * `w` - Start of the week, given as a [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time). * * `a` - Number of additions * * `d` - Number of deletions * * `c` - Number of commits * - * FROM: + * > [!NOTE] + * > This endpoint will return `0` values for all addition and deletion counts in repositories with 10,000 or more commits. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_contributors_stats( &self, @@ -7386,8 +10027,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/stats/contributors", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7411,12 +10052,15 @@ impl Repos { * * Returns the `total` number of commits authored by the contributor. In addition, the response includes a Weekly Hash (`weeks` array) with the following information: * - * * `w` - Start of the week, given as a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time). + * * `w` - Start of the week, given as a [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time). * * `a` - Number of additions * * `d` - Number of deletions * * `c` - Number of commits * - * FROM: + * > [!NOTE] + * > This endpoint will return `0` values for all addition and deletion counts in repositories with 10,000 or more commits. + * + * FROM: */ pub async fn get_all_contributors_stats( &self, @@ -7426,8 +10070,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/stats/contributors", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7450,12 +10094,14 @@ impl Repos { * * The array order is oldest week (index 0) to most recent week. * - * FROM: + * The most recent week is seven days ago at UTC midnight to today at UTC midnight. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_participation_stats( &self, @@ -7465,8 +10111,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/stats/participation", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7493,12 +10139,12 @@ impl Repos { * * For example, `[2, 14, 25]` indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. All times are based on the time zone of individual commits. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_punch_card_stats( &self, @@ -7508,8 +10154,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/stats/punch_card", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7538,7 +10184,7 @@ impl Repos { * * For example, `[2, 14, 25]` indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. All times are based on the time zone of individual commits. * - * FROM: + * FROM: */ pub async fn get_all_punch_card_stats( &self, @@ -7548,8 +10194,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/stats/punch_card", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7572,12 +10218,12 @@ impl Repos { * * Note: there is a limit of 1000 statuses per `sha` and `context` within a repository. Attempts to create more than 1000 statuses will result in a validation error. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `sha: &str` */ pub async fn create_commit_status( @@ -7590,9 +10236,9 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/statuses/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(sha), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&sha.to_string()), ), None, ); @@ -7613,14 +10259,14 @@ impl Repos { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_tags( &self, @@ -7640,8 +10286,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/tags?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -7665,7 +10311,7 @@ impl Repos { * * * - * FROM: + * FROM: */ pub async fn list_all_tags( &self, @@ -7675,8 +10321,89 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/tags", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Closing down - List tag protection states for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/tags/protection` endpoint. + * + * > [!WARNING] + * > **Closing down notice:** This operation is closing down and will be removed after August 30, 2024. Use the "[Repository Rulesets](https://docs.github.com/rest/repos/rules#get-all-repository-rulesets)" endpoint instead. + * + * This returns the tag protection states of a repository. + * + * This information is only available to repository administrators. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn list_tag_protection( + &self, + owner: &str, + repo: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/tags/protection", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Closing down - List tag protection states for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/tags/protection` endpoint. + * + * As opposed to `list_tag_protection`, this function returns all the pages of the request at once. + * + * > [!WARNING] + * > **Closing down notice:** This operation is closing down and will be removed after August 30, 2024. Use the "[Repository Rulesets](https://docs.github.com/rest/repos/rules#get-all-repository-rulesets)" endpoint instead. + * + * This returns the tag protection states of a repository. + * + * This information is only available to repository administrators. + * + * FROM: + */ + pub async fn list_all_tag_protection( + &self, + owner: &str, + repo: &str, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/tags/protection", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7690,22 +10417,110 @@ impl Repos { ) .await } + /** + * Closing down - Create a tag protection state for a repository. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/tags/protection` endpoint. + * + * > [!WARNING] + * > **Closing down notice:** This operation is closing down and will be removed after August 30, 2024. Use the "[Repository Rulesets](https://docs.github.com/rest/repos/rules#create-a-repository-ruleset)" endpoint instead. + * + * This creates a tag protection state for a repository. + * This endpoint is only available to repository administrators. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_tag_protection( + &self, + owner: &str, + repo: &str, + body: &crate::types::ReposCreateTagProtectionRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/tags/protection", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Closing down - Delete a tag protection state for a repository. + * + * This function performs a `DELETE` to the `/repos/{owner}/{repo}/tags/protection/{tag_protection_id}` endpoint. + * + * > [!WARNING] + * > **Closing down notice:** This operation is closing down and will be removed after August 30, 2024. Use the "[Repository Rulesets](https://docs.github.com/rest/repos/rules#delete-a-repository-ruleset)" endpoint instead. + * + * This deletes a tag protection state for a repository. + * This endpoint is only available to repository administrators. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `tag_protection_id: i64` -- The unique identifier of the tag protection. + */ + pub async fn delete_tag_protection( + &self, + owner: &str, + repo: &str, + tag_protection_id: i64, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/tags/protection/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&tag_protection_id.to_string()), + ), + None, + ); + self.client + .delete( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } /** * Download a repository archive (tar). * * This function performs a `GET` to the `/repos/{owner}/{repo}/tarball/{ref}` endpoint. * * Gets a redirect URL to download a tar archive for a repository. If you omit `:ref`, the repository’s default branch (usually - * `master`) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use + * `main`) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use * the `Location` header to make a second `GET` request. - * **Note**: For private repositories, these links are temporary and expire after five minutes. * - * FROM: + * > [!NOTE] + * > For private repositories, these links are temporary and expire after five minutes. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `ref_: &str` */ pub async fn download_tarball_archive( @@ -7717,9 +10532,9 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/tarball/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), ), None, ); @@ -7738,16 +10553,20 @@ impl Repos { * * This function performs a `GET` to the `/repos/{owner}/{repo}/teams` endpoint. * + * Lists the teams that have access to the specified repository and that are also visible to the authenticated user. * + * For a public repository, a team is listed only if that team added the public repository explicitly. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to use this endpoint with a public repository, and `repo` scope to use this endpoint with a private repository. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_teams( &self, @@ -7767,8 +10586,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/teams?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -7790,9 +10609,13 @@ impl Repos { * * As opposed to `list_teams`, this function returns all the pages of the request at once. * + * Lists the teams that have access to the specified repository and that are also visible to the authenticated user. + * + * For a public repository, a team is listed only if that team added the public repository explicitly. * + * OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to use this endpoint with a public repository, and `repo` scope to use this endpoint with a private repository. * - * FROM: + * FROM: */ pub async fn list_all_teams( &self, @@ -7802,8 +10625,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/teams", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7824,14 +10647,14 @@ impl Repos { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `page: i64` -- Page number of the results to fetch. - * * `per_page: i64` -- Results per page (max 100). + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn get_all_topics( &self, @@ -7851,8 +10674,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/topics?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -7874,12 +10697,12 @@ impl Repos { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn replace_all_topics( &self, @@ -7890,8 +10713,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/topics", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7912,13 +10735,13 @@ impl Repos { * * Get the total number of clones and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per: crate::types::Per` -- Must be one of: `day`, `week`. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per: crate::types::Per` -- The time frame to display results for. */ pub async fn get_clones( &self, @@ -7934,8 +10757,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/traffic/clones?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -7957,12 +10780,12 @@ impl Repos { * * Get the top 10 popular contents over the last 14 days. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_top_paths( &self, @@ -7972,8 +10795,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/traffic/popular/paths", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -7996,7 +10819,7 @@ impl Repos { * * Get the top 10 popular contents over the last 14 days. * - * FROM: + * FROM: */ pub async fn get_all_top_paths( &self, @@ -8006,8 +10829,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/traffic/popular/paths", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -8028,12 +10851,12 @@ impl Repos { * * Get the top 10 referrers over the last 14 days. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn get_top_referrers( &self, @@ -8043,8 +10866,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/traffic/popular/referrers", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -8067,7 +10890,7 @@ impl Repos { * * Get the top 10 referrers over the last 14 days. * - * FROM: + * FROM: */ pub async fn get_all_top_referrers( &self, @@ -8077,8 +10900,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/traffic/popular/referrers", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -8099,13 +10922,13 @@ impl Repos { * * Get the total number of views and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `per: crate::types::Per` -- Must be one of: `day`, `week`. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `per: crate::types::Per` -- The time frame to display results for. */ pub async fn get_views( &self, @@ -8121,8 +10944,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/traffic/views?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -8142,14 +10965,14 @@ impl Repos { * * This function performs a `POST` to the `/repos/{owner}/{repo}/transfer` endpoint. * - * A transfer request will need to be accepted by the new owner when transferring a personal repository to another user. The response will contain the original `owner`, and the transfer will continue asynchronously. For more details on the requirements to transfer personal and organization-owned repositories, see [about repository transfers](https://help.github.com/articles/about-repository-transfers/). + * A transfer request will need to be accepted by the new owner when transferring a personal repository to another user. The response will contain the original `owner`, and the transfer will continue asynchronously. For more details on the requirements to transfer personal and organization-owned repositories, see [about repository transfers](https://docs.github.com/articles/about-repository-transfers/). * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn transfer( &self, @@ -8160,8 +10983,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/transfer", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -8180,14 +11003,14 @@ impl Repos { * * This function performs a `GET` to the `/repos/{owner}/{repo}/vulnerability-alerts` endpoint. * - * Shows whether dependency alerts are enabled or disabled for a repository. The authenticated user must have admin access to the repository. For more information, see "[About security alerts for vulnerable dependencies](https://help.github.com/en/articles/about-security-alerts-for-vulnerable-dependencies)". + * Shows whether dependency alerts are enabled or disabled for a repository. The authenticated user must have admin read access to the repository. For more information, see "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)". * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn check_vulnerability_alerts( &self, @@ -8197,8 +11020,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/vulnerability-alerts", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -8217,14 +11040,14 @@ impl Repos { * * This function performs a `PUT` to the `/repos/{owner}/{repo}/vulnerability-alerts` endpoint. * - * Enables dependency alerts and the dependency graph for a repository. The authenticated user must have admin access to the repository. For more information, see "[About security alerts for vulnerable dependencies](https://help.github.com/en/articles/about-security-alerts-for-vulnerable-dependencies)". + * Enables dependency alerts and the dependency graph for a repository. The authenticated user must have admin access to the repository. For more information, see "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)". * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn enable_vulnerability_alerts( &self, @@ -8234,8 +11057,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/vulnerability-alerts", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -8254,14 +11077,16 @@ impl Repos { * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/vulnerability-alerts` endpoint. * - * Disables dependency alerts and the dependency graph for a repository. The authenticated user must have admin access to the repository. For more information, see "[About security alerts for vulnerable dependencies](https://help.github.com/en/articles/about-security-alerts-for-vulnerable-dependencies)". + * Disables dependency alerts and the dependency graph for a repository. + * The authenticated user must have admin access to the repository. For more information, + * see "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)". * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn disable_vulnerability_alerts( &self, @@ -8271,8 +11096,8 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/vulnerability-alerts", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -8292,16 +11117,18 @@ impl Repos { * This function performs a `GET` to the `/repos/{owner}/{repo}/zipball/{ref}` endpoint. * * Gets a redirect URL to download a zip archive for a repository. If you omit `:ref`, the repository’s default branch (usually - * `master`) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use + * `main`) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use * the `Location` header to make a second `GET` request. - * **Note**: For private repositories, these links are temporary and expire after five minutes. * - * FROM: + * > [!NOTE] + * > For private repositories, these links are temporary and expire after five minutes. If the repository is empty, you will receive a 404 when you follow the redirect. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `ref_: &str` */ pub async fn download_zipball_archive( @@ -8313,9 +11140,9 @@ impl Repos { let url = self.client.url( &format!( "/repos/{}/{}/zipball/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - crate::progenitor_support::encode_path(ref_), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ref_.to_string()), ), None, ); @@ -8334,33 +11161,28 @@ impl Repos { * * This function performs a `POST` to the `/repos/{template_owner}/{template_repo}/generate` endpoint. * - * Creates a new repository using a repository template. Use the `template_owner` and `template_repo` route parameters to specify the repository to use as the template. The authenticated user must own or be a member of an organization that owns the repository. To check if a repository is available to use as a template, get the repository's information using the [Get a repository](https://docs.github.com/rest/reference/repos#get-a-repository) endpoint and check that the `is_template` key is `true`. - * - * **OAuth scope requirements** + * Creates a new repository using a repository template. Use the `template_owner` and `template_repo` route parameters to specify the repository to use as the template. If the repository is not public, the authenticated user must own or be a member of an organization that owns the repository. To check if a repository is available to use as a template, get the repository's information using the [Get a repository](https://docs.github.com/rest/repos/repos#get-a-repository) endpoint and check that the `is_template` key is `true`. * - * When using [OAuth](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/), authorizations must include: + * OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to create a public repository, and `repo` scope to create a private repository. * - * * `public_repo` scope or `repo` scope to create a public repository. Note: For GitHub AE, use `repo` scope to create an internal repository. - * * `repo` scope to create a private repository - * - * FROM: + * FROM: * * **Parameters:** * - * * `template_owner: &str` - * * `template_repo: &str` + * * `template_owner: &str` -- The account owner of the template repository. The name is not case sensitive. + * * `template_repo: &str` -- The name of the template repository without the `.git` extension. The name is not case sensitive. */ pub async fn create_using_template( &self, template_owner: &str, template_repo: &str, body: &crate::types::ReposCreateUsingTemplateRequest, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( "/repos/{}/{}/generate", - crate::progenitor_support::encode_path(template_owner), - crate::progenitor_support::encode_path(template_repo), + crate::progenitor_support::encode_path(&template_owner.to_string()), + crate::progenitor_support::encode_path(&template_repo.to_string()), ), None, ); @@ -8383,9 +11205,9 @@ impl Repos { * * Note: * - For GitHub Enterprise Server, this endpoint will only list repositories available to all users on the enterprise. - * - Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header) to get the URL for the next page of repositories. + * - Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of repositories. * - * FROM: + * FROM: * * **Parameters:** * @@ -8422,9 +11244,9 @@ impl Repos { * * Note: * - For GitHub Enterprise Server, this endpoint will only list repositories available to all users on the enterprise. - * - Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header) to get the URL for the next page of repositories. + * - Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of repositories. * - * FROM: + * FROM: */ pub async fn list_all_public( &self, @@ -8455,26 +11277,22 @@ impl Repos { * * The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership. * - * FROM: + * FROM: * * **Parameters:** * - * * `visibility: crate::types::ReposListVisibility` -- Can be one of `all`, `public`, or `private`. Note: For GitHub AE, can be one of `all`, `internal`, or `private`. + * * `visibility: crate::types::ReposListVisibility` -- Limit results to repositories with the specified visibility. * * `affiliation: &str` -- Comma-separated list of values. Can include: - * \* `owner`: Repositories that are owned by the authenticated user. - * \* `collaborator`: Repositories that the user has been added to as a collaborator. - * \* `organization_member`: Repositories that the user has access to through being a member of an organization. This includes every repository on every team that the user is on. - * * `type_: crate::types::ReposListType` -- Can be one of `all`, `owner`, `public`, `private`, `member`. Note: For GitHub AE, can be one of `all`, `owner`, `internal`, `private`, `member`. Default: `all` - * - * Will cause a `422` error if used in the same request as \*\*visibility\*\* or \*\*affiliation\*\*. Will cause a `422` error if used in the same request as \*\*visibility\*\* or \*\*affiliation\*\*. - * * `sort: crate::types::ReposListOrgSort` -- Can be one of `created`, `updated`, `pushed`, `full_name`. - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - * * `since: chrono::DateTime` -- Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * * `before: chrono::DateTime` -- Only show notifications updated before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `owner`: Repositories that are owned by the authenticated user. + * * `collaborator`: Repositories that the user has been added to as a collaborator. + * * `organization_member`: Repositories that the user has access to through being a member of an organization. This includes every repository on every team that the user is on. + * * `type_: crate::types::ReposListType` -- Limit results to repositories of the specified type. Will cause a `422` error if used in the same request as \*\*visibility\*\* or \*\*affiliation\*\*. + * * `sort: crate::types::ReposListOrgSort` -- The property to sort the results by. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `since: chrono::DateTime` -- Only show repositories updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * * `before: chrono::DateTime` -- Only show repositories updated before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. */ pub async fn list_for_authenticated_user( &self, @@ -8539,7 +11357,7 @@ impl Repos { * * The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership. * - * FROM: + * FROM: */ pub async fn list_all_for_authenticated_user( &self, @@ -8592,20 +11410,15 @@ impl Repos { * * Creates a new repository for the authenticated user. * - * **OAuth scope requirements** - * - * When using [OAuth](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/), authorizations must include: + * OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to create a public repository, and `repo` scope to create a private repository. * - * * `public_repo` scope or `repo` scope to create a public repository. Note: For GitHub AE, use `repo` scope to create an internal repository. - * * `repo` scope to create a private repository. - * - * FROM: + * FROM: */ pub async fn create_for_authenticated_user( &self, body: &crate::types::ReposCreateRequest, - ) -> ClientResult> { - let url = self.client.url("/user/repos", None); + ) -> ClientResult> { + let url = self.client.url(&"/user/repos".to_string(), None); self.client .post( &url, @@ -8623,12 +11436,12 @@ impl Repos { * * When authenticating as a user, this endpoint will list all currently open repository invitations for that user. * - * FROM: + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_invitations_for_authenticated_user( &self, @@ -8665,12 +11478,14 @@ impl Repos { * * When authenticating as a user, this endpoint will list all currently open repository invitations for that user. * - * FROM: + * FROM: */ pub async fn list_all_invitations_for_authenticated_user( &self, ) -> ClientResult>> { - let url = self.client.url("/user/repository_invitations", None); + let url = self + .client + .url(&"/user/repository_invitations".to_string(), None); self.client .get_all_pages( &url, @@ -8688,13 +11503,13 @@ impl Repos { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `invitation_id: i64` -- invitation_id parameter. + * * `invitation_id: i64` -- The unique identifier of the invitation. */ - pub async fn decline_invitation( + pub async fn decline_invitation_for_authenticated_user( &self, invitation_id: i64, ) -> ClientResult> { @@ -8722,13 +11537,16 @@ impl Repos { * * * - * FROM: + * FROM: * * **Parameters:** * - * * `invitation_id: i64` -- invitation_id parameter. + * * `invitation_id: i64` -- The unique identifier of the invitation. */ - pub async fn accept_invitation(&self, invitation_id: i64) -> ClientResult> { + pub async fn accept_invitation_for_authenticated_user( + &self, + invitation_id: i64, + ) -> ClientResult> { let url = self.client.url( &format!( "/user/repository_invitations/{}", @@ -8751,20 +11569,18 @@ impl Repos { * * This function performs a `GET` to the `/users/{username}/repos` endpoint. * - * Lists public repositories for the specified user. Note: For GitHub AE, this endpoint will list internal repositories for the specified user. + * Lists public repositories for the specified user. * - * FROM: + * FROM: * * **Parameters:** * - * * `username: &str` - * * `type_: crate::types::ReposListUserType` -- Can be one of `all`, `owner`, `member`. - * * `sort: crate::types::ReposListOrgSort` -- Can be one of `created`, `updated`, `pushed`, `full_name`. - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `username: &str` -- The handle for the GitHub user account. + * * `type_: crate::types::ReposListUserType` -- Limit results to repositories of the specified type. + * * `sort: crate::types::ReposListOrgSort` -- The property to sort the results by. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_user( &self, @@ -8795,7 +11611,7 @@ impl Repos { let url = self.client.url( &format!( "/users/{}/repos?{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), query_ ), None, @@ -8817,9 +11633,9 @@ impl Repos { * * As opposed to `list_for_user`, this function returns all the pages of the request at once. * - * Lists public repositories for the specified user. Note: For GitHub AE, this endpoint will list internal repositories for the specified user. + * Lists public repositories for the specified user. * - * FROM: + * FROM: */ pub async fn list_all_for_user( &self, @@ -8842,7 +11658,7 @@ impl Repos { let url = self.client.url( &format!( "/users/{}/repos?{}", - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), query_ ), None, diff --git a/github/src/search.rs b/github/src/search.rs index 1b50a0fe..2f0296bb 100644 --- a/github/src/search.rs +++ b/github/src/search.rs @@ -16,9 +16,9 @@ impl Search { * * This function performs a `GET` to the `/search/code` endpoint. * - * Searches for query terms inside of a file. This method returns up to 100 results [per page](https://docs.github.com/rest/overview/resources-in-the-rest-api#pagination). + * Searches for query terms inside of a file. This method returns up to 100 results [per page](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api). * - * When searching for code, you can get text match metadata for the file **content** and file **path** fields when you pass the `text-match` media type. For more details about how to receive highlighted search results, see [Text match metadata](https://docs.github.com/rest/reference/search#text-match-metadata). + * When searching for code, you can get text match metadata for the file **content** and file **path** fields when you pass the `text-match` media type. For more details about how to receive highlighted search results, see [Text match metadata](https://docs.github.com/rest/search/search#text-match-metadata). * * For example, if you want to find the definition of the `addClass` function inside [jQuery](https://github.com/jquery/jquery) repository, your query would look something like this: * @@ -26,7 +26,7 @@ impl Search { * * This query searches for the keyword `addClass` within a file's contents. The query limits the search to files where the language is JavaScript in the `jquery/jquery` repository. * - * #### Considerations for code search + * Considerations for code search: * * Due to the complexity of searching code, there are a few restrictions on how searches are performed: * @@ -35,15 +35,17 @@ impl Search { * * You must always include at least one search term when searching source code. For example, searching for [`language:go`](https://github.com/search?utf8=%E2%9C%93&q=language%3Ago&type=Code) is not valid, while [`amazing * language:go`](https://github.com/search?utf8=%E2%9C%93&q=amazing+language%3Ago&type=Code) is. * - * FROM: + * This endpoint requires you to authenticate and limits you to 10 requests per minute. + * + * FROM: * * **Parameters:** * - * * `q: &str` -- The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/reference/search#constructing-a-search-query). See "[Searching code](https://help.github.com/articles/searching-code/)" for a detailed list of qualifiers. - * * `sort: crate::types::SearchCodeSort` -- Sorts the results of your query. Can only be `indexed`, which indicates how recently a file has been indexed by the GitHub search infrastructure. Default: [best match](https://docs.github.com/rest/reference/search#ranking-search-results). - * * `order: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `q: &str` -- The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as the web interface for GitHub. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/search/search#constructing-a-search-query). See "[Searching code](https://docs.github.com/search-github/searching-on-github/searching-code)" for a detailed list of qualifiers. + * * `sort: crate::types::SearchCodeSort` -- \*\*This field is closing down.\*\* Sorts the results of your query. Can only be `indexed`, which indicates how recently a file has been indexed by the GitHub search infrastructure. Default: [best match](https://docs.github.com/rest/search/search#ranking-search-results). + * * `order: crate::types::Order` -- **This field is closing down.** Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. . + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn code( &self, @@ -86,24 +88,24 @@ impl Search { * * This function performs a `GET` to the `/search/commits` endpoint. * - * Find commits via various criteria on the default branch (usually `master`). This method returns up to 100 results [per page](https://docs.github.com/rest/overview/resources-in-the-rest-api#pagination). + * Find commits via various criteria on the default branch (usually `main`). This method returns up to 100 results [per page](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api). * * When searching for commits, you can get text match metadata for the **message** field when you provide the `text-match` media type. For more details about how to receive highlighted search results, see [Text match - * metadata](https://docs.github.com/rest/reference/search#text-match-metadata). + * metadata](https://docs.github.com/rest/search/search#text-match-metadata). * * For example, if you want to find commits related to CSS in the [octocat/Spoon-Knife](https://github.com/octocat/Spoon-Knife) repository. Your query would look something like this: * * `q=repo:octocat/Spoon-Knife+css` * - * FROM: + * FROM: * * **Parameters:** * - * * `q: &str` -- The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/reference/search#constructing-a-search-query). See "[Searching commits](https://help.github.com/articles/searching-commits/)" for a detailed list of qualifiers. - * * `sort: crate::types::SearchCommitsSort` -- Sorts the results of your query by `author-date` or `committer-date`. Default: [best match](https://docs.github.com/rest/reference/search#ranking-search-results). + * * `q: &str` -- The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as the web interface for GitHub. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/search/search#constructing-a-search-query). See "[Searching commits](https://docs.github.com/search-github/searching-on-github/searching-commits)" for a detailed list of qualifiers. + * * `sort: crate::types::SearchCommitsSort` -- Sorts the results of your query by `author-date` or `committer-date`. Default: [best match](https://docs.github.com/rest/search/search#ranking-search-results). * * `order: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn commits( &self, @@ -148,10 +150,10 @@ impl Search { * * This function performs a `GET` to the `/search/issues` endpoint. * - * Find issues by state and keyword. This method returns up to 100 results [per page](https://docs.github.com/rest/overview/resources-in-the-rest-api#pagination). + * Find issues by state and keyword. This method returns up to 100 results [per page](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api). * * When searching for issues, you can get text match metadata for the issue **title**, issue **body**, and issue **comment body** fields when you pass the `text-match` media type. For more details about how to receive highlighted - * search results, see [Text match metadata](https://docs.github.com/rest/reference/search#text-match-metadata). + * search results, see [Text match metadata](https://docs.github.com/rest/search/search#text-match-metadata). * * For example, if you want to find the oldest unresolved Python bugs on Windows. Your query might look something like this. * @@ -159,17 +161,20 @@ impl Search { * * This query searches for the keyword `windows`, within any open issue that is labeled as `bug`. The search runs across repositories whose primary language is Python. The results are sorted by creation date in ascending order, which means the oldest issues appear first in the search results. * - * **Note:** For [user-to-server](https://docs.github.com/developers/apps/identifying-and-authorizing-users-for-github-apps#user-to-server-requests) GitHub App requests, you can't retrieve a combination of issues and pull requests in a single query. Requests that don't include the `is:issue` or `is:pull-request` qualifier will receive an HTTP `422 Unprocessable Entity` response. To get results for both issues and pull requests, you must send separate queries for issues and pull requests. For more information about the `is` qualifier, see "[Searching only issues or pull requests](https://docs.github.com/github/searching-for-information-on-github/searching-issues-and-pull-requests#search-only-issues-or-pull-requests)." + * > [!NOTE] + * > For requests made by GitHub Apps with a user access token, you can't retrieve a combination of issues and pull requests in a single query. Requests that don't include the `is:issue` or `is:pull-request` qualifier will receive an HTTP `422 Unprocessable Entity` response. To get results for both issues and pull requests, you must send separate queries for issues and pull requests. For more information about the `is` qualifier, see "[Searching only issues or pull requests](https://docs.github.com/github/searching-for-information-on-github/searching-issues-and-pull-requests#search-only-issues-or-pull-requests)." * - * FROM: + * FROM: * * **Parameters:** * - * * `q: &str` -- The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/reference/search#constructing-a-search-query). See "[Searching issues and pull requests](https://help.github.com/articles/searching-issues-and-pull-requests/)" for a detailed list of qualifiers. - * * `sort: crate::types::SearchIssuesPullRequestsSort` -- Sorts the results of your query by the number of `comments`, `reactions`, `reactions-+1`, `reactions--1`, `reactions-smile`, `reactions-thinking_face`, `reactions-heart`, `reactions-tada`, or `interactions`. You can also sort results by how recently the items were `created` or `updated`, Default: [best match](https://docs.github.com/rest/reference/search#ranking-search-results). + * * `q: &str` -- The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as the web interface for GitHub. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/search/search#constructing-a-search-query). See "[Searching issues and pull requests](https://docs.github.com/search-github/searching-on-github/searching-issues-and-pull-requests)" for a detailed list of qualifiers. + * * `sort: crate::types::SearchIssuesPullRequestsSort` -- Sorts the results of your query by the number of `comments`, `reactions`, `reactions-+1`, `reactions--1`, `reactions-smile`, `reactions-thinking_face`, `reactions-heart`, `reactions-tada`, or `interactions`. You can also sort results by how recently the items were `created` or `updated`, Default: [best match](https://docs.github.com/rest/search/search#ranking-search-results). * * `order: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `advanced_search: &str` -- Set to `true` to use advanced search. + * Example: `http://api.github.com/search/issues?q={query}&advanced_search=true`. */ pub async fn issues_and_pull_requests( &self, @@ -178,8 +183,12 @@ impl Search { order: crate::types::Order, per_page: i64, page: i64, + advanced_search: &str, ) -> ClientResult> { let mut query_args: Vec<(String, String)> = Default::default(); + if !advanced_search.is_empty() { + query_args.push(("advanced_search".to_string(), advanced_search.to_string())); + } if !order.to_string().is_empty() { query_args.push(("order".to_string(), order.to_string())); } @@ -212,9 +221,9 @@ impl Search { * * This function performs a `GET` to the `/search/labels` endpoint. * - * Find labels in a repository with names or descriptions that match search keywords. Returns up to 100 results [per page](https://docs.github.com/rest/overview/resources-in-the-rest-api#pagination). + * Find labels in a repository with names or descriptions that match search keywords. Returns up to 100 results [per page](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api). * - * When searching for labels, you can get text match metadata for the label **name** and **description** fields when you pass the `text-match` media type. For more details about how to receive highlighted search results, see [Text match metadata](https://docs.github.com/rest/reference/search#text-match-metadata). + * When searching for labels, you can get text match metadata for the label **name** and **description** fields when you pass the `text-match` media type. For more details about how to receive highlighted search results, see [Text match metadata](https://docs.github.com/rest/search/search#text-match-metadata). * * For example, if you want to find labels in the `linguist` repository that match `bug`, `defect`, or `enhancement`. Your query might look like this: * @@ -222,22 +231,22 @@ impl Search { * * The labels that best match the query appear first in the search results. * - * FROM: + * FROM: * * **Parameters:** * * * `repository_id: i64` -- The id of the repository. - * * `q: &str` -- The search keywords. This endpoint does not accept qualifiers in the query. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/reference/search#constructing-a-search-query). - * * `sort: crate::types::Sort` -- Sorts the results of your query by when the label was `created` or `updated`. Default: [best match](https://docs.github.com/rest/reference/search#ranking-search-results). + * * `q: &str` -- The search keywords. This endpoint does not accept qualifiers in the query. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/search/search#constructing-a-search-query). + * * `sort: crate::types::SortData` -- Sorts the results of your query by when the label was `created` or `updated`. Default: [best match](https://docs.github.com/rest/search/search#ranking-search-results). * * `order: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn labels( &self, repository_id: i64, q: &str, - sort: crate::types::Sort, + sort: crate::types::SortData, order: crate::types::Order, per_page: i64, page: i64, @@ -278,9 +287,9 @@ impl Search { * * This function performs a `GET` to the `/search/repositories` endpoint. * - * Find repositories via various criteria. This method returns up to 100 results [per page](https://docs.github.com/rest/overview/resources-in-the-rest-api#pagination). + * Find repositories via various criteria. This method returns up to 100 results [per page](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api). * - * When searching for repositories, you can get text match metadata for the **name** and **description** fields when you pass the `text-match` media type. For more details about how to receive highlighted search results, see [Text match metadata](https://docs.github.com/rest/reference/search#text-match-metadata). + * When searching for repositories, you can get text match metadata for the **name** and **description** fields when you pass the `text-match` media type. For more details about how to receive highlighted search results, see [Text match metadata](https://docs.github.com/rest/search/search#text-match-metadata). * * For example, if you want to search for popular Tetris repositories written in assembly code, your query might look like this: * @@ -288,19 +297,15 @@ impl Search { * * This query searches for repositories with the word `tetris` in the name, the description, or the README. The results are limited to repositories where the primary language is assembly. The results are sorted by stars in descending order, so that the most popular repositories appear first in the search results. * - * When you include the `mercy` preview header, you can also search for multiple topics by adding more `topic:` instances. For example, your query might look like this: - * - * `q=topic:ruby+topic:rails` - * - * FROM: + * FROM: * * **Parameters:** * - * * `q: &str` -- The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/reference/search#constructing-a-search-query). See "[Searching for repositories](https://help.github.com/articles/searching-for-repositories/)" for a detailed list of qualifiers. - * * `sort: crate::types::SearchReposSort` -- Sorts the results of your query by number of `stars`, `forks`, or `help-wanted-issues` or how recently the items were `updated`. Default: [best match](https://docs.github.com/rest/reference/search#ranking-search-results). + * * `q: &str` -- The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as the web interface for GitHub. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/search/search#constructing-a-search-query). See "[Searching for repositories](https://docs.github.com/articles/searching-for-repositories/)" for a detailed list of qualifiers. + * * `sort: crate::types::SearchReposSort` -- Sorts the results of your query by number of `stars`, `forks`, or `help-wanted-issues` or how recently the items were `updated`. Default: [best match](https://docs.github.com/rest/search/search#ranking-search-results). * * `order: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn repos( &self, @@ -345,9 +350,9 @@ impl Search { * * This function performs a `GET` to the `/search/topics` endpoint. * - * Find topics via various criteria. Results are sorted by best match. This method returns up to 100 results [per page](https://docs.github.com/rest/overview/resources-in-the-rest-api#pagination). See "[Searching topics](https://help.github.com/articles/searching-topics/)" for a detailed list of qualifiers. + * Find topics via various criteria. Results are sorted by best match. This method returns up to 100 results [per page](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api). See "[Searching topics](https://docs.github.com/articles/searching-topics/)" for a detailed list of qualifiers. * - * When searching for topics, you can get text match metadata for the topic's **short\_description**, **description**, **name**, or **display\_name** field when you pass the `text-match` media type. For more details about how to receive highlighted search results, see [Text match metadata](https://docs.github.com/rest/reference/search#text-match-metadata). + * When searching for topics, you can get text match metadata for the topic's **short\_description**, **description**, **name**, or **display\_name** field when you pass the `text-match` media type. For more details about how to receive highlighted search results, see [Text match metadata](https://docs.github.com/rest/search/search#text-match-metadata). * * For example, if you want to search for topics related to Ruby that are featured on https://github.com/topics. Your query might look like this: * @@ -355,13 +360,13 @@ impl Search { * * This query searches for topics with the keyword `ruby` and limits the results to find only topics that are featured. The topics that are the best match for the query appear first in the search results. * - * FROM: + * FROM: * * **Parameters:** * - * * `q: &str` -- The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/reference/search#constructing-a-search-query). - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `q: &str` -- The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as the web interface for GitHub. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/search/search#constructing-a-search-query). + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn topics( &self, @@ -396,9 +401,9 @@ impl Search { * * This function performs a `GET` to the `/search/users` endpoint. * - * Find users via various criteria. This method returns up to 100 results [per page](https://docs.github.com/rest/overview/resources-in-the-rest-api#pagination). + * Find users via various criteria. This method returns up to 100 results [per page](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api). * - * When searching for users, you can get text match metadata for the issue **login**, **email**, and **name** fields when you pass the `text-match` media type. For more details about highlighting search results, see [Text match metadata](https://docs.github.com/rest/reference/search#text-match-metadata). For more details about how to receive highlighted search results, see [Text match metadata](https://docs.github.com/rest/reference/search#text-match-metadata). + * When searching for users, you can get text match metadata for the issue **login**, public **email**, and **name** fields when you pass the `text-match` media type. For more details about highlighting search results, see [Text match metadata](https://docs.github.com/rest/search/search#text-match-metadata). For more details about how to receive highlighted search results, see [Text match metadata](https://docs.github.com/rest/search/search#text-match-metadata). * * For example, if you're looking for a list of popular users, you might try this query: * @@ -406,15 +411,17 @@ impl Search { * * This query searches for users with the name `tom`. The results are restricted to users with more than 42 repositories and over 1,000 followers. * - * FROM: + * This endpoint does not accept authentication and will only include publicly visible users. As an alternative, you can use the GraphQL API. The GraphQL API requires authentication and will return private users, including Enterprise Managed Users (EMUs), that you are authorized to view. For more information, see "[GraphQL Queries](https://docs.github.com/graphql/reference/queries#search)." + * + * FROM: * * **Parameters:** * - * * `q: &str` -- The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/reference/search#constructing-a-search-query). See "[Searching users](https://help.github.com/articles/searching-users/)" for a detailed list of qualifiers. - * * `sort: crate::types::SearchUsersSort` -- Sorts the results of your query by number of `followers` or `repositories`, or when the person `joined` GitHub. Default: [best match](https://docs.github.com/rest/reference/search#ranking-search-results). + * * `q: &str` -- The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as the web interface for GitHub. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/search/search#constructing-a-search-query). See "[Searching users](https://docs.github.com/search-github/searching-on-github/searching-users)" for a detailed list of qualifiers. + * * `sort: crate::types::SearchUsersSort` -- Sorts the results of your query by number of `followers` or `repositories`, or when the person `joined` GitHub. Default: [best match](https://docs.github.com/rest/search/search#ranking-search-results). * * `order: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn users( &self, diff --git a/github/src/secret_scanning.rs b/github/src/secret_scanning.rs index 3e86d4fe..6d2ee557 100644 --- a/github/src/secret_scanning.rs +++ b/github/src/secret_scanning.rs @@ -11,25 +11,315 @@ impl SecretScanning { SecretScanning { client } } + /** + * List secret scanning alerts for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/secret-scanning/alerts` endpoint. + * + * Lists secret scanning alerts for eligible repositories in an organization, from newest to oldest. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `state: crate::types::SecretScanningAlertState` -- Sets the state of the secret scanning alert. You must provide `resolution` when you set the state to `resolved`. + * * `secret_type: &str` -- A comma-separated list of secret types to return. All default secret patterns are returned. To return generic patterns, pass the token name(s) in the parameter. See "[Supported secret scanning patterns](https://docs.github.com/code-security/secret-scanning/introduction/supported-secret-scanning-patterns#supported-secrets)" for a complete list of secret types. + * * `resolution: &str` -- A comma-separated list of resolutions. Only secret scanning alerts with one of these resolutions are listed. Valid resolutions are `false_positive`, `wont_fix`, `revoked`, `pattern_edited`, `pattern_deleted` or `used_in_tests`. + * * `assignee: &str` -- Filters alerts by assignee. Use `*` to get all assigned alerts, `none` to get all unassigned alerts, or a GitHub username to get alerts assigned to a specific user. + * * `sort: crate::types::SortData` -- The property to sort the results by. `created` means when the alert was created. `updated` means when the alert was updated or resolved. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for events before this cursor. To receive an initial cursor on your first request, include an empty "before" query string. + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for events after this cursor. To receive an initial cursor on your first request, include an empty "after" query string. + * * `validity: &str` -- A comma-separated list of validities that, when present, will return alerts that match the validities in this list. Valid options are `active`, `inactive`, and `unknown`. + * * `is_publicly_leaked: bool` -- A boolean value representing whether or not to filter alerts by the publicly-leaked tag being present. + * * `is_multi_repo: bool` -- A boolean value representing whether or not to filter alerts by the multi-repo tag being present. + * * `hide_secret: bool` -- A boolean value representing whether or not to hide literal secrets in the results. + */ + pub async fn list_alerts_for_org( + &self, + org: &str, + state: crate::types::SecretScanningAlertState, + secret_type: &str, + resolution: &str, + assignee: &str, + sort: crate::types::SortData, + direction: crate::types::Order, + page: i64, + per_page: i64, + before: &str, + after: &str, + validity: &str, + is_publicly_leaked: bool, + is_multi_repo: bool, + hide_secret: bool, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !assignee.is_empty() { + query_args.push(("assignee".to_string(), assignee.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if hide_secret { + query_args.push(("hide_secret".to_string(), hide_secret.to_string())); + } + if is_multi_repo { + query_args.push(("is_multi_repo".to_string(), is_multi_repo.to_string())); + } + if is_publicly_leaked { + query_args.push(( + "is_publicly_leaked".to_string(), + is_publicly_leaked.to_string(), + )); + } + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !resolution.is_empty() { + query_args.push(("resolution".to_string(), resolution.to_string())); + } + if !secret_type.is_empty() { + query_args.push(("secret_type".to_string(), secret_type.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.to_string().is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + if !validity.is_empty() { + query_args.push(("validity".to_string(), validity.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/secret-scanning/alerts?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List secret scanning alerts for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/secret-scanning/alerts` endpoint. + * + * As opposed to `list_alerts_for_org`, this function returns all the pages of the request at once. + * + * Lists secret scanning alerts for eligible repositories in an organization, from newest to oldest. + * + * The authenticated user must be an administrator or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: + */ + pub async fn list_all_alerts_for_org( + &self, + org: &str, + state: crate::types::SecretScanningAlertState, + secret_type: &str, + resolution: &str, + assignee: &str, + sort: crate::types::SortData, + direction: crate::types::Order, + before: &str, + after: &str, + validity: &str, + is_publicly_leaked: bool, + is_multi_repo: bool, + hide_secret: bool, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !assignee.is_empty() { + query_args.push(("assignee".to_string(), assignee.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if hide_secret { + query_args.push(("hide_secret".to_string(), hide_secret.to_string())); + } + if is_multi_repo { + query_args.push(("is_multi_repo".to_string(), is_multi_repo.to_string())); + } + if is_publicly_leaked { + query_args.push(( + "is_publicly_leaked".to_string(), + is_publicly_leaked.to_string(), + )); + } + if !resolution.is_empty() { + query_args.push(("resolution".to_string(), resolution.to_string())); + } + if !secret_type.is_empty() { + query_args.push(("secret_type".to_string(), secret_type.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.to_string().is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + if !validity.is_empty() { + query_args.push(("validity".to_string(), validity.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/secret-scanning/alerts?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List organization pattern configurations. + * + * This function performs a `GET` to the `/orgs/{org}/secret-scanning/pattern-configurations` endpoint. + * + * Lists the secret scanning pattern configurations for an organization. + * + * Personal access tokens (classic) need the `read:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn list_org_pattern_configs( + &self, + org: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/orgs/{}/secret-scanning/pattern-configurations", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update organization pattern configurations. + * + * This function performs a `PATCH` to the `/orgs/{org}/secret-scanning/pattern-configurations` endpoint. + * + * Updates the secret scanning pattern configurations for an organization. + * + * Personal access tokens (classic) need the `write:org` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + */ + pub async fn update_org_pattern_configs( + &self, + org: &str, + body: &crate::types::SecretScanningUpdateOrgPatternConfigsRequest, + ) -> ClientResult> + { + let url = self.client.url( + &format!( + "/orgs/{}/secret-scanning/pattern-configurations", + crate::progenitor_support::encode_path(&org.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } /** * List secret scanning alerts for a repository. * * This function performs a `GET` to the `/repos/{owner}/{repo}/secret-scanning/alerts` endpoint. * - * Lists all secret scanning alerts for a private repository, from newest to oldest. To use this endpoint, you must be an administrator for the repository or organization, and you must use an access token with the `repo` scope or `security_events` scope. + * Lists secret scanning alerts for an eligible repository, from newest to oldest. + * + * The authenticated user must be an administrator for the repository or for the organization that owns the repository to use this endpoint. * - * GitHub Apps must have the `secret_scanning_alerts` read permission to use this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` - * * `state: crate::types::SecretScanningAlertState` -- Sets the state of the secret scanning alert. Can be either `open` or `resolved`. You must provide `resolution` when you set the state to `resolved`. - * * `secret_type: &str` -- A comma separated list of secret types to return. By default all secret types are returned. See "[About secret scanning for private repositories](https://docs.github.com/code-security/secret-security/about-secret-scanning#about-secret-scanning-for-private-repositories)" for a complete list of secret types (API slug). - * * `page: i64` -- Page number of the results to fetch. - * * `per_page: i64` -- Results per page (max 100). + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `state: crate::types::SecretScanningAlertState` -- Sets the state of the secret scanning alert. You must provide `resolution` when you set the state to `resolved`. + * * `secret_type: &str` -- A comma-separated list of secret types to return. All default secret patterns are returned. To return generic patterns, pass the token name(s) in the parameter. See "[Supported secret scanning patterns](https://docs.github.com/code-security/secret-scanning/introduction/supported-secret-scanning-patterns#supported-secrets)" for a complete list of secret types. + * * `resolution: &str` -- A comma-separated list of resolutions. Only secret scanning alerts with one of these resolutions are listed. Valid resolutions are `false_positive`, `wont_fix`, `revoked`, `pattern_edited`, `pattern_deleted` or `used_in_tests`. + * * `assignee: &str` -- Filters alerts by assignee. Use `*` to get all assigned alerts, `none` to get all unassigned alerts, or a GitHub username to get alerts assigned to a specific user. + * * `sort: crate::types::SortData` -- The property to sort the results by. `created` means when the alert was created. `updated` means when the alert was updated or resolved. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for events before this cursor. To receive an initial cursor on your first request, include an empty "before" query string. + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for events after this cursor. To receive an initial cursor on your first request, include an empty "after" query string. + * * `validity: &str` -- A comma-separated list of validities that, when present, will return alerts that match the validities in this list. Valid options are `active`, `inactive`, and `unknown`. + * * `is_publicly_leaked: bool` -- A boolean value representing whether or not to filter alerts by the publicly-leaked tag being present. + * * `is_multi_repo: bool` -- A boolean value representing whether or not to filter alerts by the multi-repo tag being present. + * * `hide_secret: bool` -- A boolean value representing whether or not to hide literal secrets in the results. */ pub async fn list_alerts_for_repo( &self, @@ -37,28 +327,71 @@ impl SecretScanning { repo: &str, state: crate::types::SecretScanningAlertState, secret_type: &str, + resolution: &str, + assignee: &str, + sort: crate::types::SortData, + direction: crate::types::Order, page: i64, per_page: i64, + before: &str, + after: &str, + validity: &str, + is_publicly_leaked: bool, + is_multi_repo: bool, + hide_secret: bool, ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !assignee.is_empty() { + query_args.push(("assignee".to_string(), assignee.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if hide_secret { + query_args.push(("hide_secret".to_string(), hide_secret.to_string())); + } + if is_multi_repo { + query_args.push(("is_multi_repo".to_string(), is_multi_repo.to_string())); + } + if is_publicly_leaked { + query_args.push(( + "is_publicly_leaked".to_string(), + is_publicly_leaked.to_string(), + )); + } if page > 0 { query_args.push(("page".to_string(), page.to_string())); } if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } + if !resolution.is_empty() { + query_args.push(("resolution".to_string(), resolution.to_string())); + } if !secret_type.is_empty() { query_args.push(("secret_type".to_string(), secret_type.to_string())); } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } if !state.to_string().is_empty() { query_args.push(("state".to_string(), state.to_string())); } + if !validity.is_empty() { + query_args.push(("validity".to_string(), validity.to_string())); + } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( "/repos/{}/{}/secret-scanning/alerts?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -80,11 +413,13 @@ impl SecretScanning { * * As opposed to `list_alerts_for_repo`, this function returns all the pages of the request at once. * - * Lists all secret scanning alerts for a private repository, from newest to oldest. To use this endpoint, you must be an administrator for the repository or organization, and you must use an access token with the `repo` scope or `security_events` scope. + * Lists secret scanning alerts for an eligible repository, from newest to oldest. * - * GitHub Apps must have the `secret_scanning_alerts` read permission to use this endpoint. + * The authenticated user must be an administrator for the repository or for the organization that owns the repository to use this endpoint. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: */ pub async fn list_all_alerts_for_repo( &self, @@ -92,20 +427,63 @@ impl SecretScanning { repo: &str, state: crate::types::SecretScanningAlertState, secret_type: &str, + resolution: &str, + assignee: &str, + sort: crate::types::SortData, + direction: crate::types::Order, + before: &str, + after: &str, + validity: &str, + is_publicly_leaked: bool, + is_multi_repo: bool, + hide_secret: bool, ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !assignee.is_empty() { + query_args.push(("assignee".to_string(), assignee.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if hide_secret { + query_args.push(("hide_secret".to_string(), hide_secret.to_string())); + } + if is_multi_repo { + query_args.push(("is_multi_repo".to_string(), is_multi_repo.to_string())); + } + if is_publicly_leaked { + query_args.push(( + "is_publicly_leaked".to_string(), + is_publicly_leaked.to_string(), + )); + } + if !resolution.is_empty() { + query_args.push(("resolution".to_string(), resolution.to_string())); + } if !secret_type.is_empty() { query_args.push(("secret_type".to_string(), secret_type.to_string())); } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } if !state.to_string().is_empty() { query_args.push(("state".to_string(), state.to_string())); } + if !validity.is_empty() { + query_args.push(("validity".to_string(), validity.to_string())); + } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( "/repos/{}/{}/secret-scanning/alerts?{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), query_ ), None, @@ -125,30 +503,40 @@ impl SecretScanning { * * This function performs a `GET` to the `/repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}` endpoint. * - * Gets a single secret scanning alert detected in a private repository. To use this endpoint, you must be an administrator for the repository or organization, and you must use an access token with the `repo` scope or `security_events` scope. + * Gets a single secret scanning alert detected in an eligible repository. * - * GitHub Apps must have the `secret_scanning_alerts` read permission to use this endpoint. + * The authenticated user must be an administrator for the repository or for the organization that owns the repository to use this endpoint. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `alert_number: i64` -- The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the `number` field in the response from the `GET /repos/{owner}/{repo}/code-scanning/alerts` operation. + * * `hide_secret: bool` -- A boolean value representing whether or not to hide literal secrets in the results. */ pub async fn get_alert( &self, owner: &str, repo: &str, alert_number: i64, + hide_secret: bool, ) -> ClientResult> { + let mut query_args: Vec<(String, String)> = Default::default(); + if hide_secret { + query_args.push(("hide_secret".to_string(), hide_secret.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/repos/{}/{}/secret-scanning/alerts/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + "/repos/{}/{}/secret-scanning/alerts/{}?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&alert_number.to_string()), + query_ ), None, ); @@ -167,16 +555,20 @@ impl SecretScanning { * * This function performs a `PATCH` to the `/repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}` endpoint. * - * Updates the status of a secret scanning alert in a private repository. To use this endpoint, you must be an administrator for the repository or organization, and you must use an access token with the `repo` scope or `security_events` scope. + * Updates the status of a secret scanning alert in an eligible repository. + * + * You can also use this endpoint to assign or unassign an alert to a user who has write access to the repository. + * + * The authenticated user must be an administrator for the repository or for the organization that owns the repository to use this endpoint. * - * GitHub Apps must have the `secret_scanning_alerts` write permission to use this endpoint. + * OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. * - * FROM: + * FROM: * * **Parameters:** * - * * `owner: &str` - * * `repo: &str` + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. * * `alert_number: i64` -- The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the `number` field in the response from the `GET /repos/{owner}/{repo}/code-scanning/alerts` operation. */ pub async fn update_alert( @@ -189,8 +581,8 @@ impl SecretScanning { let url = self.client.url( &format!( "/repos/{}/{}/secret-scanning/alerts/{}", - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), crate::progenitor_support::encode_path(&alert_number.to_string()), ), None, @@ -205,4 +597,185 @@ impl SecretScanning { ) .await } + /** + * List locations for a secret scanning alert. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}/locations` endpoint. + * + * Lists all locations for a given secret scanning alert for an eligible repository. + * + * The authenticated user must be an administrator for the repository or for the organization that owns the repository to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `alert_number: i64` -- The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the `number` field in the response from the `GET /repos/{owner}/{repo}/code-scanning/alerts` operation. + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + */ + pub async fn list_locations_for_alert( + &self, + owner: &str, + repo: &str, + alert_number: i64, + page: i64, + per_page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/secret-scanning/alerts/{}/locations?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&alert_number.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List locations for a secret scanning alert. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}/locations` endpoint. + * + * As opposed to `list_locations_for_alert`, this function returns all the pages of the request at once. + * + * Lists all locations for a given secret scanning alert for an eligible repository. + * + * The authenticated user must be an administrator for the repository or for the organization that owns the repository to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: + */ + pub async fn list_all_locations_for_alert( + &self, + owner: &str, + repo: &str, + alert_number: i64, + ) -> ClientResult>> { + let url = self.client.url( + &format!( + "/repos/{}/{}/secret-scanning/alerts/{}/locations", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&alert_number.to_string()), + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a push protection bypass. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/secret-scanning/push-protection-bypasses` endpoint. + * + * Creates a bypass for a previously push protected secret. + * + * The authenticated user must be the original author of the committed secret. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_push_protection_bypass( + &self, + owner: &str, + repo: &str, + body: &crate::types::SecretScanningCreatePushProtectionBypassRequest, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/secret-scanning/push-protection-bypasses", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get secret scanning scan history for a repository. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/secret-scanning/scan-history` endpoint. + * + * Lists the latest default incremental and backfill scans by type for a repository. Scans from Copilot Secret Scanning are not included. + * + * > [!NOTE] + * > This endpoint requires [GitHub Advanced Security](https://docs.github.com/get-started/learning-about-github/about-github-advanced-security)." + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn get_scan_history( + &self, + owner: &str, + repo: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/secret-scanning/scan-history", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } } diff --git a/github/src/security_advisories.rs b/github/src/security_advisories.rs new file mode 100644 index 00000000..ff66752b --- /dev/null +++ b/github/src/security_advisories.rs @@ -0,0 +1,806 @@ +use crate::Client; +use crate::ClientResult; + +pub struct SecurityAdvisories { + pub client: Client, +} + +impl SecurityAdvisories { + #[doc(hidden)] + pub fn new(client: Client) -> Self { + SecurityAdvisories { client } + } + + /** + * List global security advisories. + * + * This function performs a `GET` to the `/advisories` endpoint. + * + * Lists all global security advisories that match the specified parameters. If no other parameters are defined, the request will return only GitHub-reviewed advisories that are not malware. + * + * By default, all responses will exclude advisories for malware, because malware are not standard vulnerabilities. To list advisories for malware, you must include the `type` parameter in your request, with the value `malware`. For more information about the different types of security advisories, see "[About the GitHub Advisory database](https://docs.github.com/code-security/security-advisories/global-security-advisories/about-the-github-advisory-database#about-types-of-security-advisories)." + * + * FROM: + * + * **Parameters:** + * + * * `ghsa_id: &str` -- If specified, only advisories with this GHSA (GitHub Security Advisory) identifier will be returned. + * * `type_: crate::types::Type` -- If specified, only advisories of this type will be returned. By default, a request with no other parameters defined will only return reviewed advisories that are not malware. + * * `cve_id: &str` -- If specified, only advisories with this CVE (Common Vulnerabilities and Exposures) identifier will be returned. + * * `ecosystem: crate::types::SecurityAdvisoryEcosystems` -- If specified, only advisories for these ecosystems will be returned. + * * `severity: crate::types::Severity` -- If specified, only advisories with these severities will be returned. + * * `cwes: &str` -- If specified, only advisories with these Common Weakness Enumerations (CWEs) will be returned. + * + * Example: `cwes=79,284,22` or `cwes[]=79&cwes[]=284&cwes[]=22`. + * * `is_withdrawn: bool` -- Whether to only return advisories that have been withdrawn. + * * `affects: &str` -- If specified, only return advisories that affect any of `package` or `package@version`. A maximum of 1000 packages can be specified. + * If the query parameter causes the URL to exceed the maximum URL length supported by your client, you must specify fewer packages. + * + * Example: `affects=package1,package2@1.0.0,package3@2.0.0` or `affects[]=package1&affects[]=package2@1.0.0`. + * * `published: &str` -- If specified, only return advisories that were published on a date or date range. + * + * For more information on the syntax of the date range, see "[Understanding the search syntax](https://docs.github.com/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates).". + * * `updated: &str` -- If specified, only return advisories that were updated on a date or date range. + * + * For more information on the syntax of the date range, see "[Understanding the search syntax](https://docs.github.com/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates).". + * * `modified: &str` -- If specified, only show advisories that were updated or published on a date or date range. + * + * For more information on the syntax of the date range, see "[Understanding the search syntax](https://docs.github.com/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates).". + * * `epss_percentage: &str` -- If specified, only return advisories that have an EPSS percentage score that matches the provided value. + * The EPSS percentage represents the likelihood of a CVE being exploited. + * * `epss_percentile: &str` -- If specified, only return advisories that have an EPSS percentile score that matches the provided value. + * The EPSS percentile represents the relative rank of the CVE's likelihood of being exploited compared to other CVEs. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `sort: crate::types::SecurityAdvisoriesListGlobalSort` -- The property to sort the results by. + */ + pub async fn list_global_advisories( + &self, + ghsa_id: &str, + type_: crate::types::Type, + cve_id: &str, + ecosystem: crate::types::SecurityAdvisoryEcosystems, + severity: crate::types::Severity, + cwes: &str, + is_withdrawn: bool, + affects: &str, + published: &str, + updated: &str, + modified: &str, + epss_percentage: &str, + epss_percentile: &str, + before: &str, + after: &str, + direction: crate::types::Order, + per_page: i64, + sort: crate::types::SecurityAdvisoriesListGlobalSort, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !affects.is_empty() { + query_args.push(("affects".to_string(), affects.to_string())); + } + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !cve_id.is_empty() { + query_args.push(("cve_id".to_string(), cve_id.to_string())); + } + if !cwes.is_empty() { + query_args.push(("cwes".to_string(), cwes.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !ecosystem.to_string().is_empty() { + query_args.push(("ecosystem".to_string(), ecosystem.to_string())); + } + if !epss_percentage.is_empty() { + query_args.push(("epss_percentage".to_string(), epss_percentage.to_string())); + } + if !epss_percentile.is_empty() { + query_args.push(("epss_percentile".to_string(), epss_percentile.to_string())); + } + if !ghsa_id.is_empty() { + query_args.push(("ghsa_id".to_string(), ghsa_id.to_string())); + } + if is_withdrawn { + query_args.push(("is_withdrawn".to_string(), is_withdrawn.to_string())); + } + if !modified.is_empty() { + query_args.push(("modified".to_string(), modified.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !published.is_empty() { + query_args.push(("published".to_string(), published.to_string())); + } + if !severity.to_string().is_empty() { + query_args.push(("severity".to_string(), severity.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !type_.to_string().is_empty() { + query_args.push(("type".to_string(), type_.to_string())); + } + if !updated.is_empty() { + query_args.push(("updated".to_string(), updated.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url(&format!("/advisories?{}", query_), None); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List global security advisories. + * + * This function performs a `GET` to the `/advisories` endpoint. + * + * As opposed to `list_global_advisories`, this function returns all the pages of the request at once. + * + * Lists all global security advisories that match the specified parameters. If no other parameters are defined, the request will return only GitHub-reviewed advisories that are not malware. + * + * By default, all responses will exclude advisories for malware, because malware are not standard vulnerabilities. To list advisories for malware, you must include the `type` parameter in your request, with the value `malware`. For more information about the different types of security advisories, see "[About the GitHub Advisory database](https://docs.github.com/code-security/security-advisories/global-security-advisories/about-the-github-advisory-database#about-types-of-security-advisories)." + * + * FROM: + */ + pub async fn list_all_global_advisories( + &self, + ghsa_id: &str, + type_: crate::types::Type, + cve_id: &str, + ecosystem: crate::types::SecurityAdvisoryEcosystems, + severity: crate::types::Severity, + cwes: &str, + is_withdrawn: bool, + affects: &str, + published: &str, + updated: &str, + modified: &str, + epss_percentage: &str, + epss_percentile: &str, + before: &str, + after: &str, + direction: crate::types::Order, + sort: crate::types::SecurityAdvisoriesListGlobalSort, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !affects.is_empty() { + query_args.push(("affects".to_string(), affects.to_string())); + } + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !cve_id.is_empty() { + query_args.push(("cve_id".to_string(), cve_id.to_string())); + } + if !cwes.is_empty() { + query_args.push(("cwes".to_string(), cwes.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !ecosystem.to_string().is_empty() { + query_args.push(("ecosystem".to_string(), ecosystem.to_string())); + } + if !epss_percentage.is_empty() { + query_args.push(("epss_percentage".to_string(), epss_percentage.to_string())); + } + if !epss_percentile.is_empty() { + query_args.push(("epss_percentile".to_string(), epss_percentile.to_string())); + } + if !ghsa_id.is_empty() { + query_args.push(("ghsa_id".to_string(), ghsa_id.to_string())); + } + if is_withdrawn { + query_args.push(("is_withdrawn".to_string(), is_withdrawn.to_string())); + } + if !modified.is_empty() { + query_args.push(("modified".to_string(), modified.to_string())); + } + if !published.is_empty() { + query_args.push(("published".to_string(), published.to_string())); + } + if !severity.to_string().is_empty() { + query_args.push(("severity".to_string(), severity.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !type_.to_string().is_empty() { + query_args.push(("type".to_string(), type_.to_string())); + } + if !updated.is_empty() { + query_args.push(("updated".to_string(), updated.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url(&format!("/advisories?{}", query_), None); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Get a global security advisory. + * + * This function performs a `GET` to the `/advisories/{ghsa_id}` endpoint. + * + * Gets a global security advisory using its GitHub Security Advisory (GHSA) identifier. + * + * FROM: + * + * **Parameters:** + * + * * `ghsa_id: &str` -- The GHSA (GitHub Security Advisory) identifier of the advisory. + */ + pub async fn get_global_advisory( + &self, + ghsa_id: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/advisories/{}", + crate::progenitor_support::encode_path(&ghsa_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List repository security advisories for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/security-advisories` endpoint. + * + * Lists repository security advisories for an organization. + * + * The authenticated user must be an owner or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:write` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `sort: crate::types::SecurityAdvisoriesListOrgRepositorySort` -- The property to sort the results by. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of advisories to return per page. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `state: crate::types::SecurityAdvisoriesListOrgRepositoryState` -- Filter by the state of the repository advisories. Only advisories of this state will be returned. + */ + pub async fn list_org_repository_advisories( + &self, + org: &str, + direction: crate::types::Order, + sort: crate::types::SecurityAdvisoriesListOrgRepositorySort, + before: &str, + after: &str, + per_page: i64, + state: crate::types::SecurityAdvisoriesListOrgRepositoryState, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.to_string().is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/security-advisories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List repository security advisories for an organization. + * + * This function performs a `GET` to the `/orgs/{org}/security-advisories` endpoint. + * + * As opposed to `list_org_repository_advisories`, this function returns all the pages of the request at once. + * + * Lists repository security advisories for an organization. + * + * The authenticated user must be an owner or security manager for the organization to use this endpoint. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:write` scope to use this endpoint. + * + * FROM: + */ + pub async fn list_all_org_repository_advisories( + &self, + org: &str, + direction: crate::types::Order, + sort: crate::types::SecurityAdvisoriesListOrgRepositorySort, + before: &str, + after: &str, + state: crate::types::SecurityAdvisoriesListOrgRepositoryState, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.to_string().is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/orgs/{}/security-advisories?{}", + crate::progenitor_support::encode_path(&org.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List repository security advisories. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/security-advisories` endpoint. + * + * Lists security advisories in a repository. + * + * The authenticated user can access unpublished security advisories from a repository if they are a security manager or administrator of that repository, or if they are a collaborator on any security advisory. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:read` scope to to get a published security advisory in a private repository, or any unpublished security advisory that the authenticated user has access to. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `direction: crate::types::Order` -- Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. + * * `sort: crate::types::SecurityAdvisoriesListOrgRepositorySort` -- The property to sort the results by. + * * `before: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `after: &str` -- A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `per_page: i64` -- The number of advisories to return per page. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `state: crate::types::SecurityAdvisoriesListOrgRepositoryState` -- Filter by the state of the repository advisories. Only advisories of this state will be returned. + */ + pub async fn list_repository_advisories( + &self, + owner: &str, + repo: &str, + direction: crate::types::Order, + sort: crate::types::SecurityAdvisoriesListOrgRepositorySort, + before: &str, + after: &str, + per_page: i64, + state: crate::types::SecurityAdvisoriesListOrgRepositoryState, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.to_string().is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/security-advisories?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * List repository security advisories. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/security-advisories` endpoint. + * + * As opposed to `list_repository_advisories`, this function returns all the pages of the request at once. + * + * Lists security advisories in a repository. + * + * The authenticated user can access unpublished security advisories from a repository if they are a security manager or administrator of that repository, or if they are a collaborator on any security advisory. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:read` scope to to get a published security advisory in a private repository, or any unpublished security advisory that the authenticated user has access to. + * + * FROM: + */ + pub async fn list_all_repository_advisories( + &self, + owner: &str, + repo: &str, + direction: crate::types::Order, + sort: crate::types::SecurityAdvisoriesListOrgRepositorySort, + before: &str, + after: &str, + state: crate::types::SecurityAdvisoriesListOrgRepositoryState, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !after.is_empty() { + query_args.push(("after".to_string(), after.to_string())); + } + if !before.is_empty() { + query_args.push(("before".to_string(), before.to_string())); + } + if !direction.to_string().is_empty() { + query_args.push(("direction".to_string(), direction.to_string())); + } + if !sort.to_string().is_empty() { + query_args.push(("sort".to_string(), sort.to_string())); + } + if !state.to_string().is_empty() { + query_args.push(("state".to_string(), state.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + let url = self.client.url( + &format!( + "/repos/{}/{}/security-advisories?{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + query_ + ), + None, + ); + self.client + .get_all_pages( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a repository security advisory. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/security-advisories` endpoint. + * + * Creates a new repository security advisory. + * + * In order to create a draft repository security advisory, the authenticated user must be a security manager or administrator of that repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:write` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_repository_advisory( + &self, + owner: &str, + repo: &str, + body: &crate::types::RepositoryAdvisoryCreate, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/security-advisories", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Privately report a security vulnerability. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/security-advisories/reports` endpoint. + * + * Report a security vulnerability to the maintainers of the repository. + * See "[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)" for more information about private vulnerability reporting. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + */ + pub async fn create_private_vulnerability_report( + &self, + owner: &str, + repo: &str, + body: &crate::types::PrivateVulnerabilityReportCreate, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/security-advisories/reports", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Get a repository security advisory. + * + * This function performs a `GET` to the `/repos/{owner}/{repo}/security-advisories/{ghsa_id}` endpoint. + * + * Get a repository security advisory using its GitHub Security Advisory (GHSA) identifier. + * + * Anyone can access any published security advisory on a public repository. + * + * The authenticated user can access an unpublished security advisory from a repository if they are a security manager or administrator of that repository, or if they are a + * collaborator on the security advisory. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:read` scope to to get a published security advisory in a private repository, or any unpublished security advisory that the authenticated user has access to. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ghsa_id: &str` -- The GHSA (GitHub Security Advisory) identifier of the advisory. + */ + pub async fn get_repository_advisory( + &self, + owner: &str, + repo: &str, + ghsa_id: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/security-advisories/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ghsa_id.to_string()), + ), + None, + ); + self.client + .get( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Update a repository security advisory. + * + * This function performs a `PATCH` to the `/repos/{owner}/{repo}/security-advisories/{ghsa_id}` endpoint. + * + * Update a repository security advisory using its GitHub Security Advisory (GHSA) identifier. + * + * In order to update any security advisory, the authenticated user must be a security manager or administrator of that repository, + * or a collaborator on the repository security advisory. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:write` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ghsa_id: &str` -- The GHSA (GitHub Security Advisory) identifier of the advisory. + */ + pub async fn update_repository_advisory( + &self, + owner: &str, + repo: &str, + ghsa_id: &str, + body: &crate::types::RepositoryAdvisoryUpdate, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/security-advisories/{}", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ghsa_id.to_string()), + ), + None, + ); + self.client + .patch( + &url, + crate::Message { + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), + }, + ) + .await + } + /** + * Request a CVE for a repository security advisory. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/security-advisories/{ghsa_id}/cve` endpoint. + * + * If you want a CVE identification number for the security vulnerability in your project, and don't already have one, you can request a CVE identification number from GitHub. For more information see "[Requesting a CVE identification number](https://docs.github.com/code-security/security-advisories/repository-security-advisories/publishing-a-repository-security-advisory#requesting-a-cve-identification-number-optional)." + * + * You may request a CVE for public repositories, but cannot do so for private repositories. + * + * In order to request a CVE for a repository security advisory, the authenticated user must be a security manager or administrator of that repository. + * + * OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:write` scope to use this endpoint. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ghsa_id: &str` -- The GHSA (GitHub Security Advisory) identifier of the advisory. + */ + pub async fn create_repository_advisory_cve_request( + &self, + owner: &str, + repo: &str, + ghsa_id: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/security-advisories/{}/cve", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ghsa_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } + /** + * Create a temporary private fork. + * + * This function performs a `POST` to the `/repos/{owner}/{repo}/security-advisories/{ghsa_id}/forks` endpoint. + * + * Create a temporary private fork to collaborate on fixing a security vulnerability in your repository. + * + * > [!NOTE] + * > Forking a repository happens asynchronously. You may have to wait up to 5 minutes before you can access the fork. + * + * FROM: + * + * **Parameters:** + * + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. + * * `ghsa_id: &str` -- The GHSA (GitHub Security Advisory) identifier of the advisory. + */ + pub async fn create_fork( + &self, + owner: &str, + repo: &str, + ghsa_id: &str, + ) -> ClientResult> { + let url = self.client.url( + &format!( + "/repos/{}/{}/security-advisories/{}/forks", + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), + crate::progenitor_support::encode_path(&ghsa_id.to_string()), + ), + None, + ); + self.client + .post( + &url, + crate::Message { + body: None, + content_type: None, + }, + ) + .await + } +} diff --git a/github/src/teams.rs b/github/src/teams.rs index 5bfe8ac8..fcfaf964 100644 --- a/github/src/teams.rs +++ b/github/src/teams.rs @@ -11,57 +11,6 @@ impl Teams { Teams { client } } - /** - * List IdP groups for an organization. - * - * This function performs a `GET` to the `/orgs/{org}/team-sync/groups` endpoint. - * - * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. - * - * List IdP groups available in an organization. You can limit your page results using the `per_page` parameter. GitHub generates a url-encoded `page` token using a cursor value for where the next page begins. For more information on cursor pagination, see "[Offset and Cursor Pagination explained](https://dev.to/jackmarchant/offset-and-cursor-pagination-explained-b89)." - * - * The `per_page` parameter provides pagination for a list of IdP groups the authenticated user can access in an organization. For example, if the user `octocat` wants to see two groups per page in `octo-org` via cURL, it would look like this: - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: &str` -- Page token. - */ - pub async fn list_idp_groups_for_org( - &self, - org: &str, - per_page: i64, - page: &str, - ) -> ClientResult> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !page.is_empty() { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/orgs/{}/team-sync/groups?{}", - crate::progenitor_support::encode_path(org), - query_ - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } /** * List teams. * @@ -69,13 +18,13 @@ impl Teams { * * Lists all teams in an organization that are visible to the authenticated user. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list( &self, @@ -94,7 +43,7 @@ impl Teams { let url = self.client.url( &format!( "/orgs/{}/teams?{}", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), query_ ), None, @@ -118,7 +67,7 @@ impl Teams { * * Lists all teams in an organization that are visible to the authenticated user. * - * FROM: + * FROM: */ pub async fn list_all( &self, @@ -127,7 +76,7 @@ impl Teams { let url = self.client.url( &format!( "/orgs/{}/teams", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -146,15 +95,15 @@ impl Teams { * * This function performs a `POST` to the `/orgs/{org}/teams` endpoint. * - * To create a team, the authenticated user must be a member or owner of `{org}`. By default, organization members can create teams. Organization owners can limit team creation to organization owners. For more information, see "[Setting team creation permissions](https://help.github.com/en/articles/setting-team-creation-permissions-in-your-organization)." + * To create a team, the authenticated user must be a member or owner of `{org}`. By default, organization members can create teams. Organization owners can limit team creation to organization owners. For more information, see "[Setting team creation permissions](https://docs.github.com/articles/setting-team-creation-permissions-in-your-organization)." * - * When you create a new team, you automatically become a team maintainer without explicitly adding yourself to the optional array of `maintainers`. For more information, see "[About teams](https://help.github.com/en/github/setting-up-and-managing-organizations-and-teams/about-teams)". + * When you create a new team, you automatically become a team maintainer without explicitly adding yourself to the optional array of `maintainers`. For more information, see "[About teams](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/about-teams)". * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` + * * `org: &str` -- The organization name. The name is not case sensitive. */ pub async fn create( &self, @@ -164,7 +113,7 @@ impl Teams { let url = self.client.url( &format!( "/orgs/{}/teams", - crate::progenitor_support::encode_path(org), + crate::progenitor_support::encode_path(&org.to_string()), ), None, ); @@ -183,16 +132,17 @@ impl Teams { * * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}` endpoint. * - * Gets a team using the team's `slug`. GitHub generates the `slug` from the team `name`. + * Gets a team using the team's `slug`. To create the `slug`, GitHub replaces special characters in the `name` string, changes all words to lowercase, and replaces spaces with a `-` separator. For example, `"My TEam Näme"` would become `my-team-name`. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}`. + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}`. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. */ pub async fn get_by_name( &self, @@ -202,8 +152,8 @@ impl Teams { let url = self.client.url( &format!( "/orgs/{}/teams/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), ), None, ); @@ -226,14 +176,15 @@ impl Teams { * * If you are an organization owner, deleting a parent team will delete all of its child teams as well. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}`. + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}`. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. */ pub async fn delete_in_org( &self, @@ -243,8 +194,8 @@ impl Teams { let url = self.client.url( &format!( "/orgs/{}/teams/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), ), None, ); @@ -265,14 +216,15 @@ impl Teams { * * To edit a team, the authenticated user must either be an organization owner or a team maintainer. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `PATCH /organizations/{org_id}/team/{team_id}`. + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `PATCH /organizations/{org_id}/team/{team_id}`. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. */ pub async fn update_in_org( &self, @@ -283,8 +235,8 @@ impl Teams { let url = self.client.url( &format!( "/orgs/{}/teams/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), ), None, ); @@ -299,55 +251,44 @@ impl Teams { .await } /** - * List discussions. + * List pending team invitations. * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/discussions` endpoint. + * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/invitations` endpoint. * - * List all discussions on a team's page. OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, `hiring_manager`, or `reinstate`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions`. + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/invitations`. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - * * `pinned: &str` -- Pinned discussions only filter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_discussions_in_org( + pub async fn list_pending_invitations_in_org( &self, org: &str, team_slug: &str, - direction: crate::types::Order, per_page: i64, page: i64, - pinned: &str, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if !direction.to_string().is_empty() { - query_args.push(("direction".to_string(), direction.to_string())); - } if page > 0 { query_args.push(("page".to_string(), page.to_string())); } if per_page > 0 { query_args.push(("per_page".to_string(), per_page.to_string())); } - if !pinned.is_empty() { - query_args.push(("pinned".to_string(), pinned.to_string())); - } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/teams/{}/discussions?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), + "/orgs/{}/teams/{}/invitations?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), query_ ), None, @@ -363,39 +304,29 @@ impl Teams { .await } /** - * List discussions. + * List pending team invitations. * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/discussions` endpoint. + * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/invitations` endpoint. * - * As opposed to `list_discussions_in_org`, this function returns all the pages of the request at once. + * As opposed to `list_pending_invitations_in_org`, this function returns all the pages of the request at once. * - * List all discussions on a team's page. OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, `hiring_manager`, or `reinstate`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions`. + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/invitations`. * - * FROM: + * FROM: */ - pub async fn list_all_discussions_in_org( + pub async fn list_all_pending_invitations_in_org( &self, org: &str, team_slug: &str, - direction: crate::types::Order, - pinned: &str, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !direction.to_string().is_empty() { - query_args.push(("direction".to_string(), direction.to_string())); - } - if !pinned.is_empty() { - query_args.push(("pinned".to_string(), pinned.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + ) -> ClientResult>> { let url = self.client.url( &format!( - "/orgs/{}/teams/{}/discussions?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - query_ + "/orgs/{}/teams/{}/invitations", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), ), None, ); @@ -410,81 +341,97 @@ impl Teams { .await } /** - * Create a discussion. - * - * This function performs a `POST` to the `/orgs/{org}/teams/{team_slug}/discussions` endpoint. + * List team members. * - * Creates a new discussion post on a team's page. OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/members` endpoint. * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * Team members will include the members of child teams. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `POST /organizations/{org_id}/team/{team_id}/discussions`. + * To list members in a team, the team must be visible to the authenticated user. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `role: crate::types::TeamsListMembersInOrgRole` -- Filters members returned by their role in the team. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn create_discussion_in_org( + pub async fn list_members_in_org( &self, org: &str, team_slug: &str, - body: &crate::types::TeamsCreateDiscussionInOrgRequest, - ) -> ClientResult> { + role: crate::types::TeamsListMembersInOrgRole, + per_page: i64, + page: i64, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } + if !role.to_string().is_empty() { + query_args.push(("role".to_string(), role.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/teams/{}/discussions", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), + "/orgs/{}/teams/{}/members?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + query_ ), None, ); self.client - .post( + .get( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get a discussion. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}` endpoint. + * List team members. * - * Get a specific discussion on a team's page. OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/members` endpoint. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}`. + * As opposed to `list_members_in_org`, this function returns all the pages of the request at once. * - * FROM: + * Team members will include the members of child teams. * - * **Parameters:** + * To list members in a team, the team must be visible to the authenticated user. * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` + * FROM: */ - pub async fn get_discussion_in_org( + pub async fn list_all_members_in_org( &self, org: &str, team_slug: &str, - discussion_number: i64, - ) -> ClientResult> { + role: crate::types::TeamsListMembersInOrgRole, + ) -> ClientResult>> { + let mut query_args: Vec<(String, String)> = Default::default(); + if !role.to_string().is_empty() { + query_args.push(("role".to_string(), role.to_string())); + } + let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/teams/{}/discussions/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), + "/orgs/{}/teams/{}/members?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + query_ ), None, ); self.client - .get( + .get_all_pages( &url, crate::Message { body: None, @@ -494,39 +441,47 @@ impl Teams { .await } /** - * Delete a discussion. + * Get team membership for a user. + * + * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/memberships/{username}` endpoint. + * + * Team members will include the members of child teams. + * + * To get a user's membership with a team, the team must be visible to the authenticated user. * - * This function performs a `DELETE` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}` endpoint. + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/memberships/{username}`. * - * Delete a discussion from a team's page. OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * > [!NOTE] + * > The response contains the `state` of the membership and the member's `role`. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}`. + * The `role` for organization owners is set to `maintainer`. For more information about `maintainer` roles, see [Create a team](https://docs.github.com/rest/teams/teams#create-a-team). * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn delete_discussion_in_org( + pub async fn get_membership_for_user_in_org( &self, org: &str, team_slug: &str, - discussion_number: i64, - ) -> ClientResult> { + username: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/teams/{}/discussions/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), + "/orgs/{}/teams/{}/memberships/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); self.client - .delete( + .get( &url, crate::Message { body: None, @@ -536,40 +491,50 @@ impl Teams { .await } /** - * Update a discussion. + * Add or update team membership for a user. + * + * This function performs a `PUT` to the `/orgs/{org}/teams/{team_slug}/memberships/{username}` endpoint. + * + * Adds an organization member to a team. An authenticated organization owner or team maintainer can add organization members to a team. + * + * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * This function performs a `PATCH` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}` endpoint. + * > [!NOTE] + * > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)." * - * Edits the title and body text of a discussion post. Only the parameters you provide are updated. OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * An organization owner can add someone who is not part of the team's organization to a team. When an organization owner adds someone to a team who is not an organization member, this endpoint will send an invitation to the person via email. This newly-created membership will be in the "pending" state until the person accepts the invitation, at which point the membership will transition to the "active" state and the user will be added as a member of the team. + * + * If the user is already a member of the team, this endpoint will update the role of the team member's role. To update the membership of a team member, the authenticated user must be an organization owner or a team maintainer. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `PATCH /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}`. + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `PUT /organizations/{org_id}/team/{team_id}/memberships/{username}`. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn update_discussion_in_org( + pub async fn add_or_update_membership_for_user_in_org( &self, org: &str, team_slug: &str, - discussion_number: i64, - body: &crate::types::TeamsUpdateDiscussionInOrgRequest, - ) -> ClientResult> { + username: &str, + body: &crate::types::TeamsAddUpdateMembershipUserInOrgRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/teams/{}/discussions/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), + "/orgs/{}/teams/{}/memberships/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); self.client - .patch( + .put( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), @@ -579,59 +544,45 @@ impl Teams { .await } /** - * List discussion comments. + * Remove team membership for a user. + * + * This function performs a `DELETE` to the `/orgs/{org}/teams/{team_slug}/memberships/{username}` endpoint. + * + * To remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. Removing team membership does not delete the user, it just removes their membership from the team. * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments` endpoint. + * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * - * List all comments on a team discussion. OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * > [!NOTE] + * > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)." * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments`. + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/memberships/{username}`. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `username: &str` -- The handle for the GitHub user account. */ - pub async fn list_discussion_comments_in_org( + pub async fn remove_membership_for_user_in_org( &self, org: &str, team_slug: &str, - discussion_number: i64, - direction: crate::types::Order, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !direction.to_string().is_empty() { - query_args.push(("direction".to_string(), direction.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); + username: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/teams/{}/discussions/{}/comments?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - query_ + "/orgs/{}/teams/{}/memberships/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); self.client - .get( + .delete( &url, crate::Message { body: None, @@ -641,42 +592,50 @@ impl Teams { .await } /** - * List discussion comments. + * List team repositories. + * + * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/repos` endpoint. * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments` endpoint. + * Lists a team's repositories visible to the authenticated user. * - * As opposed to `list_discussion_comments_in_org`, this function returns all the pages of the request at once. + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/repos`. * - * List all comments on a team discussion. OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * FROM: * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments`. + * **Parameters:** * - * FROM: + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_all_discussion_comments_in_org( + pub async fn list_repos_in_org( &self, org: &str, team_slug: &str, - discussion_number: i64, - direction: crate::types::Order, - ) -> ClientResult>> { + per_page: i64, + page: i64, + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); - if !direction.to_string().is_empty() { - query_args.push(("direction".to_string(), direction.to_string())); + if page > 0 { + query_args.push(("page".to_string(), page.to_string())); + } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/orgs/{}/teams/{}/discussions/{}/comments?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), + "/orgs/{}/teams/{}/repos?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), query_ ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -686,82 +645,81 @@ impl Teams { .await } /** - * Create a discussion comment. - * - * This function performs a `POST` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments` endpoint. - * - * Creates a new comment on a team discussion. OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * List team repositories. * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/repos` endpoint. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `POST /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments`. + * As opposed to `list_repos_in_org`, this function returns all the pages of the request at once. * - * FROM: + * Lists a team's repositories visible to the authenticated user. * - * **Parameters:** + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/repos`. * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` + * FROM: */ - pub async fn create_discussion_comment_in_org( + pub async fn list_all_repos_in_org( &self, org: &str, team_slug: &str, - discussion_number: i64, - body: &crate::types::PullsUpdateReviewRequest, - ) -> ClientResult> { + ) -> ClientResult>> { let url = self.client.url( &format!( - "/orgs/{}/teams/{}/discussions/{}/comments", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), + "/orgs/{}/teams/{}/repos", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), ), None, ); self.client - .post( + .get_all_pages( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get a discussion comment. + * Check team permissions for a repository. + * + * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}` endpoint. + * + * Checks whether a team has `admin`, `push`, `maintain`, `triage`, or `pull` permission for a repository. Repositories inherited through a parent team will also be checked. + * + * You can also get information about the specified repository, including what permissions the team grants on it, by passing the following custom [media type](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types/) via the `application/vnd.github.v3.repository+json` accept header. * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}` endpoint. + * If a team doesn't have permission for the repository, you will receive a `404 Not Found` response status. * - * Get a specific comment on a team discussion. OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * If the repository is private, you must have at least `read` permission for that repository, and your token must have the `repo` or `admin:org` scope. Otherwise, you will receive a `404 Not Found` response status. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments/{comment_number}`. + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}`. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` - * * `comment_number: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn get_discussion_comment_in_org( + pub async fn check_permissions_for_repo_in_org( &self, org: &str, team_slug: &str, - discussion_number: i64, - comment_number: i64, - ) -> ClientResult> { + owner: &str, + repo: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/teams/{}/discussions/{}/comments/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), + "/orgs/{}/teams/{}/repos/{}/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -776,1505 +734,145 @@ impl Teams { .await } /** - * Delete a discussion comment. + * Add or update team repository permissions. + * + * This function performs a `PUT` to the `/orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}` endpoint. * - * This function performs a `DELETE` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}` endpoint. + * To add a repository to a team or update the team's permission on a repository, the authenticated user must have admin access to the repository, and must be able to see the team. The repository must be owned by the organization, or a direct fork of a repository owned by the organization. You will get a `422 Unprocessable Entity` status if you attempt to add a repository to a team that is not owned by the organization. Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)." * - * Deletes a comment on a team discussion. OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `PUT /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}`. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments/{comment_number}`. + * For more information about the permission levels, see "[Repository permission levels for an organization](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization#permission-levels-for-repositories-owned-by-an-organization)". * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` - * * `comment_number: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn delete_discussion_comment_in_org( + pub async fn add_or_update_repo_permissions_in_org( &self, org: &str, team_slug: &str, - discussion_number: i64, - comment_number: i64, + owner: &str, + repo: &str, + body: &crate::types::ReposAddCollaboratorRequest, ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/teams/{}/discussions/{}/comments/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), + "/orgs/{}/teams/{}/repos/{}/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .delete( + .put( &url, crate::Message { - body: None, - content_type: None, + body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), + content_type: Some("application/json".to_string()), }, ) .await } /** - * Update a discussion comment. + * Remove a repository from a team. * - * This function performs a `PATCH` to the `/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}` endpoint. + * This function performs a `DELETE` to the `/orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}` endpoint. * - * Edits the body text of a discussion comment. OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * If the authenticated user is an organization owner or a team maintainer, they can remove any repositories from the team. To remove a repository from a team as an organization member, the authenticated user must have admin access to the repository and must be able to see the team. This does not delete the repository, it just removes it from the team. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `PATCH /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments/{comment_number}`. + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}`. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `discussion_number: i64` - * * `comment_number: i64` + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ - pub async fn update_discussion_comment_in_org( + pub async fn remove_repo_in_org( &self, org: &str, team_slug: &str, - discussion_number: i64, - comment_number: i64, - body: &crate::types::PullsUpdateReviewRequest, - ) -> ClientResult> { + owner: &str, + repo: &str, + ) -> ClientResult> { let url = self.client.url( &format!( - "/orgs/{}/teams/{}/discussions/{}/comments/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), + "/orgs/{}/teams/{}/repos/{}/{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); self.client - .patch( + .delete( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * List pending team invitations. + * List child teams. * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/invitations` endpoint. + * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/teams` endpoint. * - * The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, `hiring_manager`, or `reinstate`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`. + * Lists the child teams of the team specified by `{team_slug}`. * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/invitations`. + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/teams`. * - * FROM: + * FROM: * * **Parameters:** * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `org: &str` -- The organization name. The name is not case sensitive. + * * `team_slug: &str` -- The slug of the team name. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ - pub async fn list_pending_invitations_in_org( + pub async fn list_child_in_org( &self, org: &str, team_slug: &str, per_page: i64, page: i64, - ) -> ClientResult>> { + ) -> ClientResult>> { let mut query_args: Vec<(String, String)> = Default::default(); if page > 0 { query_args.push(("page".to_string(), page.to_string())); } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/invitations?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - query_ - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List pending team invitations. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/invitations` endpoint. - * - * As opposed to `list_pending_invitations_in_org`, this function returns all the pages of the request at once. - * - * The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, `hiring_manager`, or `reinstate`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/invitations`. - * - * FROM: - */ - pub async fn list_all_pending_invitations_in_org( - &self, - org: &str, - team_slug: &str, - ) -> ClientResult>> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/invitations", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - ), - None, - ); - self.client - .get_all_pages( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List team members. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/members` endpoint. - * - * Team members will include the members of child teams. - * - * To list members in a team, the team must be visible to the authenticated user. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `role: crate::types::TeamsListMembersInOrgRole` -- Filters members returned by their role in the team. Can be one of: - * \\* `member` - normal members of the team. - * \\* `maintainer` - team maintainers. - * \\* `all` - all members of the team. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - */ - pub async fn list_members_in_org( - &self, - org: &str, - team_slug: &str, - role: crate::types::TeamsListMembersInOrgRole, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - if !role.to_string().is_empty() { - query_args.push(("role".to_string(), role.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/members?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - query_ - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List team members. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/members` endpoint. - * - * As opposed to `list_members_in_org`, this function returns all the pages of the request at once. - * - * Team members will include the members of child teams. - * - * To list members in a team, the team must be visible to the authenticated user. - * - * FROM: - */ - pub async fn list_all_members_in_org( - &self, - org: &str, - team_slug: &str, - role: crate::types::TeamsListMembersInOrgRole, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !role.to_string().is_empty() { - query_args.push(("role".to_string(), role.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/members?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - query_ - ), - None, - ); - self.client - .get_all_pages( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Get team membership for a user. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/memberships/{username}` endpoint. - * - * Team members will include the members of child teams. - * - * To get a user's membership with a team, the team must be visible to the authenticated user. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/memberships/{username}`. - * - * **Note:** - * The response contains the `state` of the membership and the member's `role`. - * - * The `role` for organization owners is set to `maintainer`. For more information about `maintainer` roles, see see [Create a team](https://docs.github.com/rest/reference/teams#create-a-team). - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `username: &str` - */ - pub async fn get_membership_for_user_in_org( - &self, - org: &str, - team_slug: &str, - username: &str, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/memberships/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(username), - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Add or update team membership for a user. - * - * This function performs a `PUT` to the `/orgs/{org}/teams/{team_slug}/memberships/{username}` endpoint. - * - * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. - * - * Adds an organization member to a team. An authenticated organization owner or team maintainer can add organization members to a team. - * - * **Note:** When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://help.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)." - * - * An organization owner can add someone who is not part of the team's organization to a team. When an organization owner adds someone to a team who is not an organization member, this endpoint will send an invitation to the person via email. This newly-created membership will be in the "pending" state until the person accepts the invitation, at which point the membership will transition to the "active" state and the user will be added as a member of the team. - * - * If the user is already a member of the team, this endpoint will update the role of the team member's role. To update the membership of a team member, the authenticated user must be an organization owner or a team maintainer. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `PUT /organizations/{org_id}/team/{team_id}/memberships/{username}`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `username: &str` - */ - pub async fn add_or_update_membership_for_user_in_org( - &self, - org: &str, - team_slug: &str, - username: &str, - body: &crate::types::TeamsAddUpdateMembershipUserInOrgRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/memberships/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(username), - ), - None, - ); - self.client - .put( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } - /** - * Remove team membership for a user. - * - * This function performs a `DELETE` to the `/orgs/{org}/teams/{team_slug}/memberships/{username}` endpoint. - * - * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. - * - * To remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. Removing team membership does not delete the user, it just removes their membership from the team. - * - * **Note:** When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://help.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)." - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/memberships/{username}`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `username: &str` - */ - pub async fn remove_membership_for_user_in_org( - &self, - org: &str, - team_slug: &str, - username: &str, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/memberships/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(username), - ), - None, - ); - self.client - .delete( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List team projects. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/projects` endpoint. - * - * Lists the organization projects for a team. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/projects`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - */ - pub async fn list_projects_in_org( - &self, - org: &str, - team_slug: &str, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/projects?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - query_ - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List team projects. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/projects` endpoint. - * - * As opposed to `list_projects_in_org`, this function returns all the pages of the request at once. - * - * Lists the organization projects for a team. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/projects`. - * - * FROM: - */ - pub async fn list_all_projects_in_org( - &self, - org: &str, - team_slug: &str, - ) -> ClientResult>> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/projects", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - ), - None, - ); - self.client - .get_all_pages( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Check team permissions for a project. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/projects/{project_id}` endpoint. - * - * Checks whether a team has `read`, `write`, or `admin` permissions for an organization project. The response includes projects inherited from a parent team. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/projects/{project_id}`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `project_id: i64` - */ - pub async fn check_permissions_for_project_in_org( - &self, - org: &str, - team_slug: &str, - project_id: i64, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/projects/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&project_id.to_string()), - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Add or update team project permissions. - * - * This function performs a `PUT` to the `/orgs/{org}/teams/{team_slug}/projects/{project_id}` endpoint. - * - * Adds an organization project to a team. To add a project to a team or update the team's permission on a project, the authenticated user must have `admin` permissions for the project. The project and team must be part of the same organization. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `PUT /organizations/{org_id}/team/{team_id}/projects/{project_id}`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `project_id: i64` - */ - pub async fn add_or_update_project_permissions_in_org( - &self, - org: &str, - team_slug: &str, - project_id: i64, - body: &crate::types::ProjectsAddCollaboratorRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/projects/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&project_id.to_string()), - ), - None, - ); - self.client - .put( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } - /** - * Remove a project from a team. - * - * This function performs a `DELETE` to the `/orgs/{org}/teams/{team_slug}/projects/{project_id}` endpoint. - * - * Removes an organization project from a team. An organization owner or a team maintainer can remove any project from the team. To remove a project from a team as an organization member, the authenticated user must have `read` access to both the team and project, or `admin` access to the team or project. This endpoint removes the project from the team, but does not delete the project. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/projects/{project_id}`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `project_id: i64` - */ - pub async fn remove_project_in_org( - &self, - org: &str, - team_slug: &str, - project_id: i64, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/projects/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(&project_id.to_string()), - ), - None, - ); - self.client - .delete( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List team repositories. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/repos` endpoint. - * - * Lists a team's repositories visible to the authenticated user. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/repos`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - */ - pub async fn list_repos_in_org( - &self, - org: &str, - team_slug: &str, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/repos?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - query_ - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List team repositories. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/repos` endpoint. - * - * As opposed to `list_repos_in_org`, this function returns all the pages of the request at once. - * - * Lists a team's repositories visible to the authenticated user. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/repos`. - * - * FROM: - */ - pub async fn list_all_repos_in_org( - &self, - org: &str, - team_slug: &str, - ) -> ClientResult>> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/repos", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - ), - None, - ); - self.client - .get_all_pages( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Check team permissions for a repository. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}` endpoint. - * - * Checks whether a team has `admin`, `push`, `maintain`, `triage`, or `pull` permission for a repository. Repositories inherited through a parent team will also be checked. - * - * You can also get information about the specified repository, including what permissions the team grants on it, by passing the following custom [media type](https://docs.github.com/rest/overview/media-types/) via the `application/vnd.github.v3.repository+json` accept header. - * - * If a team doesn't have permission for the repository, you will receive a `404 Not Found` response status. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `owner: &str` - * * `repo: &str` - */ - pub async fn check_permissions_for_repo_in_org( - &self, - org: &str, - team_slug: &str, - owner: &str, - repo: &str, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/repos/{}/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Add or update team repository permissions. - * - * This function performs a `PUT` to the `/orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}` endpoint. - * - * To add a repository to a team or update the team's permission on a repository, the authenticated user must have admin access to the repository, and must be able to see the team. The repository must be owned by the organization, or a direct fork of a repository owned by the organization. You will get a `422 Unprocessable Entity` status if you attempt to add a repository to a team that is not owned by the organization. Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://docs.github.com/rest/overview/resources-in-the-rest-api#http-verbs)." - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `PUT /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}`. - * - * For more information about the permission levels, see "[Repository permission levels for an organization](https://help.github.com/en/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization#permission-levels-for-repositories-owned-by-an-organization)". - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `owner: &str` - * * `repo: &str` - */ - pub async fn add_or_update_repo_permissions_in_org( - &self, - org: &str, - team_slug: &str, - owner: &str, - repo: &str, - body: &crate::types::TeamsAddUpdateRepoPermissionsInOrgRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/repos/{}/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - ), - None, - ); - self.client - .put( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } - /** - * Remove a repository from a team. - * - * This function performs a `DELETE` to the `/orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}` endpoint. - * - * If the authenticated user is an organization owner or a team maintainer, they can remove any repositories from the team. To remove a repository from a team as an organization member, the authenticated user must have admin access to the repository and must be able to see the team. This does not delete the repository, it just removes it from the team. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `owner: &str` - * * `repo: &str` - */ - pub async fn remove_repo_in_org( - &self, - org: &str, - team_slug: &str, - owner: &str, - repo: &str, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/repos/{}/{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), - ), - None, - ); - self.client - .delete( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List IdP groups for a team. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/team-sync/group-mappings` endpoint. - * - * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. - * - * List IdP groups connected to a team on GitHub. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/team-sync/group-mappings`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - */ - pub async fn list_idp_groups_in_org( - &self, - org: &str, - team_slug: &str, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/team-sync/group-mappings", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Create or update IdP group connections. - * - * This function performs a `PATCH` to the `/orgs/{org}/teams/{team_slug}/team-sync/group-mappings` endpoint. - * - * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. - * - * Creates, updates, or removes a connection between a team and an IdP group. When adding groups to a team, you must include all new and existing groups to avoid replacing existing groups with the new ones. Specifying an empty `groups` array will remove all connections for a team. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `PATCH /organizations/{org_id}/team/{team_id}/team-sync/group-mappings`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - */ - pub async fn create_or_update_idp_group_connections_in_org( - &self, - org: &str, - team_slug: &str, - body: &crate::types::TeamsCreateUpdateIdpGroupConnectionsInOrgRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/team-sync/group-mappings", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - ), - None, - ); - self.client - .patch( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } - /** - * List child teams. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/teams` endpoint. - * - * Lists the child teams of the team specified by `{team_slug}`. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/teams`. - * - * FROM: - * - * **Parameters:** - * - * * `org: &str` - * * `team_slug: &str` -- team_slug parameter. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - */ - pub async fn list_child_in_org( - &self, - org: &str, - team_slug: &str, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/teams?{}", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - query_ - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List child teams. - * - * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/teams` endpoint. - * - * As opposed to `list_child_in_org`, this function returns all the pages of the request at once. - * - * Lists the child teams of the team specified by `{team_slug}`. - * - * **Note:** You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/teams`. - * - * FROM: - */ - pub async fn list_all_child_in_org( - &self, - org: &str, - team_slug: &str, - ) -> ClientResult>> { - let url = self.client.url( - &format!( - "/orgs/{}/teams/{}/teams", - crate::progenitor_support::encode_path(org), - crate::progenitor_support::encode_path(team_slug), - ), - None, - ); - self.client - .get_all_pages( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Get a team (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the [Get a team by name](https://docs.github.com/rest/reference/teams#get-a-team-by-name) endpoint. - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - */ - pub async fn get_legacy( - &self, - team_id: i64, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Delete a team (Legacy). - * - * This function performs a `DELETE` to the `/teams/{team_id}` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Delete a team](https://docs.github.com/rest/reference/teams#delete-a-team) endpoint. - * - * To delete a team, the authenticated user must be an organization owner or team maintainer. - * - * If you are an organization owner, deleting a parent team will delete all of its child teams as well. - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - */ - pub async fn delete_legacy(&self, team_id: i64) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - ), - None, - ); - self.client - .delete( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Update a team (Legacy). - * - * This function performs a `PATCH` to the `/teams/{team_id}` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Update a team](https://docs.github.com/rest/reference/teams#update-a-team) endpoint. - * - * To edit a team, the authenticated user must either be an organization owner or a team maintainer. - * - * **Note:** With nested teams, the `privacy` for parent teams cannot be `secret`. - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - */ - pub async fn update_legacy( - &self, - team_id: i64, - body: &crate::types::TeamsUpdateInOrgRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - ), - None, - ); - self.client - .patch( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } - /** - * List discussions (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/discussions` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List discussions`](https://docs.github.com/rest/reference/teams#list-discussions) endpoint. - * - * List all discussions on a team's page. OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - */ - pub async fn list_discussions_legacy( - &self, - team_id: i64, - direction: crate::types::Order, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !direction.to_string().is_empty() { - query_args.push(("direction".to_string(), direction.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/teams/{}/discussions?{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - query_ - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List discussions (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/discussions` endpoint. - * - * As opposed to `list_discussions_legacy`, this function returns all the pages of the request at once. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List discussions`](https://docs.github.com/rest/reference/teams#list-discussions) endpoint. - * - * List all discussions on a team's page. OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * FROM: - */ - pub async fn list_all_discussions_legacy( - &self, - team_id: i64, - direction: crate::types::Order, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !direction.to_string().is_empty() { - query_args.push(("direction".to_string(), direction.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/teams/{}/discussions?{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - query_ - ), - None, - ); - self.client - .get_all_pages( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Create a discussion (Legacy). - * - * This function performs a `POST` to the `/teams/{team_id}/discussions` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`Create a discussion`](https://docs.github.com/rest/reference/teams#create-a-discussion) endpoint. - * - * Creates a new discussion post on a team's page. OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - */ - pub async fn create_discussion_legacy( - &self, - team_id: i64, - body: &crate::types::TeamsCreateDiscussionInOrgRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}/discussions", - crate::progenitor_support::encode_path(&team_id.to_string()), - ), - None, - ); - self.client - .post( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } - /** - * Get a discussion (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/discussions/{discussion_number}` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Get a discussion](https://docs.github.com/rest/reference/teams#get-a-discussion) endpoint. - * - * Get a specific discussion on a team's page. OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - * * `discussion_number: i64` - */ - pub async fn get_discussion_legacy( - &self, - team_id: i64, - discussion_number: i64, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}/discussions/{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Delete a discussion (Legacy). - * - * This function performs a `DELETE` to the `/teams/{team_id}/discussions/{discussion_number}` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`Delete a discussion`](https://docs.github.com/rest/reference/teams#delete-a-discussion) endpoint. - * - * Delete a discussion from a team's page. OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - * * `discussion_number: i64` - */ - pub async fn delete_discussion_legacy( - &self, - team_id: i64, - discussion_number: i64, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}/discussions/{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - ), - None, - ); - self.client - .delete( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Update a discussion (Legacy). - * - * This function performs a `PATCH` to the `/teams/{team_id}/discussions/{discussion_number}` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Update a discussion](https://docs.github.com/rest/reference/teams#update-a-discussion) endpoint. - * - * Edits the title and body text of a discussion post. Only the parameters you provide are updated. OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - * * `discussion_number: i64` - */ - pub async fn update_discussion_legacy( - &self, - team_id: i64, - discussion_number: i64, - body: &crate::types::TeamsUpdateDiscussionInOrgRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}/discussions/{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - ), - None, - ); - self.client - .patch( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } - /** - * List discussion comments (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/discussions/{discussion_number}/comments` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [List discussion comments](https://docs.github.com/rest/reference/teams#list-discussion-comments) endpoint. - * - * List all comments on a team discussion. OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - * * `discussion_number: i64` - * * `direction: crate::types::Order` -- The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. - * - * The default is `desc`. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - */ - pub async fn list_discussion_comments_legacy( - &self, - team_id: i64, - discussion_number: i64, - direction: crate::types::Order, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !direction.to_string().is_empty() { - query_args.push(("direction".to_string(), direction.to_string())); - } - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/teams/{}/discussions/{}/comments?{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - query_ - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List discussion comments (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/discussions/{discussion_number}/comments` endpoint. - * - * As opposed to `list_discussion_comments_legacy`, this function returns all the pages of the request at once. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [List discussion comments](https://docs.github.com/rest/reference/teams#list-discussion-comments) endpoint. - * - * List all comments on a team discussion. OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). - * - * FROM: - */ - pub async fn list_all_discussion_comments_legacy( - &self, - team_id: i64, - discussion_number: i64, - direction: crate::types::Order, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if !direction.to_string().is_empty() { - query_args.push(("direction".to_string(), direction.to_string())); - } + if per_page > 0 { + query_args.push(("per_page".to_string(), per_page.to_string())); + } let query_ = serde_urlencoded::to_string(&query_args).unwrap(); let url = self.client.url( &format!( - "/teams/{}/discussions/{}/comments?{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), + "/orgs/{}/teams/{}/teams?{}", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), query_ ), None, ); self.client - .get_all_pages( + .get( &url, crate::Message { body: None, @@ -2284,76 +882,64 @@ impl Teams { .await } /** - * Create a discussion comment (Legacy). - * - * This function performs a `POST` to the `/teams/{team_id}/discussions/{discussion_number}/comments` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Create a discussion comment](https://docs.github.com/rest/reference/teams#create-a-discussion-comment) endpoint. + * List child teams. * - * Creates a new comment on a team discussion. OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * This function performs a `GET` to the `/orgs/{org}/teams/{team_slug}/teams` endpoint. * - * This endpoint triggers [notifications](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. + * As opposed to `list_child_in_org`, this function returns all the pages of the request at once. * - * FROM: + * Lists the child teams of the team specified by `{team_slug}`. * - * **Parameters:** + * > [!NOTE] + * > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/teams`. * - * * `team_id: i64` - * * `discussion_number: i64` + * FROM: */ - pub async fn create_discussion_comment_legacy( + pub async fn list_all_child_in_org( &self, - team_id: i64, - discussion_number: i64, - body: &crate::types::PullsUpdateReviewRequest, - ) -> ClientResult> { + org: &str, + team_slug: &str, + ) -> ClientResult>> { let url = self.client.url( &format!( - "/teams/{}/discussions/{}/comments", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), + "/orgs/{}/teams/{}/teams", + crate::progenitor_support::encode_path(&org.to_string()), + crate::progenitor_support::encode_path(&team_slug.to_string()), ), None, ); self.client - .post( + .get_all_pages( &url, crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), + body: None, + content_type: None, }, ) .await } /** - * Get a discussion comment (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}` endpoint. + * Get a team (Legacy). * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Get a discussion comment](https://docs.github.com/rest/reference/teams#get-a-discussion-comment) endpoint. + * This function performs a `GET` to the `/teams/{team_id}` endpoint. * - * Get a specific comment on a team discussion. OAuth access tokens require the `read:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the [Get a team by name](https://docs.github.com/rest/teams/teams#get-a-team-by-name) endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `discussion_number: i64` - * * `comment_number: i64` + * * `team_id: i64` -- The unique identifier of the team. */ - pub async fn get_discussion_comment_legacy( + pub async fn get_legacy( &self, team_id: i64, - discussion_number: i64, - comment_number: i64, - ) -> ClientResult> { + ) -> ClientResult> { let url = self.client.url( &format!( - "/teams/{}/discussions/{}/comments/{}", + "/teams/{}", crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), ), None, ); @@ -2368,34 +954,28 @@ impl Teams { .await } /** - * Delete a discussion comment (Legacy). + * Delete a team (Legacy). + * + * This function performs a `DELETE` to the `/teams/{team_id}` endpoint. * - * This function performs a `DELETE` to the `/teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}` endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Delete a team](https://docs.github.com/rest/teams/teams#delete-a-team) endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Delete a discussion comment](https://docs.github.com/rest/reference/teams#delete-a-discussion-comment) endpoint. + * To delete a team, the authenticated user must be an organization owner or team maintainer. * - * Deletes a comment on a team discussion. OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * If you are an organization owner, deleting a parent team will delete all of its child teams as well. * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `discussion_number: i64` - * * `comment_number: i64` + * * `team_id: i64` -- The unique identifier of the team. */ - pub async fn delete_discussion_comment_legacy( - &self, - team_id: i64, - discussion_number: i64, - comment_number: i64, - ) -> ClientResult> { + pub async fn delete_legacy(&self, team_id: i64) -> ClientResult> { let url = self.client.url( &format!( - "/teams/{}/discussions/{}/comments/{}", + "/teams/{}", crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), ), None, ); @@ -2410,35 +990,33 @@ impl Teams { .await } /** - * Update a discussion comment (Legacy). + * Update a team (Legacy). * - * This function performs a `PATCH` to the `/teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}` endpoint. + * This function performs a `PATCH` to the `/teams/{team_id}` endpoint. + * + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Update a team](https://docs.github.com/rest/teams/teams#update-a-team) endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Update a discussion comment](https://docs.github.com/rest/reference/teams#update-a-discussion-comment) endpoint. + * To edit a team, the authenticated user must either be an organization owner or a team maintainer. * - * Edits the body text of a discussion comment. OAuth access tokens require the `write:discussion` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/). + * > [!NOTE] + * > With nested teams, the `privacy` for parent teams cannot be `secret`. * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `discussion_number: i64` - * * `comment_number: i64` + * * `team_id: i64` -- The unique identifier of the team. */ - pub async fn update_discussion_comment_legacy( + pub async fn update_legacy( &self, team_id: i64, - discussion_number: i64, - comment_number: i64, - body: &crate::types::PullsUpdateReviewRequest, - ) -> ClientResult> { + body: &crate::types::TeamsUpdateLegacyRequest, + ) -> ClientResult> { let url = self.client.url( &format!( - "/teams/{}/discussions/{}/comments/{}", + "/teams/{}", crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&discussion_number.to_string()), - crate::progenitor_support::encode_path(&comment_number.to_string()), ), None, ); @@ -2457,17 +1035,18 @@ impl Teams { * * This function performs a `GET` to the `/teams/{team_id}/invitations` endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List pending team invitations`](https://docs.github.com/rest/reference/teams#list-pending-team-invitations) endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List pending team invitations`](https://docs.github.com/rest/teams/members#list-pending-team-invitations) endpoint. * * The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, `hiring_manager`, or `reinstate`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`. * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `team_id: i64` -- The unique identifier of the team. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_pending_invitations_legacy( &self, @@ -2508,11 +1087,12 @@ impl Teams { * * As opposed to `list_pending_invitations_legacy`, this function returns all the pages of the request at once. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List pending team invitations`](https://docs.github.com/rest/reference/teams#list-pending-team-invitations) endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List pending team invitations`](https://docs.github.com/rest/teams/members#list-pending-team-invitations) endpoint. * * The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, `hiring_manager`, or `reinstate`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`. * - * FROM: + * FROM: */ pub async fn list_all_pending_invitations_legacy( &self, @@ -2540,21 +1120,19 @@ impl Teams { * * This function performs a `GET` to the `/teams/{team_id}/members` endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List team members`](https://docs.github.com/rest/reference/teams#list-team-members) endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List team members`](https://docs.github.com/rest/teams/members#list-team-members) endpoint. * * Team members will include the members of child teams. * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `role: crate::types::TeamsListMembersInOrgRole` -- Filters members returned by their role in the team. Can be one of: - * \\* `member` - normal members of the team. - * \\* `maintainer` - team maintainers. - * \\* `all` - all members of the team. - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `team_id: i64` -- The unique identifier of the team. + * * `role: crate::types::TeamsListMembersInOrgRole` -- Filters members returned by their role in the team. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_members_legacy( &self, @@ -2599,11 +1177,12 @@ impl Teams { * * As opposed to `list_members_legacy`, this function returns all the pages of the request at once. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List team members`](https://docs.github.com/rest/reference/teams#list-team-members) endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List team members`](https://docs.github.com/rest/teams/members#list-team-members) endpoint. * * Team members will include the members of child teams. * - * FROM: + * FROM: */ pub async fn list_all_members_legacy( &self, @@ -2638,18 +1217,18 @@ impl Teams { * * This function performs a `GET` to the `/teams/{team_id}/members/{username}` endpoint. * - * The "Get team member" endpoint (described below) is deprecated. + * The "Get team member" endpoint (described below) is closing down. * - * We recommend using the [Get team membership for a user](https://docs.github.com/rest/reference/teams#get-team-membership-for-a-user) endpoint instead. It allows you to get both active and pending memberships. + * We recommend using the [Get team membership for a user](https://docs.github.com/rest/teams/members#get-team-membership-for-a-user) endpoint instead. It allows you to get both active and pending memberships. * * To list members in a team, the team must be visible to the authenticated user. * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `username: &str` + * * `team_id: i64` -- The unique identifier of the team. + * * `username: &str` -- The handle for the GitHub user account. */ pub async fn get_member_legacy( &self, @@ -2660,7 +1239,7 @@ impl Teams { &format!( "/teams/{}/members/{}", crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); @@ -2679,24 +1258,25 @@ impl Teams { * * This function performs a `PUT` to the `/teams/{team_id}/members/{username}` endpoint. * - * The "Add team member" endpoint (described below) is deprecated. + * The "Add team member" endpoint (described below) is closing down. * - * We recommend using the [Add or update team membership for a user](https://docs.github.com/rest/reference/teams#add-or-update-team-membership-for-a-user) endpoint instead. It allows you to invite new organization members to your teams. + * We recommend using the [Add or update team membership for a user](https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user) endpoint instead. It allows you to invite new organization members to your teams. * - * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * * To add someone to a team, the authenticated user must be an organization owner or a team maintainer in the team they're changing. The person being added to the team must be a member of the team's organization. * - * **Note:** When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://help.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)." + * > [!NOTE] + * > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)." * - * Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://docs.github.com/rest/overview/resources-in-the-rest-api#http-verbs)." + * Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)." * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `username: &str` + * * `team_id: i64` -- The unique identifier of the team. + * * `username: &str` -- The handle for the GitHub user account. */ pub async fn add_member_legacy( &self, @@ -2707,7 +1287,7 @@ impl Teams { &format!( "/teams/{}/members/{}", crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); @@ -2726,22 +1306,23 @@ impl Teams { * * This function performs a `DELETE` to the `/teams/{team_id}/members/{username}` endpoint. * - * The "Remove team member" endpoint (described below) is deprecated. + * The "Remove team member" endpoint (described below) is closing down. * - * We recommend using the [Remove team membership for a user](https://docs.github.com/rest/reference/teams#remove-team-membership-for-a-user) endpoint instead. It allows you to remove both active and pending memberships. + * We recommend using the [Remove team membership for a user](https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user) endpoint instead. It allows you to remove both active and pending memberships. * - * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * * To remove a team member, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. Removing a team member does not delete the user, it just removes them from the team. * - * **Note:** When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://help.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)." + * > [!NOTE] + * > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)." * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `username: &str` + * * `team_id: i64` -- The unique identifier of the team. + * * `username: &str` -- The handle for the GitHub user account. */ pub async fn remove_member_legacy( &self, @@ -2752,7 +1333,7 @@ impl Teams { &format!( "/teams/{}/members/{}", crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); @@ -2771,7 +1352,8 @@ impl Teams { * * This function performs a `GET` to the `/teams/{team_id}/memberships/{username}` endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Get team membership for a user](https://docs.github.com/rest/reference/teams#get-team-membership-for-a-user) endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Get team membership for a user](https://docs.github.com/rest/teams/members#get-team-membership-for-a-user) endpoint. * * Team members will include the members of child teams. * @@ -2780,14 +1362,14 @@ impl Teams { * **Note:** * The response contains the `state` of the membership and the member's `role`. * - * The `role` for organization owners is set to `maintainer`. For more information about `maintainer` roles, see [Create a team](https://docs.github.com/rest/reference/teams#create-a-team). + * The `role` for organization owners is set to `maintainer`. For more information about `maintainer` roles, see [Create a team](https://docs.github.com/rest/teams/teams#create-a-team). * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `username: &str` + * * `team_id: i64` -- The unique identifier of the team. + * * `username: &str` -- The handle for the GitHub user account. */ pub async fn get_membership_for_user_legacy( &self, @@ -2798,7 +1380,7 @@ impl Teams { &format!( "/teams/{}/memberships/{}", crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); @@ -2817,24 +1399,26 @@ impl Teams { * * This function performs a `PUT` to the `/teams/{team_id}/memberships/{username}` endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Add or update team membership for a user](https://docs.github.com/rest/reference/teams#add-or-update-team-membership-for-a-user) endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Add or update team membership for a user](https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user) endpoint. * - * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * * If the user is already a member of the team's organization, this endpoint will add the user to the team. To add a membership between an organization member and a team, the authenticated user must be an organization owner or a team maintainer. * - * **Note:** When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://help.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)." + * > [!NOTE] + * > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)." * * If the user is unaffiliated with the team's organization, this endpoint will send an invitation to the user via email. This newly-created membership will be in the "pending" state until the user accepts the invitation, at which point the membership will transition to the "active" state and the user will be added as a member of the team. To add a membership between an unaffiliated user and a team, the authenticated user must be an organization owner. * * If the user is already a member of the team, this endpoint will update the role of the team member's role. To update the membership of a team member, the authenticated user must be an organization owner or a team maintainer. * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `username: &str` + * * `team_id: i64` -- The unique identifier of the team. + * * `username: &str` -- The handle for the GitHub user account. */ pub async fn add_or_update_membership_for_user_legacy( &self, @@ -2846,7 +1430,7 @@ impl Teams { &format!( "/teams/{}/memberships/{}", crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(username), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); @@ -2865,20 +1449,22 @@ impl Teams { * * This function performs a `DELETE` to the `/teams/{team_id}/memberships/{username}` endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Remove team membership for a user](https://docs.github.com/rest/reference/teams#remove-team-membership-for-a-user) endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Remove team membership for a user](https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user) endpoint. * - * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. + * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. * * To remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. Removing team membership does not delete the user, it just removes their membership from the team. * - * **Note:** When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://help.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)." + * > [!NOTE] + * > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)." * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `username: &str` + * * `team_id: i64` -- The unique identifier of the team. + * * `username: &str` -- The handle for the GitHub user account. */ pub async fn remove_membership_for_user_legacy( &self, @@ -2889,208 +1475,7 @@ impl Teams { &format!( "/teams/{}/memberships/{}", crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(username), - ), - None, - ); - self.client - .delete( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List team projects (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/projects` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List team projects`](https://docs.github.com/rest/reference/teams#list-team-projects) endpoint. - * - * Lists the organization projects for a team. - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. - */ - pub async fn list_projects_legacy( - &self, - team_id: i64, - per_page: i64, - page: i64, - ) -> ClientResult>> { - let mut query_args: Vec<(String, String)> = Default::default(); - if page > 0 { - query_args.push(("page".to_string(), page.to_string())); - } - if per_page > 0 { - query_args.push(("per_page".to_string(), per_page.to_string())); - } - let query_ = serde_urlencoded::to_string(&query_args).unwrap(); - let url = self.client.url( - &format!( - "/teams/{}/projects?{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - query_ - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * List team projects (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/projects` endpoint. - * - * As opposed to `list_projects_legacy`, this function returns all the pages of the request at once. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List team projects`](https://docs.github.com/rest/reference/teams#list-team-projects) endpoint. - * - * Lists the organization projects for a team. - * - * FROM: - */ - pub async fn list_all_projects_legacy( - &self, - team_id: i64, - ) -> ClientResult>> { - let url = self.client.url( - &format!( - "/teams/{}/projects", - crate::progenitor_support::encode_path(&team_id.to_string()), - ), - None, - ); - self.client - .get_all_pages( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Check team permissions for a project (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/projects/{project_id}` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Check team permissions for a project](https://docs.github.com/rest/reference/teams#check-team-permissions-for-a-project) endpoint. - * - * Checks whether a team has `read`, `write`, or `admin` permissions for an organization project. The response includes projects inherited from a parent team. - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - * * `project_id: i64` - */ - pub async fn check_permissions_for_project_legacy( - &self, - team_id: i64, - project_id: i64, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}/projects/{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&project_id.to_string()), - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Add or update team project permissions (Legacy). - * - * This function performs a `PUT` to the `/teams/{team_id}/projects/{project_id}` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Add or update team project permissions](https://docs.github.com/rest/reference/teams#add-or-update-team-project-permissions) endpoint. - * - * Adds an organization project to a team. To add a project to a team or update the team's permission on a project, the authenticated user must have `admin` permissions for the project. The project and team must be part of the same organization. - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - * * `project_id: i64` - */ - pub async fn add_or_update_project_permissions_legacy( - &self, - team_id: i64, - project_id: i64, - body: &crate::types::TeamsAddUpdateProjectPermissionsLegacyRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}/projects/{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&project_id.to_string()), - ), - None, - ); - self.client - .put( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } - /** - * Remove a project from a team (Legacy). - * - * This function performs a `DELETE` to the `/teams/{team_id}/projects/{project_id}` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Remove a project from a team](https://docs.github.com/rest/reference/teams#remove-a-project-from-a-team) endpoint. - * - * Removes an organization project from a team. An organization owner or a team maintainer can remove any project from the team. To remove a project from a team as an organization member, the authenticated user must have `read` access to both the team and project, or `admin` access to the team or project. **Note:** This endpoint removes the project from the team, but does not delete it. - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - * * `project_id: i64` - */ - pub async fn remove_project_legacy( - &self, - team_id: i64, - project_id: i64, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}/projects/{}", - crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(&project_id.to_string()), + crate::progenitor_support::encode_path(&username.to_string()), ), None, ); @@ -3109,15 +1494,16 @@ impl Teams { * * This function performs a `GET` to the `/teams/{team_id}/repos` endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [List team repositories](https://docs.github.com/rest/reference/teams#list-team-repositories) endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [List team repositories](https://docs.github.com/rest/teams/teams#list-team-repositories) endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `team_id: i64` -- The unique identifier of the team. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_repos_legacy( &self, @@ -3158,9 +1544,10 @@ impl Teams { * * As opposed to `list_repos_legacy`, this function returns all the pages of the request at once. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [List team repositories](https://docs.github.com/rest/reference/teams#list-team-repositories) endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [List team repositories](https://docs.github.com/rest/teams/teams#list-team-repositories) endpoint. * - * FROM: + * FROM: */ pub async fn list_all_repos_legacy( &self, @@ -3188,19 +1575,21 @@ impl Teams { * * This function performs a `GET` to the `/teams/{team_id}/repos/{owner}/{repo}` endpoint. * - * **Note**: Repositories inherited through a parent team will also be checked. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Check team permissions for a repository](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-repository) endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Check team permissions for a repository](https://docs.github.com/rest/reference/teams#check-team-permissions-for-a-repository) endpoint. + * > [!NOTE] + * > Repositories inherited through a parent team will also be checked. * - * You can also get information about the specified repository, including what permissions the team grants on it, by passing the following custom [media type](https://docs.github.com/rest/overview/media-types/) via the `Accept` header: + * You can also get information about the specified repository, including what permissions the team grants on it, by passing the following custom [media type](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types/) via the `Accept` header: * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `owner: &str` - * * `repo: &str` + * * `team_id: i64` -- The unique identifier of the team. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn check_permissions_for_repo_legacy( &self, @@ -3212,8 +1601,8 @@ impl Teams { &format!( "/teams/{}/repos/{}/{}", crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -3232,19 +1621,20 @@ impl Teams { * * This function performs a `PUT` to the `/teams/{team_id}/repos/{owner}/{repo}` endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new "[Add or update team repository permissions](https://docs.github.com/rest/reference/teams#add-or-update-team-repository-permissions)" endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new "[Add or update team repository permissions](https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions)" endpoint. * * To add a repository to a team or update the team's permission on a repository, the authenticated user must have admin access to the repository, and must be able to see the team. The repository must be owned by the organization, or a direct fork of a repository owned by the organization. You will get a `422 Unprocessable Entity` status if you attempt to add a repository to a team that is not owned by the organization. * - * Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://docs.github.com/rest/overview/resources-in-the-rest-api#http-verbs)." + * Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)." * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `owner: &str` - * * `repo: &str` + * * `team_id: i64` -- The unique identifier of the team. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn add_or_update_repo_permissions_legacy( &self, @@ -3257,8 +1647,8 @@ impl Teams { &format!( "/teams/{}/repos/{}/{}", crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -3277,17 +1667,18 @@ impl Teams { * * This function performs a `DELETE` to the `/teams/{team_id}/repos/{owner}/{repo}` endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [Remove a repository from a team](https://docs.github.com/rest/reference/teams#remove-a-repository-from-a-team) endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Remove a repository from a team](https://docs.github.com/rest/teams/teams#remove-a-repository-from-a-team) endpoint. * * If the authenticated user is an organization owner or a team maintainer, they can remove any repositories from the team. To remove a repository from a team as an organization member, the authenticated user must have admin access to the repository and must be able to see the team. NOTE: This does not delete the repository, it just removes it from the team. * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `owner: &str` - * * `repo: &str` + * * `team_id: i64` -- The unique identifier of the team. + * * `owner: &str` -- The account owner of the repository. The name is not case sensitive. + * * `repo: &str` -- The name of the repository without the `.git` extension. The name is not case sensitive. */ pub async fn remove_repo_legacy( &self, @@ -3299,8 +1690,8 @@ impl Teams { &format!( "/teams/{}/repos/{}/{}", crate::progenitor_support::encode_path(&team_id.to_string()), - crate::progenitor_support::encode_path(owner), - crate::progenitor_support::encode_path(repo), + crate::progenitor_support::encode_path(&owner.to_string()), + crate::progenitor_support::encode_path(&repo.to_string()), ), None, ); @@ -3314,97 +1705,21 @@ impl Teams { ) .await } - /** - * List IdP groups for a team (Legacy). - * - * This function performs a `GET` to the `/teams/{team_id}/team-sync/group-mappings` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List IdP groups for a team`](https://docs.github.com/rest/reference/teams#list-idp-groups-for-a-team) endpoint. - * - * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. - * - * List IdP groups connected to a team on GitHub. - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - */ - pub async fn list_idp_groups_for_legacy( - &self, - team_id: i64, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}/team-sync/group-mappings", - crate::progenitor_support::encode_path(&team_id.to_string()), - ), - None, - ); - self.client - .get( - &url, - crate::Message { - body: None, - content_type: None, - }, - ) - .await - } - /** - * Create or update IdP group connections (Legacy). - * - * This function performs a `PATCH` to the `/teams/{team_id}/team-sync/group-mappings` endpoint. - * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`Create or update IdP group connections`](https://docs.github.com/rest/reference/teams#create-or-update-idp-group-connections) endpoint. - * - * Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://help.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation. - * - * Creates, updates, or removes a connection between a team and an IdP group. When adding groups to a team, you must include all new and existing groups to avoid replacing existing groups with the new ones. Specifying an empty `groups` array will remove all connections for a team. - * - * FROM: - * - * **Parameters:** - * - * * `team_id: i64` - */ - pub async fn create_or_update_idp_group_connections_legacy( - &self, - team_id: i64, - body: &crate::types::TeamsCreateUpdateIdpGroupConnectionsLegacyRequest, - ) -> ClientResult> { - let url = self.client.url( - &format!( - "/teams/{}/team-sync/group-mappings", - crate::progenitor_support::encode_path(&team_id.to_string()), - ), - None, - ); - self.client - .patch( - &url, - crate::Message { - body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), - content_type: Some("application/json".to_string()), - }, - ) - .await - } /** * List child teams (Legacy). * * This function performs a `GET` to the `/teams/{team_id}/teams` endpoint. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List child teams`](https://docs.github.com/rest/reference/teams#list-child-teams) endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List child teams`](https://docs.github.com/rest/teams/teams#list-child-teams) endpoint. * - * FROM: + * FROM: * * **Parameters:** * - * * `team_id: i64` - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `team_id: i64` -- The unique identifier of the team. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_child_legacy( &self, @@ -3445,9 +1760,10 @@ impl Teams { * * As opposed to `list_child_legacy`, this function returns all the pages of the request at once. * - * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List child teams`](https://docs.github.com/rest/reference/teams#list-child-teams) endpoint. + * > [!WARNING] + * > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List child teams`](https://docs.github.com/rest/teams/teams#list-child-teams) endpoint. * - * FROM: + * FROM: */ pub async fn list_all_child_legacy( &self, @@ -3475,14 +1791,19 @@ impl Teams { * * This function performs a `GET` to the `/user/teams` endpoint. * - * List all of the teams across all of the organizations to which the authenticated user belongs. This method requires `user`, `repo`, or `read:org` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/) when authenticating via [OAuth](https://docs.github.com/apps/building-oauth-apps/). + * List all of the teams across all of the organizations to which the authenticated + * user belongs. * - * FROM: + * OAuth app tokens and personal access tokens (classic) need the `user`, `repo`, or `read:org` scope to use this endpoint. + * + * When using a fine-grained personal access token, the resource owner of the token must be a single organization, and the response will only include the teams from that organization. + * + * FROM: * * **Parameters:** * - * * `per_page: i64` -- Results per page (max 100). - * * `page: i64` -- Page number of the results to fetch. + * * `per_page: i64` -- The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". + * * `page: i64` -- The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).". */ pub async fn list_for_authenticated_user( &self, @@ -3515,14 +1836,19 @@ impl Teams { * * As opposed to `list_for_authenticated_user`, this function returns all the pages of the request at once. * - * List all of the teams across all of the organizations to which the authenticated user belongs. This method requires `user`, `repo`, or `read:org` [scope](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/) when authenticating via [OAuth](https://docs.github.com/apps/building-oauth-apps/). + * List all of the teams across all of the organizations to which the authenticated + * user belongs. + * + * OAuth app tokens and personal access tokens (classic) need the `user`, `repo`, or `read:org` scope to use this endpoint. + * + * When using a fine-grained personal access token, the resource owner of the token must be a single organization, and the response will only include the teams from that organization. * - * FROM: + * FROM: */ pub async fn list_all_for_authenticated_user( &self, ) -> ClientResult>> { - let url = self.client.url("/user/teams", None); + let url = self.client.url(&"/user/teams".to_string(), None); self.client .get_all_pages( &url, diff --git a/github/src/types.rs b/github/src/types.rs index 8d96b9a5..2470b726 100644 --- a/github/src/types.rs +++ b/github/src/types.rs @@ -2,449 +2,429 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -/// Simple User #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct SimpleUser { +pub struct Root { #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub avatar_url: String, + pub authorizations_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub email: String, + pub code_search_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub events_url: String, + pub commit_search_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub followers_url: String, + pub current_user_authorizations_html_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub following_url: String, + pub current_user_repositories_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub gists_url: String, + pub current_user_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub gravatar_id: String, + pub emails_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub html_url: String, - #[serde( - default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" - )] - pub id: i64, + pub emojis_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub login: String, + pub events_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub name: String, + pub feeds_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub node_id: String, + pub followers_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub organizations_url: String, + pub following_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub received_events_url: String, + pub gists_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub repos_url: String, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub site_admin: bool, + pub hub_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub starred_at: String, + pub issue_search_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub starred_url: String, + pub issues_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub subscriptions_url: String, - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize", - rename = "type" - )] - pub type_: String, + pub keys_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub url: String, -} - -/// The set of permissions for the GitHub app -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct Permissions { + pub label_search_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub checks: String, + pub notifications_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub contents: String, + pub organization_repositories_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub deployments: String, + pub organization_teams_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub issues: String, + pub organization_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub metadata: String, -} - -/// GitHub apps are a new way to extend GitHub. They can be installed directly on organizations and user accounts and granted access to specific repositories. They come with granular permissions and built-in webhooks. GitHub apps are first class actors within GitHub. -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct GitHubApp { + pub public_gists_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub client_id: String, + pub rate_limit_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub client_secret: String, - #[serde( - default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" - )] - pub created_at: Option>, + pub repository_search_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub description: String, - /** - * The list of events for the GitHub app - */ - #[serde( - default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" - )] - pub events: Vec, + pub repository_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub external_url: String, + pub starred_gists_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub html_url: String, - #[serde( - default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" - )] - pub id: i64, - /** - * GitHub apps are a new way to extend GitHub. They can be installed directly on organizations and user accounts and granted access to specific repositories. They come with granular permissions and built-in webhooks. GitHub apps are first class actors within GitHub. - */ - #[serde( - default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" - )] - pub installations_count: i64, + pub starred_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub name: String, + pub topic_search_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub node_id: String, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub owner: Option, + pub user_organizations_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub pem: String, - /** - * The set of permissions for the GitHub app - */ - pub permissions: Permissions, + pub user_repositories_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub slug: String, - #[serde( - default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" - )] - pub updated_at: Option>, + pub user_search_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub webhook_secret: String, + pub user_url: String, } -/// Basic Error +/** + * The package's language or package management ecosystem. + */ #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct BasicError { +pub enum SecurityAdvisoryEcosystems { + #[serde(rename = "actions")] + Actions, + #[serde(rename = "composer")] + Composer, + #[serde(rename = "erlang")] + Erlang, + #[serde(rename = "go")] + Go, + #[serde(rename = "maven")] + Maven, + #[serde(rename = "npm")] + Npm, + #[serde(rename = "nuget")] + Nuget, + #[serde(rename = "other")] + Other, + #[serde(rename = "pip")] + Pip, + #[serde(rename = "pub")] + Pub, + #[serde(rename = "rubygems")] + Rubygems, + #[serde(rename = "rust")] + Rust, + #[serde(rename = "swift")] + Swift, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for SecurityAdvisoryEcosystems { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SecurityAdvisoryEcosystems::Actions => "actions", + SecurityAdvisoryEcosystems::Composer => "composer", + SecurityAdvisoryEcosystems::Erlang => "erlang", + SecurityAdvisoryEcosystems::Go => "go", + SecurityAdvisoryEcosystems::Maven => "maven", + SecurityAdvisoryEcosystems::Npm => "npm", + SecurityAdvisoryEcosystems::Nuget => "nuget", + SecurityAdvisoryEcosystems::Other => "other", + SecurityAdvisoryEcosystems::Pip => "pip", + SecurityAdvisoryEcosystems::Pub => "pub", + SecurityAdvisoryEcosystems::Rubygems => "rubygems", + SecurityAdvisoryEcosystems::Rust => "rust", + SecurityAdvisoryEcosystems::Swift => "swift", + SecurityAdvisoryEcosystems::Noop => "", + SecurityAdvisoryEcosystems::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for SecurityAdvisoryEcosystems { + fn default() -> SecurityAdvisoryEcosystems { + SecurityAdvisoryEcosystems::Noop + } +} +impl SecurityAdvisoryEcosystems { + pub fn is_noop(&self) -> bool { + matches!(self, SecurityAdvisoryEcosystems::Noop) + } +} + +/// The name of the package affected by the vulnerability. +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct Package { + /** + * The package's language or package management ecosystem. + */ + pub ecosystem: SecurityAdvisoryEcosystems, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub documentation_url: String, + pub name: String, +} + +/// A vulnerability describing the product and its affected versions within a GitHub Security Advisory. +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct Vulnerability { #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub message: String, + pub first_patched_version: String, + /** + * The name of the package affected by the vulnerability. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub package: Option, + /** + * The functions in the package that are affected by the vulnerability. + */ #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" )] - pub status: String, + pub vulnerable_functions: Vec, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub url: String, + pub vulnerable_version_range: String, } -/// Validation Error Simple #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct ValidationErrorSimple { - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" - )] - pub documentation_url: String, +pub struct Cvss { /** - * Validation Error Simple + * The CVSS 3 score. */ #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + skip_serializing_if = "crate::utils::zero_f64", + deserialize_with = "crate::utils::deserialize_null_f64::deserialize" )] - pub errors: Vec, + pub score: f64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub message: String, + pub vector_string: String, } -/// All of the following types: -/// -/// - `String` -/// - `f64` -/// -/// You can easily convert this enum to the inner value with `From` and `Into`, as both are implemented for each type. -/// #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -#[serde(untagged)] -pub enum WebhookConfigInsecureSslOneOf { - String(String), - F64(f64), -} - -impl WebhookConfigInsecureSslOneOf { - pub fn f64(&self) -> Option<&f64> { - if let WebhookConfigInsecureSslOneOf::F64(ref_) = self { - return Some(ref_); - } - None - } - - pub fn string(&self) -> Option<&String> { - if let WebhookConfigInsecureSslOneOf::String(ref_) = self { - return Some(ref_); - } - None - } -} - -impl std::convert::From for WebhookConfigInsecureSslOneOf { - fn from(f: f64) -> Self { - WebhookConfigInsecureSslOneOf::F64(f) - } -} - -impl std::convert::From for WebhookConfigInsecureSslOneOf { - fn from(f: String) -> Self { - WebhookConfigInsecureSslOneOf::String(f) - } +pub struct CvssSeverities { + #[serde(default, skip_serializing_if = "Option::is_none", rename = "cvss_v3")] + pub cvss_v_3: Option, + #[serde(default, skip_serializing_if = "Option::is_none", rename = "cvss_v4")] + pub cvss_v_4: Option, } -impl std::convert::From for f64 { - fn from(f: WebhookConfigInsecureSslOneOf) -> Self { - *f.f64().unwrap() - } -} - -impl std::convert::From for String { - fn from(f: WebhookConfigInsecureSslOneOf) -> Self { - f.string().unwrap().clone() - } +/// The EPSS scores as calculated by the [Exploit Prediction Scoring System](https://www.first.org/epss). +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct SecurityAdvisoryEpss { + /** + * The CVSS 3 score. + */ + #[serde( + default, + skip_serializing_if = "crate::utils::zero_f64", + deserialize_with = "crate::utils::deserialize_null_f64::deserialize" + )] + pub percentage: f64, + /** + * The CVSS 3 score. + */ + #[serde( + default, + skip_serializing_if = "crate::utils::zero_f64", + deserialize_with = "crate::utils::deserialize_null_f64::deserialize" + )] + pub percentile: f64, } -/// Configuration object of the webhook +/// A GitHub user. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct WebhookConfig { +pub struct SimpleUser { #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub content_type: String, + pub avatar_url: String, /** - * Configuration object of the webhook + * A GitHub user. */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub insecure_ssl: Option, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub secret: String, + pub email: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub url: String, -} - -/// Delivery made by a webhook, without request and response information. -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct HookDeliveryItem { + pub events_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub action: String, + pub followers_url: String, #[serde( default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub delivered_at: Option>, + pub following_url: String, #[serde( default, - skip_serializing_if = "crate::utils::zero_f64", - deserialize_with = "crate::utils::deserialize_null_f64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub duration: f64, + pub gists_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub event: String, + pub gravatar_id: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub guid: String, + pub html_url: String, #[serde( default, skip_serializing_if = "crate::utils::zero_i64", @@ -453,328 +433,553 @@ pub struct HookDeliveryItem { pub id: i64, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub installation_id: i64, + pub login: String, + /** + * A GitHub user. + */ #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub redelivery: bool, + pub name: String, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub repository_id: i64, + pub node_id: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub status: String, + pub organizations_url: String, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub status_code: i64, -} - -/// Scim Error -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct ScimError { + pub received_events_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub detail: String, + pub repos_url: String, + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub site_admin: bool, + /** + * A GitHub user. + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub documentation_url: String, + pub starred_at: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub message: String, - /** - * Scim Error - */ + pub starred_url: String, #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub schemas: Vec, + pub subscriptions_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize", - rename = "scimType" + rename = "type" )] - pub scim_type: String, + pub type_: String, + #[serde( + default, + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" + )] + pub url: String, /** - * Scim Error + * A GitHub user. */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub status: i64, + pub user_view_type: String, } -/// All of the following types: -/// -/// - `String` -/// - `i64` -/// - `Vec` -/// -/// You can easily convert this enum to the inner value with `From` and `Into`, as both are implemented for each type. -/// +/** + * The type of credit the user is receiving. + */ #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -#[serde(untagged)] -pub enum ValueOneOf { - String(String), - I64(i64), - /** - * The list of events for the GitHub app - */ - StringVector(Vec), +pub enum SecurityAdvisoryCreditTypes { + #[serde(rename = "analyst")] + Analyst, + #[serde(rename = "coordinator")] + Coordinator, + #[serde(rename = "finder")] + Finder, + #[serde(rename = "other")] + Other, + #[serde(rename = "remediation_developer")] + RemediationDeveloper, + #[serde(rename = "remediation_reviewer")] + RemediationReviewer, + #[serde(rename = "remediation_verifier")] + RemediationVerifier, + #[serde(rename = "reporter")] + Reporter, + #[serde(rename = "sponsor")] + Sponsor, + #[serde(rename = "tool")] + Tool, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, } -impl ValueOneOf { - pub fn i64(&self) -> Option<&i64> { - if let ValueOneOf::I64(ref_) = self { - return Some(ref_); +impl std::fmt::Display for SecurityAdvisoryCreditTypes { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SecurityAdvisoryCreditTypes::Analyst => "analyst", + SecurityAdvisoryCreditTypes::Coordinator => "coordinator", + SecurityAdvisoryCreditTypes::Finder => "finder", + SecurityAdvisoryCreditTypes::Other => "other", + SecurityAdvisoryCreditTypes::RemediationDeveloper => "remediation_developer", + SecurityAdvisoryCreditTypes::RemediationReviewer => "remediation_reviewer", + SecurityAdvisoryCreditTypes::RemediationVerifier => "remediation_verifier", + SecurityAdvisoryCreditTypes::Reporter => "reporter", + SecurityAdvisoryCreditTypes::Sponsor => "sponsor", + SecurityAdvisoryCreditTypes::Tool => "tool", + SecurityAdvisoryCreditTypes::Noop => "", + SecurityAdvisoryCreditTypes::FallthroughString => "*", } - None + .fmt(f) } +} - pub fn string(&self) -> Option<&String> { - if let ValueOneOf::String(ref_) = self { - return Some(ref_); - } - None +impl Default for SecurityAdvisoryCreditTypes { + fn default() -> SecurityAdvisoryCreditTypes { + SecurityAdvisoryCreditTypes::Noop + } +} +impl SecurityAdvisoryCreditTypes { + pub fn is_noop(&self) -> bool { + matches!(self, SecurityAdvisoryCreditTypes::Noop) } +} - pub fn vec_string(&self) -> Option<&Vec> { - if let ValueOneOf::StringVector(ref_) = self { - return Some(ref_); +/** + * The type of advisory. + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum Type { + #[serde(rename = "malware")] + Malware, + #[serde(rename = "reviewed")] + Reviewed, + #[serde(rename = "unreviewed")] + Unreviewed, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for Type { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Type::Malware => "malware", + Type::Reviewed => "reviewed", + Type::Unreviewed => "unreviewed", + Type::Noop => "", + Type::FallthroughString => "*", } - None + .fmt(f) } } -impl std::convert::From for ValueOneOf { - fn from(f: i64) -> Self { - ValueOneOf::I64(f) +impl Default for Type { + fn default() -> Type { + Type::Noop } } - -impl std::convert::From for ValueOneOf { - fn from(f: String) -> Self { - ValueOneOf::String(f) +impl Type { + pub fn is_noop(&self) -> bool { + matches!(self, Type::Noop) } } -impl std::convert::From> for ValueOneOf { - fn from(f: Vec) -> Self { - ValueOneOf::StringVector(f) +/** + * The severity of the advisory. + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum Severity { + #[serde(rename = "critical")] + Critical, + #[serde(rename = "high")] + High, + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "unknown")] + Unknown, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for Severity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Severity::Critical => "critical", + Severity::High => "high", + Severity::Low => "low", + Severity::Medium => "medium", + Severity::Unknown => "unknown", + Severity::Noop => "", + Severity::FallthroughString => "*", + } + .fmt(f) } } -impl std::convert::From for i64 { - fn from(f: ValueOneOf) -> Self { - *f.i64().unwrap() +impl Default for Severity { + fn default() -> Severity { + Severity::Noop + } +} +impl Severity { + pub fn is_noop(&self) -> bool { + matches!(self, Severity::Noop) } } -impl std::convert::From for String { - fn from(f: ValueOneOf) -> Self { - f.string().unwrap().clone() +/** + * The type of identifier. + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum GlobalAdvisoryIdentifiersType { + #[serde(rename = "CVE")] + Cve, + #[serde(rename = "GHSA")] + Ghsa, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for GlobalAdvisoryIdentifiersType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + GlobalAdvisoryIdentifiersType::Cve => "CVE", + GlobalAdvisoryIdentifiersType::Ghsa => "GHSA", + GlobalAdvisoryIdentifiersType::Noop => "", + GlobalAdvisoryIdentifiersType::FallthroughString => "*", + } + .fmt(f) } } -impl std::convert::From for Vec { - fn from(f: ValueOneOf) -> Self { - f.vec_string().unwrap().clone() +impl Default for GlobalAdvisoryIdentifiersType { + fn default() -> GlobalAdvisoryIdentifiersType { + GlobalAdvisoryIdentifiersType::Noop + } +} +impl GlobalAdvisoryIdentifiersType { + pub fn is_noop(&self) -> bool { + matches!(self, GlobalAdvisoryIdentifiersType::Noop) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct Errors { +pub struct Identifiers { + /** + * The type of identifier. + */ + #[serde( + default, + skip_serializing_if = "GlobalAdvisoryIdentifiersType::is_noop", + rename = "type" + )] + pub type_: GlobalAdvisoryIdentifiersType, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub code: String, + pub value: String, +} + +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct Cwes { #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub field: String, + pub cwe_id: String, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" - )] - pub index: i64, + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" + )] + pub name: String, +} + +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct Credits { + /** + * The type of credit the user is receiving. + */ + #[serde(rename = "type")] + pub type_: SecurityAdvisoryCreditTypes, + /** + * A GitHub user. + */ + pub user: SimpleUser, +} + +/// A GitHub Security Advisory. +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct GlobalAdvisory { + /** + * The users who contributed to the advisory. + */ + #[serde( + default, + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + )] + pub credits: Vec, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub message: String, + pub cve_id: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cvss: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cvss_severities: Option, + #[serde( + default, + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + )] + pub cwes: Vec, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub resource: String, + pub description: String, + /** + * The EPSS scores as calculated by the [Exploit Prediction Scoring System](https://www.first.org/epss). + */ #[serde(default, skip_serializing_if = "Option::is_none")] - pub value: Option, -} - -/// Validation Error -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct ValidationError { + pub epss: Option, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub documentation_url: String, + pub ghsa_id: String, /** - * Validation Error + * The date and time of when the advisory was published, in ISO 8601 format. */ #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" )] - pub errors: Vec, + pub github_reviewed_at: Option>, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub message: String, -} - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct Data {} - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct Request { + pub html_url: String, + #[serde( + default, + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + )] + pub identifiers: Vec, /** - * The request headers sent with the webhook delivery. + * The date and time of when the advisory was published, in ISO 8601 format. */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub headers: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" + )] + pub nvd_published_at: Option>, /** - * The request headers sent with the webhook delivery. + * The date and time of when the advisory was published, in ISO 8601 format. */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub payload: Option, -} - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct Response { + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" + )] + pub published_at: Option>, /** - * The request headers sent with the webhook delivery. + * The functions in the package that are affected by the vulnerability. */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub headers: Option, + #[serde( + default, + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + )] + pub references: Vec, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub payload: String, -} - -/// Delivery made by a webhook. -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct HookDelivery { + pub repository_advisory_url: String, + /** + * The severity of the advisory. + */ + #[serde(default, skip_serializing_if = "Severity::is_noop")] + pub severity: Severity, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub action: String, + pub source_code_location: String, + #[serde( + default, + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" + )] + pub summary: String, + /** + * The type of advisory. + */ + #[serde(default, skip_serializing_if = "Type::is_noop", rename = "type")] + pub type_: Type, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::utils::date_time_format::deserialize" )] - pub delivered_at: Option>, + pub updated_at: Option>, #[serde( default, - skip_serializing_if = "crate::utils::zero_f64", - deserialize_with = "crate::utils::deserialize_null_f64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub duration: f64, + pub url: String, + /** + * The products and respective version ranges affected by the advisory. + */ + #[serde( + default, + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + )] + pub vulnerabilities: Vec, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" + )] + pub withdrawn_at: Option>, +} + +/// Basic Error +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct BasicError { + /** + * Basic Error + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub event: String, + pub documentation_url: String, + /** + * Basic Error + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub guid: String, + pub message: String, + /** + * Basic Error + */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub id: i64, + pub status: String, + /** + * Basic Error + */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub installation_id: i64, + pub url: String, +} + +/// Validation Error Simple +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct ValidationErrorSimple { #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub redelivery: bool, + pub documentation_url: String, + /** + * The functions in the package that are affected by the vulnerability. + */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" )] - pub repository_id: i64, - pub request: Request, - pub response: Response, + pub errors: Vec, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub status: String, - #[serde( - default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" - )] - pub status_code: i64, + pub message: String, } -/// An enterprise account +/// An enterprise on GitHub. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] pub struct Enterprise { #[serde( @@ -783,12 +988,18 @@ pub struct Enterprise { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub avatar_url: String, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::utils::date_time_format::deserialize" )] pub created_at: Option>, + /** + * An enterprise on GitHub. + */ #[serde( default, skip_serializing_if = "String::is_empty", @@ -825,12 +1036,18 @@ pub struct Enterprise { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub slug: String, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::utils::date_time_format::deserialize" )] pub updated_at: Option>, + /** + * An enterprise on GitHub. + */ #[serde( default, skip_serializing_if = "String::is_empty", @@ -839,506 +1056,278 @@ pub struct Enterprise { pub website_url: String, } -/** - * The level of permission to grant the access token to retrieve Pages statuses, configuration, and builds, as well as create new builds. Can be one of: `read` or `write`. - */ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema, Default)] -pub enum Pages { - #[serde(rename = "read")] - Read, - #[serde(rename = "write")] - Write, - #[serde(rename = "")] - #[default] - Noop, - #[serde(other)] - FallthroughString, -} - -impl std::fmt::Display for Pages { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Pages::Read => "read", - Pages::Write => "write", - Pages::Noop => "", - Pages::FallthroughString => "*", - } - .fmt(f) - } -} - -impl Pages { - pub fn is_noop(&self) -> bool { - matches!(self, Pages::Noop) - } -} - -/** - * The level of permission to grant the access token to manage repository projects, columns, and cards. Can be one of: `read`, `write`, or `admin`. - */ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema, Default)] -pub enum RepositoryProjects { - #[serde(rename = "admin")] - Admin, - #[serde(rename = "read")] - Read, - #[serde(rename = "write")] - Write, - #[serde(rename = "")] - #[default] - Noop, - #[serde(other)] - FallthroughString, -} - -impl std::fmt::Display for RepositoryProjects { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - RepositoryProjects::Admin => "admin", - RepositoryProjects::Read => "read", - RepositoryProjects::Write => "write", - RepositoryProjects::Noop => "", - RepositoryProjects::FallthroughString => "*", - } - .fmt(f) - } -} - -impl RepositoryProjects { - pub fn is_noop(&self) -> bool { - matches!(self, RepositoryProjects::Noop) - } -} - -/** - * The level of permission to grant the access token for viewing an organization's plan. Can be one of: `read`. - */ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema, Default)] -pub enum OrganizationPlan { - #[serde(rename = "read")] - Read, - #[serde(rename = "")] - #[default] - Noop, - #[serde(other)] - FallthroughString, -} - -impl std::fmt::Display for OrganizationPlan { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - OrganizationPlan::Read => "read", - OrganizationPlan::Noop => "", - OrganizationPlan::FallthroughString => "*", - } - .fmt(f) - } -} - -impl OrganizationPlan { - pub fn is_noop(&self) -> bool { - matches!(self, OrganizationPlan::Noop) - } -} - -/** - * The level of permission to grant the access token to update GitHub Actions workflow files. Can be one of: `write`. - */ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema, Default)] -pub enum Workflows { - #[serde(rename = "write")] - Write, - #[serde(rename = "")] - #[default] - Noop, - #[serde(other)] - FallthroughString, -} - -impl std::fmt::Display for Workflows { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Workflows::Write => "write", - Workflows::Noop => "", - Workflows::FallthroughString => "*", - } - .fmt(f) - } -} - -impl Workflows { - pub fn is_noop(&self) -> bool { - matches!(self, Workflows::Noop) - } -} - -/// The permissions granted to the user-to-server access token. -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct AppPermissions { - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub actions: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub administration: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub checks: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub content_references: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub contents: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub deployments: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub environments: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub issues: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub members: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub metadata: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub organization_administration: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub organization_hooks: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub organization_packages: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub organization_plan: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub organization_projects: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub organization_secrets: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub organization_self_hosted_runners: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub organization_user_blocking: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub packages: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub pages: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub pull_requests: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub repository_hooks: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub repository_projects: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub secret_scanning_alerts: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub secrets: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub security_events: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub single_file: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub statuses: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub team_discussions: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub vulnerability_alerts: Option, - /** - * The permissions granted to the user-to-server access token. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub workflows: Option, -} - -/// All of the following types are flattened into one object: +/// All of the following types: /// /// - `SimpleUser` /// - `Enterprise` /// +/// You can easily convert this enum to the inner value with `From` and `Into`, as both are implemented for each type. +/// #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct AccountAnyOf { +#[serde(untagged)] +pub enum OwnerOneOf { /** - * Simple User + * A GitHub user. */ - #[serde(flatten)] - pub simple_user: SimpleUser, + SimpleUser(SimpleUser), /** - * An enterprise account + * An enterprise on GitHub. */ - #[serde(flatten)] - pub enterprise: Enterprise, -} - -/** - * Describe whether all repositories have been selected or there's a selection involved - */ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema, Default)] -pub enum RepositorySelection { - #[serde(rename = "all")] - All, - #[serde(rename = "selected")] - Selected, - #[serde(rename = "")] - #[default] - Noop, - #[serde(other)] - FallthroughString, + Enterprise(Enterprise), } -impl std::fmt::Display for RepositorySelection { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - RepositorySelection::All => "all", - RepositorySelection::Selected => "selected", - RepositorySelection::Noop => "", - RepositorySelection::FallthroughString => "*", +impl OwnerOneOf { + pub fn enterprise(&self) -> Option<&Enterprise> { + if let OwnerOneOf::Enterprise(ref_) = self { + return Some(ref_); } - .fmt(f) + None } -} -impl RepositorySelection { - pub fn is_noop(&self) -> bool { - matches!(self, RepositorySelection::Noop) + pub fn simple_user(&self) -> Option<&SimpleUser> { + if let OwnerOneOf::SimpleUser(ref_) = self { + return Some(ref_); + } + None } } -/// Installation +/// The set of permissions for the GitHub app #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct Installation { +pub struct Permissions { + /** + * The set of permissions for the GitHub app + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub access_tokens_url: String, - pub account: AccountAnyOf, + pub checks: String, + /** + * The set of permissions for the GitHub app + */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub app_id: i64, + pub contents: String, + /** + * The set of permissions for the GitHub app + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub app_slug: String, + pub deployments: String, + /** + * The set of permissions for the GitHub app + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub contact_email: String, + pub issues: String, + /** + * The set of permissions for the GitHub app + */ #[serde( default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub created_at: Option>, + pub metadata: String, +} + +/// GitHub apps are a new way to extend GitHub. They can be installed directly on organizations and user accounts and granted access to specific repositories. They come with granular permissions and built-in webhooks. GitHub apps are first class actors within GitHub. +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct GitHubApp { /** - * The list of events for the GitHub app + * GitHub apps are a new way to extend GitHub. They can be installed directly on organizations and user accounts and granted access to specific repositories. They come with granular permissions and built-in webhooks. GitHub apps are first class actors within GitHub. */ #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub events: Vec, + pub client_id: String, /** - * Installation + * The date and time of when the advisory was published, in ISO 8601 format. */ #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" )] - pub has_multiple_single_files: bool, + pub created_at: Option>, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub html_url: String, - #[serde( - default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" - )] - pub id: i64, + pub description: String, /** - * The permissions granted to the user-to-server access token. + * The functions in the package that are affected by the vulnerability. */ - pub permissions: AppPermissions, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" )] - pub repositories_url: String, - /** - * Describe whether all repositories have been selected or there's a selection involved - */ - #[serde(default, skip_serializing_if = "RepositorySelection::is_noop")] - pub repository_selection: RepositorySelection, + pub events: Vec, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub single_file_name: String, - /** - * Installation - */ + pub external_url: String, #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub single_file_paths: Vec, + pub html_url: String, #[serde( default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub suspended_at: Option>, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub suspended_by: Option, + pub id: i64, + /** + * GitHub apps are a new way to extend GitHub. They can be installed directly on organizations and user accounts and granted access to specific repositories. They come with granular permissions and built-in webhooks. GitHub apps are first class actors within GitHub. + */ #[serde( default, skip_serializing_if = "crate::utils::zero_i64", deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub target_id: i64, + pub installations_count: i64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub target_type: String, - #[serde( - default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" - )] - pub updated_at: Option>, -} - -/// License Simple -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct LicenseSimple { + pub name: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub html_url: String, + pub node_id: String, + pub owner: OwnerOneOf, + /** + * The set of permissions for the GitHub app + */ + pub permissions: Permissions, + /** + * GitHub apps are a new way to extend GitHub. They can be installed directly on organizations and user accounts and granted access to specific repositories. They come with granular permissions and built-in webhooks. GitHub apps are first class actors within GitHub. + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub key: String, + pub slug: String, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" )] - pub name: String, + pub updated_at: Option>, +} + +/// All of the following types: +/// +/// - `String` +/// - `f64` +/// +/// You can easily convert this enum to the inner value with `From` and `Into`, as both are implemented for each type. +/// +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +#[serde(untagged)] +pub enum WebhookConfigInsecureSslOneOf { + String(String), + /** + * The CVSS 3 score. + */ + F64(f64), +} + +impl WebhookConfigInsecureSslOneOf { + pub fn f64(&self) -> Option<&f64> { + if let WebhookConfigInsecureSslOneOf::F64(ref_) = self { + return Some(ref_); + } + None + } + + pub fn string(&self) -> Option<&String> { + if let WebhookConfigInsecureSslOneOf::String(ref_) = self { + return Some(ref_); + } + None + } +} + +impl std::convert::From for WebhookConfigInsecureSslOneOf { + fn from(f: f64) -> Self { + WebhookConfigInsecureSslOneOf::F64(f) + } +} + +impl std::convert::From for WebhookConfigInsecureSslOneOf { + fn from(f: String) -> Self { + WebhookConfigInsecureSslOneOf::String(f) + } +} + +impl std::convert::From for f64 { + fn from(f: WebhookConfigInsecureSslOneOf) -> Self { + *f.f64().unwrap() + } +} + +impl std::convert::From for String { + fn from(f: WebhookConfigInsecureSslOneOf) -> Self { + f.string().unwrap().clone() + } +} + +/// Configuration object of the webhook +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct WebhookConfig { + /** + * Configuration object of the webhook + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub node_id: String, + pub content_type: String, + /** + * Configuration object of the webhook + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub insecure_ssl: Option, + /** + * Configuration object of the webhook + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub spdx_id: String, + pub secret: String, + /** + * Configuration object of the webhook + */ #[serde( default, skip_serializing_if = "String::is_empty", @@ -1347,389 +1336,939 @@ pub struct LicenseSimple { pub url: String, } +/// Delivery made by a webhook, without request and response information. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct RepositoryPermissions { - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub admin: bool, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub maintain: bool, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub pull: bool, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub push: bool, +pub struct HookDeliveryItem { #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub triage: bool, -} - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct Users { + pub action: String, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" )] - pub avatar_url: String, + pub delivered_at: Option>, + /** + * The CVSS 3 score. + */ #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_f64", + deserialize_with = "crate::utils::deserialize_null_f64::deserialize" )] - pub events_url: String, + pub duration: f64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub followers_url: String, + pub event: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub following_url: String, + pub guid: String, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub gists_url: String, + pub id: i64, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub gravatar_id: String, + pub installation_id: i64, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub html_url: String, + pub redelivery: bool, #[serde( default, skip_serializing_if = "crate::utils::zero_i64", deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub id: i64, + pub repository_id: i64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub login: String, + pub status: String, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub node_id: String, + pub status_code: i64, + /** + * Delivery made by a webhook, without request and response information. + */ #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" )] - pub organizations_url: String, + pub throttled_at: Option>, +} + +/// Scim Error +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct ScimError { + /** + * Scim Error + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub received_events_url: String, + pub detail: String, + /** + * Scim Error + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub repos_url: String, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub site_admin: bool, + pub documentation_url: String, + /** + * Scim Error + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub starred_url: String, + pub message: String, + /** + * The functions in the package that are affected by the vulnerability. + */ #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" )] - pub subscriptions_url: String, + pub schemas: Vec, + /** + * Scim Error + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize", - rename = "type" + rename = "scimType" )] - pub type_: String, + pub scim_type: String, + /** + * Scim Error + */ #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub url: String, + pub status: i64, } +/// All of the following types: +/// +/// - `String` +/// - `Vec` +/// - `i64` +/// +/// You can easily convert this enum to the inner value with `From` and `Into`, as both are implemented for each type. +/// #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct RepositoryTemplatePermissions { - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub admin: bool, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub pull: bool, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub push: bool, +#[serde(untagged)] +pub enum ValueOneOf { + String(String), + /** + * The functions in the package that are affected by the vulnerability. + */ + StringVector(Vec), + I64(i64), +} + +impl ValueOneOf { + pub fn i64(&self) -> Option<&i64> { + if let ValueOneOf::I64(ref_) = self { + return Some(ref_); + } + None + } + + pub fn string(&self) -> Option<&String> { + if let ValueOneOf::String(ref_) = self { + return Some(ref_); + } + None + } + + pub fn vec_string(&self) -> Option<&Vec> { + if let ValueOneOf::StringVector(ref_) = self { + return Some(ref_); + } + None + } +} + +impl std::convert::From for ValueOneOf { + fn from(f: i64) -> Self { + ValueOneOf::I64(f) + } +} + +impl std::convert::From for ValueOneOf { + fn from(f: String) -> Self { + ValueOneOf::String(f) + } +} + +impl std::convert::From> for ValueOneOf { + fn from(f: Vec) -> Self { + ValueOneOf::StringVector(f) + } +} + +impl std::convert::From for i64 { + fn from(f: ValueOneOf) -> Self { + *f.i64().unwrap() + } +} + +impl std::convert::From for String { + fn from(f: ValueOneOf) -> Self { + f.string().unwrap().clone() + } +} + +impl std::convert::From for Vec { + fn from(f: ValueOneOf) -> Self { + f.vec_string().unwrap().clone() + } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct TemplateRepository { - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub allow_auto_merge: bool, +pub struct Errors { #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub allow_merge_commit: bool, + pub code: String, #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub allow_rebase_merge: bool, + pub field: String, #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub allow_squash_merge: bool, + pub index: i64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub archive_url: String, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub archived: bool, + pub message: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub assignees_url: String, + pub resource: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, +} + +/// Validation Error +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct ValidationError { #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub blobs_url: String, + pub documentation_url: String, + /** + * Validation Error + */ #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" )] - pub branches_url: String, + pub errors: Vec, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub clone_url: String, + pub message: String, +} + +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct Fields {} + +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct Request { + /** + * The request headers sent with the webhook delivery. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub headers: Option, + /** + * The request headers sent with the webhook delivery. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub payload: Option, +} + +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct Response { + /** + * The request headers sent with the webhook delivery. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub headers: Option, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub collaborators_url: String, + pub payload: String, +} + +/// Delivery made by a webhook. +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct HookDelivery { #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub comments_url: String, + pub action: String, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" )] - pub commits_url: String, + pub delivered_at: Option>, + /** + * The CVSS 3 score. + */ #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_f64", + deserialize_with = "crate::utils::deserialize_null_f64::deserialize" )] - pub compare_url: String, + pub duration: f64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub contents_url: String, + pub event: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub contributors_url: String, + pub guid: String, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub created_at: String, + pub id: i64, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub default_branch: String, + pub installation_id: i64, #[serde( default, deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub delete_branch_on_merge: bool, + pub redelivery: bool, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub deployments_url: String, + pub repository_id: i64, + pub request: Request, + pub response: Response, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub description: String, + pub status: String, #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub disabled: bool, + pub status_code: i64, + /** + * Delivery made by a webhook. + */ #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" )] - pub downloads_url: String, + pub throttled_at: Option>, + /** + * Delivery made by a webhook. + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub events_url: String, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub fork: bool, - #[serde( - default, + pub url: String, +} + +/// All of the following types are flattened into one object: +/// +/// - `SimpleUser` +/// - `Enterprise` +/// +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct AccountAnyOf { + /** + * A GitHub user. + */ + #[serde(flatten)] + pub simple_user: SimpleUser, + /** + * An enterprise on GitHub. + */ + #[serde(flatten)] + pub enterprise: Enterprise, +} + +/// Request to install an integration on a target +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct IntegrationInstallationRequest { + pub account: AccountAnyOf, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" + )] + pub created_at: Option>, + #[serde( + default, skip_serializing_if = "crate::utils::zero_i64", deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub forks_count: i64, + pub id: i64, + /** + * Request to install an integration on a target + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub forks_url: String, + pub node_id: String, + /** + * A GitHub user. + */ + pub requester: SimpleUser, +} + +/** + * The level of permission to grant the access token to retrieve Pages statuses, configuration, and builds, as well as create new builds. + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum Pages { + #[serde(rename = "read")] + Read, + #[serde(rename = "write")] + Write, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for Pages { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Pages::Read => "read", + Pages::Write => "write", + Pages::Noop => "", + Pages::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for Pages { + fn default() -> Pages { + Pages::Noop + } +} +impl Pages { + pub fn is_noop(&self) -> bool { + matches!(self, Pages::Noop) + } +} + +/** + * The level of permission to grant the access token to manage repository projects, columns, and cards. + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum RepositoryProjects { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "read")] + Read, + #[serde(rename = "write")] + Write, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for RepositoryProjects { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RepositoryProjects::Admin => "admin", + RepositoryProjects::Read => "read", + RepositoryProjects::Write => "write", + RepositoryProjects::Noop => "", + RepositoryProjects::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for RepositoryProjects { + fn default() -> RepositoryProjects { + RepositoryProjects::Noop + } +} +impl RepositoryProjects { + pub fn is_noop(&self) -> bool { + matches!(self, RepositoryProjects::Noop) + } +} + +/** + * The level of permission to grant the access token to manage the profile settings belonging to a user. + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum Profile { + #[serde(rename = "write")] + Write, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for Profile { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Profile::Write => "write", + Profile::Noop => "", + Profile::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for Profile { + fn default() -> Profile { + Profile::Noop + } +} +impl Profile { + pub fn is_noop(&self) -> bool { + matches!(self, Profile::Noop) + } +} + +/** + * The level of permission to grant the access token for viewing an organization's plan. + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum OrganizationPlan { + #[serde(rename = "read")] + Read, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for OrganizationPlan { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + OrganizationPlan::Read => "read", + OrganizationPlan::Noop => "", + OrganizationPlan::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for OrganizationPlan { + fn default() -> OrganizationPlan { + OrganizationPlan::Noop + } +} +impl OrganizationPlan { + pub fn is_noop(&self) -> bool { + matches!(self, OrganizationPlan::Noop) + } +} + +/// The permissions granted to the user access token. +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct AppPermissions { + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub actions: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub administration: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub artifact_metadata: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub attestations: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub checks: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub codespaces: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub contents: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub custom_properties_for_organizations: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dependabot_secrets: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub deployments: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub discussions: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub email_addresses: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub enterprise_custom_properties_for_organizations: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub environments: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub followers: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub git_ssh_keys: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub gpg_keys: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub interaction_limits: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub issues: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub members: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub merge_queues: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub metadata: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_administration: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_announcement_banners: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_copilot_seat_management: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_custom_org_roles: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_custom_properties: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_custom_roles: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_events: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_hooks: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_packages: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_personal_access_token_requests: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_personal_access_tokens: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_plan: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_projects: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_secrets: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_self_hosted_runners: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub organization_user_blocking: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub packages: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pages: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub profile: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pull_requests: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub repository_custom_properties: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub repository_hooks: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub repository_projects: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub secret_scanning_alerts: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub secrets: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub security_events: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub single_file: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub starring: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub statuses: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub vulnerability_alerts: Option, + /** + * The permissions granted to the user access token. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub workflows: Option, +} + +/// A GitHub user. +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct NullableSimpleUser { #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub full_name: String, + pub avatar_url: String, + /** + * A GitHub user. + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub git_commits_url: String, + pub email: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub git_refs_url: String, + pub events_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub git_tags_url: String, + pub followers_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub git_url: String, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub has_downloads: bool, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub has_issues: bool, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub has_pages: bool, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub has_projects: bool, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub has_wiki: bool, + pub following_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub homepage: String, + pub gists_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub hooks_url: String, + pub gravatar_id: String, #[serde( default, skip_serializing_if = "String::is_empty", @@ -1742,243 +2281,550 @@ pub struct TemplateRepository { deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] pub id: i64, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub is_template: bool, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub issue_comment_url: String, + pub login: String, + /** + * A GitHub user. + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub issue_events_url: String, + pub name: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub issues_url: String, + pub node_id: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub keys_url: String, + pub organizations_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub labels_url: String, + pub received_events_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub language: String, + pub repos_url: String, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub languages_url: String, + pub site_admin: bool, + /** + * A GitHub user. + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub merges_url: String, + pub starred_at: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub milestones_url: String, + pub starred_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub mirror_url: String, + pub subscriptions_url: String, #[serde( default, skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + deserialize_with = "crate::utils::deserialize_null_string::deserialize", + rename = "type" )] - pub name: String, + pub type_: String, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub network_count: i64, + pub url: String, + /** + * A GitHub user. + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub node_id: String, + pub user_view_type: String, +} + +/** + * Describe whether all repositories have been selected or there's a selection involved + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum RepositorySelection { + #[serde(rename = "all")] + All, + #[serde(rename = "selected")] + Selected, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for RepositorySelection { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RepositorySelection::All => "all", + RepositorySelection::Selected => "selected", + RepositorySelection::Noop => "", + RepositorySelection::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for RepositorySelection { + fn default() -> RepositorySelection { + RepositorySelection::Noop + } +} +impl RepositorySelection { + pub fn is_noop(&self) -> bool { + matches!(self, RepositorySelection::Noop) + } +} + +/// Installation +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct Installation { #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub notifications_url: String, + pub access_tokens_url: String, + pub account: AccountAnyOf, #[serde( default, skip_serializing_if = "crate::utils::zero_i64", deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub open_issues_count: i64, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub owner: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub permissions: Option, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub private: bool, + pub app_id: i64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub pulls_url: String, + pub app_slug: String, + /** + * Installation + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub pushed_at: String, + pub client_id: String, + /** + * Installation + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub releases_url: String, + pub contact_email: String, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" )] - pub size: i64, + pub created_at: Option>, + /** + * The functions in the package that are affected by the vulnerability. + */ + #[serde( + default, + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + )] + pub events: Vec, + /** + * Installation + */ + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub has_multiple_single_files: bool, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub ssh_url: String, + pub html_url: String, #[serde( default, skip_serializing_if = "crate::utils::zero_i64", deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub stargazers_count: i64, + pub id: i64, + /** + * The permissions granted to the user access token. + */ + pub permissions: AppPermissions, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub stargazers_url: String, + pub repositories_url: String, + /** + * Describe whether all repositories have been selected or there's a selection involved + */ + #[serde(default, skip_serializing_if = "RepositorySelection::is_noop")] + pub repository_selection: RepositorySelection, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub statuses_url: String, + pub single_file_name: String, + /** + * The functions in the package that are affected by the vulnerability. + */ + #[serde( + default, + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + )] + pub single_file_paths: Vec, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" + )] + pub suspended_at: Option>, + /** + * A GitHub user. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub suspended_by: Option, #[serde( default, skip_serializing_if = "crate::utils::zero_i64", deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub subscribers_count: i64, + pub target_id: i64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub subscribers_url: String, + pub target_type: String, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" )] - pub subscription_url: String, + pub updated_at: Option>, +} + +/// License Simple +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct LicenseSimple { + /** + * License Simple + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub svn_url: String, + pub html_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub tags_url: String, + pub key: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub teams_url: String, + pub name: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub temp_clone_token: String, + pub node_id: String, #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub topics: Vec, + pub spdx_id: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub trees_url: String, + pub url: String, +} + +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct RepositoryPermissions { #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub updated_at: String, + pub admin: bool, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub url: String, + pub maintain: bool, + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub pull: bool, + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub push: bool, + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub triage: bool, +} + +/** + * The default value for a squash merge commit title: + * + * - `PR_TITLE` - default to the pull request's title. + * - `COMMIT_OR_PR_TITLE` - default to the commit's title (if only one commit) or the pull request's title (when more than one commit). + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum SquashMergeCommitTitle { + #[serde(rename = "COMMIT_OR_PR_TITLE")] + CommitOrPrTitle, + #[serde(rename = "PR_TITLE")] + PrTitle, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for SquashMergeCommitTitle { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SquashMergeCommitTitle::CommitOrPrTitle => "COMMIT_OR_PR_TITLE", + SquashMergeCommitTitle::PrTitle => "PR_TITLE", + SquashMergeCommitTitle::Noop => "", + SquashMergeCommitTitle::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for SquashMergeCommitTitle { + fn default() -> SquashMergeCommitTitle { + SquashMergeCommitTitle::Noop + } +} +impl SquashMergeCommitTitle { + pub fn is_noop(&self) -> bool { + matches!(self, SquashMergeCommitTitle::Noop) + } +} + +/** + * The default value for a squash merge commit message: + * + * - `PR_BODY` - default to the pull request's body. + * - `COMMIT_MESSAGES` - default to the branch's commit messages. + * - `BLANK` - default to a blank commit message. + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum SquashMergeCommitMessage { + #[serde(rename = "BLANK")] + Blank, + #[serde(rename = "COMMIT_MESSAGES")] + CommitMessages, + #[serde(rename = "PR_BODY")] + PrBody, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for SquashMergeCommitMessage { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SquashMergeCommitMessage::Blank => "BLANK", + SquashMergeCommitMessage::CommitMessages => "COMMIT_MESSAGES", + SquashMergeCommitMessage::PrBody => "PR_BODY", + SquashMergeCommitMessage::Noop => "", + SquashMergeCommitMessage::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for SquashMergeCommitMessage { + fn default() -> SquashMergeCommitMessage { + SquashMergeCommitMessage::Noop + } +} +impl SquashMergeCommitMessage { + pub fn is_noop(&self) -> bool { + matches!(self, SquashMergeCommitMessage::Noop) + } +} + +/** + * The default value for a merge commit title. + * + * - `PR_TITLE` - default to the pull request's title. + * - `MERGE_MESSAGE` - default to the classic title for a merge message (e.g., Merge pull request #123 from branch-name). + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum MergeCommitTitle { + #[serde(rename = "MERGE_MESSAGE")] + MergeMessage, + #[serde(rename = "PR_TITLE")] + PrTitle, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for MergeCommitTitle { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MergeCommitTitle::MergeMessage => "MERGE_MESSAGE", + MergeCommitTitle::PrTitle => "PR_TITLE", + MergeCommitTitle::Noop => "", + MergeCommitTitle::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for MergeCommitTitle { + fn default() -> MergeCommitTitle { + MergeCommitTitle::Noop + } +} +impl MergeCommitTitle { + pub fn is_noop(&self) -> bool { + matches!(self, MergeCommitTitle::Noop) + } +} + +/** + * The default value for a merge commit message. + * + * - `PR_TITLE` - default to the pull request's title. + * - `PR_BODY` - default to the pull request's body. + * - `BLANK` - default to a blank commit message. + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum MergeCommitMessage { + #[serde(rename = "BLANK")] + Blank, + #[serde(rename = "PR_BODY")] + PrBody, + #[serde(rename = "PR_TITLE")] + PrTitle, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for MergeCommitMessage { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MergeCommitMessage::Blank => "BLANK", + MergeCommitMessage::PrBody => "PR_BODY", + MergeCommitMessage::PrTitle => "PR_TITLE", + MergeCommitMessage::Noop => "", + MergeCommitMessage::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for MergeCommitMessage { + fn default() -> MergeCommitMessage { + MergeCommitMessage::Noop + } +} +impl MergeCommitMessage { + pub fn is_noop(&self) -> bool { + matches!(self, MergeCommitMessage::Noop) + } +} + +/// The status of the code search index for this repository +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct CodeSearchIndexStatus { + /** + * The status of the code search index for this repository + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub visibility: String, + pub lexical_commit_sha: String, + /** + * The status of the code search index for this repository + */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub watchers_count: i64, + pub lexical_search_ok: bool, } -/// A git repository +/// A repository on GitHub. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] pub struct Repository { /** - * A git repository + * A repository on GitHub. */ #[serde( default, @@ -1986,7 +2832,15 @@ pub struct Repository { )] pub allow_auto_merge: bool, /** - * A git repository + * A repository on GitHub. + */ + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub allow_forking: bool, + /** + * A repository on GitHub. */ #[serde( default, @@ -1994,7 +2848,7 @@ pub struct Repository { )] pub allow_merge_commit: bool, /** - * A git repository + * A repository on GitHub. */ #[serde( default, @@ -2002,13 +2856,29 @@ pub struct Repository { )] pub allow_rebase_merge: bool, /** - * A git repository + * A repository on GitHub. */ #[serde( default, deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] pub allow_squash_merge: bool, + /** + * A repository on GitHub. + */ + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub allow_update_branch: bool, + /** + * A repository on GitHub. + */ + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub anonymous_access_enabled: bool, #[serde( default, skip_serializing_if = "String::is_empty", @@ -2044,6 +2914,11 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub clone_url: String, + /** + * A repository on GitHub. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub code_search_index_status: Option, #[serde( default, skip_serializing_if = "String::is_empty", @@ -2080,6 +2955,9 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub contributors_url: String, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, skip_serializing_if = "Option::is_none", @@ -2093,7 +2971,7 @@ pub struct Repository { )] pub default_branch: String, /** - * A git repository + * A repository on GitHub. */ #[serde( default, @@ -2182,6 +3060,14 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub git_url: String, + /** + * A repository on GitHub. + */ + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub has_discussions: bool, #[serde( default, deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" @@ -2202,6 +3088,14 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] pub has_projects: bool, + /** + * A repository on GitHub. + */ + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub has_pull_requests: bool, #[serde( default, deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" @@ -2232,7 +3126,7 @@ pub struct Repository { )] pub id: i64, /** - * A git repository + * A repository on GitHub. */ #[serde( default, @@ -2281,14 +3175,30 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub languages_url: String, + /** + * License Simple + */ #[serde(default, skip_serializing_if = "Option::is_none")] pub license: Option, + /** + * A repository on GitHub. + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub master_branch: String, + /** + * A repository on GitHub. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub merge_commit_message: Option, + /** + * A repository on GitHub. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub merge_commit_title: Option, #[serde( default, skip_serializing_if = "String::is_empty", @@ -2313,15 +3223,6 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub name: String, - /** - * A git repository - */ - #[serde( - default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" - )] - pub network_count: i64, #[serde( default, skip_serializing_if = "String::is_empty", @@ -2346,15 +3247,12 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] pub open_issues_count: i64, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub organization: Option, /** - * Simple User + * A GitHub user. */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub owner: Option, + pub owner: SimpleUser, /** - * A git repository + * A repository on GitHub. */ #[serde(default, skip_serializing_if = "Option::is_none")] pub permissions: Option, @@ -2369,6 +3267,9 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub pulls_url: String, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, skip_serializing_if = "Option::is_none", @@ -2387,6 +3288,16 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] pub size: i64, + /** + * A repository on GitHub. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub squash_merge_commit_message: Option, + /** + * A repository on GitHub. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub squash_merge_commit_title: Option, #[serde( default, skip_serializing_if = "String::is_empty", @@ -2405,6 +3316,9 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub stargazers_url: String, + /** + * A repository on GitHub. + */ #[serde( default, skip_serializing_if = "String::is_empty", @@ -2417,15 +3331,6 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub statuses_url: String, - /** - * A git repository - */ - #[serde( - default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" - )] - pub subscribers_count: i64, #[serde( default, skip_serializing_if = "String::is_empty", @@ -2456,16 +3361,17 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub teams_url: String, + /** + * A repository on GitHub. + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub temp_clone_token: String, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub template_repository: Option, /** - * A git repository + * The functions in the package that are affected by the vulnerability. */ #[serde( default, @@ -2479,6 +3385,9 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub trees_url: String, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, skip_serializing_if = "Option::is_none", @@ -2491,6 +3400,17 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub url: String, + /** + * A repository on GitHub. + */ + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub use_squash_pr_title_as_default: bool, + /** + * A repository on GitHub. + */ #[serde( default, skip_serializing_if = "String::is_empty", @@ -2509,6 +3429,14 @@ pub struct Repository { deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] pub watchers_count: i64, + /** + * A repository on GitHub. + */ + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub web_commit_signoff_required: bool, } /// Authentication token for a GitHub App installed on a user or org. @@ -2521,7 +3449,7 @@ pub struct InstallationToken { )] pub expires_at: String, /** - * Authentication token for a GitHub App installed on a user or org. + * Authentication token for a GitHub App installed on a user or org. */ #[serde( default, @@ -2529,12 +3457,12 @@ pub struct InstallationToken { )] pub has_multiple_single_files: bool, /** - * Authentication token for a GitHub App installed on a user or org. + * Authentication token for a GitHub App installed on a user or org. */ #[serde(default, skip_serializing_if = "Option::is_none")] pub permissions: Option, /** - * Authentication token for a GitHub App installed on a user or org. + * Authentication token for a GitHub App installed on a user or org. */ #[serde( default, @@ -2543,10 +3471,13 @@ pub struct InstallationToken { )] pub repositories: Vec, /** - * Authentication token for a GitHub App installed on a user or org. + * Authentication token for a GitHub App installed on a user or org. */ #[serde(default, skip_serializing_if = "Option::is_none")] pub repository_selection: Option, + /** + * Authentication token for a GitHub App installed on a user or org. + */ #[serde( default, skip_serializing_if = "String::is_empty", @@ -2554,7 +3485,7 @@ pub struct InstallationToken { )] pub single_file: String, /** - * Authentication token for a GitHub App installed on a user or org. + * The functions in the package that are affected by the vulnerability. */ #[serde( default, @@ -2571,119 +3502,92 @@ pub struct InstallationToken { } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct App { +pub struct ScopedInstallation { + /** + * A GitHub user. + */ + pub account: SimpleUser, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub client_id: String, + pub has_multiple_single_files: bool, + /** + * The permissions granted to the user access token. + */ + pub permissions: AppPermissions, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub name: String, + pub repositories_url: String, + /** + * Describe whether all repositories have been selected or there's a selection involved + */ + #[serde(default, skip_serializing_if = "RepositorySelection::is_noop")] + pub repository_selection: RepositorySelection, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub url: String, -} - -/// The authorization associated with an OAuth Access. -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct ApplicationGrant { - pub app: App, - #[serde( - default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" - )] - pub created_at: Option>, - #[serde( - default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" - )] - pub id: i64, + pub single_file_name: String, /** - * The list of events for the GitHub app + * The functions in the package that are affected by the vulnerability. */ #[serde( default, skip_serializing_if = "Vec::is_empty", deserialize_with = "crate::utils::deserialize_null_vector::deserialize" )] - pub scopes: Vec, - #[serde( - default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" - )] - pub updated_at: Option>, - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" - )] - pub url: String, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub user: Option, + pub single_file_paths: Vec, } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct ScopedInstallation { - /** - * Simple User - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub account: Option, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub has_multiple_single_files: bool, - /** - * The permissions granted to the user-to-server access token. - */ - pub permissions: AppPermissions, +pub struct App { #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub repositories_url: String, - /** - * Describe whether all repositories have been selected or there's a selection involved - */ - #[serde(default, skip_serializing_if = "RepositorySelection::is_noop")] - pub repository_selection: RepositorySelection, + pub client_id: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub single_file_name: String, + pub name: String, #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub single_file_paths: Vec, + pub url: String, } /// The authorization for an OAuth app, GitHub App, or a Personal Access Token. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] pub struct Authorization { pub app: App, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::utils::date_time_format::deserialize" )] pub created_at: Option>, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" + )] + pub expires_at: Option>, #[serde( default, skip_serializing_if = "String::is_empty", @@ -2717,7 +3621,7 @@ pub struct Authorization { )] pub note_url: String, /** - * The list of events for the GitHub app + * The functions in the package that are affected by the vulnerability. */ #[serde( default, @@ -2737,6 +3641,9 @@ pub struct Authorization { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub token_last_eight: String, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, skip_serializing_if = "Option::is_none", @@ -2749,147 +3656,56 @@ pub struct Authorization { deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub url: String, + /** + * A GitHub user. + */ #[serde(default, skip_serializing_if = "Option::is_none")] - pub user: Option, + pub user: Option, } -/// Code Of Conduct +/// A GitHub repository view for Classroom #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct CodeOfConduct { +pub struct SimpleClassroomRepository { #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub body: String, - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" - )] - pub html_url: String, + pub default_branch: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub key: String, + pub full_name: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub name: String, + pub html_url: String, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub url: String, -} - -/** - * The policy that controls the repositories in the organization that are allowed to run GitHub Actions. Can be one of: `all`, `none`, or `selected`. - */ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema, Default)] -pub enum EnabledRepositories { - #[serde(rename = "all")] - All, - #[serde(rename = "none")] - None, - #[serde(rename = "selected")] - Selected, - #[serde(rename = "")] - #[default] - Noop, - #[serde(other)] - FallthroughString, -} - -impl std::fmt::Display for EnabledRepositories { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - EnabledRepositories::All => "all", - EnabledRepositories::None => "none", - EnabledRepositories::Selected => "selected", - EnabledRepositories::Noop => "", - EnabledRepositories::FallthroughString => "*", - } - .fmt(f) - } -} - -impl EnabledRepositories { - pub fn is_noop(&self) -> bool { - matches!(self, EnabledRepositories::Noop) - } -} - -/** - * The permissions policy that controls the actions that are allowed to run. Can be one of: `all`, `local_only`, or `selected`. - */ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema, Default)] -pub enum AllowedActions { - #[serde(rename = "all")] - All, - #[serde(rename = "local_only")] - LocalOnly, - #[serde(rename = "selected")] - Selected, - #[serde(rename = "")] - #[default] - Noop, - #[serde(other)] - FallthroughString, -} - -impl std::fmt::Display for AllowedActions { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - AllowedActions::All => "all", - AllowedActions::LocalOnly => "local_only", - AllowedActions::Selected => "selected", - AllowedActions::Noop => "", - AllowedActions::FallthroughString => "*", - } - .fmt(f) - } -} - -impl AllowedActions { - pub fn is_noop(&self) -> bool { - matches!(self, AllowedActions::Noop) - } -} - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct ActionsEnterprisePermissions { - /** - * The permissions policy that controls the actions that are allowed to run. Can be one of: `all`, `local_only`, or `selected`. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub allowed_actions: Option, - /** - * The policy that controls the repositories in the organization that are allowed to run GitHub Actions. Can be one of: `all`, `none`, or `selected`. - */ - pub enabled_organizations: EnabledRepositories, + pub id: i64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub selected_actions_url: String, + pub node_id: String, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub selected_organizations_url: String, + pub private: bool, } -/// Organization Simple +/// A GitHub organization. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct OrganizationSimple { +pub struct SimpleClassroomOrganization { #[serde( default, skip_serializing_if = "String::is_empty", @@ -2901,19 +3717,7 @@ pub struct OrganizationSimple { skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub description: String, - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" - )] - pub events_url: String, - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" - )] - pub hooks_url: String, + pub html_url: String, #[serde( default, skip_serializing_if = "crate::utils::zero_i64", @@ -2925,175 +3729,124 @@ pub struct OrganizationSimple { skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub issues_url: String, - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" - )] pub login: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub members_url: String, + pub name: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub node_id: String, - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" - )] - pub public_members_url: String, - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" - )] - pub repos_url: String, - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" - )] - pub url: String, -} - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct SelectedActions { - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub github_owned_allowed: bool, - /** - * The list of events for the GitHub app - */ - #[serde( - default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" - )] - pub patterns_allowed: Vec, - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub verified_allowed: bool, } +/// A GitHub Classroom classroom #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct RunnerGroupsEnterprise { - #[serde( - default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" - )] - pub allows_public_repositories: bool, +pub struct Classroom { #[serde( default, deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub default: bool, + pub archived: bool, #[serde( default, - skip_serializing_if = "crate::utils::zero_f64", - deserialize_with = "crate::utils::deserialize_null_f64::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub id: f64, + pub id: i64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] pub name: String, + /** + * A GitHub organization. + */ + pub organization: SimpleClassroomOrganization, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub runners_url: String, - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" - )] - pub selected_organizations_url: String, - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" - )] - pub visibility: String, + pub url: String, } /** - * The type of label. Read-only labels are applied automatically when the runner is configured. + * Whether it's a group assignment or individual assignment. */ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema, Default)] -pub enum Type { - #[serde(rename = "custom")] - Custom, - #[serde(rename = "read-only")] - ReadOnly, +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum ClassroomAssignmentType { + #[serde(rename = "group")] + Group, + #[serde(rename = "individual")] + Individual, #[serde(rename = "")] - #[default] Noop, #[serde(other)] FallthroughString, } -impl std::fmt::Display for Type { +impl std::fmt::Display for ClassroomAssignmentType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Type::Custom => "custom", - Type::ReadOnly => "read-only", - Type::Noop => "", - Type::FallthroughString => "*", + ClassroomAssignmentType::Group => "group", + ClassroomAssignmentType::Individual => "individual", + ClassroomAssignmentType::Noop => "", + ClassroomAssignmentType::FallthroughString => "*", } .fmt(f) } } -impl Type { +impl Default for ClassroomAssignmentType { + fn default() -> ClassroomAssignmentType { + ClassroomAssignmentType::Noop + } +} +impl ClassroomAssignmentType { pub fn is_noop(&self) -> bool { - matches!(self, Type::Noop) + matches!(self, ClassroomAssignmentType::Noop) } } +/// A GitHub Classroom assignment #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct Labels { +pub struct ClassroomAssignment { #[serde( default, skip_serializing_if = "crate::utils::zero_i64", deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub id: i64, + pub accepted: i64, + /** + * A GitHub Classroom classroom + */ + pub classroom: Classroom, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" + )] + pub deadline: Option>, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub name: String, - /** - * The type of label. Read-only labels are applied automatically when the runner is configured. - */ - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub type_: Option, -} - -/// A self hosted runner -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct Runner { + pub editor: String, #[serde( default, deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub busy: bool, + pub feedback_pull_requests_enabled: bool, #[serde( default, skip_serializing_if = "crate::utils::zero_i64", @@ -3102,608 +3855,1095 @@ pub struct Runner { pub id: i64, #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub labels: Vec, + pub invitations_enabled: bool, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub name: String, + pub invite_link: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub os: String, + pub language: String, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub status: String, -} - -/// Runner Application -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct RunnerApplication { + pub max_members: i64, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub architecture: String, + pub max_teams: i64, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub download_url: String, + pub passing: i64, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub filename: String, + pub public_repo: bool, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub os: String, + pub slug: String, + /** + * A GitHub repository view for Classroom + */ + pub starter_code_repository: SimpleClassroomRepository, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize", - rename = "sha256_checksum" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub sha_256_checksum: String, + pub students_are_repo_admins: bool, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub temp_download_token: String, -} - -/// Authentication Token -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct AuthenticationToken { + pub submitted: i64, #[serde( default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub expires_at: Option>, - /** - * The request headers sent with the webhook delivery. - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub permissions: Option, + pub title: String, /** - * Authentication Token + * Whether it's a group assignment or individual assignment. */ #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + skip_serializing_if = "ClassroomAssignmentType::is_noop", + rename = "type" )] - pub repositories: Vec, - /** - * Authentication Token - */ - #[serde(default, skip_serializing_if = "Option::is_none")] - pub repository_selection: Option, + pub type_: ClassroomAssignmentType, +} + +/// A GitHub user simplified for Classroom. +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct SimpleClassroomUser { #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub single_file: String, + pub avatar_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub token: String, -} - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct ActorLocation { + pub html_url: String, + #[serde( + default, + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + )] + pub id: i64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub country_name: String, + pub login: String, } +/// A GitHub Classroom classroom #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct AuditLogEvent { +pub struct SimpleClassroom { + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub archived: bool, #[serde( default, skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize", - rename = "@timestamp" + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub timestamp: i64, + pub id: i64, #[serde( default, skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize", - rename = "_document_id" + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub document_id: String, + pub name: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub action: String, + pub url: String, +} + +/// A GitHub Classroom assignment +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct SimpleClassroomAssignment { #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub active: bool, + pub accepted: i64, + /** + * A GitHub Classroom classroom + */ + pub classroom: SimpleClassroom, + /** + * The date and time of when the advisory was published, in ISO 8601 format. + */ #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" )] - pub active_was: bool, + pub deadline: Option>, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub actor: String, + pub editor: String, + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub feedback_pull_requests_enabled: bool, #[serde( default, skip_serializing_if = "crate::utils::zero_i64", deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub actor_id: i64, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub actor_location: Option, + pub id: i64, + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub invitations_enabled: bool, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub blocked_user: String, + pub invite_link: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub business: String, + pub language: String, /** - * The list of events for the GitHub app + * A GitHub Classroom assignment */ #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub config: Vec, + pub max_members: i64, /** - * The list of events for the GitHub app + * A GitHub Classroom assignment */ #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub config_was: Vec, + pub max_teams: i64, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub content_type: String, + pub passing: i64, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub created_at: i64, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub data: Option, + pub public_repo: bool, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub deploy_key_fingerprint: String, + pub slug: String, + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub students_are_repo_admins: bool, + #[serde( + default, + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + )] + pub submitted: i64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub emoji: String, + pub title: String, /** - * The list of events for the GitHub app + * Whether it's a group assignment or individual assignment. */ #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + skip_serializing_if = "ClassroomAssignmentType::is_noop", + rename = "type" )] - pub events: Vec, + pub type_: ClassroomAssignmentType, +} + +/// A GitHub Classroom accepted assignment +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct ClassroomAcceptedAssignment { /** - * The list of events for the GitHub app + * A GitHub Classroom assignment */ + pub assignment: SimpleClassroomAssignment, #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" - )] - pub events_were: Vec, - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub explanation: String, + pub commit_count: i64, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub fingerprint: String, + pub grade: String, #[serde( default, skip_serializing_if = "crate::utils::zero_i64", deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub hook_id: i64, + pub id: i64, #[serde( default, deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub limited_availability: bool, + pub passing: bool, + /** + * A GitHub repository view for Classroom + */ + pub repository: SimpleClassroomRepository, + #[serde( + default, + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + )] + pub students: Vec, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub message: String, + pub submitted: bool, +} + +/// Grade for a student or groups GitHub Classroom assignment +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct ClassroomAssignmentGrade { #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub name: String, + pub assignment_name: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub old_user: String, + pub assignment_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub openssh_public_key: String, + pub github_username: String, + /** + * Grade for a student or groups GitHub Classroom assignment + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub org: String, + pub group_name: String, #[serde( default, skip_serializing_if = "crate::utils::zero_i64", deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub org_id: i64, + pub points_available: i64, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + skip_serializing_if = "crate::utils::zero_i64", + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub previous_visibility: String, + pub points_awarded: i64, #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub read_only: bool, + pub roster_identifier: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub repo: String, + pub starter_code_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub repository: String, + pub student_repository_name: String, #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub repository_public: bool, + pub student_repository_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub target_login: String, + pub submission_timestamp: String, +} + +/// Code Of Conduct +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct CodeOfConduct { + /** + * Code Of Conduct + */ #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub team: String, + pub body: String, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub transport_protocol: i64, + pub html_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub transport_protocol_name: String, + pub key: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub user: String, + pub name: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub visibility: String, + pub url: String, } +/// GitHub Actions cache retention policy for an enterprise. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct MinutesUsedBreakdown { +pub struct ActionsCacheRetentionLimitEnterprise { + /** + * GitHub Actions cache retention policy for an enterprise. + */ #[serde( default, skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize", - rename = "MACOS" + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub macos: i64, + pub max_cache_retention_days: i64, +} + +/// GitHub Actions cache storage policy for an enterprise. +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct ActionsCacheStorageLimitEnterprise { + /** + * GitHub Actions cache storage policy for an enterprise. + */ #[serde( default, skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize", - rename = "UBUNTU" + deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub ubuntu: i64, + pub max_cache_size_gb: i64, +} + +/** + * The type of the code security configuration. + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum TargetType { + #[serde(rename = "enterprise")] + Enterprise, + #[serde(rename = "global")] + Global, + #[serde(rename = "organization")] + Organization, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for TargetType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TargetType::Enterprise => "enterprise", + TargetType::Global => "global", + TargetType::Organization => "organization", + TargetType::Noop => "", + TargetType::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for TargetType { + fn default() -> TargetType { + TargetType::Noop + } +} +impl TargetType { + pub fn is_noop(&self) -> bool { + matches!(self, TargetType::Noop) + } +} + +/** + * The enablement status of GitHub Advanced Security + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum AdvancedSecurity { + #[serde(rename = "code_security")] + CodeSecurity, + #[serde(rename = "disabled")] + Disabled, + #[serde(rename = "enabled")] + Enabled, + #[serde(rename = "secret_protection")] + SecretProtection, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for AdvancedSecurity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AdvancedSecurity::CodeSecurity => "code_security", + AdvancedSecurity::Disabled => "disabled", + AdvancedSecurity::Enabled => "enabled", + AdvancedSecurity::SecretProtection => "secret_protection", + AdvancedSecurity::Noop => "", + AdvancedSecurity::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for AdvancedSecurity { + fn default() -> AdvancedSecurity { + AdvancedSecurity::Noop + } +} +impl AdvancedSecurity { + pub fn is_noop(&self) -> bool { + matches!(self, AdvancedSecurity::Noop) + } +} + +/** + * The enablement status of secret scanning + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum SecretScanning { + #[serde(rename = "disabled")] + Disabled, + #[serde(rename = "enabled")] + Enabled, + #[serde(rename = "not_set")] + NotSet, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for SecretScanning { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SecretScanning::Disabled => "disabled", + SecretScanning::Enabled => "enabled", + SecretScanning::NotSet => "not_set", + SecretScanning::Noop => "", + SecretScanning::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for SecretScanning { + fn default() -> SecretScanning { + SecretScanning::Noop + } +} +impl SecretScanning { + pub fn is_noop(&self) -> bool { + matches!(self, SecretScanning::Noop) + } +} + +/// Feature options for Automatic dependency submission +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct DependencyGraphAutosubmitActionOptions { + /** + * Feature options for Automatic dependency submission + */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize", - rename = "WINDOWS" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub windows: i64, + pub labeled_runners: bool, } +/// Feature options for code scanning #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct ActionsBillingUsage { +pub struct CodeScanningOptions { + /** + * Feature options for code scanning + */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub included_minutes: i64, - pub minutes_used_breakdown: MinutesUsedBreakdown, + pub allow_advanced: bool, +} + +/** + * Whether to use labeled runners or standard GitHub runners. + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum RunnerType { + #[serde(rename = "labeled")] + Labeled, + #[serde(rename = "not_set")] + NotSet, + #[serde(rename = "standard")] + Standard, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for RunnerType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RunnerType::Labeled => "labeled", + RunnerType::NotSet => "not_set", + RunnerType::Standard => "standard", + RunnerType::Noop => "", + RunnerType::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for RunnerType { + fn default() -> RunnerType { + RunnerType::Noop + } +} +impl RunnerType { + pub fn is_noop(&self) -> bool { + matches!(self, RunnerType::Noop) + } +} + +/// Feature options for code scanning default setup +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct CodeScanningDefaultSetupOptions { + /** + * Feature options for code scanning default setup + */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub total_minutes_used: i64, + pub runner_label: String, + /** + * Whether to use labeled runners or standard GitHub runners. + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub runner_type: Option, +} + +/** + * The type of the bypass reviewer + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum ReviewerType { + #[serde(rename = "ROLE")] + Role, + #[serde(rename = "TEAM")] + Team, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for ReviewerType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ReviewerType::Role => "ROLE", + ReviewerType::Team => "TEAM", + ReviewerType::Noop => "", + ReviewerType::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for ReviewerType { + fn default() -> ReviewerType { + ReviewerType::Noop + } +} +impl ReviewerType { + pub fn is_noop(&self) -> bool { + matches!(self, ReviewerType::Noop) + } +} + +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct Reviewers { #[serde( default, skip_serializing_if = "crate::utils::zero_i64", deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub total_paid_minutes_used: i64, + pub reviewer_id: i64, + /** + * The type of the bypass reviewer + */ + #[serde(default, skip_serializing_if = "ReviewerType::is_noop")] + pub reviewer_type: ReviewerType, } +/// Feature options for secret scanning delegated bypass #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct PackagesBillingUsage { +pub struct SecretScanningDelegatedBypassOptions { + /** + * Feature options for secret scanning delegated bypass + */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "Vec::is_empty", + deserialize_with = "crate::utils::deserialize_null_vector::deserialize" )] - pub included_gigabytes_bandwidth: i64, + pub reviewers: Vec, +} + +/** + * The enforcement status for a security configuration + */ +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub enum Enforcement { + #[serde(rename = "enforced")] + Enforced, + #[serde(rename = "unenforced")] + Unenforced, + #[serde(rename = "")] + Noop, + #[serde(other)] + FallthroughString, +} + +impl std::fmt::Display for Enforcement { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Enforcement::Enforced => "enforced", + Enforcement::Unenforced => "unenforced", + Enforcement::Noop => "", + Enforcement::FallthroughString => "*", + } + .fmt(f) + } +} + +impl Default for Enforcement { + fn default() -> Enforcement { + Enforcement::Noop + } +} +impl Enforcement { + pub fn is_noop(&self) -> bool { + matches!(self, Enforcement::Noop) + } +} + +/// A code security configuration +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct CodeSecurityConfiguration { + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub advanced_security: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub code_scanning_default_setup: Option, + /** + * Feature options for code scanning default setup + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub code_scanning_default_setup_options: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub code_scanning_delegated_alert_dismissal: Option, + /** + * Feature options for code scanning + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub code_scanning_options: Option, + /** + * A code security configuration + */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" + )] + pub created_at: Option>, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dependabot_alerts: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dependabot_delegated_alert_dismissal: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dependabot_security_updates: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dependency_graph: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dependency_graph_autosubmit_action: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dependency_graph_autosubmit_action_options: Option, + /** + * A code security configuration + */ + #[serde( + default, + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" + )] + pub description: String, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub enforcement: Option, + /** + * A code security configuration + */ + #[serde( + default, + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub total_gigabytes_bandwidth_used: i64, + pub html_url: String, + /** + * A code security configuration + */ #[serde( default, skip_serializing_if = "crate::utils::zero_i64", deserialize_with = "crate::utils::deserialize_null_i64::deserialize" )] - pub total_paid_gigabytes_bandwidth_used: i64, + pub id: i64, + /** + * A code security configuration + */ + #[serde( + default, + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" + )] + pub name: String, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub private_vulnerability_reporting: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub secret_scanning: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub secret_scanning_delegated_alert_dismissal: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub secret_scanning_delegated_bypass: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub secret_scanning_delegated_bypass_options: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub secret_scanning_generic_secrets: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub secret_scanning_non_provider_patterns: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub secret_scanning_push_protection: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub secret_scanning_validity_checks: Option, + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub target_type: Option, + /** + * A code security configuration + */ + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::utils::date_time_format::deserialize" + )] + pub updated_at: Option>, + /** + * A code security configuration + */ + #[serde( + default, + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" + )] + pub url: String, } +/// Security Configuration feature options for code scanning #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct CombinedBillingUsage { +pub struct CodeScanningOptionsData { + /** + * Security Configuration feature options for code scanning + */ #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub days_left_in_billing_cycle: i64, + pub allow_advanced: bool, +} + +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct CodeSecurityDefaultConfigurations { + /** + * A code security configuration + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub configuration: Option, + /** + * The visibility of newly created repositories for which the code security configuration will be applied to by default + */ + #[serde(default, skip_serializing_if = "Option::is_none")] + pub default_for_new_repos: Option, +} + +/// A GitHub repository. +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] +pub struct SimpleRepository { #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub estimated_paid_storage_for_month: i64, + pub archive_url: String, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub estimated_storage_for_month: i64, -} - -/// Actor -#[derive(Serialize, Default, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct Actor { + pub assignees_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub avatar_url: String, + pub blobs_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub display_login: String, + pub branches_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub gravatar_id: String, + pub collaborators_url: String, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub id: i64, + pub comments_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub login: String, + pub commits_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub url: String, -} - -/// Color-coded labels help you categorize and filter your issues (just like labels in Gmail). -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct Label { + pub compare_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub color: String, + pub contents_url: String, #[serde( default, - deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub default: bool, + pub contributors_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub description: String, + pub deployments_url: String, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub id: i64, + pub description: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub name: String, + pub downloads_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub node_id: String, + pub events_url: String, + #[serde( + default, + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" + )] + pub fork: bool, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub url: String, -} - -/** - * The state of the milestone. - */ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema, Default)] -pub enum State { - #[serde(rename = "closed")] - Closed, - #[serde(rename = "open")] - #[default] - Open, - #[serde(other)] - FallthroughString, -} - -impl std::fmt::Display for State { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - State::Closed => "closed", - State::Open => "open", - State::FallthroughString => "*", - } - .fmt(f) - } -} - -/// A collection of related issues and pull requests. -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct Milestone { + pub forks_url: String, #[serde( default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub closed_at: Option>, + pub full_name: String, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub closed_issues: i64, + pub git_commits_url: String, #[serde( default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub created_at: Option>, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub creator: Option, + pub git_refs_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub description: String, + pub git_tags_url: String, #[serde( default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub due_on: Option>, + pub hooks_url: String, #[serde( default, skip_serializing_if = "String::is_empty", @@ -3721,955 +4961,1180 @@ pub struct Milestone { skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub labels_url: String, + pub issue_comment_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub node_id: String, + pub issue_events_url: String, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub number: i64, + pub issues_url: String, #[serde( default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub open_issues: i64, - /** - * The state of the milestone. - */ - #[serde(default)] - pub state: State, + pub keys_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub title: String, + pub labels_url: String, #[serde( default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub updated_at: Option>, + pub languages_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub url: String, -} - -/** - * How the author is associated with the repository. - */ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema, Default)] -pub enum AuthorAssociation { - #[serde(rename = "COLLABORATOR")] - Collaborator, - #[serde(rename = "CONTRIBUTOR")] - Contributor, - #[serde(rename = "FIRST_TIMER")] - FirstTimer, - #[serde(rename = "FIRST_TIME_CONTRIBUTOR")] - FirstTimeContributor, - #[serde(rename = "MANNEQUIN")] - Mannequin, - #[serde(rename = "MEMBER")] - Member, - #[serde(rename = "NONE")] - None, - #[serde(rename = "OWNER")] - Owner, - #[serde(rename = "")] - #[default] - Noop, - #[serde(other)] - FallthroughString, -} - -impl std::fmt::Display for AuthorAssociation { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - AuthorAssociation::Collaborator => "COLLABORATOR", - AuthorAssociation::Contributor => "CONTRIBUTOR", - AuthorAssociation::FirstTimer => "FIRST_TIMER", - AuthorAssociation::FirstTimeContributor => "FIRST_TIME_CONTRIBUTOR", - AuthorAssociation::Mannequin => "MANNEQUIN", - AuthorAssociation::Member => "MEMBER", - AuthorAssociation::None => "NONE", - AuthorAssociation::Owner => "OWNER", - AuthorAssociation::Noop => "", - AuthorAssociation::FallthroughString => "*", - } - .fmt(f) - } -} - -impl AuthorAssociation { - pub fn is_noop(&self) -> bool { - matches!(self, AuthorAssociation::Noop) - } -} - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct PullRequest { - #[serde( - default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" - )] - pub diff_url: String, + pub merges_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub html_url: String, - #[serde( - default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" - )] - pub merged_at: Option>, + pub milestones_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub patch_url: String, + pub name: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub url: String, -} - -/// Issue Simple -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)] -pub struct IssueSimple { + pub node_id: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub active_lock_reason: String, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub assignee: Option, - #[serde( - default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" - )] - pub assignees: Vec, + pub notifications_url: String, /** - * How the author is associated with the repository. + * A GitHub user. */ - pub author_association: AuthorAssociation, + pub owner: SimpleUser, #[serde( default, - skip_serializing_if = "String::is_empty", - deserialize_with = "crate::utils::deserialize_null_string::deserialize" + deserialize_with = "crate::utils::deserialize_null_boolean::deserialize" )] - pub body: String, + pub private: bool, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub body_html: String, + pub pulls_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub body_text: String, - #[serde( - default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" - )] - pub closed_at: Option>, - #[serde( - default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" - )] - pub comments: i64, + pub releases_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub comments_url: String, - #[serde( - default, - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::utils::date_time_format::deserialize" - )] - pub created_at: Option>, + pub stargazers_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub events_url: String, + pub statuses_url: String, #[serde( default, skip_serializing_if = "String::is_empty", deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub html_url: String, - #[serde( - default, - skip_serializing_if = "crate::utils::zero_i64", - deserialize_with = "crate::utils::deserialize_null_i64::deserialize" - )] - pub id: i64, + pub subscribers_url: String, #[serde( default, - skip_serializing_if = "Vec::is_empty", - deserialize_with = "crate::utils::deserialize_null_vector::deserialize" + skip_serializing_if = "String::is_empty", + deserialize_with = "crate::utils::deserialize_null_string::deserialize" )] - pub labels: Vec