diff --git a/Cargo.lock b/Cargo.lock index 14a7005..facefeb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -916,7 +916,7 @@ dependencies = [ [[package]] name = "roctogen" -version = "0.11.0" +version = "0.12.0" dependencies = [ "base64", "cfg-if 0.1.10", diff --git a/Cargo.toml b/Cargo.toml index 087f0f8..bf3e177 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "roctogen" -version = "0.11.0" +version = "0.12.0" authors = [ "Roctogen contributors" ] description = "Github API and models generated from the official swagger OpenAPI specification" license = "Apache-2.0" diff --git a/README.md b/README.md index c1066d6..2a6af70 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Add the following to your `Cargo.toml` file ```nocompile [dependencies] -roctogen = "0.9" +roctogen = "0.12" ``` ## API @@ -62,6 +62,7 @@ Supported endpoints: - [Checks](https://docs.rs/roctogen/latest/roctogen/endpoints/checks/struct.Checks.html) - [Billing](https://docs.rs/roctogen/latest/roctogen/endpoints/billing/struct.Billing.html) - [Interactions](https://docs.rs/roctogen/latest/roctogen/endpoints/interactions/struct.Interactions.html) + - [Codespaces](https://docs.rs/roctogen/latest/roctogen/endpoints/codespaces/struct.Codespaces.html) - [Emojis](https://docs.rs/roctogen/latest/roctogen/endpoints/emojis/struct.Emojis.html) ## Usage diff --git a/src/endpoints/actions.rs b/src/endpoints/actions.rs index 19f8d48..1bffeb6 100644 --- a/src/endpoints/actions.rs +++ b/src/endpoints/actions.rs @@ -31,6 +31,48 @@ pub fn new(auth: &Auth) -> Actions { Actions { auth } } +/// Errors for the [Add custom labels to a self-hosted runner for an organization](Actions::add_custom_labels_to_self_hosted_runner_for_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsAddCustomLabelsToSelfHostedRunnerForOrgError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Validation failed")] + Status422(ValidationErrorSimple), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Add custom labels to a self-hosted runner for a repository](Actions::add_custom_labels_to_self_hosted_runner_for_repo_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsAddCustomLabelsToSelfHostedRunnerForRepoError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Validation failed")] + Status422(ValidationErrorSimple), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + /// Errors for the [Add repository access to a self-hosted runner group in an organization](Actions::add_repo_access_to_self_hosted_runner_group_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError { @@ -1022,6 +1064,44 @@ pub enum ActionsListJobsForWorkflowRunAttemptError { Generic { code: u16 }, } +/// Errors for the [List labels for a self-hosted runner for an organization](Actions::list_labels_for_self_hosted_runner_for_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsListLabelsForSelfHostedRunnerForOrgError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [List labels for a self-hosted runner for a repository](Actions::list_labels_for_self_hosted_runner_for_repo_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsListLabelsForSelfHostedRunnerForRepoError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + /// Errors for the [List organization secrets](Actions::list_org_secrets_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListOrgSecretsError { @@ -1294,6 +1374,86 @@ pub enum ActionsReRunWorkflowError { Generic { code: u16 }, } +/// Errors for the [Remove all custom labels from a self-hosted runner for an organization](Actions::remove_all_custom_labels_from_self_hosted_runner_for_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Remove all custom labels from a self-hosted runner for a repository](Actions::remove_all_custom_labels_from_self_hosted_runner_for_repo_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Remove a custom label from a self-hosted runner for an organization](Actions::remove_custom_label_from_self_hosted_runner_for_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Validation failed")] + Status422(ValidationErrorSimple), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Remove a custom label from a self-hosted runner for a repository](Actions::remove_custom_label_from_self_hosted_runner_for_repo_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Validation failed")] + Status422(ValidationErrorSimple), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + /// Errors for the [Remove repository access to a self-hosted runner group in an organization](Actions::remove_repo_access_to_self_hosted_runner_group_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError { @@ -1398,6 +1558,48 @@ pub enum ActionsSetAllowedActionsRepositoryError { Generic { code: u16 }, } +/// Errors for the [Set custom labels for a self-hosted runner for an organization](Actions::set_custom_labels_for_self_hosted_runner_for_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsSetCustomLabelsForSelfHostedRunnerForOrgError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Validation failed")] + Status422(ValidationErrorSimple), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Set custom labels for a self-hosted runner for a repository](Actions::set_custom_labels_for_self_hosted_runner_for_repo_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsSetCustomLabelsForSelfHostedRunnerForRepoError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Validation failed")] + Status422(ValidationErrorSimple), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + /// Errors for the [Set GitHub Actions permissions for an organization](Actions::set_github_actions_permissions_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsSetGithubActionsPermissionsOrganizationError { @@ -2471,28 +2673,24 @@ impl<'enc> From<&'enc PerPage> for ActionsListWorkflowRunsForRepoParams<'enc> { impl<'api> Actions<'api> { /// --- /// - /// # Add repository access to a self-hosted runner group in an organization + /// # Add custom labels to a self-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)." + /// Add custom labels to a self-hosted runner configured in an organization. /// + /// You must authenticate using an access token with the `admin:org` scope to use this 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)." - /// - /// You must authenticate using an access token with the `admin:org` - /// scope to use this endpoint. - /// - /// [GitHub API docs for add_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/reference/actions#add-repository-acess-to-a-self-hosted-runner-group-in-an-organization) + /// [GitHub API docs for add_custom_labels_to_self_hosted_runner_for_org](https://docs.github.com/rest/reference/actions#add-custom-labels-to-a-self-hosted-runner-for-an-organization) /// /// --- - pub async fn add_repo_access_to_self_hosted_runner_group_in_org_async(&self, org: &str, runner_group_id: i32, repository_id: i32) -> Result<(), ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError> { + pub async fn add_custom_labels_to_self_hosted_runner_for_org_async(&self, org: &str, runner_id: i32, body: PostActionsAddCustomLabelsToSelfHostedRunnerForOrg) -> Result { - let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, repository_id); + let request_uri = format!("{}/orgs/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); let req = GitHubRequest { uri: request_uri, - body: None, - method: "PUT", + body: Some(PostActionsAddCustomLabelsToSelfHostedRunnerForOrg::from_json(body)?), + method: "POST", headers: vec![] }; @@ -2508,36 +2706,34 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { - code => Err(ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }), + 404 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status404(crate::adapters::to_json_async(github_response).await?)), + 422 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status422(crate::adapters::to_json_async(github_response).await?)), + code => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Generic { code }), } } } /// --- /// - /// # Add repository access to a self-hosted runner group in an organization + /// # Add custom labels to a self-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)." - /// + /// Add custom labels to a self-hosted runner configured in an organization. /// - /// 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)." - /// - /// You must authenticate using an access token with the `admin:org` - /// scope to use this endpoint. + /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. /// - /// [GitHub API docs for add_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/reference/actions#add-repository-acess-to-a-self-hosted-runner-group-in-an-organization) + /// [GitHub API docs for add_custom_labels_to_self_hosted_runner_for_org](https://docs.github.com/rest/reference/actions#add-custom-labels-to-a-self-hosted-runner-for-an-organization) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_repo_access_to_self_hosted_runner_group_in_org(&self, org: &str, runner_group_id: i32, repository_id: i32) -> Result<(), ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError> { + pub fn add_custom_labels_to_self_hosted_runner_for_org(&self, org: &str, runner_id: i32, body: PostActionsAddCustomLabelsToSelfHostedRunnerForOrg) -> Result { - let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, repository_id); + let request_uri = format!("{}/orgs/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); let req = GitHubRequest { uri: request_uri, - body: None, - method: "PUT", + body: Some(PostActionsAddCustomLabelsToSelfHostedRunnerForOrg::from_json(body)?), + method: "POST", headers: vec![] }; @@ -2553,29 +2749,34 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { - code => Err(ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }), + 404 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status404(crate::adapters::to_json(github_response)?)), + 422 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status422(crate::adapters::to_json(github_response)?)), + code => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Generic { code }), } } } /// --- /// - /// # Add selected repository to an organization secret + /// # Add custom labels to a self-hosted runner for a repository /// - /// 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. + /// Add custom labels to a self-hosted runner configured in a repository. /// - /// [GitHub API docs for add_selected_repo_to_org_secret](https://docs.github.com/rest/reference/actions#add-selected-repository-to-an-organization-secret) + /// You must authenticate using an access token with the `repo` scope to use this + /// endpoint. + /// + /// [GitHub API docs for add_custom_labels_to_self_hosted_runner_for_repo](https://docs.github.com/rest/reference/actions#add-custom-labels-to-a-self-hosted-runner-for-a-repository) /// /// --- - pub async fn add_selected_repo_to_org_secret_async(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), ActionsAddSelectedRepoToOrgSecretError> { + pub async fn add_custom_labels_to_self_hosted_runner_for_repo_async(&self, owner: &str, repo: &str, runner_id: i32, body: PostActionsAddCustomLabelsToSelfHostedRunnerForRepo) -> Result { - let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); + let request_uri = format!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); let req = GitHubRequest { uri: request_uri, - body: None, - method: "PUT", + body: Some(PostActionsAddCustomLabelsToSelfHostedRunnerForRepo::from_json(body)?), + method: "POST", headers: vec![] }; @@ -2591,31 +2792,35 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { - 409 => Err(ActionsAddSelectedRepoToOrgSecretError::Status409), - code => Err(ActionsAddSelectedRepoToOrgSecretError::Generic { code }), + 404 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status404(crate::adapters::to_json_async(github_response).await?)), + 422 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status422(crate::adapters::to_json_async(github_response).await?)), + code => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Generic { code }), } } } /// --- /// - /// # Add selected repository to an organization secret + /// # Add custom labels to a self-hosted runner for a repository /// - /// 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. + /// Add custom labels to a self-hosted runner configured in a repository. /// - /// [GitHub API docs for add_selected_repo_to_org_secret](https://docs.github.com/rest/reference/actions#add-selected-repository-to-an-organization-secret) + /// You must authenticate using an access token with the `repo` scope to use this + /// endpoint. + /// + /// [GitHub API docs for add_custom_labels_to_self_hosted_runner_for_repo](https://docs.github.com/rest/reference/actions#add-custom-labels-to-a-self-hosted-runner-for-a-repository) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_selected_repo_to_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), ActionsAddSelectedRepoToOrgSecretError> { + pub fn add_custom_labels_to_self_hosted_runner_for_repo(&self, owner: &str, repo: &str, runner_id: i32, body: PostActionsAddCustomLabelsToSelfHostedRunnerForRepo) -> Result { - let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); + let request_uri = format!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); let req = GitHubRequest { uri: request_uri, - body: None, - method: "PUT", + body: Some(PostActionsAddCustomLabelsToSelfHostedRunnerForRepo::from_json(body)?), + method: "POST", headers: vec![] }; @@ -2631,30 +2836,31 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { - 409 => Err(ActionsAddSelectedRepoToOrgSecretError::Status409), - code => Err(ActionsAddSelectedRepoToOrgSecretError::Generic { code }), + 404 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status404(crate::adapters::to_json(github_response)?)), + 422 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status422(crate::adapters::to_json(github_response)?)), + code => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Generic { code }), } } } /// --- /// - /// # Add a self-hosted runner to a group for an organization + /// # Add repository access to a self-hosted runner group in 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)." /// /// - /// Adds a self-hosted runner to a runner group configured in an organization. + /// 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)." /// /// You must authenticate using an access token with the `admin:org` /// scope to use this endpoint. /// - /// [GitHub API docs for add_self_hosted_runner_to_group_for_org](https://docs.github.com/rest/reference/actions#add-a-self-hosted-runner-to-a-group-for-an-organization) + /// [GitHub API docs for add_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/reference/actions#add-repository-acess-to-a-self-hosted-runner-group-in-an-organization) /// /// --- - pub async fn add_self_hosted_runner_to_group_for_org_async(&self, org: &str, runner_group_id: i32, runner_id: i32) -> Result<(), ActionsAddSelfHostedRunnerToGroupForOrgError> { + pub async fn add_repo_access_to_self_hosted_runner_group_in_org_async(&self, org: &str, runner_group_id: i32, repository_id: i32) -> Result<(), ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError> { - let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, runner_id); + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, repository_id); let req = GitHubRequest { @@ -2676,30 +2882,30 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { - code => Err(ActionsAddSelfHostedRunnerToGroupForOrgError::Generic { code }), + code => Err(ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }), } } } /// --- /// - /// # Add a self-hosted runner to a group for an organization + /// # Add repository access to a self-hosted runner group in 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)." /// /// - /// Adds a self-hosted runner to a runner group configured in an organization. + /// 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)." /// /// You must authenticate using an access token with the `admin:org` /// scope to use this endpoint. /// - /// [GitHub API docs for add_self_hosted_runner_to_group_for_org](https://docs.github.com/rest/reference/actions#add-a-self-hosted-runner-to-a-group-for-an-organization) + /// [GitHub API docs for add_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/reference/actions#add-repository-acess-to-a-self-hosted-runner-group-in-an-organization) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_self_hosted_runner_to_group_for_org(&self, org: &str, runner_group_id: i32, runner_id: i32) -> Result<(), ActionsAddSelfHostedRunnerToGroupForOrgError> { + pub fn add_repo_access_to_self_hosted_runner_group_in_org(&self, org: &str, runner_group_id: i32, repository_id: i32) -> Result<(), ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError> { - let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, runner_id); + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, repository_id); let req = GitHubRequest { @@ -2721,18 +2927,186 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { - code => Err(ActionsAddSelfHostedRunnerToGroupForOrgError::Generic { code }), + code => Err(ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }), } } } /// --- /// - /// # Approve a workflow run for a fork pull request + /// # Add selected repository to an organization secret /// - /// 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)." - /// - /// 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 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. + /// + /// [GitHub API docs for add_selected_repo_to_org_secret](https://docs.github.com/rest/reference/actions#add-selected-repository-to-an-organization-secret) + /// + /// --- + pub async fn add_selected_repo_to_org_secret_async(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), ActionsAddSelectedRepoToOrgSecretError> { + + let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 409 => Err(ActionsAddSelectedRepoToOrgSecretError::Status409), + code => Err(ActionsAddSelectedRepoToOrgSecretError::Generic { code }), + } + } + } + + /// --- + /// + /// # Add selected repository to an organization secret + /// + /// 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. + /// + /// [GitHub API docs for add_selected_repo_to_org_secret](https://docs.github.com/rest/reference/actions#add-selected-repository-to-an-organization-secret) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn add_selected_repo_to_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), ActionsAddSelectedRepoToOrgSecretError> { + + let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 409 => Err(ActionsAddSelectedRepoToOrgSecretError::Status409), + code => Err(ActionsAddSelectedRepoToOrgSecretError::Generic { code }), + } + } + } + + /// --- + /// + /// # Add a self-hosted runner to a group 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)." + /// + /// + /// Adds a self-hosted runner to a runner group configured in an organization. + /// + /// You must authenticate using an access token with the `admin:org` + /// scope to use this endpoint. + /// + /// [GitHub API docs for add_self_hosted_runner_to_group_for_org](https://docs.github.com/rest/reference/actions#add-a-self-hosted-runner-to-a-group-for-an-organization) + /// + /// --- + pub async fn add_self_hosted_runner_to_group_for_org_async(&self, org: &str, runner_group_id: i32, runner_id: i32) -> Result<(), ActionsAddSelfHostedRunnerToGroupForOrgError> { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + code => Err(ActionsAddSelfHostedRunnerToGroupForOrgError::Generic { code }), + } + } + } + + /// --- + /// + /// # Add a self-hosted runner to a group 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)." + /// + /// + /// Adds a self-hosted runner to a runner group configured in an organization. + /// + /// You must authenticate using an access token with the `admin:org` + /// scope to use this endpoint. + /// + /// [GitHub API docs for add_self_hosted_runner_to_group_for_org](https://docs.github.com/rest/reference/actions#add-a-self-hosted-runner-to-a-group-for-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn add_self_hosted_runner_to_group_for_org(&self, org: &str, runner_group_id: i32, runner_id: i32) -> Result<(), ActionsAddSelfHostedRunnerToGroupForOrgError> { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + code => Err(ActionsAddSelfHostedRunnerToGroupForOrgError::Generic { code }), + } + } + } + + /// --- + /// + /// # Approve a workflow run for a fork pull request + /// + /// 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)." + /// + /// 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. /// /// [GitHub API docs for approve_workflow_run](https://docs.github.com/rest/reference/actions#approve-a-workflow-run-for-a-fork-pull-request) /// @@ -7618,21 +7992,19 @@ impl<'api> Actions<'api> { /// --- /// - /// # List organization secrets + /// # List labels for a self-hosted runner for an organization /// - /// 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. + /// Lists all labels for a self-hosted runner configured in an organization. /// - /// [GitHub API docs for list_org_secrets](https://docs.github.com/rest/reference/actions#list-organization-secrets) + /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for list_labels_for_self_hosted_runner_for_org](https://docs.github.com/rest/reference/actions#list-labels-for-a-self-hosted-runner-for-an-organization) /// /// --- - pub async fn list_org_secrets_async(&self, org: &str, query_params: Option>) -> Result { + pub async fn list_labels_for_self_hosted_runner_for_org_async(&self, org: &str, runner_id: i32) -> Result { - let mut request_uri = format!("{}/orgs/{}/actions/secrets", super::GITHUB_BASE_API_URL, org); + let request_uri = format!("{}/orgs/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); - if let Some(params) = query_params { - request_uri.push_str("?"); - request_uri.push_str(&serde_urlencoded::to_string(params.into())?); - } let req = GitHubRequest { uri: request_uri, @@ -7653,30 +8025,28 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { - code => Err(ActionsListOrgSecretsError::Generic { code }), + 404 => Err(ActionsListLabelsForSelfHostedRunnerForOrgError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(ActionsListLabelsForSelfHostedRunnerForOrgError::Generic { code }), } } } /// --- /// - /// # List organization secrets + /// # List labels for a self-hosted runner for an organization /// - /// 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. + /// Lists all labels for a self-hosted runner configured in an organization. /// - /// [GitHub API docs for list_org_secrets](https://docs.github.com/rest/reference/actions#list-organization-secrets) + /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for list_labels_for_self_hosted_runner_for_org](https://docs.github.com/rest/reference/actions#list-labels-for-a-self-hosted-runner-for-an-organization) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_org_secrets(&self, org: &str, query_params: Option>) -> Result { + pub fn list_labels_for_self_hosted_runner_for_org(&self, org: &str, runner_id: i32) -> Result { - let mut request_uri = format!("{}/orgs/{}/actions/secrets", super::GITHUB_BASE_API_URL, org); + let request_uri = format!("{}/orgs/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); - if let Some(params) = query_params { - request_uri.push_str("?"); - let qp: ActionsListOrgSecretsParams = params.into(); - request_uri.push_str(&serde_urlencoded::to_string(qp)?); - } let req = GitHubRequest { uri: request_uri, @@ -7697,32 +8067,28 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { - code => Err(ActionsListOrgSecretsError::Generic { code }), + 404 => Err(ActionsListLabelsForSelfHostedRunnerForOrgError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(ActionsListLabelsForSelfHostedRunnerForOrgError::Generic { code }), } } } /// --- /// - /// # List repository access to a self-hosted runner group in an organization + /// # List labels for a self-hosted runner for a repository /// - /// 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)." - /// - /// Lists the repositories with access to a self-hosted runner group configured in an organization. + /// Lists all labels for a self-hosted runner configured in a repository. /// - /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. + /// You must authenticate using an access token with the `repo` scope to use this + /// endpoint. /// - /// [GitHub API docs for list_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/reference/actions#list-repository-access-to-a-self-hosted-runner-group-in-an-organization) + /// [GitHub API docs for list_labels_for_self_hosted_runner_for_repo](https://docs.github.com/rest/reference/actions#list-labels-for-a-self-hosted-runner-for-a-repository) /// /// --- - pub async fn list_repo_access_to_self_hosted_runner_group_in_org_async(&self, org: &str, runner_group_id: i32, query_params: Option>) -> Result { + pub async fn list_labels_for_self_hosted_runner_for_repo_async(&self, owner: &str, repo: &str, runner_id: i32) -> Result { - let mut request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories", super::GITHUB_BASE_API_URL, org, runner_group_id); + let request_uri = format!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); - if let Some(params) = query_params { - request_uri.push_str("?"); - request_uri.push_str(&serde_urlencoded::to_string(params.into())?); - } let req = GitHubRequest { uri: request_uri, @@ -7743,34 +8109,29 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { - code => Err(ActionsListRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }), + 404 => Err(ActionsListLabelsForSelfHostedRunnerForRepoError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(ActionsListLabelsForSelfHostedRunnerForRepoError::Generic { code }), } } } /// --- /// - /// # List repository access to a self-hosted runner group in an organization + /// # List labels for a self-hosted runner for a repository /// - /// 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)." + /// Lists all labels for a self-hosted runner configured in a repository. /// - /// Lists the repositories with access to a self-hosted runner group configured in an organization. - /// - /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. + /// You must authenticate using an access token with the `repo` scope to use this + /// endpoint. /// - /// [GitHub API docs for list_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/reference/actions#list-repository-access-to-a-self-hosted-runner-group-in-an-organization) + /// [GitHub API docs for list_labels_for_self_hosted_runner_for_repo](https://docs.github.com/rest/reference/actions#list-labels-for-a-self-hosted-runner-for-a-repository) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repo_access_to_self_hosted_runner_group_in_org(&self, org: &str, runner_group_id: i32, query_params: Option>) -> Result { + pub fn list_labels_for_self_hosted_runner_for_repo(&self, owner: &str, repo: &str, runner_id: i32) -> Result { - let mut request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories", super::GITHUB_BASE_API_URL, org, runner_group_id); + let request_uri = format!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); - if let Some(params) = query_params { - request_uri.push_str("?"); - let qp: ActionsListRepoAccessToSelfHostedRunnerGroupInOrgParams = params.into(); - request_uri.push_str(&serde_urlencoded::to_string(qp)?); - } let req = GitHubRequest { uri: request_uri, @@ -7791,23 +8152,24 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { - code => Err(ActionsListRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }), + 404 => Err(ActionsListLabelsForSelfHostedRunnerForRepoError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(ActionsListLabelsForSelfHostedRunnerForRepoError::Generic { code }), } } } /// --- /// - /// # List repository secrets + /// # List organization secrets /// - /// 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 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. /// - /// [GitHub API docs for list_repo_secrets](https://docs.github.com/rest/reference/actions#list-repository-secrets) + /// [GitHub API docs for list_org_secrets](https://docs.github.com/rest/reference/actions#list-organization-secrets) /// /// --- - pub async fn list_repo_secrets_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub async fn list_org_secrets_async(&self, org: &str, query_params: Option>) -> Result { - let mut request_uri = format!("{}/repos/{}/{}/actions/secrets", super::GITHUB_BASE_API_URL, owner, repo); + let mut request_uri = format!("{}/orgs/{}/actions/secrets", super::GITHUB_BASE_API_URL, org); if let Some(params) = query_params { request_uri.push_str("?"); @@ -7833,28 +8195,28 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { - code => Err(ActionsListRepoSecretsError::Generic { code }), + code => Err(ActionsListOrgSecretsError::Generic { code }), } } } /// --- /// - /// # List repository secrets + /// # List organization secrets /// - /// 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 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. /// - /// [GitHub API docs for list_repo_secrets](https://docs.github.com/rest/reference/actions#list-repository-secrets) + /// [GitHub API docs for list_org_secrets](https://docs.github.com/rest/reference/actions#list-organization-secrets) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repo_secrets(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub fn list_org_secrets(&self, org: &str, query_params: Option>) -> Result { - let mut request_uri = format!("{}/repos/{}/{}/actions/secrets", super::GITHUB_BASE_API_URL, owner, repo); + let mut request_uri = format!("{}/orgs/{}/actions/secrets", super::GITHUB_BASE_API_URL, org); if let Some(params) = query_params { request_uri.push_str("?"); - let qp: ActionsListRepoSecretsParams = params.into(); + let qp: ActionsListOrgSecretsParams = params.into(); request_uri.push_str(&serde_urlencoded::to_string(qp)?); } @@ -7877,16 +8239,196 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { - code => Err(ActionsListRepoSecretsError::Generic { code }), + code => Err(ActionsListOrgSecretsError::Generic { code }), } } } /// --- /// - /// # List repository workflows + /// # List repository access to a self-hosted runner group in an organization /// - /// 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. + /// 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)." + /// + /// Lists the repositories with access to a self-hosted runner group configured in an organization. + /// + /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for list_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/reference/actions#list-repository-access-to-a-self-hosted-runner-group-in-an-organization) + /// + /// --- + pub async fn list_repo_access_to_self_hosted_runner_group_in_org_async(&self, org: &str, runner_group_id: i32, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories", super::GITHUB_BASE_API_URL, org, runner_group_id); + + if let Some(params) = query_params { + request_uri.push_str("?"); + request_uri.push_str(&serde_urlencoded::to_string(params.into())?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + code => Err(ActionsListRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }), + } + } + } + + /// --- + /// + /// # List repository access to a self-hosted runner group in 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)." + /// + /// Lists the repositories with access to a self-hosted runner group configured in an organization. + /// + /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for list_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/reference/actions#list-repository-access-to-a-self-hosted-runner-group-in-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn list_repo_access_to_self_hosted_runner_group_in_org(&self, org: &str, runner_group_id: i32, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories", super::GITHUB_BASE_API_URL, org, runner_group_id); + + if let Some(params) = query_params { + request_uri.push_str("?"); + let qp: ActionsListRepoAccessToSelfHostedRunnerGroupInOrgParams = params.into(); + request_uri.push_str(&serde_urlencoded::to_string(qp)?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + code => Err(ActionsListRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }), + } + } + } + + /// --- + /// + /// # List repository secrets + /// + /// 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. + /// + /// [GitHub API docs for list_repo_secrets](https://docs.github.com/rest/reference/actions#list-repository-secrets) + /// + /// --- + pub async fn list_repo_secrets_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/repos/{}/{}/actions/secrets", super::GITHUB_BASE_API_URL, owner, repo); + + if let Some(params) = query_params { + request_uri.push_str("?"); + request_uri.push_str(&serde_urlencoded::to_string(params.into())?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + code => Err(ActionsListRepoSecretsError::Generic { code }), + } + } + } + + /// --- + /// + /// # List repository secrets + /// + /// 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. + /// + /// [GitHub API docs for list_repo_secrets](https://docs.github.com/rest/reference/actions#list-repository-secrets) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn list_repo_secrets(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/repos/{}/{}/actions/secrets", super::GITHUB_BASE_API_URL, owner, repo); + + if let Some(params) = query_params { + request_uri.push_str("?"); + let qp: ActionsListRepoSecretsParams = params.into(); + request_uri.push_str(&serde_urlencoded::to_string(qp)?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + code => Err(ActionsListRepoSecretsError::Generic { code }), + } + } + } + + /// --- + /// + /// # List repository workflows + /// + /// 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. /// /// [GitHub API docs for list_repo_workflows](https://docs.github.com/rest/reference/actions#list-repository-workflows) /// @@ -8139,7 +8681,7 @@ impl<'api> Actions<'api> { /// [GitHub API docs for list_selected_repos_for_org_secret](https://docs.github.com/rest/reference/actions#list-selected-repositories-for-an-organization-secret) /// /// --- - pub async fn list_selected_repos_for_org_secret_async(&self, org: &str, secret_name: &str, query_params: Option>) -> Result { + pub async fn list_selected_repos_for_org_secret_async(&self, org: &str, secret_name: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); @@ -8182,7 +8724,7 @@ impl<'api> Actions<'api> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_selected_repos_for_org_secret(&self, org: &str, secret_name: &str, query_params: Option>) -> Result { + pub fn list_selected_repos_for_org_secret(&self, org: &str, secret_name: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); @@ -9015,21 +9557,19 @@ impl<'api> Actions<'api> { /// --- /// - /// # Remove repository access to a self-hosted runner group in an organization + /// # Remove all custom labels from a self-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)." - /// - /// - /// 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)." + /// Remove all custom labels from a self-hosted runner configured in an + /// organization. Returns the remaining read-only labels from the runner. /// /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. /// - /// [GitHub API docs for remove_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/reference/actions#remove-repository-access-to-a-self-hosted-runner-group-in-an-organization) + /// [GitHub API docs for remove_all_custom_labels_from_self_hosted_runner_for_org](https://docs.github.com/rest/reference/actions#remove-all-custom-labels-from-a-self-hosted-runner-for-an-organization) /// /// --- - pub async fn remove_repo_access_to_self_hosted_runner_group_in_org_async(&self, org: &str, runner_group_id: i32, repository_id: i32) -> Result<(), ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError> { + pub async fn remove_all_custom_labels_from_self_hosted_runner_for_org_async(&self, org: &str, runner_id: i32) -> Result { - let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, repository_id); + let request_uri = format!("{}/orgs/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); let req = GitHubRequest { @@ -9051,29 +9591,28 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { - code => Err(ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }), + 404 => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Generic { code }), } } } /// --- /// - /// # Remove repository access to a self-hosted runner group in an organization + /// # Remove all custom labels from a self-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)." - /// - /// - /// 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)." + /// Remove all custom labels from a self-hosted runner configured in an + /// organization. Returns the remaining read-only labels from the runner. /// /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. /// - /// [GitHub API docs for remove_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/reference/actions#remove-repository-access-to-a-self-hosted-runner-group-in-an-organization) + /// [GitHub API docs for remove_all_custom_labels_from_self_hosted_runner_for_org](https://docs.github.com/rest/reference/actions#remove-all-custom-labels-from-a-self-hosted-runner-for-an-organization) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_repo_access_to_self_hosted_runner_group_in_org(&self, org: &str, runner_group_id: i32, repository_id: i32) -> Result<(), ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError> { + pub fn remove_all_custom_labels_from_self_hosted_runner_for_org(&self, org: &str, runner_id: i32) -> Result { - let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, repository_id); + let request_uri = format!("{}/orgs/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); let req = GitHubRequest { @@ -9095,23 +9634,28 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { - code => Err(ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }), + 404 => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Generic { code }), } } } /// --- /// - /// # Remove selected repository from an organization secret + /// # Remove all custom labels from a self-hosted runner for a repository /// - /// 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. + /// Remove all custom labels from a self-hosted runner configured in a + /// repository. Returns the remaining read-only labels from the runner. /// - /// [GitHub API docs for remove_selected_repo_from_org_secret](https://docs.github.com/rest/reference/actions#remove-selected-repository-from-an-organization-secret) + /// You must authenticate using an access token with the `repo` scope to use this + /// endpoint. + /// + /// [GitHub API docs for remove_all_custom_labels_from_self_hosted_runner_for_repo](https://docs.github.com/rest/reference/actions#remove-all-custom-labels-from-a-self-hosted-runner-for-a-repository) /// /// --- - pub async fn remove_selected_repo_from_org_secret_async(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), ActionsRemoveSelectedRepoFromOrgSecretError> { + pub async fn remove_all_custom_labels_from_self_hosted_runner_for_repo_async(&self, owner: &str, repo: &str, runner_id: i32) -> Result { - let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); + let request_uri = format!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); let req = GitHubRequest { @@ -9133,25 +9677,29 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { - 409 => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Status409), - code => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Generic { code }), + 404 => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Generic { code }), } } } /// --- /// - /// # Remove selected repository from an organization secret + /// # Remove all custom labels from a self-hosted runner for a repository /// - /// 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. + /// Remove all custom labels from a self-hosted runner configured in a + /// repository. Returns the remaining read-only labels from the runner. /// - /// [GitHub API docs for remove_selected_repo_from_org_secret](https://docs.github.com/rest/reference/actions#remove-selected-repository-from-an-organization-secret) + /// You must authenticate using an access token with the `repo` scope to use this + /// endpoint. + /// + /// [GitHub API docs for remove_all_custom_labels_from_self_hosted_runner_for_repo](https://docs.github.com/rest/reference/actions#remove-all-custom-labels-from-a-self-hosted-runner-for-a-repository) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_selected_repo_from_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), ActionsRemoveSelectedRepoFromOrgSecretError> { + pub fn remove_all_custom_labels_from_self_hosted_runner_for_repo(&self, owner: &str, repo: &str, runner_id: i32) -> Result { - let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); + let request_uri = format!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); let req = GitHubRequest { @@ -9173,29 +9721,30 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { - 409 => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Status409), - code => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Generic { code }), + 404 => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Generic { code }), } } } /// --- /// - /// # Remove a self-hosted runner from a group for an organization + /// # Remove a custom label from a self-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)." + /// Remove a custom label from a self-hosted runner configured + /// in an organization. Returns the remaining labels from the runner. /// - /// - /// Removes a self-hosted runner from a group configured in an organization. The runner is then returned to the default group. + /// This endpoint returns a `404 Not Found` status if the custom label is not + /// present on the runner. /// /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. /// - /// [GitHub API docs for remove_self_hosted_runner_from_group_for_org](https://docs.github.com/rest/reference/actions#remove-a-self-hosted-runner-from-a-group-for-an-organization) + /// [GitHub API docs for remove_custom_label_from_self_hosted_runner_for_org](https://docs.github.com/rest/reference/actions#remove-a-custom-label-from-a-self-hosted-runner-for-an-organization) /// /// --- - pub async fn remove_self_hosted_runner_from_group_for_org_async(&self, org: &str, runner_group_id: i32, runner_id: i32) -> Result<(), ActionsRemoveSelfHostedRunnerFromGroupForOrgError> { + pub async fn remove_custom_label_from_self_hosted_runner_for_org_async(&self, org: &str, runner_id: i32, name: &str) -> Result { - let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, runner_id); + let request_uri = format!("{}/orgs/{}/actions/runners/{}/labels/{}", super::GITHUB_BASE_API_URL, org, runner_id, name); let req = GitHubRequest { @@ -9217,29 +9766,32 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { - code => Err(ActionsRemoveSelfHostedRunnerFromGroupForOrgError::Generic { code }), + 404 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status404(crate::adapters::to_json_async(github_response).await?)), + 422 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status422(crate::adapters::to_json_async(github_response).await?)), + code => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Generic { code }), } } } /// --- /// - /// # Remove a self-hosted runner from a group for an organization + /// # Remove a custom label from a self-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)." + /// Remove a custom label from a self-hosted runner configured + /// in an organization. Returns the remaining labels from the runner. /// - /// - /// Removes a self-hosted runner from a group configured in an organization. The runner is then returned to the default group. + /// This endpoint returns a `404 Not Found` status if the custom label is not + /// present on the runner. /// /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. /// - /// [GitHub API docs for remove_self_hosted_runner_from_group_for_org](https://docs.github.com/rest/reference/actions#remove-a-self-hosted-runner-from-a-group-for-an-organization) + /// [GitHub API docs for remove_custom_label_from_self_hosted_runner_for_org](https://docs.github.com/rest/reference/actions#remove-a-custom-label-from-a-self-hosted-runner-for-an-organization) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_self_hosted_runner_from_group_for_org(&self, org: &str, runner_group_id: i32, runner_id: i32) -> Result<(), ActionsRemoveSelfHostedRunnerFromGroupForOrgError> { + pub fn remove_custom_label_from_self_hosted_runner_for_org(&self, org: &str, runner_id: i32, name: &str) -> Result { - let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, runner_id); + let request_uri = format!("{}/orgs/{}/actions/runners/{}/labels/{}", super::GITHUB_BASE_API_URL, org, runner_id, name); let req = GitHubRequest { @@ -9261,31 +9813,38 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { - code => Err(ActionsRemoveSelfHostedRunnerFromGroupForOrgError::Generic { code }), + 404 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status404(crate::adapters::to_json(github_response)?)), + 422 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status422(crate::adapters::to_json(github_response)?)), + code => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Generic { code }), } } } /// --- /// - /// # Review pending deployments for a workflow run + /// # Remove a custom label from a self-hosted runner for a repository /// - /// Approve or reject pending deployments that are waiting on approval by a required reviewer. + /// Remove a custom label from a self-hosted runner configured + /// in a repository. Returns the remaining labels from the runner. /// - /// Anyone with read access to the repository contents and deployments can use this endpoint. + /// This endpoint returns a `404 Not Found` status if the custom label is not + /// present on the runner. /// - /// [GitHub API docs for review_pending_deployments_for_run](https://docs.github.com/rest/reference/actions#review-pending-deployments-for-a-workflow-run) + /// You must authenticate using an access token with the `repo` scope to use this + /// endpoint. + /// + /// [GitHub API docs for remove_custom_label_from_self_hosted_runner_for_repo](https://docs.github.com/rest/reference/actions#remove-a-custom-label-from-a-self-hosted-runner-for-a-repository) /// /// --- - pub async fn review_pending_deployments_for_run_async(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReviewPendingDeploymentsForRun) -> Result, ActionsReviewPendingDeploymentsForRunError> { + pub async fn remove_custom_label_from_self_hosted_runner_for_repo_async(&self, owner: &str, repo: &str, runner_id: i32, name: &str) -> Result { - let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/pending_deployments", super::GITHUB_BASE_API_URL, owner, repo, run_id); + let request_uri = format!("{}/repos/{}/{}/actions/runners/{}/labels/{}", super::GITHUB_BASE_API_URL, owner, repo, runner_id, name); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsReviewPendingDeploymentsForRun::from_json(body)?), - method: "POST", + body: None, + method: "DELETE", headers: vec![] }; @@ -9301,24 +9860,367 @@ impl<'api> Actions<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { - code => Err(ActionsReviewPendingDeploymentsForRunError::Generic { code }), + 404 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status404(crate::adapters::to_json_async(github_response).await?)), + 422 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status422(crate::adapters::to_json_async(github_response).await?)), + code => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Generic { code }), } } } /// --- /// - /// # Review pending deployments for a workflow run + /// # Remove a custom label from a self-hosted runner for a repository /// - /// Approve or reject pending deployments that are waiting on approval by a required reviewer. + /// Remove a custom label from a self-hosted runner configured + /// in a repository. Returns the remaining labels from the runner. /// - /// Anyone with read access to the repository contents and deployments can use this endpoint. + /// This endpoint returns a `404 Not Found` status if the custom label is not + /// present on the runner. /// - /// [GitHub API docs for review_pending_deployments_for_run](https://docs.github.com/rest/reference/actions#review-pending-deployments-for-a-workflow-run) + /// You must authenticate using an access token with the `repo` scope to use this + /// endpoint. + /// + /// [GitHub API docs for remove_custom_label_from_self_hosted_runner_for_repo](https://docs.github.com/rest/reference/actions#remove-a-custom-label-from-a-self-hosted-runner-for-a-repository) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn review_pending_deployments_for_run(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReviewPendingDeploymentsForRun) -> Result, ActionsReviewPendingDeploymentsForRunError> { + pub fn remove_custom_label_from_self_hosted_runner_for_repo(&self, owner: &str, repo: &str, runner_id: i32, name: &str) -> Result { + + let request_uri = format!("{}/repos/{}/{}/actions/runners/{}/labels/{}", super::GITHUB_BASE_API_URL, owner, repo, runner_id, name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 404 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status404(crate::adapters::to_json(github_response)?)), + 422 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status422(crate::adapters::to_json(github_response)?)), + code => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Generic { code }), + } + } + } + + /// --- + /// + /// # Remove repository access to a self-hosted runner group in 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)." + /// + /// + /// 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. + /// + /// [GitHub API docs for remove_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/reference/actions#remove-repository-access-to-a-self-hosted-runner-group-in-an-organization) + /// + /// --- + pub async fn remove_repo_access_to_self_hosted_runner_group_in_org_async(&self, org: &str, runner_group_id: i32, repository_id: i32) -> Result<(), ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError> { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, repository_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + code => Err(ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }), + } + } + } + + /// --- + /// + /// # Remove repository access to a self-hosted runner group in 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)." + /// + /// + /// 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. + /// + /// [GitHub API docs for remove_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/reference/actions#remove-repository-access-to-a-self-hosted-runner-group-in-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn remove_repo_access_to_self_hosted_runner_group_in_org(&self, org: &str, runner_group_id: i32, repository_id: i32) -> Result<(), ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError> { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, repository_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + code => Err(ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }), + } + } + } + + /// --- + /// + /// # Remove selected repository from an organization secret + /// + /// 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. + /// + /// [GitHub API docs for remove_selected_repo_from_org_secret](https://docs.github.com/rest/reference/actions#remove-selected-repository-from-an-organization-secret) + /// + /// --- + pub async fn remove_selected_repo_from_org_secret_async(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), ActionsRemoveSelectedRepoFromOrgSecretError> { + + let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 409 => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Status409), + code => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Generic { code }), + } + } + } + + /// --- + /// + /// # Remove selected repository from an organization secret + /// + /// 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. + /// + /// [GitHub API docs for remove_selected_repo_from_org_secret](https://docs.github.com/rest/reference/actions#remove-selected-repository-from-an-organization-secret) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn remove_selected_repo_from_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), ActionsRemoveSelectedRepoFromOrgSecretError> { + + let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 409 => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Status409), + code => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Generic { code }), + } + } + } + + /// --- + /// + /// # Remove a self-hosted runner from a group 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)." + /// + /// + /// 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. + /// + /// [GitHub API docs for remove_self_hosted_runner_from_group_for_org](https://docs.github.com/rest/reference/actions#remove-a-self-hosted-runner-from-a-group-for-an-organization) + /// + /// --- + pub async fn remove_self_hosted_runner_from_group_for_org_async(&self, org: &str, runner_group_id: i32, runner_id: i32) -> Result<(), ActionsRemoveSelfHostedRunnerFromGroupForOrgError> { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + code => Err(ActionsRemoveSelfHostedRunnerFromGroupForOrgError::Generic { code }), + } + } + } + + /// --- + /// + /// # Remove a self-hosted runner from a group 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)." + /// + /// + /// 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. + /// + /// [GitHub API docs for remove_self_hosted_runner_from_group_for_org](https://docs.github.com/rest/reference/actions#remove-a-self-hosted-runner-from-a-group-for-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn remove_self_hosted_runner_from_group_for_org(&self, org: &str, runner_group_id: i32, runner_id: i32) -> Result<(), ActionsRemoveSelfHostedRunnerFromGroupForOrgError> { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + code => Err(ActionsRemoveSelfHostedRunnerFromGroupForOrgError::Generic { code }), + } + } + } + + /// --- + /// + /// # Review pending deployments for a workflow run + /// + /// 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. + /// + /// [GitHub API docs for review_pending_deployments_for_run](https://docs.github.com/rest/reference/actions#review-pending-deployments-for-a-workflow-run) + /// + /// --- + pub async fn review_pending_deployments_for_run_async(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReviewPendingDeploymentsForRun) -> Result, ActionsReviewPendingDeploymentsForRunError> { + + let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/pending_deployments", super::GITHUB_BASE_API_URL, owner, repo, run_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PostActionsReviewPendingDeploymentsForRun::from_json(body)?), + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + code => Err(ActionsReviewPendingDeploymentsForRunError::Generic { code }), + } + } + } + + /// --- + /// + /// # Review pending deployments for a workflow run + /// + /// 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. + /// + /// [GitHub API docs for review_pending_deployments_for_run](https://docs.github.com/rest/reference/actions#review-pending-deployments-for-a-workflow-run) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn review_pending_deployments_for_run(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReviewPendingDeploymentsForRun) -> Result, ActionsReviewPendingDeploymentsForRunError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/pending_deployments", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -9525,6 +10427,182 @@ impl<'api> Actions<'api> { } } + /// --- + /// + /// # Set custom labels for a self-hosted runner for an organization + /// + /// Remove all previous custom labels and set the new custom labels for a specific + /// self-hosted runner configured in an organization. + /// + /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for set_custom_labels_for_self_hosted_runner_for_org](https://docs.github.com/rest/reference/actions#set-custom-labels-for-a-self-hosted-runner-for-an-organization) + /// + /// --- + pub async fn set_custom_labels_for_self_hosted_runner_for_org_async(&self, org: &str, runner_id: i32, body: PutActionsSetCustomLabelsForSelfHostedRunnerForOrg) -> Result { + + let request_uri = format!("{}/orgs/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PutActionsSetCustomLabelsForSelfHostedRunnerForOrg::from_json(body)?), + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 404 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status404(crate::adapters::to_json_async(github_response).await?)), + 422 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status422(crate::adapters::to_json_async(github_response).await?)), + code => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Generic { code }), + } + } + } + + /// --- + /// + /// # Set custom labels for a self-hosted runner for an organization + /// + /// Remove all previous custom labels and set the new custom labels for a specific + /// self-hosted runner configured in an organization. + /// + /// You must authenticate using an access token with the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for set_custom_labels_for_self_hosted_runner_for_org](https://docs.github.com/rest/reference/actions#set-custom-labels-for-a-self-hosted-runner-for-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn set_custom_labels_for_self_hosted_runner_for_org(&self, org: &str, runner_id: i32, body: PutActionsSetCustomLabelsForSelfHostedRunnerForOrg) -> Result { + + let request_uri = format!("{}/orgs/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PutActionsSetCustomLabelsForSelfHostedRunnerForOrg::from_json(body)?), + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 404 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status404(crate::adapters::to_json(github_response)?)), + 422 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status422(crate::adapters::to_json(github_response)?)), + code => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Generic { code }), + } + } + } + + /// --- + /// + /// # Set custom labels for a self-hosted runner 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 API docs for set_custom_labels_for_self_hosted_runner_for_repo](https://docs.github.com/rest/reference/actions#set-custom-labels-for-a-self-hosted-runner-for-a-repository) + /// + /// --- + pub async fn set_custom_labels_for_self_hosted_runner_for_repo_async(&self, owner: &str, repo: &str, runner_id: i32, body: PutActionsSetCustomLabelsForSelfHostedRunnerForRepo) -> Result { + + let request_uri = format!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PutActionsSetCustomLabelsForSelfHostedRunnerForRepo::from_json(body)?), + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 404 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status404(crate::adapters::to_json_async(github_response).await?)), + 422 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status422(crate::adapters::to_json_async(github_response).await?)), + code => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Generic { code }), + } + } + } + + /// --- + /// + /// # Set custom labels for a self-hosted runner 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 API docs for set_custom_labels_for_self_hosted_runner_for_repo](https://docs.github.com/rest/reference/actions#set-custom-labels-for-a-self-hosted-runner-for-a-repository) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn set_custom_labels_for_self_hosted_runner_for_repo(&self, owner: &str, repo: &str, runner_id: i32, body: PutActionsSetCustomLabelsForSelfHostedRunnerForRepo) -> Result { + + let request_uri = format!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PutActionsSetCustomLabelsForSelfHostedRunnerForRepo::from_json(body)?), + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 404 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status404(crate::adapters::to_json(github_response)?)), + 422 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status422(crate::adapters::to_json(github_response)?)), + code => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Generic { code }), + } + } + } + /// --- /// /// # Set GitHub Actions permissions for an organization diff --git a/src/endpoints/apps.rs b/src/endpoints/apps.rs index 3264c2a..143eb8f 100644 --- a/src/endpoints/apps.rs +++ b/src/endpoints/apps.rs @@ -75,35 +75,6 @@ pub enum AppsCheckTokenError { Generic { code: u16 }, } -/// Errors for the [Create a content attachment](Apps::create_content_attachment_async()) endpoint. -#[derive(Debug, thiserror::Error)] -pub enum AppsCreateContentAttachmentError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - - #[error("Validation failed")] - Status422(ValidationError), - #[error("Resource not found")] - Status404(BasicError), - #[error("Gone")] - Status410(BasicError), - #[error("Preview header missing")] - Status415(PostProjectsCreateForAuthenticatedUserResponse415), - #[error("Not modified")] - Status304, - #[error("Forbidden")] - Status403(BasicError), - #[error("Status code: {}", code)] - Generic { code: u16 }, -} - /// Errors for the [Create a GitHub App from a manifest](Apps::create_from_manifest_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsCreateFromManifestError { @@ -1486,109 +1457,6 @@ impl<'api> Apps<'api> { } } - /// --- - /// - /// # Create a content attachment - /// - /// 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. - /// - /// [GitHub API docs for create_content_attachment](https://docs.github.com/rest/reference/apps#create-a-content-attachment) - /// - /// The `create_content_attachment_async` endpoint is enabled with the `corsair` cargo feature. - /// - /// --- - #[cfg(feature = "corsair")] - pub async fn create_content_attachment_async(&self, owner: &str, repo: &str, content_reference_id: i32, body: PostAppsCreateContentAttachment) -> Result { - - let request_uri = format!("{}/repos/{}/{}/content_references/{}/attachments", super::GITHUB_BASE_API_URL, owner, repo, content_reference_id); - - - let req = GitHubRequest { - uri: request_uri, - body: Some(PostAppsCreateContentAttachment::from_json(body)?), - method: "POST", - headers: vec![("Accept", "application/vnd.github.corsair-preview+json"), ] - }; - - let request = GitHubRequestBuilder::build(req, self.auth)?; - - // -- - - let github_response = crate::adapters::fetch_async(request).await?; - - // -- - - if github_response.is_success() { - Ok(crate::adapters::to_json_async(github_response).await?) - } else { - match github_response.status_code() { - 422 => Err(AppsCreateContentAttachmentError::Status422(crate::adapters::to_json_async(github_response).await?)), - 404 => Err(AppsCreateContentAttachmentError::Status404(crate::adapters::to_json_async(github_response).await?)), - 410 => Err(AppsCreateContentAttachmentError::Status410(crate::adapters::to_json_async(github_response).await?)), - 415 => Err(AppsCreateContentAttachmentError::Status415(crate::adapters::to_json_async(github_response).await?)), - 304 => Err(AppsCreateContentAttachmentError::Status304), - 403 => Err(AppsCreateContentAttachmentError::Status403(crate::adapters::to_json_async(github_response).await?)), - code => Err(AppsCreateContentAttachmentError::Generic { code }), - } - } - } - - /// --- - /// - /// # Create a content attachment - /// - /// 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. - /// - /// [GitHub API docs for create_content_attachment](https://docs.github.com/rest/reference/apps#create-a-content-attachment) - /// - /// The `create_content_attachment` endpoint is enabled with the `corsair` cargo feature. - /// - /// --- - #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "corsair")] - pub fn create_content_attachment(&self, owner: &str, repo: &str, content_reference_id: i32, body: PostAppsCreateContentAttachment) -> Result { - - let request_uri = format!("{}/repos/{}/{}/content_references/{}/attachments", super::GITHUB_BASE_API_URL, owner, repo, content_reference_id); - - - let req = GitHubRequest { - uri: request_uri, - body: Some(PostAppsCreateContentAttachment::from_json(body)?), - method: "POST", - headers: vec![("Accept", "application/vnd.github.corsair-preview+json"), ] - }; - - let request = GitHubRequestBuilder::build(req, self.auth)?; - - // -- - - let github_response = crate::adapters::fetch(request)?; - - // -- - - if github_response.is_success() { - Ok(crate::adapters::to_json(github_response)?) - } else { - match github_response.status_code() { - 422 => Err(AppsCreateContentAttachmentError::Status422(crate::adapters::to_json(github_response)?)), - 404 => Err(AppsCreateContentAttachmentError::Status404(crate::adapters::to_json(github_response)?)), - 410 => Err(AppsCreateContentAttachmentError::Status410(crate::adapters::to_json(github_response)?)), - 415 => Err(AppsCreateContentAttachmentError::Status415(crate::adapters::to_json(github_response)?)), - 304 => Err(AppsCreateContentAttachmentError::Status304), - 403 => Err(AppsCreateContentAttachmentError::Status403(crate::adapters::to_json(github_response)?)), - code => Err(AppsCreateContentAttachmentError::Generic { code }), - } - } - } - /// --- /// /// # Create a GitHub App from a manifest @@ -3042,10 +2910,7 @@ impl<'api> Apps<'api> { /// /// [GitHub API docs for list_installation_repos_for_authenticated_user](https://docs.github.com/rest/reference/apps#list-repositories-accessible-to-the-user-access-token) /// - /// The `list_installation_repos_for_authenticated_user_async` endpoint is enabled with the `mercy` cargo feature. - /// /// --- - #[cfg(feature = "mercy")] pub async fn list_installation_repos_for_authenticated_user_async(&self, installation_id: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/user/installations/{}/repositories", super::GITHUB_BASE_API_URL, installation_id); @@ -3059,7 +2924,7 @@ impl<'api> Apps<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.mercy-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -3096,11 +2961,8 @@ impl<'api> Apps<'api> { /// /// [GitHub API docs for list_installation_repos_for_authenticated_user](https://docs.github.com/rest/reference/apps#list-repositories-accessible-to-the-user-access-token) /// - /// The `list_installation_repos_for_authenticated_user` endpoint is enabled with the `mercy` cargo feature. - /// /// --- #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "mercy")] pub fn list_installation_repos_for_authenticated_user(&self, installation_id: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/user/installations/{}/repositories", super::GITHUB_BASE_API_URL, installation_id); @@ -3115,7 +2977,7 @@ impl<'api> Apps<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.mercy-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -3530,10 +3392,7 @@ impl<'api> Apps<'api> { /// /// [GitHub API docs for list_repos_accessible_to_installation](https://docs.github.com/rest/reference/apps#list-repositories-accessible-to-the-app-installation) /// - /// The `list_repos_accessible_to_installation_async` endpoint is enabled with the `mercy` cargo feature. - /// /// --- - #[cfg(feature = "mercy")] pub async fn list_repos_accessible_to_installation_async(&self, query_params: Option>) -> Result { let mut request_uri = format!("{}/installation/repositories", super::GITHUB_BASE_API_URL); @@ -3547,7 +3406,7 @@ impl<'api> Apps<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.mercy-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -3580,11 +3439,8 @@ impl<'api> Apps<'api> { /// /// [GitHub API docs for list_repos_accessible_to_installation](https://docs.github.com/rest/reference/apps#list-repositories-accessible-to-the-app-installation) /// - /// The `list_repos_accessible_to_installation` endpoint is enabled with the `mercy` cargo feature. - /// /// --- #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "mercy")] pub fn list_repos_accessible_to_installation(&self, query_params: Option>) -> Result { let mut request_uri = format!("{}/installation/repositories", super::GITHUB_BASE_API_URL); @@ -3599,7 +3455,7 @@ impl<'api> Apps<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.mercy-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; diff --git a/src/endpoints/billing.rs b/src/endpoints/billing.rs index 1fbee33..23f0aea 100644 --- a/src/endpoints/billing.rs +++ b/src/endpoints/billing.rs @@ -82,6 +82,44 @@ pub enum BillingGetGithubActionsBillingUserError { Generic { code: u16 }, } +/// Errors for the [Get GitHub Advanced Security active committers for an enterprise](Billing::get_github_advanced_security_billing_ghe_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum BillingGetGithubAdvancedSecurityBillingGheError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Response if GitHub Advanced Security is not enabled for this repository")] + Status403(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Get GitHub Advanced Security active committers for an organization](Billing::get_github_advanced_security_billing_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum BillingGetGithubAdvancedSecurityBillingOrgError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Response if GitHub Advanced Security is not enabled for this repository")] + Status403(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + /// Errors for the [Get GitHub Packages billing for an enterprise](Billing::get_github_packages_billing_ghe_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum BillingGetGithubPackagesBillingGheError { @@ -185,6 +223,86 @@ pub enum BillingGetSharedStorageBillingUserError { } +/// Query parameters for the [Get GitHub Advanced Security active committers for an enterprise](Billing::get_github_advanced_security_billing_ghe_async()) endpoint. +#[derive(Default, Serialize)] +pub struct BillingGetGithubAdvancedSecurityBillingGheParams { + /// Results per page (max 100) + per_page: Option, + /// Page number of the results to fetch. + page: Option +} + +impl BillingGetGithubAdvancedSecurityBillingGheParams { + pub fn new() -> Self { + Self::default() + } + + /// Results per page (max 100) + pub fn per_page(self, per_page: u16) -> Self { + Self { + per_page: Some(per_page), + page: self.page, + } + } + + /// Page number of the results to fetch. + pub fn page(self, page: u16) -> Self { + Self { + per_page: self.per_page, + page: Some(page), + } + } +} + +impl<'enc> From<&'enc PerPage> for BillingGetGithubAdvancedSecurityBillingGheParams { + fn from(per_page: &'enc PerPage) -> Self { + Self { + per_page: Some(per_page.per_page), + page: Some(per_page.page), + ..Default::default() + } + } +} +/// Query parameters for the [Get GitHub Advanced Security active committers for an organization](Billing::get_github_advanced_security_billing_org_async()) endpoint. +#[derive(Default, Serialize)] +pub struct BillingGetGithubAdvancedSecurityBillingOrgParams { + /// Results per page (max 100) + per_page: Option, + /// Page number of the results to fetch. + page: Option +} + +impl BillingGetGithubAdvancedSecurityBillingOrgParams { + pub fn new() -> Self { + Self::default() + } + + /// Results per page (max 100) + pub fn per_page(self, per_page: u16) -> Self { + Self { + per_page: Some(per_page), + page: self.page, + } + } + + /// Page number of the results to fetch. + pub fn page(self, page: u16) -> Self { + Self { + per_page: self.per_page, + page: Some(page), + } + } +} + +impl<'enc> From<&'enc PerPage> for BillingGetGithubAdvancedSecurityBillingOrgParams { + fn from(per_page: &'enc PerPage) -> Self { + Self { + per_page: Some(per_page.per_page), + page: Some(per_page.page), + ..Default::default() + } + } +} impl<'api> Billing<'api> { /// --- @@ -442,6 +560,188 @@ impl<'api> Billing<'api> { } } + /// --- + /// + /// # Get GitHub Advanced Security active committers for an enterprise + /// + /// Gets the GitHub Advanced Security active committers for an enterprise per repository. + /// Each distinct user login across all repositories is counted as a single Advanced Security seat, so the total_advanced_security_committers is not the sum of active_users for each repository. + /// + /// [GitHub API docs for get_github_advanced_security_billing_ghe](https://docs.github.com/rest/reference/billing#export-advanced-security-active-committers-data-for-enterprise) + /// + /// --- + pub async fn get_github_advanced_security_billing_ghe_async(&self, enterprise: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/enterprises/{}/settings/billing/advanced-security", super::GITHUB_BASE_API_URL, enterprise); + + if let Some(params) = query_params { + request_uri.push_str("?"); + request_uri.push_str(&serde_urlencoded::to_string(params.into())?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 403 => Err(BillingGetGithubAdvancedSecurityBillingGheError::Status403(crate::adapters::to_json_async(github_response).await?)), + code => Err(BillingGetGithubAdvancedSecurityBillingGheError::Generic { code }), + } + } + } + + /// --- + /// + /// # Get GitHub Advanced Security active committers for an enterprise + /// + /// Gets the GitHub Advanced Security active committers for an enterprise per repository. + /// Each distinct user login across all repositories is counted as a single Advanced Security seat, so the total_advanced_security_committers is not the sum of active_users for each repository. + /// + /// [GitHub API docs for get_github_advanced_security_billing_ghe](https://docs.github.com/rest/reference/billing#export-advanced-security-active-committers-data-for-enterprise) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn get_github_advanced_security_billing_ghe(&self, enterprise: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/enterprises/{}/settings/billing/advanced-security", super::GITHUB_BASE_API_URL, enterprise); + + if let Some(params) = query_params { + request_uri.push_str("?"); + let qp: BillingGetGithubAdvancedSecurityBillingGheParams = params.into(); + request_uri.push_str(&serde_urlencoded::to_string(qp)?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 403 => Err(BillingGetGithubAdvancedSecurityBillingGheError::Status403(crate::adapters::to_json(github_response)?)), + code => Err(BillingGetGithubAdvancedSecurityBillingGheError::Generic { code }), + } + } + } + + /// --- + /// + /// # Get GitHub Advanced Security active committers for an organization + /// + /// Gets the GitHub Advanced Security active committers for an organization per repository. + /// Each distinct user login across all repositories is counted as a single Advanced Security seat, so the total_advanced_security_committers is not the sum of advanced_security_committers for each repository. + /// If this organization defers to an enterprise for billing, the total_advanced_security_committers returned from the organization API may include some users that are in more than one organization, so they will only consume a single Advanced Security seat at the enterprise level. + /// + /// [GitHub API docs for get_github_advanced_security_billing_org](https://docs.github.com/rest/reference/billing#get-github-advanced-security-active-committers-for-an-organization) + /// + /// --- + pub async fn get_github_advanced_security_billing_org_async(&self, org: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/orgs/{}/settings/billing/advanced-security", super::GITHUB_BASE_API_URL, org); + + if let Some(params) = query_params { + request_uri.push_str("?"); + request_uri.push_str(&serde_urlencoded::to_string(params.into())?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 403 => Err(BillingGetGithubAdvancedSecurityBillingOrgError::Status403(crate::adapters::to_json_async(github_response).await?)), + code => Err(BillingGetGithubAdvancedSecurityBillingOrgError::Generic { code }), + } + } + } + + /// --- + /// + /// # Get GitHub Advanced Security active committers for an organization + /// + /// Gets the GitHub Advanced Security active committers for an organization per repository. + /// Each distinct user login across all repositories is counted as a single Advanced Security seat, so the total_advanced_security_committers is not the sum of advanced_security_committers for each repository. + /// If this organization defers to an enterprise for billing, the total_advanced_security_committers returned from the organization API may include some users that are in more than one organization, so they will only consume a single Advanced Security seat at the enterprise level. + /// + /// [GitHub API docs for get_github_advanced_security_billing_org](https://docs.github.com/rest/reference/billing#get-github-advanced-security-active-committers-for-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn get_github_advanced_security_billing_org(&self, org: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/orgs/{}/settings/billing/advanced-security", super::GITHUB_BASE_API_URL, org); + + if let Some(params) = query_params { + request_uri.push_str("?"); + let qp: BillingGetGithubAdvancedSecurityBillingOrgParams = params.into(); + request_uri.push_str(&serde_urlencoded::to_string(qp)?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 403 => Err(BillingGetGithubAdvancedSecurityBillingOrgError::Status403(crate::adapters::to_json(github_response)?)), + code => Err(BillingGetGithubAdvancedSecurityBillingOrgError::Generic { code }), + } + } + } + /// --- /// /// # Get GitHub Packages billing for an enterprise diff --git a/src/endpoints/code_scanning.rs b/src/endpoints/code_scanning.rs index f70578f..1b153ee 100644 --- a/src/endpoints/code_scanning.rs +++ b/src/endpoints/code_scanning.rs @@ -69,6 +69,8 @@ pub enum CodeScanningGetAlertError { // -- endpoint errors + #[error("Not modified")] + Status304, #[error("Response if GitHub Advanced Security is not enabled for this repository")] Status403(BasicError), #[error("Resource not found")] @@ -161,6 +163,8 @@ pub enum CodeScanningListAlertsForRepoError { // -- endpoint errors + #[error("Not modified")] + Status304, #[error("Response if GitHub Advanced Security is not enabled for this repository")] Status403(BasicError), #[error("Resource not found")] @@ -320,7 +324,7 @@ impl<'enc> From<&'enc PerPage> for CodeScanningListAlertInstancesParams { } /// Query parameters for the [List code scanning alerts for a repository](CodeScanning::list_alerts_for_repo_async()) endpoint. #[derive(Default, Serialize)] -pub struct CodeScanningListAlertsForRepoParams { +pub struct CodeScanningListAlertsForRepoParams<'req> { /// 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_name: Option, /// 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. @@ -331,11 +335,15 @@ pub struct CodeScanningListAlertsForRepoParams { per_page: Option, /// 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`. git_ref: Option, + /// One of `asc` (ascending) or `desc` (descending). + direction: Option<&'req str>, + /// Can be one of `created`, `updated`, `number`. + sort: Option<&'req str>, /// Set to `open`, `fixed`, or `dismissed` to list code scanning alerts in a specific state. state: Option } -impl CodeScanningListAlertsForRepoParams { +impl<'req> CodeScanningListAlertsForRepoParams<'req> { pub fn new() -> Self { Self::default() } @@ -348,6 +356,8 @@ impl CodeScanningListAlertsForRepoParams { page: self.page, per_page: self.per_page, git_ref: self.git_ref, + direction: self.direction, + sort: self.sort, state: self.state, } } @@ -360,6 +370,8 @@ impl CodeScanningListAlertsForRepoParams { page: self.page, per_page: self.per_page, git_ref: self.git_ref, + direction: self.direction, + sort: self.sort, state: self.state, } } @@ -372,6 +384,8 @@ impl CodeScanningListAlertsForRepoParams { page: Some(page), per_page: self.per_page, git_ref: self.git_ref, + direction: self.direction, + sort: self.sort, state: self.state, } } @@ -384,6 +398,8 @@ impl CodeScanningListAlertsForRepoParams { page: self.page, per_page: Some(per_page), git_ref: self.git_ref, + direction: self.direction, + sort: self.sort, state: self.state, } } @@ -396,6 +412,36 @@ impl CodeScanningListAlertsForRepoParams { page: self.page, per_page: self.per_page, git_ref: Some(git_ref), + direction: self.direction, + sort: self.sort, + state: self.state, + } + } + + /// One of `asc` (ascending) or `desc` (descending). + pub fn direction(self, direction: &'req str) -> Self { + Self { + tool_name: self.tool_name, + tool_guid: self.tool_guid, + page: self.page, + per_page: self.per_page, + git_ref: self.git_ref, + direction: Some(direction), + sort: self.sort, + state: self.state, + } + } + + /// Can be one of `created`, `updated`, `number`. + pub fn sort(self, sort: &'req str) -> Self { + Self { + tool_name: self.tool_name, + tool_guid: self.tool_guid, + page: self.page, + per_page: self.per_page, + git_ref: self.git_ref, + direction: self.direction, + sort: Some(sort), state: self.state, } } @@ -408,12 +454,14 @@ impl CodeScanningListAlertsForRepoParams { page: self.page, per_page: self.per_page, git_ref: self.git_ref, + direction: self.direction, + sort: self.sort, state: Some(state), } } } -impl<'enc> From<&'enc PerPage> for CodeScanningListAlertsForRepoParams { +impl<'enc> From<&'enc PerPage> for CodeScanningListAlertsForRepoParams<'enc> { fn from(per_page: &'enc PerPage) -> Self { Self { per_page: Some(per_page.per_page), @@ -534,7 +582,7 @@ impl<'api> CodeScanning<'api> { /// /// 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. + /// you must use an access token with `public_repo` scope. /// GitHub Apps must have the `security_events` write permission to use this endpoint. /// /// You can delete one analysis at a time. @@ -566,13 +614,13 @@ impl<'api> CodeScanning<'api> { /// ``` /// /// 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, @@ -582,9 +630,11 @@ impl<'api> CodeScanning<'api> { /// 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**: @@ -643,7 +693,7 @@ impl<'api> CodeScanning<'api> { /// /// 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. + /// you must use an access token with `public_repo` scope. /// GitHub Apps must have the `security_events` write permission to use this endpoint. /// /// You can delete one analysis at a time. @@ -675,13 +725,13 @@ impl<'api> CodeScanning<'api> { /// ``` /// /// 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, @@ -691,9 +741,11 @@ impl<'api> CodeScanning<'api> { /// 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**: @@ -752,7 +804,7 @@ impl<'api> CodeScanning<'api> { /// /// # Get a code scanning alert /// - /// 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. You must use an access token with the `security_events` scope to use this endpoint with private repos, the `public_repo` scope also grants permission to read security events on public repos only. GitHub Apps must have the `security_events` read permission to use this endpoint. /// /// **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`. @@ -784,6 +836,7 @@ impl<'api> CodeScanning<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { + 304 => Err(CodeScanningGetAlertError::Status304), 403 => Err(CodeScanningGetAlertError::Status403(crate::adapters::to_json_async(github_response).await?)), 404 => Err(CodeScanningGetAlertError::Status404(crate::adapters::to_json_async(github_response).await?)), 503 => Err(CodeScanningGetAlertError::Status503(crate::adapters::to_json_async(github_response).await?)), @@ -796,7 +849,7 @@ impl<'api> CodeScanning<'api> { /// /// # Get a code scanning alert /// - /// 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. You must use an access token with the `security_events` scope to use this endpoint with private repos, the `public_repo` scope also grants permission to read security events on public repos only. GitHub Apps must have the `security_events` read permission to use this endpoint. /// /// **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`. @@ -829,6 +882,7 @@ impl<'api> CodeScanning<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { + 304 => Err(CodeScanningGetAlertError::Status304), 403 => Err(CodeScanningGetAlertError::Status403(crate::adapters::to_json(github_response)?)), 404 => Err(CodeScanningGetAlertError::Status404(crate::adapters::to_json(github_response)?)), 503 => Err(CodeScanningGetAlertError::Status503(crate::adapters::to_json(github_response)?)), @@ -842,7 +896,8 @@ impl<'api> CodeScanning<'api> { /// # Get a code scanning analysis for a repository /// /// Gets a specified code scanning analysis for a repository. - /// You must use an access token with the `security_events` scope to use this endpoint. + /// You must use an access token with the `security_events` scope to use this endpoint with private repos, + /// the `public_repo` scope also grants permission to read security events on public repos only. /// GitHub Apps must have the `security_events` read permission to use this endpoint. /// /// The default JSON response contains fields that describe the analysis. @@ -900,7 +955,8 @@ impl<'api> CodeScanning<'api> { /// # Get a code scanning analysis for a repository /// /// Gets a specified code scanning analysis for a repository. - /// You must use an access token with the `security_events` scope to use this endpoint. + /// You must use an access token with the `security_events` scope to use this endpoint with private repos, + /// the `public_repo` scope also grants permission to read security events on public repos only. /// GitHub Apps must have the `security_events` read permission to use this endpoint. /// /// The default JSON response contains fields that describe the analysis. @@ -958,7 +1014,7 @@ impl<'api> CodeScanning<'api> { /// /// # Get information about a SARIF upload /// - /// 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/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 with private repos, the `public_repo` scope also grants permission to read security events on public repos only. GitHub Apps must have the `security_events` read permission to use this endpoint. /// /// [GitHub API docs for get_sarif](https://docs.github.com/rest/reference/code-scanning#list-recent-code-scanning-analyses-for-a-repository) /// @@ -999,7 +1055,7 @@ impl<'api> CodeScanning<'api> { /// /// # Get information about a SARIF upload /// - /// 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/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 with private repos, the `public_repo` scope also grants permission to read security events on public repos only. GitHub Apps must have the `security_events` read permission to use this endpoint. /// /// [GitHub API docs for get_sarif](https://docs.github.com/rest/reference/code-scanning#list-recent-code-scanning-analyses-for-a-repository) /// @@ -1041,7 +1097,10 @@ impl<'api> CodeScanning<'api> { /// /// # List instances of a code scanning alert /// - /// 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. + /// You must use an access token with the `security_events` scope to use this endpoint with private repos, + /// the `public_repo` scope also grants permission to read security events on public repos only. + /// GitHub Apps must have the `security_events` read permission to use this endpoint. /// /// [GitHub API docs for list_alert_instances](https://docs.github.com/rest/reference/code-scanning#list-instances-of-a-code-scanning-alert) /// @@ -1086,7 +1145,10 @@ impl<'api> CodeScanning<'api> { /// /// # List instances of a code scanning alert /// - /// 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. + /// You must use an access token with the `security_events` scope to use this endpoint with private repos, + /// the `public_repo` scope also grants permission to read security events on public repos only. + /// GitHub Apps must have the `security_events` read permission to use this endpoint. /// /// [GitHub API docs for list_alert_instances](https://docs.github.com/rest/reference/code-scanning#list-instances-of-a-code-scanning-alert) /// @@ -1135,8 +1197,9 @@ impl<'api> CodeScanning<'api> { /// /// 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. + /// this endpoint with private repos, the `public_repo` scope also grants permission to read + /// security events on public repos only. GitHub Apps must have the `security_events` read + /// permission to use this endpoint. /// /// The response includes a `most_recent_instance` object. /// This provides details of the most recent instance of this alert @@ -1146,7 +1209,7 @@ impl<'api> CodeScanning<'api> { /// [GitHub API docs for list_alerts_for_repo](https://docs.github.com/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository) /// /// --- - pub async fn list_alerts_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, CodeScanningListAlertsForRepoError> { + pub async fn list_alerts_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, CodeScanningListAlertsForRepoError> { let mut request_uri = format!("{}/repos/{}/{}/code-scanning/alerts", super::GITHUB_BASE_API_URL, owner, repo); @@ -1174,6 +1237,7 @@ impl<'api> CodeScanning<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { + 304 => Err(CodeScanningListAlertsForRepoError::Status304), 403 => Err(CodeScanningListAlertsForRepoError::Status403(crate::adapters::to_json_async(github_response).await?)), 404 => Err(CodeScanningListAlertsForRepoError::Status404(crate::adapters::to_json_async(github_response).await?)), 503 => Err(CodeScanningListAlertsForRepoError::Status503(crate::adapters::to_json_async(github_response).await?)), @@ -1188,8 +1252,9 @@ impl<'api> CodeScanning<'api> { /// /// 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. + /// this endpoint with private repos, the `public_repo` scope also grants permission to read + /// security events on public repos only. GitHub Apps must have the `security_events` read + /// permission to use this endpoint. /// /// The response includes a `most_recent_instance` object. /// This provides details of the most recent instance of this alert @@ -1200,7 +1265,7 @@ impl<'api> CodeScanning<'api> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_alerts_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result, CodeScanningListAlertsForRepoError> { + pub fn list_alerts_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, CodeScanningListAlertsForRepoError> { let mut request_uri = format!("{}/repos/{}/{}/code-scanning/alerts", super::GITHUB_BASE_API_URL, owner, repo); @@ -1229,6 +1294,7 @@ impl<'api> CodeScanning<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { + 304 => Err(CodeScanningListAlertsForRepoError::Status304), 403 => Err(CodeScanningListAlertsForRepoError::Status403(crate::adapters::to_json(github_response)?)), 404 => Err(CodeScanningListAlertsForRepoError::Status404(crate::adapters::to_json(github_response)?)), 503 => Err(CodeScanningListAlertsForRepoError::Status503(crate::adapters::to_json(github_response)?)), @@ -1252,7 +1318,8 @@ impl<'api> CodeScanning<'api> { /// 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. + /// You must use an access token with the `security_events` scope to use this endpoint with private repos, + /// the `public_repo` scope also grants permission to read security events on public repos only. /// GitHub Apps must have the `security_events` read permission to use this endpoint. /// /// **Deprecation notice**: @@ -1312,7 +1379,8 @@ impl<'api> CodeScanning<'api> { /// 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. + /// You must use an access token with the `security_events` scope to use this endpoint with private repos, + /// the `public_repo` scope also grants permission to read security events on public repos only. /// GitHub Apps must have the `security_events` read permission to use this endpoint. /// /// **Deprecation notice**: @@ -1363,7 +1431,7 @@ impl<'api> CodeScanning<'api> { /// /// # Update a code scanning alert /// - /// 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. You must use an access token with the `security_events` scope to use this endpoint with private repositories. You can also use tokens with the `public_repo` scope for public repositories only. GitHub Apps must have the `security_events` write permission to use this endpoint. /// /// [GitHub API docs for update_alert](https://docs.github.com/rest/reference/code-scanning#update-a-code-scanning-alert) /// @@ -1404,7 +1472,7 @@ impl<'api> CodeScanning<'api> { /// /// # Update a code scanning alert /// - /// 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. You must use an access token with the `security_events` scope to use this endpoint with private repositories. You can also use tokens with the `public_repo` scope for public repositories only. GitHub Apps must have the `security_events` write permission to use this endpoint. /// /// [GitHub API docs for update_alert](https://docs.github.com/rest/reference/code-scanning#update-a-code-scanning-alert) /// @@ -1446,7 +1514,7 @@ impl<'api> CodeScanning<'api> { /// /// # Upload an analysis as SARIF data /// - /// 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. You must use an access token with the `security_events` scope to use this endpoint for private repositories. You can also use tokens with the `public_repo` scope for public repositories only. GitHub Apps must have the `security_events` write permission to use this endpoint. /// /// 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)." @@ -1505,7 +1573,7 @@ impl<'api> CodeScanning<'api> { /// /// # Upload an analysis as SARIF data /// - /// 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. You must use an access token with the `security_events` scope to use this endpoint for private repositories. You can also use tokens with the `public_repo` scope for public repositories only. GitHub Apps must have the `security_events` write permission to use this endpoint. /// /// 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)." diff --git a/src/endpoints/codespaces.rs b/src/endpoints/codespaces.rs new file mode 100644 index 0000000..361b2f6 --- /dev/null +++ b/src/endpoints/codespaces.rs @@ -0,0 +1,2714 @@ +//! Method, error and parameter types for the Codespaces endpoint. +#![allow( + unused_imports, +)] +/* + * GitHub v3 REST API + * + * GitHub's v3 REST API. + * + * OpenAPI spec version: 1.1.4 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +use serde::Deserialize; + +use crate::adapters::{AdapterError, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::auth::Auth; +use crate::models::*; + +use super::PerPage; + +use std::collections::HashMap; +use serde_json::value::Value; + +pub struct Codespaces<'api> { + auth: &'api Auth +} + +pub fn new(auth: &Auth) -> Codespaces { + Codespaces { auth } +} + +/// Errors for the [Add a selected repository to a user secret](Codespaces::add_repository_for_secret_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesAddRepositoryForSecretForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Internal Error")] + Status500(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [List machine types for a codespace](Codespaces::codespace_machines_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesCodespaceMachinesForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Not modified")] + Status304, + #[error("Internal Error")] + Status500(BasicError), + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Create a codespace for the authenticated user](Codespaces::create_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesCreateForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Response when the codespace creation partially failed but is being retried in the background")] + Status202(Codespace), + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Create or update a secret for the authenticated user](Codespaces::create_or_update_secret_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesCreateOrUpdateSecretForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Response after successfully updating a secret")] + Status204, + #[error("Validation failed")] + Status422(ValidationError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Create a codespace from a pull request](Codespaces::create_with_pr_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesCreateWithPrForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Response when the codespace creation partially failed but is being retried in the background")] + Status202(Codespace), + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Create a codespace in a repository](Codespaces::create_with_repo_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesCreateWithRepoForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Response when the codespace creation partially failed but is being retried in the background")] + Status202(Codespace), + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Delete a codespace for the authenticated user](Codespaces::delete_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesDeleteForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Not modified")] + Status304, + #[error("Internal Error")] + Status500(BasicError), + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Delete a secret for the authenticated user](Codespaces::delete_secret_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesDeleteSecretForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Get a codespace for the authenticated user](Codespaces::get_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesGetForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Not modified")] + Status304, + #[error("Internal Error")] + Status500(BasicError), + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Get public key for the authenticated user](Codespaces::get_public_key_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesGetPublicKeyForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Get a secret for the authenticated user](Codespaces::get_secret_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesGetSecretForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [List codespaces for the authenticated user](Codespaces::list_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesListForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Not modified")] + Status304, + #[error("Internal Error")] + Status500(BasicError), + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [List codespaces in a repository for the authenticated user](Codespaces::list_in_repository_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesListInRepositoryForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Internal Error")] + Status500(BasicError), + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [List selected repositories for a user secret](Codespaces::list_repositories_for_secret_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesListRepositoriesForSecretForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Internal Error")] + Status500(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [List secrets for the authenticated user](Codespaces::list_secrets_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesListSecretsForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Remove a selected repository from a user secret](Codespaces::remove_repository_for_secret_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesRemoveRepositoryForSecretForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Internal Error")] + Status500(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [List available machine types for a repository](Codespaces::repo_machines_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesRepoMachinesForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Not modified")] + Status304, + #[error("Internal Error")] + Status500(BasicError), + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Set selected repositories for a user secret](Codespaces::set_repositories_for_secret_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesSetRepositoriesForSecretForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Internal Error")] + Status500(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Start a codespace for the authenticated user](Codespaces::start_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesStartForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Not modified")] + Status304, + #[error("Internal Error")] + Status500(BasicError), + #[error("Bad Request")] + Status400(BasicError), + #[error("Requires authentication")] + Status401(BasicError), + #[error("Payment required")] + Status402(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Conflict")] + Status409(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Stop a codespace for the authenticated user](Codespaces::stop_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesStopForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Internal Error")] + Status500(BasicError), + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Update a codespace for the authenticated user](Codespaces::update_for_authenticated_user_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum CodespacesUpdateForAuthenticatedUserError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Requires authentication")] + Status401(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + + +/// Query parameters for the [List codespaces for the authenticated user](Codespaces::list_for_authenticated_user_async()) endpoint. +#[derive(Default, Serialize)] +pub struct CodespacesListForAuthenticatedUserParams { + /// Results per page (max 100) + per_page: Option, + /// Page number of the results to fetch. + page: Option, + /// ID of the Repository to filter on + repository_id: Option +} + +impl CodespacesListForAuthenticatedUserParams { + pub fn new() -> Self { + Self::default() + } + + /// Results per page (max 100) + pub fn per_page(self, per_page: u16) -> Self { + Self { + per_page: Some(per_page), + page: self.page, + repository_id: self.repository_id, + } + } + + /// Page number of the results to fetch. + pub fn page(self, page: u16) -> Self { + Self { + per_page: self.per_page, + page: Some(page), + repository_id: self.repository_id, + } + } + + /// ID of the Repository to filter on + pub fn repository_id(self, repository_id: i32) -> Self { + Self { + per_page: self.per_page, + page: self.page, + repository_id: Some(repository_id), + } + } +} + +impl<'enc> From<&'enc PerPage> for CodespacesListForAuthenticatedUserParams { + fn from(per_page: &'enc PerPage) -> Self { + Self { + per_page: Some(per_page.per_page), + page: Some(per_page.page), + ..Default::default() + } + } +} +/// Query parameters for the [List codespaces in a repository for the authenticated user](Codespaces::list_in_repository_for_authenticated_user_async()) endpoint. +#[derive(Default, Serialize)] +pub struct CodespacesListInRepositoryForAuthenticatedUserParams { + /// Results per page (max 100) + per_page: Option, + /// Page number of the results to fetch. + page: Option +} + +impl CodespacesListInRepositoryForAuthenticatedUserParams { + pub fn new() -> Self { + Self::default() + } + + /// Results per page (max 100) + pub fn per_page(self, per_page: u16) -> Self { + Self { + per_page: Some(per_page), + page: self.page, + } + } + + /// Page number of the results to fetch. + pub fn page(self, page: u16) -> Self { + Self { + per_page: self.per_page, + page: Some(page), + } + } +} + +impl<'enc> From<&'enc PerPage> for CodespacesListInRepositoryForAuthenticatedUserParams { + fn from(per_page: &'enc PerPage) -> Self { + Self { + per_page: Some(per_page.per_page), + page: Some(per_page.page), + ..Default::default() + } + } +} +/// Query parameters for the [List secrets for the authenticated user](Codespaces::list_secrets_for_authenticated_user_async()) endpoint. +#[derive(Default, Serialize)] +pub struct CodespacesListSecretsForAuthenticatedUserParams { + /// Results per page (max 100) + per_page: Option, + /// Page number of the results to fetch. + page: Option +} + +impl CodespacesListSecretsForAuthenticatedUserParams { + pub fn new() -> Self { + Self::default() + } + + /// Results per page (max 100) + pub fn per_page(self, per_page: u16) -> Self { + Self { + per_page: Some(per_page), + page: self.page, + } + } + + /// Page number of the results to fetch. + pub fn page(self, page: u16) -> Self { + Self { + per_page: self.per_page, + page: Some(page), + } + } +} + +impl<'enc> From<&'enc PerPage> for CodespacesListSecretsForAuthenticatedUserParams { + fn from(per_page: &'enc PerPage) -> Self { + Self { + per_page: Some(per_page.per_page), + page: Some(per_page.page), + ..Default::default() + } + } +} +/// Query parameters for the [List available machine types for a repository](Codespaces::repo_machines_for_authenticated_user_async()) endpoint. +#[derive(Default, Serialize)] +pub struct CodespacesRepoMachinesForAuthenticatedUserParams<'req> { + /// Required. The location to check for available machines. + location: &'req str +} + +impl<'req> CodespacesRepoMachinesForAuthenticatedUserParams<'req> { + pub fn new() -> Self { + Self::default() + } + + /// Required. The location to check for available machines. + pub fn location(self, location: &'req str) -> Self { + Self { + location: location, + } + } +} + + +impl<'api> Codespaces<'api> { + /// --- + /// + /// # Add a selected repository to a user secret + /// + /// Adds a repository to the selected repositories for a user's codespace secret. + /// You must authenticate using an access token with the `user` or `read:user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for add_repository_for_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#add-a-selected-repository-to-a-user-secret) + /// + /// --- + pub async fn add_repository_for_secret_for_authenticated_user_async(&self, secret_name: &str, repository_id: i32) -> Result<(), CodespacesAddRepositoryForSecretForAuthenticatedUserError> { + + let request_uri = format!("{}/user/codespaces/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, secret_name, repository_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 401 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + 500 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status500(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Add a selected repository to a user secret + /// + /// Adds a repository to the selected repositories for a user's codespace secret. + /// You must authenticate using an access token with the `user` or `read:user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for add_repository_for_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#add-a-selected-repository-to-a-user-secret) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn add_repository_for_secret_for_authenticated_user(&self, secret_name: &str, repository_id: i32) -> Result<(), CodespacesAddRepositoryForSecretForAuthenticatedUserError> { + + let request_uri = format!("{}/user/codespaces/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, secret_name, repository_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 401 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + 500 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status500(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # List machine types for a codespace + /// + /// List the machine types a codespace can transition to use. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for codespace_machines_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#list-machine-types-for-a-codespace) + /// + /// --- + pub async fn codespace_machines_for_authenticated_user_async(&self, codespace_name: &str) -> Result { + + let request_uri = format!("{}/user/codespaces/{}/machines", super::GITHUB_BASE_API_URL, codespace_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 304 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status304), + 500 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status500(crate::adapters::to_json_async(github_response).await?)), + 401 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # List machine types for a codespace + /// + /// List the machine types a codespace can transition to use. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for codespace_machines_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#list-machine-types-for-a-codespace) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn codespace_machines_for_authenticated_user(&self, codespace_name: &str) -> Result { + + let request_uri = format!("{}/user/codespaces/{}/machines", super::GITHUB_BASE_API_URL, codespace_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 304 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status304), + 500 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status500(crate::adapters::to_json(github_response)?)), + 401 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Create a codespace for the authenticated user + /// + /// Creates a new codespace, owned by the authenticated user. + /// + /// This endpoint requires either a `repository_id` OR a `pull_request` but not both. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for create_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#create-a-codespace-for-the-authenticated-user) + /// + /// --- + pub async fn create_for_authenticated_user_async(&self, body: PostCodespacesCreateForAuthenticatedUser) -> Result { + + let request_uri = format!("{}/user/codespaces", super::GITHUB_BASE_API_URL); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PostCodespacesCreateForAuthenticatedUser::from_json(body)?), + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 202 => Err(CodespacesCreateForAuthenticatedUserError::Status202(crate::adapters::to_json_async(github_response).await?)), + 401 => Err(CodespacesCreateForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesCreateForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesCreateForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesCreateForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Create a codespace for the authenticated user + /// + /// Creates a new codespace, owned by the authenticated user. + /// + /// This endpoint requires either a `repository_id` OR a `pull_request` but not both. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for create_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#create-a-codespace-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn create_for_authenticated_user(&self, body: PostCodespacesCreateForAuthenticatedUser) -> Result { + + let request_uri = format!("{}/user/codespaces", super::GITHUB_BASE_API_URL); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PostCodespacesCreateForAuthenticatedUser::from_json(body)?), + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 202 => Err(CodespacesCreateForAuthenticatedUserError::Status202(crate::adapters::to_json(github_response)?)), + 401 => Err(CodespacesCreateForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesCreateForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesCreateForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesCreateForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Create or update a secret for the authenticated user + /// + /// Creates or updates a secret for a user's codespace 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 `user` scope to use this endpoint. User must also have Codespaces access to use this endpoint. + /// + /// #### Example encrypting a secret using Node.js + /// + /// Encrypt your secret using the [tweetsodium](https://github.com/github/tweetsodium) library. + /// + /// ```nocompile + /// const sodium = require('tweetsodium'); + /// + /// const key = "base64-encoded-public-key"; + /// const value = "plain-text-secret"; + /// + /// // Convert the message and key to Uint8Array's (Buffer implements that interface) + /// const messageBytes = Buffer.from(value); + /// const keyBytes = Buffer.from(key, 'base64'); + /// + /// // Encrypt using LibSodium. + /// const encryptedBytes = sodium.seal(messageBytes, keyBytes); + /// + /// // Base64 the encrypted secret + /// const encrypted = Buffer.from(encryptedBytes).toString('base64'); + /// + /// console.log(encrypted); + /// ``` + /// + /// + /// #### Example encrypting a secret using Python + /// + /// Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/stable/public/#nacl-public-sealedbox) with Python 3. + /// + /// ```nocompile + /// 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. + /// + /// ```nocompile + /// var secretValue = System.Text.Encoding.UTF8.GetBytes("mySecret"); + /// var publicKey = Convert.FromBase64String("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvvcCU="); + /// + /// var sealedPublicKeyBox = Sodium.SealedPublicKeyBox.Create(secretValue, publicKey); + /// + /// Console.WriteLine(Convert.ToBase64String(sealedPublicKeyBox)); + /// ``` + /// + /// #### Example encrypting a secret using Ruby + /// + /// Encrypt your secret using the [rbnacl](https://github.com/RubyCrypto/rbnacl) gem. + /// + /// ```ruby,nocompile + /// require "rbnacl" + /// require "base64" + /// + /// key = Base64.decode64("+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0=") + /// public_key = RbNaCl::PublicKey.new(key) + /// + /// box = RbNaCl::Boxes::Sealed.from_public_key(public_key) + /// encrypted_secret = box.encrypt("my_secret") + /// + /// # Print the base64 encoded secret + /// puts Base64.strict_encode64(encrypted_secret) + /// ``` + /// + /// [GitHub API docs for create_or_update_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#create-or-update-a-secret-for-the-authenticated-user) + /// + /// --- + pub async fn create_or_update_secret_for_authenticated_user_async(&self, secret_name: &str, body: PutCodespacesCreateOrUpdateSecretForAuthenticatedUser) -> Result, CodespacesCreateOrUpdateSecretForAuthenticatedUserError> { + + let request_uri = format!("{}/user/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, secret_name); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PutCodespacesCreateOrUpdateSecretForAuthenticatedUser::from_json(body)?), + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 204 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status204), + 422 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status422(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Create or update a secret for the authenticated user + /// + /// Creates or updates a secret for a user's codespace 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 `user` scope to use this endpoint. User must also have Codespaces access to use this endpoint. + /// + /// #### Example encrypting a secret using Node.js + /// + /// Encrypt your secret using the [tweetsodium](https://github.com/github/tweetsodium) library. + /// + /// ```nocompile + /// const sodium = require('tweetsodium'); + /// + /// const key = "base64-encoded-public-key"; + /// const value = "plain-text-secret"; + /// + /// // Convert the message and key to Uint8Array's (Buffer implements that interface) + /// const messageBytes = Buffer.from(value); + /// const keyBytes = Buffer.from(key, 'base64'); + /// + /// // Encrypt using LibSodium. + /// const encryptedBytes = sodium.seal(messageBytes, keyBytes); + /// + /// // Base64 the encrypted secret + /// const encrypted = Buffer.from(encryptedBytes).toString('base64'); + /// + /// console.log(encrypted); + /// ``` + /// + /// + /// #### Example encrypting a secret using Python + /// + /// Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/stable/public/#nacl-public-sealedbox) with Python 3. + /// + /// ```nocompile + /// 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. + /// + /// ```nocompile + /// var secretValue = System.Text.Encoding.UTF8.GetBytes("mySecret"); + /// var publicKey = Convert.FromBase64String("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvvcCU="); + /// + /// var sealedPublicKeyBox = Sodium.SealedPublicKeyBox.Create(secretValue, publicKey); + /// + /// Console.WriteLine(Convert.ToBase64String(sealedPublicKeyBox)); + /// ``` + /// + /// #### Example encrypting a secret using Ruby + /// + /// Encrypt your secret using the [rbnacl](https://github.com/RubyCrypto/rbnacl) gem. + /// + /// ```ruby,nocompile + /// require "rbnacl" + /// require "base64" + /// + /// key = Base64.decode64("+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0=") + /// public_key = RbNaCl::PublicKey.new(key) + /// + /// box = RbNaCl::Boxes::Sealed.from_public_key(public_key) + /// encrypted_secret = box.encrypt("my_secret") + /// + /// # Print the base64 encoded secret + /// puts Base64.strict_encode64(encrypted_secret) + /// ``` + /// + /// [GitHub API docs for create_or_update_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#create-or-update-a-secret-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn create_or_update_secret_for_authenticated_user(&self, secret_name: &str, body: PutCodespacesCreateOrUpdateSecretForAuthenticatedUser) -> Result, CodespacesCreateOrUpdateSecretForAuthenticatedUserError> { + + let request_uri = format!("{}/user/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, secret_name); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PutCodespacesCreateOrUpdateSecretForAuthenticatedUser::from_json(body)?), + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 204 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status204), + 422 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status422(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Create a codespace from a pull request + /// + /// Creates a codespace owned by the authenticated user for the specified pull request. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for create_with_pr_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#create-a-codespace-from-a-pull-request) + /// + /// --- + pub async fn create_with_pr_for_authenticated_user_async(&self, owner: &str, repo: &str, pull_number: i32, body: PostCodespacesCreateWithPrForAuthenticatedUser) -> Result { + + let request_uri = format!("{}/repos/{}/{}/pulls/{}/codespaces", super::GITHUB_BASE_API_URL, owner, repo, pull_number); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PostCodespacesCreateWithPrForAuthenticatedUser::from_json(body)?), + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 202 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status202(crate::adapters::to_json_async(github_response).await?)), + 401 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesCreateWithPrForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Create a codespace from a pull request + /// + /// Creates a codespace owned by the authenticated user for the specified pull request. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for create_with_pr_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#create-a-codespace-from-a-pull-request) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn create_with_pr_for_authenticated_user(&self, owner: &str, repo: &str, pull_number: i32, body: PostCodespacesCreateWithPrForAuthenticatedUser) -> Result { + + let request_uri = format!("{}/repos/{}/{}/pulls/{}/codespaces", super::GITHUB_BASE_API_URL, owner, repo, pull_number); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PostCodespacesCreateWithPrForAuthenticatedUser::from_json(body)?), + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 202 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status202(crate::adapters::to_json(github_response)?)), + 401 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesCreateWithPrForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Create a codespace in a repository + /// + /// Creates a codespace owned by the authenticated user in the specified repository. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for create_with_repo_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#create-a-codespace-in-a-repository) + /// + /// --- + pub async fn create_with_repo_for_authenticated_user_async(&self, owner: &str, repo: &str, body: PostCodespacesCreateWithRepoForAuthenticatedUser) -> Result { + + let request_uri = format!("{}/repos/{}/{}/codespaces", super::GITHUB_BASE_API_URL, owner, repo); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PostCodespacesCreateWithRepoForAuthenticatedUser::from_json(body)?), + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 202 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status202(crate::adapters::to_json_async(github_response).await?)), + 401 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Create a codespace in a repository + /// + /// Creates a codespace owned by the authenticated user in the specified repository. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for create_with_repo_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#create-a-codespace-in-a-repository) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn create_with_repo_for_authenticated_user(&self, owner: &str, repo: &str, body: PostCodespacesCreateWithRepoForAuthenticatedUser) -> Result { + + let request_uri = format!("{}/repos/{}/{}/codespaces", super::GITHUB_BASE_API_URL, owner, repo); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PostCodespacesCreateWithRepoForAuthenticatedUser::from_json(body)?), + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 202 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status202(crate::adapters::to_json(github_response)?)), + 401 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Delete a codespace for the authenticated user + /// + /// Deletes a user's codespace. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for delete_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#delete-a-codespace-for-the-authenticated-user) + /// + /// --- + pub async fn delete_for_authenticated_user_async(&self, codespace_name: &str) -> Result, CodespacesDeleteForAuthenticatedUserError> { + + let request_uri = format!("{}/user/codespaces/{}", super::GITHUB_BASE_API_URL, codespace_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 304 => Err(CodespacesDeleteForAuthenticatedUserError::Status304), + 500 => Err(CodespacesDeleteForAuthenticatedUserError::Status500(crate::adapters::to_json_async(github_response).await?)), + 401 => Err(CodespacesDeleteForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesDeleteForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesDeleteForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesDeleteForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Delete a codespace for the authenticated user + /// + /// Deletes a user's codespace. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for delete_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#delete-a-codespace-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn delete_for_authenticated_user(&self, codespace_name: &str) -> Result, CodespacesDeleteForAuthenticatedUserError> { + + let request_uri = format!("{}/user/codespaces/{}", super::GITHUB_BASE_API_URL, codespace_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 304 => Err(CodespacesDeleteForAuthenticatedUserError::Status304), + 500 => Err(CodespacesDeleteForAuthenticatedUserError::Status500(crate::adapters::to_json(github_response)?)), + 401 => Err(CodespacesDeleteForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesDeleteForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesDeleteForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesDeleteForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Delete a secret for the authenticated user + /// + /// Deletes a 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. You must authenticate using an access token with the `user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for delete_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#delete-a-secret-for-the-authenticated-user) + /// + /// --- + pub async fn delete_secret_for_authenticated_user_async(&self, secret_name: &str) -> Result<(), CodespacesDeleteSecretForAuthenticatedUserError> { + + let request_uri = format!("{}/user/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, secret_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + code => Err(CodespacesDeleteSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Delete a secret for the authenticated user + /// + /// Deletes a 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. You must authenticate using an access token with the `user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for delete_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#delete-a-secret-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn delete_secret_for_authenticated_user(&self, secret_name: &str) -> Result<(), CodespacesDeleteSecretForAuthenticatedUserError> { + + let request_uri = format!("{}/user/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, secret_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + code => Err(CodespacesDeleteSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Get a codespace for the authenticated user + /// + /// Gets information about a user's codespace. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for get_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#get-a-codespace-for-the-authenticated-user) + /// + /// --- + pub async fn get_for_authenticated_user_async(&self, codespace_name: &str) -> Result { + + let request_uri = format!("{}/user/codespaces/{}", super::GITHUB_BASE_API_URL, codespace_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 304 => Err(CodespacesGetForAuthenticatedUserError::Status304), + 500 => Err(CodespacesGetForAuthenticatedUserError::Status500(crate::adapters::to_json_async(github_response).await?)), + 401 => Err(CodespacesGetForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesGetForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesGetForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesGetForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Get a codespace for the authenticated user + /// + /// Gets information about a user's codespace. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for get_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#get-a-codespace-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn get_for_authenticated_user(&self, codespace_name: &str) -> Result { + + let request_uri = format!("{}/user/codespaces/{}", super::GITHUB_BASE_API_URL, codespace_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 304 => Err(CodespacesGetForAuthenticatedUserError::Status304), + 500 => Err(CodespacesGetForAuthenticatedUserError::Status500(crate::adapters::to_json(github_response)?)), + 401 => Err(CodespacesGetForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesGetForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesGetForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesGetForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Get public key for the authenticated user + /// + /// 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 one of the 'read:user' or 'user' scopes in their personal access token. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for get_public_key_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#get-public-key-for-the-authenticated-user) + /// + /// --- + pub async fn get_public_key_for_authenticated_user_async(&self) -> Result { + + let request_uri = format!("{}/user/codespaces/secrets/public-key", super::GITHUB_BASE_API_URL); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + code => Err(CodespacesGetPublicKeyForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Get public key for the authenticated user + /// + /// 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 one of the 'read:user' or 'user' scopes in their personal access token. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for get_public_key_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#get-public-key-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn get_public_key_for_authenticated_user(&self) -> Result { + + let request_uri = format!("{}/user/codespaces/secrets/public-key", super::GITHUB_BASE_API_URL); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + code => Err(CodespacesGetPublicKeyForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Get a secret for the authenticated user + /// + /// Gets a secret available to a user's codespaces without revealing its encrypted value. + /// You must authenticate using an access token with the `user` or `read:user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for get_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#get-a-secret-for-the-authenticated-user) + /// + /// --- + pub async fn get_secret_for_authenticated_user_async(&self, secret_name: &str) -> Result { + + let request_uri = format!("{}/user/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, secret_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + code => Err(CodespacesGetSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Get a secret for the authenticated user + /// + /// Gets a secret available to a user's codespaces without revealing its encrypted value. + /// You must authenticate using an access token with the `user` or `read:user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for get_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#get-a-secret-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn get_secret_for_authenticated_user(&self, secret_name: &str) -> Result { + + let request_uri = format!("{}/user/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, secret_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + code => Err(CodespacesGetSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # List codespaces for the authenticated user + /// + /// Lists the authenticated user's codespaces. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#list-codespaces-for-the-authenticated-user) + /// + /// --- + pub async fn list_for_authenticated_user_async(&self, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/user/codespaces", super::GITHUB_BASE_API_URL); + + if let Some(params) = query_params { + request_uri.push_str("?"); + request_uri.push_str(&serde_urlencoded::to_string(params.into())?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 304 => Err(CodespacesListForAuthenticatedUserError::Status304), + 500 => Err(CodespacesListForAuthenticatedUserError::Status500(crate::adapters::to_json_async(github_response).await?)), + 401 => Err(CodespacesListForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesListForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesListForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesListForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # List codespaces for the authenticated user + /// + /// Lists the authenticated user's codespaces. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#list-codespaces-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn list_for_authenticated_user(&self, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/user/codespaces", super::GITHUB_BASE_API_URL); + + if let Some(params) = query_params { + request_uri.push_str("?"); + let qp: CodespacesListForAuthenticatedUserParams = params.into(); + request_uri.push_str(&serde_urlencoded::to_string(qp)?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 304 => Err(CodespacesListForAuthenticatedUserError::Status304), + 500 => Err(CodespacesListForAuthenticatedUserError::Status500(crate::adapters::to_json(github_response)?)), + 401 => Err(CodespacesListForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesListForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesListForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesListForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # List codespaces in a repository for the authenticated user + /// + /// Lists the codespaces associated to a specified repository and the authenticated user. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for list_in_repository_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#list-codespaces-in-a-repository-for-the-authenticated-user) + /// + /// --- + pub async fn list_in_repository_for_authenticated_user_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/repos/{}/{}/codespaces", super::GITHUB_BASE_API_URL, owner, repo); + + if let Some(params) = query_params { + request_uri.push_str("?"); + request_uri.push_str(&serde_urlencoded::to_string(params.into())?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 500 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status500(crate::adapters::to_json_async(github_response).await?)), + 401 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesListInRepositoryForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # List codespaces in a repository for the authenticated user + /// + /// Lists the codespaces associated to a specified repository and the authenticated user. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for list_in_repository_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#list-codespaces-in-a-repository-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn list_in_repository_for_authenticated_user(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/repos/{}/{}/codespaces", super::GITHUB_BASE_API_URL, owner, repo); + + if let Some(params) = query_params { + request_uri.push_str("?"); + let qp: CodespacesListInRepositoryForAuthenticatedUserParams = params.into(); + request_uri.push_str(&serde_urlencoded::to_string(qp)?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 500 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status500(crate::adapters::to_json(github_response)?)), + 401 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesListInRepositoryForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # List selected repositories for a user secret + /// + /// List the repositories that have been granted the ability to use a user's codespace secret. + /// You must authenticate using an access token with the `user` or `read:user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for list_repositories_for_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#list-selected-repositories-for-a-user-secret) + /// + /// --- + pub async fn list_repositories_for_secret_for_authenticated_user_async(&self, secret_name: &str) -> Result { + + let request_uri = format!("{}/user/codespaces/secrets/{}/repositories", super::GITHUB_BASE_API_URL, secret_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 401 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + 500 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status500(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # List selected repositories for a user secret + /// + /// List the repositories that have been granted the ability to use a user's codespace secret. + /// You must authenticate using an access token with the `user` or `read:user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for list_repositories_for_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#list-selected-repositories-for-a-user-secret) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn list_repositories_for_secret_for_authenticated_user(&self, secret_name: &str) -> Result { + + let request_uri = format!("{}/user/codespaces/secrets/{}/repositories", super::GITHUB_BASE_API_URL, secret_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 401 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + 500 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status500(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # List secrets for the authenticated user + /// + /// Lists all secrets available for a user's Codespaces without revealing their + /// encrypted values. + /// You must authenticate using an access token with the `user` or `read:user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for list_secrets_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#list-secrets-for-the-authenticated-user) + /// + /// --- + pub async fn list_secrets_for_authenticated_user_async(&self, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/user/codespaces/secrets", super::GITHUB_BASE_API_URL); + + if let Some(params) = query_params { + request_uri.push_str("?"); + request_uri.push_str(&serde_urlencoded::to_string(params.into())?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + code => Err(CodespacesListSecretsForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # List secrets for the authenticated user + /// + /// Lists all secrets available for a user's Codespaces without revealing their + /// encrypted values. + /// You must authenticate using an access token with the `user` or `read:user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for list_secrets_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#list-secrets-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn list_secrets_for_authenticated_user(&self, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/user/codespaces/secrets", super::GITHUB_BASE_API_URL); + + if let Some(params) = query_params { + request_uri.push_str("?"); + let qp: CodespacesListSecretsForAuthenticatedUserParams = params.into(); + request_uri.push_str(&serde_urlencoded::to_string(qp)?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + code => Err(CodespacesListSecretsForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Remove a selected repository from a user secret + /// + /// Removes a repository from the selected repositories for a user's codespace secret. + /// You must authenticate using an access token with the `user` or `read:user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for remove_repository_for_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#remove-a-selected-repository-from-a-user-secret) + /// + /// --- + pub async fn remove_repository_for_secret_for_authenticated_user_async(&self, secret_name: &str, repository_id: i32) -> Result<(), CodespacesRemoveRepositoryForSecretForAuthenticatedUserError> { + + let request_uri = format!("{}/user/codespaces/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, secret_name, repository_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 401 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + 500 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status500(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Remove a selected repository from a user secret + /// + /// Removes a repository from the selected repositories for a user's codespace secret. + /// You must authenticate using an access token with the `user` or `read:user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for remove_repository_for_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#remove-a-selected-repository-from-a-user-secret) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn remove_repository_for_secret_for_authenticated_user(&self, secret_name: &str, repository_id: i32) -> Result<(), CodespacesRemoveRepositoryForSecretForAuthenticatedUserError> { + + let request_uri = format!("{}/user/codespaces/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, secret_name, repository_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 401 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + 500 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status500(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # List available machine types for a repository + /// + /// List the machine types available for a given repository based on its configuration. + /// + /// Location is required. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for repo_machines_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#list-available-machine-types-for-a-repository) + /// + /// --- + pub async fn repo_machines_for_authenticated_user_async(&self, owner: &str, repo: &str, query_params: impl Into>) -> Result { + + let mut request_uri = format!("{}/repos/{}/{}/codespaces/machines", super::GITHUB_BASE_API_URL, owner, repo); + + request_uri.push_str("?"); + request_uri.push_str(&serde_urlencoded::to_string(query_params.into())?); + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 304 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status304), + 500 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status500(crate::adapters::to_json_async(github_response).await?)), + 401 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesRepoMachinesForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # List available machine types for a repository + /// + /// List the machine types available for a given repository based on its configuration. + /// + /// Location is required. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for repo_machines_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#list-available-machine-types-for-a-repository) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn repo_machines_for_authenticated_user(&self, owner: &str, repo: &str, query_params: impl Into>) -> Result { + + let mut request_uri = format!("{}/repos/{}/{}/codespaces/machines", super::GITHUB_BASE_API_URL, owner, repo); + + request_uri.push_str("?"); + let qp: CodespacesRepoMachinesForAuthenticatedUserParams = query_params.into(); + request_uri.push_str(&serde_urlencoded::to_string(qp)?); + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 304 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status304), + 500 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status500(crate::adapters::to_json(github_response)?)), + 401 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesRepoMachinesForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Set selected repositories for a user secret + /// + /// Select the repositories that will use a user's codespace secret. + /// You must authenticate using an access token with the `user` or `read:user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for set_repositories_for_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#set-selected-repositories-for-a-user-secret) + /// + /// --- + pub async fn set_repositories_for_secret_for_authenticated_user_async(&self, secret_name: &str, body: PutCodespacesSetRepositoriesForSecretForAuthenticatedUser) -> Result<(), CodespacesSetRepositoriesForSecretForAuthenticatedUserError> { + + let request_uri = format!("{}/user/codespaces/secrets/{}/repositories", super::GITHUB_BASE_API_URL, secret_name); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PutCodespacesSetRepositoriesForSecretForAuthenticatedUser::from_json(body)?), + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 401 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + 500 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status500(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Set selected repositories for a user secret + /// + /// Select the repositories that will use a user's codespace secret. + /// You must authenticate using an access token with the `user` or `read:user` scope to use this endpoint. User must have Codespaces access to use this endpoint. + /// + /// [GitHub API docs for set_repositories_for_secret_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#set-selected-repositories-for-a-user-secret) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn set_repositories_for_secret_for_authenticated_user(&self, secret_name: &str, body: PutCodespacesSetRepositoriesForSecretForAuthenticatedUser) -> Result<(), CodespacesSetRepositoriesForSecretForAuthenticatedUserError> { + + let request_uri = format!("{}/user/codespaces/secrets/{}/repositories", super::GITHUB_BASE_API_URL, secret_name); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PutCodespacesSetRepositoriesForSecretForAuthenticatedUser::from_json(body)?), + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 401 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + 500 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status500(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Start a codespace for the authenticated user + /// + /// Starts a user's codespace. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for start_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#start-a-codespace-for-the-authenticated-user) + /// + /// --- + pub async fn start_for_authenticated_user_async(&self, codespace_name: &str) -> Result { + + let request_uri = format!("{}/user/codespaces/{}/start", super::GITHUB_BASE_API_URL, codespace_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 304 => Err(CodespacesStartForAuthenticatedUserError::Status304), + 500 => Err(CodespacesStartForAuthenticatedUserError::Status500(crate::adapters::to_json_async(github_response).await?)), + 400 => Err(CodespacesStartForAuthenticatedUserError::Status400(crate::adapters::to_json_async(github_response).await?)), + 401 => Err(CodespacesStartForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 402 => Err(CodespacesStartForAuthenticatedUserError::Status402(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesStartForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesStartForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + 409 => Err(CodespacesStartForAuthenticatedUserError::Status409(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesStartForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Start a codespace for the authenticated user + /// + /// Starts a user's codespace. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for start_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#start-a-codespace-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn start_for_authenticated_user(&self, codespace_name: &str) -> Result { + + let request_uri = format!("{}/user/codespaces/{}/start", super::GITHUB_BASE_API_URL, codespace_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 304 => Err(CodespacesStartForAuthenticatedUserError::Status304), + 500 => Err(CodespacesStartForAuthenticatedUserError::Status500(crate::adapters::to_json(github_response)?)), + 400 => Err(CodespacesStartForAuthenticatedUserError::Status400(crate::adapters::to_json(github_response)?)), + 401 => Err(CodespacesStartForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 402 => Err(CodespacesStartForAuthenticatedUserError::Status402(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesStartForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesStartForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + 409 => Err(CodespacesStartForAuthenticatedUserError::Status409(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesStartForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Stop a codespace for the authenticated user + /// + /// Stops a user's codespace. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for stop_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#stop-a-codespace-for-the-authenticated-user) + /// + /// --- + pub async fn stop_for_authenticated_user_async(&self, codespace_name: &str) -> Result { + + let request_uri = format!("{}/user/codespaces/{}/stop", super::GITHUB_BASE_API_URL, codespace_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 500 => Err(CodespacesStopForAuthenticatedUserError::Status500(crate::adapters::to_json_async(github_response).await?)), + 401 => Err(CodespacesStopForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesStopForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesStopForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesStopForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Stop a codespace for the authenticated user + /// + /// Stops a user's codespace. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for stop_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#stop-a-codespace-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn stop_for_authenticated_user(&self, codespace_name: &str) -> Result { + + let request_uri = format!("{}/user/codespaces/{}/stop", super::GITHUB_BASE_API_URL, codespace_name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 500 => Err(CodespacesStopForAuthenticatedUserError::Status500(crate::adapters::to_json(github_response)?)), + 401 => Err(CodespacesStopForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesStopForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesStopForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesStopForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Update a codespace for the authenticated user + /// + /// Updates a codespace owned by the authenticated user. Currently only the codespace's machine type can be modified using this endpoint. + /// + /// Once you specify a new machine type it will be applied the next time your codespace is started. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for update_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#update-a-codespace-for-the-authenticated-user) + /// + /// --- + pub async fn update_for_authenticated_user_async(&self, codespace_name: &str, body: PatchCodespacesUpdateForAuthenticatedUser) -> Result { + + let request_uri = format!("{}/user/codespaces/{}", super::GITHUB_BASE_API_URL, codespace_name); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PatchCodespacesUpdateForAuthenticatedUser::from_json(body)?), + method: "PATCH", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 401 => Err(CodespacesUpdateForAuthenticatedUserError::Status401(crate::adapters::to_json_async(github_response).await?)), + 403 => Err(CodespacesUpdateForAuthenticatedUserError::Status403(crate::adapters::to_json_async(github_response).await?)), + 404 => Err(CodespacesUpdateForAuthenticatedUserError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(CodespacesUpdateForAuthenticatedUserError::Generic { code }), + } + } + } + + /// --- + /// + /// # Update a codespace for the authenticated user + /// + /// Updates a codespace owned by the authenticated user. Currently only the codespace's machine type can be modified using this endpoint. + /// + /// Once you specify a new machine type it will be applied the next time your codespace is started. + /// + /// You must authenticate using an access token with the `codespace` scope to use this endpoint. + /// + /// [GitHub API docs for update_for_authenticated_user](https://docs.github.com/rest/reference/codespaces#update-a-codespace-for-the-authenticated-user) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn update_for_authenticated_user(&self, codespace_name: &str, body: PatchCodespacesUpdateForAuthenticatedUser) -> Result { + + let request_uri = format!("{}/user/codespaces/{}", super::GITHUB_BASE_API_URL, codespace_name); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PatchCodespacesUpdateForAuthenticatedUser::from_json(body)?), + method: "PATCH", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 401 => Err(CodespacesUpdateForAuthenticatedUserError::Status401(crate::adapters::to_json(github_response)?)), + 403 => Err(CodespacesUpdateForAuthenticatedUserError::Status403(crate::adapters::to_json(github_response)?)), + 404 => Err(CodespacesUpdateForAuthenticatedUserError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(CodespacesUpdateForAuthenticatedUserError::Generic { code }), + } + } + } + +} diff --git a/src/endpoints/enterprise_admin.rs b/src/endpoints/enterprise_admin.rs index c77fb22..6aab855 100644 --- a/src/endpoints/enterprise_admin.rs +++ b/src/endpoints/enterprise_admin.rs @@ -31,6 +31,27 @@ pub fn new(auth: &Auth) -> EnterpriseAdmin { EnterpriseAdmin { auth } } +/// Errors for the [Add custom labels to a self-hosted runner for an enterprise](EnterpriseAdmin::add_custom_labels_to_self_hosted_runner_for_enterprise_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum EnterpriseAdminAddCustomLabelsToSelfHostedRunnerForEnterpriseError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Validation failed")] + Status422(ValidationErrorSimple), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + /// Errors for the [Add organization access to a self-hosted runner group in an enterprise](EnterpriseAdmin::add_org_access_to_self_hosted_runner_group_in_enterprise_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum EnterpriseAdminAddOrgAccessToSelfHostedRunnerGroupInEnterpriseError { @@ -337,6 +358,25 @@ pub enum EnterpriseAdminGetSelfHostedRunnerGroupForEnterpriseError { Generic { code: u16 }, } +/// Errors for the [List labels for a self-hosted runner for an enterprise](EnterpriseAdmin::list_labels_for_self_hosted_runner_for_enterprise_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum EnterpriseAdminListLabelsForSelfHostedRunnerForEnterpriseError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + /// Errors for the [List organization access to a self-hosted runner group in an enterprise](EnterpriseAdmin::list_org_access_to_self_hosted_runner_group_in_enterprise_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum EnterpriseAdminListOrgAccessToSelfHostedRunnerGroupInEnterpriseError { @@ -507,6 +547,48 @@ pub enum EnterpriseAdminProvisionAndInviteEnterpriseUserError { Generic { code: u16 }, } +/// Errors for the [Remove all custom labels from a self-hosted runner for an enterprise](EnterpriseAdmin::remove_all_custom_labels_from_self_hosted_runner_for_enterprise_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum EnterpriseAdminRemoveAllCustomLabelsFromSelfHostedRunnerForEnterpriseError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Validation failed")] + Status422(ValidationErrorSimple), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +/// Errors for the [Remove a custom label from a self-hosted runner for an enterprise](EnterpriseAdmin::remove_custom_label_from_self_hosted_runner_for_enterprise_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum EnterpriseAdminRemoveCustomLabelFromSelfHostedRunnerForEnterpriseError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Validation failed")] + Status422(ValidationErrorSimple), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + /// Errors for the [Remove organization access to a self-hosted runner group in an enterprise](EnterpriseAdmin::remove_org_access_to_self_hosted_runner_group_in_enterprise_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum EnterpriseAdminRemoveOrgAccessToSelfHostedRunnerGroupInEnterpriseError { @@ -558,6 +640,27 @@ pub enum EnterpriseAdminSetAllowedActionsEnterpriseError { Generic { code: u16 }, } +/// Errors for the [Set custom labels for a self-hosted runner for an enterprise](EnterpriseAdmin::set_custom_labels_for_self_hosted_runner_for_enterprise_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum EnterpriseAdminSetCustomLabelsForSelfHostedRunnerForEnterpriseError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Resource not found")] + Status404(BasicError), + #[error("Validation failed")] + Status422(ValidationErrorSimple), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + /// Errors for the [Set GitHub Actions permissions for an enterprise](EnterpriseAdmin::set_github_actions_permissions_enterprise_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum EnterpriseAdminSetGithubActionsPermissionsEnterpriseError { @@ -717,7 +820,7 @@ pub enum EnterpriseAdminUpdateSelfHostedRunnerGroupForEnterpriseError { pub struct EnterpriseAdminGetAuditLogParams<'req> { /// 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). phrase: Option<&'req str>, - /// 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`. + /// 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`. include: Option<&'req 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. after: Option<&'req str>, @@ -749,7 +852,7 @@ impl<'req> EnterpriseAdminGetAuditLogParams<'req> { } } - /// 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`. + /// 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`. pub fn include(self, include: &'req str) -> Self { Self { phrase: self.phrase, @@ -1162,6 +1265,91 @@ impl<'enc> From<&'enc PerPage> for EnterpriseAdminListSelfHostedRunnersInGroupFo } impl<'api> EnterpriseAdmin<'api> { + /// --- + /// + /// # Add custom labels to a self-hosted runner for an enterprise + /// + /// Add custom labels to a self-hosted runner configured in an enterprise. + /// + /// You must authenticate using an access token with the `manage_runners:enterprise` scope to use this endpoint. + /// + /// [GitHub API docs for add_custom_labels_to_self_hosted_runner_for_enterprise](https://docs.github.com/rest/reference/enterprise-admin#add-custom-labels-to-a-self-hosted-runner-for-an-enterprise) + /// + /// --- + pub async fn add_custom_labels_to_self_hosted_runner_for_enterprise_async(&self, enterprise: &str, runner_id: i32, body: PostEnterpriseAdminAddCustomLabelsToSelfHostedRunnerForEnterprise) -> Result { + + let request_uri = format!("{}/enterprises/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, enterprise, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PostEnterpriseAdminAddCustomLabelsToSelfHostedRunnerForEnterprise::from_json(body)?), + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 404 => Err(EnterpriseAdminAddCustomLabelsToSelfHostedRunnerForEnterpriseError::Status404(crate::adapters::to_json_async(github_response).await?)), + 422 => Err(EnterpriseAdminAddCustomLabelsToSelfHostedRunnerForEnterpriseError::Status422(crate::adapters::to_json_async(github_response).await?)), + code => Err(EnterpriseAdminAddCustomLabelsToSelfHostedRunnerForEnterpriseError::Generic { code }), + } + } + } + + /// --- + /// + /// # Add custom labels to a self-hosted runner for an enterprise + /// + /// Add custom labels to a self-hosted runner configured in an enterprise. + /// + /// You must authenticate using an access token with the `manage_runners:enterprise` scope to use this endpoint. + /// + /// [GitHub API docs for add_custom_labels_to_self_hosted_runner_for_enterprise](https://docs.github.com/rest/reference/enterprise-admin#add-custom-labels-to-a-self-hosted-runner-for-an-enterprise) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn add_custom_labels_to_self_hosted_runner_for_enterprise(&self, enterprise: &str, runner_id: i32, body: PostEnterpriseAdminAddCustomLabelsToSelfHostedRunnerForEnterprise) -> Result { + + let request_uri = format!("{}/enterprises/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, enterprise, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PostEnterpriseAdminAddCustomLabelsToSelfHostedRunnerForEnterprise::from_json(body)?), + method: "POST", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 404 => Err(EnterpriseAdminAddCustomLabelsToSelfHostedRunnerForEnterpriseError::Status404(crate::adapters::to_json(github_response)?)), + 422 => Err(EnterpriseAdminAddCustomLabelsToSelfHostedRunnerForEnterpriseError::Status422(crate::adapters::to_json(github_response)?)), + code => Err(EnterpriseAdminAddCustomLabelsToSelfHostedRunnerForEnterpriseError::Generic { code }), + } + } + } + /// --- /// /// # Add organization access to a self-hosted runner group in an enterprise @@ -2654,6 +2842,89 @@ impl<'api> EnterpriseAdmin<'api> { } } + /// --- + /// + /// # List labels for a self-hosted runner for an enterprise + /// + /// Lists all labels for a self-hosted runner configured in an enterprise. + /// + /// You must authenticate using an access token with the `manage_runners:enterprise` scope to use this endpoint. + /// + /// [GitHub API docs for list_labels_for_self_hosted_runner_for_enterprise](https://docs.github.com/rest/reference/enterprise-admin#list-labels-for-a-self-hosted-runner-for-an-enterprise) + /// + /// --- + pub async fn list_labels_for_self_hosted_runner_for_enterprise_async(&self, enterprise: &str, runner_id: i32) -> Result { + + let request_uri = format!("{}/enterprises/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, enterprise, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 404 => Err(EnterpriseAdminListLabelsForSelfHostedRunnerForEnterpriseError::Status404(crate::adapters::to_json_async(github_response).await?)), + code => Err(EnterpriseAdminListLabelsForSelfHostedRunnerForEnterpriseError::Generic { code }), + } + } + } + + /// --- + /// + /// # List labels for a self-hosted runner for an enterprise + /// + /// Lists all labels for a self-hosted runner configured in an enterprise. + /// + /// You must authenticate using an access token with the `manage_runners:enterprise` scope to use this endpoint. + /// + /// [GitHub API docs for list_labels_for_self_hosted_runner_for_enterprise](https://docs.github.com/rest/reference/enterprise-admin#list-labels-for-a-self-hosted-runner-for-an-enterprise) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn list_labels_for_self_hosted_runner_for_enterprise(&self, enterprise: &str, runner_id: i32) -> Result { + + let request_uri = format!("{}/enterprises/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, enterprise, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 404 => Err(EnterpriseAdminListLabelsForSelfHostedRunnerForEnterpriseError::Status404(crate::adapters::to_json(github_response)?)), + code => Err(EnterpriseAdminListLabelsForSelfHostedRunnerForEnterpriseError::Generic { code }), + } + } + } + /// --- /// /// # List organization access to a self-hosted runner group in an enterprise @@ -3557,6 +3828,186 @@ impl<'api> EnterpriseAdmin<'api> { } } + /// --- + /// + /// # Remove all custom labels from a self-hosted runner for an enterprise + /// + /// Remove all custom labels from a self-hosted runner configured in an + /// enterprise. Returns the remaining read-only labels from the runner. + /// + /// You must authenticate using an access token with the `manage_runners:enterprise` scope to use this endpoint. + /// + /// [GitHub API docs for remove_all_custom_labels_from_self_hosted_runner_for_enterprise](https://docs.github.com/rest/reference/enterprise-admin#remove-all-custom-labels-from-a-self-hosted-runner-for-an-enterprise) + /// + /// --- + pub async fn remove_all_custom_labels_from_self_hosted_runner_for_enterprise_async(&self, enterprise: &str, runner_id: i32) -> Result { + + let request_uri = format!("{}/enterprises/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, enterprise, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 404 => Err(EnterpriseAdminRemoveAllCustomLabelsFromSelfHostedRunnerForEnterpriseError::Status404(crate::adapters::to_json_async(github_response).await?)), + 422 => Err(EnterpriseAdminRemoveAllCustomLabelsFromSelfHostedRunnerForEnterpriseError::Status422(crate::adapters::to_json_async(github_response).await?)), + code => Err(EnterpriseAdminRemoveAllCustomLabelsFromSelfHostedRunnerForEnterpriseError::Generic { code }), + } + } + } + + /// --- + /// + /// # Remove all custom labels from a self-hosted runner for an enterprise + /// + /// Remove all custom labels from a self-hosted runner configured in an + /// enterprise. Returns the remaining read-only labels from the runner. + /// + /// You must authenticate using an access token with the `manage_runners:enterprise` scope to use this endpoint. + /// + /// [GitHub API docs for remove_all_custom_labels_from_self_hosted_runner_for_enterprise](https://docs.github.com/rest/reference/enterprise-admin#remove-all-custom-labels-from-a-self-hosted-runner-for-an-enterprise) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn remove_all_custom_labels_from_self_hosted_runner_for_enterprise(&self, enterprise: &str, runner_id: i32) -> Result { + + let request_uri = format!("{}/enterprises/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, enterprise, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 404 => Err(EnterpriseAdminRemoveAllCustomLabelsFromSelfHostedRunnerForEnterpriseError::Status404(crate::adapters::to_json(github_response)?)), + 422 => Err(EnterpriseAdminRemoveAllCustomLabelsFromSelfHostedRunnerForEnterpriseError::Status422(crate::adapters::to_json(github_response)?)), + code => Err(EnterpriseAdminRemoveAllCustomLabelsFromSelfHostedRunnerForEnterpriseError::Generic { code }), + } + } + } + + /// --- + /// + /// # Remove a custom label from a self-hosted runner for an enterprise + /// + /// Remove a custom label from a self-hosted runner configured + /// in an enterprise. 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. + /// + /// You must authenticate using an access token with the `manage_runners:enterprise` scope to use this endpoint. + /// + /// [GitHub API docs for remove_custom_label_from_self_hosted_runner_for_enterprise](https://docs.github.com/rest/reference/enterprise-admin#remove-a-custom-label-from-a-self-hosted-runner-for-an-enterprise) + /// + /// --- + pub async fn remove_custom_label_from_self_hosted_runner_for_enterprise_async(&self, enterprise: &str, runner_id: i32, name: &str) -> Result { + + let request_uri = format!("{}/enterprises/{}/actions/runners/{}/labels/{}", super::GITHUB_BASE_API_URL, enterprise, runner_id, name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 404 => Err(EnterpriseAdminRemoveCustomLabelFromSelfHostedRunnerForEnterpriseError::Status404(crate::adapters::to_json_async(github_response).await?)), + 422 => Err(EnterpriseAdminRemoveCustomLabelFromSelfHostedRunnerForEnterpriseError::Status422(crate::adapters::to_json_async(github_response).await?)), + code => Err(EnterpriseAdminRemoveCustomLabelFromSelfHostedRunnerForEnterpriseError::Generic { code }), + } + } + } + + /// --- + /// + /// # Remove a custom label from a self-hosted runner for an enterprise + /// + /// Remove a custom label from a self-hosted runner configured + /// in an enterprise. 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. + /// + /// You must authenticate using an access token with the `manage_runners:enterprise` scope to use this endpoint. + /// + /// [GitHub API docs for remove_custom_label_from_self_hosted_runner_for_enterprise](https://docs.github.com/rest/reference/enterprise-admin#remove-a-custom-label-from-a-self-hosted-runner-for-an-enterprise) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn remove_custom_label_from_self_hosted_runner_for_enterprise(&self, enterprise: &str, runner_id: i32, name: &str) -> Result { + + let request_uri = format!("{}/enterprises/{}/actions/runners/{}/labels/{}", super::GITHUB_BASE_API_URL, enterprise, runner_id, name); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 404 => Err(EnterpriseAdminRemoveCustomLabelFromSelfHostedRunnerForEnterpriseError::Status404(crate::adapters::to_json(github_response)?)), + 422 => Err(EnterpriseAdminRemoveCustomLabelFromSelfHostedRunnerForEnterpriseError::Status422(crate::adapters::to_json(github_response)?)), + code => Err(EnterpriseAdminRemoveCustomLabelFromSelfHostedRunnerForEnterpriseError::Generic { code }), + } + } + } + /// --- /// /// # Remove organization access to a self-hosted runner group in an enterprise @@ -3800,6 +4251,93 @@ impl<'api> EnterpriseAdmin<'api> { } } + /// --- + /// + /// # Set custom labels for a self-hosted runner for an enterprise + /// + /// Remove all previous custom labels and set the new custom labels for a specific + /// self-hosted runner configured in an enterprise. + /// + /// You must authenticate using an access token with the `manage_runners:enterprise` scope to use this endpoint. + /// + /// [GitHub API docs for set_custom_labels_for_self_hosted_runner_for_enterprise](https://docs.github.com/rest/reference/enterprise-admin#set-custom-labels-for-a-self-hosted-runner-for-an-enterprise) + /// + /// --- + pub async fn set_custom_labels_for_self_hosted_runner_for_enterprise_async(&self, enterprise: &str, runner_id: i32, body: PutEnterpriseAdminSetCustomLabelsForSelfHostedRunnerForEnterprise) -> Result { + + let request_uri = format!("{}/enterprises/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, enterprise, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PutEnterpriseAdminSetCustomLabelsForSelfHostedRunnerForEnterprise::from_json(body)?), + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 404 => Err(EnterpriseAdminSetCustomLabelsForSelfHostedRunnerForEnterpriseError::Status404(crate::adapters::to_json_async(github_response).await?)), + 422 => Err(EnterpriseAdminSetCustomLabelsForSelfHostedRunnerForEnterpriseError::Status422(crate::adapters::to_json_async(github_response).await?)), + code => Err(EnterpriseAdminSetCustomLabelsForSelfHostedRunnerForEnterpriseError::Generic { code }), + } + } + } + + /// --- + /// + /// # Set custom labels for a self-hosted runner for an enterprise + /// + /// Remove all previous custom labels and set the new custom labels for a specific + /// self-hosted runner configured in an enterprise. + /// + /// You must authenticate using an access token with the `manage_runners:enterprise` scope to use this endpoint. + /// + /// [GitHub API docs for set_custom_labels_for_self_hosted_runner_for_enterprise](https://docs.github.com/rest/reference/enterprise-admin#set-custom-labels-for-a-self-hosted-runner-for-an-enterprise) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn set_custom_labels_for_self_hosted_runner_for_enterprise(&self, enterprise: &str, runner_id: i32, body: PutEnterpriseAdminSetCustomLabelsForSelfHostedRunnerForEnterprise) -> Result { + + let request_uri = format!("{}/enterprises/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, enterprise, runner_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(PutEnterpriseAdminSetCustomLabelsForSelfHostedRunnerForEnterprise::from_json(body)?), + method: "PUT", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 404 => Err(EnterpriseAdminSetCustomLabelsForSelfHostedRunnerForEnterpriseError::Status404(crate::adapters::to_json(github_response)?)), + 422 => Err(EnterpriseAdminSetCustomLabelsForSelfHostedRunnerForEnterpriseError::Status422(crate::adapters::to_json(github_response)?)), + code => Err(EnterpriseAdminSetCustomLabelsForSelfHostedRunnerForEnterpriseError::Generic { code }), + } + } + } + /// --- /// /// # Set GitHub Actions permissions for an enterprise diff --git a/src/endpoints/mod.rs b/src/endpoints/mod.rs index 2e2c9a0..be18a6f 100644 --- a/src/endpoints/mod.rs +++ b/src/endpoints/mod.rs @@ -45,6 +45,7 @@ pub mod code_scanning; pub mod checks; pub mod billing; pub mod interactions; +pub mod codespaces; pub mod emojis; pub struct PerPage { diff --git a/src/endpoints/orgs.rs b/src/endpoints/orgs.rs index 05847b9..f2993d3 100644 --- a/src/endpoints/orgs.rs +++ b/src/endpoints/orgs.rs @@ -404,6 +404,23 @@ pub enum OrgsListBlockedUsersError { Generic { code: u16 }, } +/// Errors for the [List custom repository roles in an organization](Orgs::list_custom_roles_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum OrgsListCustomRolesError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + /// Errors for the [List failed organization invitations](Orgs::list_failed_invitations_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListFailedInvitationsError { @@ -918,7 +935,7 @@ pub enum OrgsUpdateWebhookConfigForOrgError { pub struct OrgsGetAuditLogParams<'req> { /// 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). phrase: Option<&'req str>, - /// 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`. + /// 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`. include: Option<&'req 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. after: Option<&'req str>, @@ -927,9 +944,7 @@ pub struct OrgsGetAuditLogParams<'req> { /// The order of audit log events. To list newest events first, specify `desc`. To list oldest events first, specify `asc`. The default is `desc`. order: Option<&'req str>, /// Results per page (max 100) - per_page: Option, - /// Page number of the results to fetch. - page: Option + per_page: Option } impl<'req> OrgsGetAuditLogParams<'req> { @@ -946,11 +961,10 @@ impl<'req> OrgsGetAuditLogParams<'req> { before: self.before, order: self.order, per_page: self.per_page, - page: self.page, } } - /// 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`. + /// 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`. pub fn include(self, include: &'req str) -> Self { Self { phrase: self.phrase, @@ -959,7 +973,6 @@ impl<'req> OrgsGetAuditLogParams<'req> { before: self.before, order: self.order, per_page: self.per_page, - page: self.page, } } @@ -972,7 +985,6 @@ impl<'req> OrgsGetAuditLogParams<'req> { before: self.before, order: self.order, per_page: self.per_page, - page: self.page, } } @@ -985,7 +997,6 @@ impl<'req> OrgsGetAuditLogParams<'req> { before: Some(before), order: self.order, per_page: self.per_page, - page: self.page, } } @@ -998,7 +1009,6 @@ impl<'req> OrgsGetAuditLogParams<'req> { before: self.before, order: Some(order), per_page: self.per_page, - page: self.page, } } @@ -1011,33 +1021,10 @@ impl<'req> OrgsGetAuditLogParams<'req> { before: self.before, order: self.order, per_page: Some(per_page), - page: self.page, - } - } - - /// Page number of the results to fetch. - pub fn page(self, page: u16) -> Self { - Self { - phrase: self.phrase, - include: self.include, - after: self.after, - before: self.before, - order: self.order, - per_page: self.per_page, - page: Some(page), } } } -impl<'enc> From<&'enc PerPage> for OrgsGetAuditLogParams<'enc> { - fn from(per_page: &'enc PerPage) -> Self { - Self { - per_page: Some(per_page.per_page), - page: Some(per_page.page), - ..Default::default() - } - } -} /// Query parameters for the [List organizations](Orgs::list_async()) endpoint. #[derive(Default, Serialize)] pub struct OrgsListParams { @@ -3140,6 +3127,89 @@ impl<'api> Orgs<'api> { } } + /// --- + /// + /// # List custom repository roles in an organization + /// + /// List the custom repository roles available in this organization. In order to see custom + /// repository roles in an organization, the authenticated user must be an organization owner. + /// + /// For more information on custom repository roles, see "[Managing custom repository roles for an organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-custom-repository-roles-for-an-organization)". + /// + /// [GitHub API docs for list_custom_roles](https://docs.github.com/rest/reference/orgs#list-custom-repository-roles-in-an-organization) + /// + /// --- + pub async fn list_custom_roles_async(&self, organization_id: &str) -> Result { + + let request_uri = format!("{}/organizations/{}/custom_roles", super::GITHUB_BASE_API_URL, organization_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + code => Err(OrgsListCustomRolesError::Generic { code }), + } + } + } + + /// --- + /// + /// # List custom repository roles in an organization + /// + /// List the custom repository roles available in this organization. In order to see custom + /// repository roles in an organization, the authenticated user must be an organization owner. + /// + /// For more information on custom repository roles, see "[Managing custom repository roles for an organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-custom-repository-roles-for-an-organization)". + /// + /// [GitHub API docs for list_custom_roles](https://docs.github.com/rest/reference/orgs#list-custom-repository-roles-in-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn list_custom_roles(&self, organization_id: &str) -> Result { + + let request_uri = format!("{}/organizations/{}/custom_roles", super::GITHUB_BASE_API_URL, organization_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + code => Err(OrgsListCustomRolesError::Generic { code }), + } + } + } + /// --- /// /// # List failed organization invitations diff --git a/src/endpoints/pulls.rs b/src/endpoints/pulls.rs index 64105cc..12b07d1 100644 --- a/src/endpoints/pulls.rs +++ b/src/endpoints/pulls.rs @@ -1417,7 +1417,7 @@ impl<'api> Pulls<'api> { /// /// 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. /// - /// 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). + /// 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. /// /// **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. /// @@ -1425,10 +1425,7 @@ impl<'api> Pulls<'api> { /// /// [GitHub API docs for create_review_comment](https://docs.github.com/rest/reference/pulls#create-a-review-comment-for-a-pull-request) /// - /// The `create_review_comment_async` endpoint is enabled with the `comfort-fade` cargo feature. - /// /// --- - #[cfg(feature = "comfort-fade")] pub async fn create_review_comment_async(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsCreateReviewComment) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -1438,7 +1435,7 @@ impl<'api> Pulls<'api> { uri: request_uri, body: Some(PostPullsCreateReviewComment::from_json(body)?), method: "POST", - headers: vec![("Accept", "application/vnd.github.comfort-fade-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -1467,7 +1464,7 @@ impl<'api> Pulls<'api> { /// /// 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. /// - /// 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). + /// 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. /// /// **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. /// @@ -1475,11 +1472,8 @@ impl<'api> Pulls<'api> { /// /// [GitHub API docs for create_review_comment](https://docs.github.com/rest/reference/pulls#create-a-review-comment-for-a-pull-request) /// - /// The `create_review_comment` endpoint is enabled with the `comfort-fade` cargo feature. - /// /// --- #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "comfort-fade")] pub fn create_review_comment(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsCreateReviewComment) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -1489,7 +1483,7 @@ impl<'api> Pulls<'api> { uri: request_uri, body: Some(PostPullsCreateReviewComment::from_json(body)?), method: "POST", - headers: vec![("Accept", "application/vnd.github.comfort-fade-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -1942,10 +1936,7 @@ impl<'api> Pulls<'api> { /// /// [GitHub API docs for get_review_comment](https://docs.github.com/rest/reference/pulls#get-a-review-comment-for-a-pull-request) /// - /// The `get_review_comment_async` endpoint is enabled with the `comfort-fade` cargo feature. - /// /// --- - #[cfg(feature = "comfort-fade")] pub async fn get_review_comment_async(&self, owner: &str, repo: &str, comment_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -1955,7 +1946,7 @@ impl<'api> Pulls<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.comfort-fade-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -1984,11 +1975,8 @@ impl<'api> Pulls<'api> { /// /// [GitHub API docs for get_review_comment](https://docs.github.com/rest/reference/pulls#get-a-review-comment-for-a-pull-request) /// - /// The `get_review_comment` endpoint is enabled with the `comfort-fade` cargo feature. - /// /// --- #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "comfort-fade")] pub fn get_review_comment(&self, owner: &str, repo: &str, comment_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -1998,7 +1986,7 @@ impl<'api> Pulls<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.comfort-fade-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -2463,10 +2451,7 @@ impl<'api> Pulls<'api> { /// /// [GitHub API docs for list_review_comments](https://docs.github.com/rest/reference/pulls#list-review-comments-on-a-pull-request) /// - /// The `list_review_comments_async` endpoint is enabled with the `comfort-fade` cargo feature. - /// /// --- - #[cfg(feature = "comfort-fade")] pub async fn list_review_comments_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>>) -> Result, PullsListReviewCommentsError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -2480,7 +2465,7 @@ impl<'api> Pulls<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.comfort-fade-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -2508,11 +2493,8 @@ impl<'api> Pulls<'api> { /// /// [GitHub API docs for list_review_comments](https://docs.github.com/rest/reference/pulls#list-review-comments-on-a-pull-request) /// - /// The `list_review_comments` endpoint is enabled with the `comfort-fade` cargo feature. - /// /// --- #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "comfort-fade")] pub fn list_review_comments(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>>) -> Result, PullsListReviewCommentsError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -2527,7 +2509,7 @@ impl<'api> Pulls<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.comfort-fade-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -2555,10 +2537,7 @@ impl<'api> Pulls<'api> { /// /// [GitHub API docs for list_review_comments_for_repo](https://docs.github.com/rest/reference/pulls#list-review-comments-in-a-repository) /// - /// The `list_review_comments_for_repo_async` endpoint is enabled with the `comfort-fade` cargo feature. - /// /// --- - #[cfg(feature = "comfort-fade")] pub async fn list_review_comments_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, PullsListReviewCommentsForRepoError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/comments", super::GITHUB_BASE_API_URL, owner, repo); @@ -2572,7 +2551,7 @@ impl<'api> Pulls<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.comfort-fade-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -2600,11 +2579,8 @@ impl<'api> Pulls<'api> { /// /// [GitHub API docs for list_review_comments_for_repo](https://docs.github.com/rest/reference/pulls#list-review-comments-in-a-repository) /// - /// The `list_review_comments_for_repo` endpoint is enabled with the `comfort-fade` cargo feature. - /// /// --- #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "comfort-fade")] pub fn list_review_comments_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, PullsListReviewCommentsForRepoError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/comments", super::GITHUB_BASE_API_URL, owner, repo); @@ -2619,7 +2595,7 @@ impl<'api> Pulls<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.comfort-fade-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -3300,10 +3276,7 @@ impl<'api> Pulls<'api> { /// /// [GitHub API docs for update_review_comment](https://docs.github.com/rest/reference/pulls#update-a-review-comment-for-a-pull-request) /// - /// The `update_review_comment_async` endpoint is enabled with the `comfort-fade` cargo feature. - /// /// --- - #[cfg(feature = "comfort-fade")] pub async fn update_review_comment_async(&self, owner: &str, repo: &str, comment_id: i32, body: PatchPullsUpdateReviewComment) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -3313,7 +3286,7 @@ impl<'api> Pulls<'api> { uri: request_uri, body: Some(PatchPullsUpdateReviewComment::from_json(body)?), method: "PATCH", - headers: vec![("Accept", "application/vnd.github.comfort-fade-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -3341,11 +3314,8 @@ impl<'api> Pulls<'api> { /// /// [GitHub API docs for update_review_comment](https://docs.github.com/rest/reference/pulls#update-a-review-comment-for-a-pull-request) /// - /// The `update_review_comment` endpoint is enabled with the `comfort-fade` cargo feature. - /// /// --- #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "comfort-fade")] pub fn update_review_comment(&self, owner: &str, repo: &str, comment_id: i32, body: PatchPullsUpdateReviewComment) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -3355,7 +3325,7 @@ impl<'api> Pulls<'api> { uri: request_uri, body: Some(PatchPullsUpdateReviewComment::from_json(body)?), method: "PATCH", - headers: vec![("Accept", "application/vnd.github.comfort-fade-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; diff --git a/src/endpoints/repos.rs b/src/endpoints/repos.rs index f34eadf..ac4f180 100644 --- a/src/endpoints/repos.rs +++ b/src/endpoints/repos.rs @@ -1194,8 +1194,6 @@ pub enum ReposGetAllTopicsError { // -- endpoint errors - #[error("Preview header missing")] - Status415(PostProjectsCreateForAuthenticatedUserResponse415), #[error("Resource not found")] Status404(BasicError), #[error("Status code: {}", code)] @@ -2767,8 +2765,6 @@ pub enum ReposReplaceAllTopicsError { // -- endpoint errors - #[error("Preview header missing")] - Status415(PostProjectsCreateForAuthenticatedUserResponse415), #[error("Resource not found")] Status404(BasicError), #[error("Validation failed")] @@ -5050,7 +5046,11 @@ impl<'api> Repos<'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. /// - /// For more information on 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)". + /// For more information on 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)". There are restrictions on which permissions can be granted to organization members when an organization base role is in place. In this case, the permission being given must be equal to or higher than the org base permission. Otherwise, the request will fail with: + /// + /// ```nocompile + /// 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 verbs](https://docs.github.com/rest/overview/resources-in-the-rest-api#http-verbs)." /// @@ -5101,7 +5101,11 @@ impl<'api> Repos<'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. /// - /// For more information on 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)". + /// For more information on 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)". There are restrictions on which permissions can be granted to organization members when an organization base role is in place. In this case, the permission being given must be equal to or higher than the org base permission. Otherwise, the request will fail with: + /// + /// ```nocompile + /// 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 verbs](https://docs.github.com/rest/overview/resources-in-the-rest-api#http-verbs)." /// @@ -8839,8 +8843,6 @@ impl<'api> Repos<'api> { /// --- /// /// # Disable Git LFS for a repository - /// - /// **Note:** The Git LFS API endpoints are currently in beta and are subject to change. /// /// [GitHub API docs for disable_lfs_for_repo](https://docs.github.com/rest/reference/repos#disable-git-lfs-for-a-repository) /// @@ -8877,8 +8879,6 @@ impl<'api> Repos<'api> { /// --- /// /// # Disable Git LFS for a repository - /// - /// **Note:** The Git LFS API endpoints are currently in beta and are subject to change. /// /// [GitHub API docs for disable_lfs_for_repo](https://docs.github.com/rest/reference/repos#disable-git-lfs-for-a-repository) /// @@ -9240,8 +9240,6 @@ impl<'api> Repos<'api> { /// --- /// /// # Enable Git LFS for a repository - /// - /// **Note:** The Git LFS API endpoints are currently in beta and are subject to change. /// /// [GitHub API docs for enable_lfs_for_repo](https://docs.github.com/rest/reference/repos#enable-git-lfs-for-a-repository) /// @@ -9279,8 +9277,6 @@ impl<'api> Repos<'api> { /// --- /// /// # Enable Git LFS for a repository - /// - /// **Note:** The Git LFS API endpoints are currently in beta and are subject to change. /// /// [GitHub API docs for enable_lfs_for_repo](https://docs.github.com/rest/reference/repos#enable-git-lfs-for-a-repository) /// @@ -9885,10 +9881,7 @@ impl<'api> Repos<'api> { /// /// [GitHub API docs for get_all_topics](https://docs.github.com/rest/reference/repos#get-all-repository-topics) /// - /// The `get_all_topics_async` endpoint is enabled with the `mercy` cargo feature. - /// /// --- - #[cfg(feature = "mercy")] pub async fn get_all_topics_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/topics", super::GITHUB_BASE_API_URL, owner, repo); @@ -9902,7 +9895,7 @@ impl<'api> Repos<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.mercy-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -9917,7 +9910,6 @@ impl<'api> Repos<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { - 415 => Err(ReposGetAllTopicsError::Status415(crate::adapters::to_json_async(github_response).await?)), 404 => Err(ReposGetAllTopicsError::Status404(crate::adapters::to_json_async(github_response).await?)), code => Err(ReposGetAllTopicsError::Generic { code }), } @@ -9930,11 +9922,8 @@ impl<'api> Repos<'api> { /// /// [GitHub API docs for get_all_topics](https://docs.github.com/rest/reference/repos#get-all-repository-topics) /// - /// The `get_all_topics` endpoint is enabled with the `mercy` cargo feature. - /// /// --- #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "mercy")] pub fn get_all_topics(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/topics", super::GITHUB_BASE_API_URL, owner, repo); @@ -9949,7 +9938,7 @@ impl<'api> Repos<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.mercy-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -9964,7 +9953,6 @@ impl<'api> Repos<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { - 415 => Err(ReposGetAllTopicsError::Status415(crate::adapters::to_json(github_response)?)), 404 => Err(ReposGetAllTopicsError::Status404(crate::adapters::to_json(github_response)?)), code => Err(ReposGetAllTopicsError::Generic { code }), } @@ -16106,8 +16094,6 @@ impl<'api> Repos<'api> { /// /// # Sync a fork branch with the upstream repository /// - /// **Note:** This endpoint is currently in beta and subject to change. - /// /// Sync a branch of a forked repository to keep it up-to-date with the upstream repository. /// /// [GitHub API docs for merge_upstream](https://docs.github.com/rest/reference/repos#sync-a-fork-branch-with-the-upstream-repository) @@ -16148,8 +16134,6 @@ impl<'api> Repos<'api> { /// /// # Sync a fork branch with the upstream repository /// - /// **Note:** This endpoint is currently in beta and subject to change. - /// /// Sync a branch of a forked repository to keep it up-to-date with the upstream repository. /// /// [GitHub API docs for merge_upstream](https://docs.github.com/rest/reference/repos#sync-a-fork-branch-with-the-upstream-repository) @@ -16968,10 +16952,7 @@ impl<'api> Repos<'api> { /// /// [GitHub API docs for replace_all_topics](https://docs.github.com/rest/reference/repos#replace-all-repository-topics) /// - /// The `replace_all_topics_async` endpoint is enabled with the `mercy` cargo feature. - /// /// --- - #[cfg(feature = "mercy")] pub async fn replace_all_topics_async(&self, owner: &str, repo: &str, body: PutReposReplaceAllTopics) -> Result { let request_uri = format!("{}/repos/{}/{}/topics", super::GITHUB_BASE_API_URL, owner, repo); @@ -16981,7 +16962,7 @@ impl<'api> Repos<'api> { uri: request_uri, body: Some(PutReposReplaceAllTopics::from_json(body)?), method: "PUT", - headers: vec![("Accept", "application/vnd.github.mercy-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -16996,7 +16977,6 @@ impl<'api> Repos<'api> { Ok(crate::adapters::to_json_async(github_response).await?) } else { match github_response.status_code() { - 415 => Err(ReposReplaceAllTopicsError::Status415(crate::adapters::to_json_async(github_response).await?)), 404 => Err(ReposReplaceAllTopicsError::Status404(crate::adapters::to_json_async(github_response).await?)), 422 => Err(ReposReplaceAllTopicsError::Status422(crate::adapters::to_json_async(github_response).await?)), code => Err(ReposReplaceAllTopicsError::Generic { code }), @@ -17010,11 +16990,8 @@ impl<'api> Repos<'api> { /// /// [GitHub API docs for replace_all_topics](https://docs.github.com/rest/reference/repos#replace-all-repository-topics) /// - /// The `replace_all_topics` endpoint is enabled with the `mercy` cargo feature. - /// /// --- #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "mercy")] pub fn replace_all_topics(&self, owner: &str, repo: &str, body: PutReposReplaceAllTopics) -> Result { let request_uri = format!("{}/repos/{}/{}/topics", super::GITHUB_BASE_API_URL, owner, repo); @@ -17024,7 +17001,7 @@ impl<'api> Repos<'api> { uri: request_uri, body: Some(PutReposReplaceAllTopics::from_json(body)?), method: "PUT", - headers: vec![("Accept", "application/vnd.github.mercy-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -17039,7 +17016,6 @@ impl<'api> Repos<'api> { Ok(crate::adapters::to_json(github_response)?) } else { match github_response.status_code() { - 415 => Err(ReposReplaceAllTopicsError::Status415(crate::adapters::to_json(github_response)?)), 404 => Err(ReposReplaceAllTopicsError::Status404(crate::adapters::to_json(github_response)?)), 422 => Err(ReposReplaceAllTopicsError::Status422(crate::adapters::to_json(github_response)?)), code => Err(ReposReplaceAllTopicsError::Generic { code }), @@ -18383,7 +18359,7 @@ impl<'api> Repos<'api> { /// /// Updating required status checks requires admin or owner permissions to the repository and branch protection to be enabled. /// - /// [GitHub API docs for update_status_check_protection](https://docs.github.com/rest/reference/repos#update-status-check-potection) + /// [GitHub API docs for update_status_check_protection](https://docs.github.com/rest/reference/repos#update-status-check-protection) /// /// --- pub async fn update_status_check_protection_async(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdateStatusCheckProtection) -> Result { @@ -18425,7 +18401,7 @@ impl<'api> Repos<'api> { /// /// Updating required status checks requires admin or owner permissions to the repository and branch protection to be enabled. /// - /// [GitHub API docs for update_status_check_protection](https://docs.github.com/rest/reference/repos#update-status-check-potection) + /// [GitHub API docs for update_status_check_protection](https://docs.github.com/rest/reference/repos#update-status-check-protection) /// /// --- #[cfg(not(target_arch = "wasm32"))] diff --git a/src/endpoints/search.rs b/src/endpoints/search.rs index cfe03ef..039008b 100644 --- a/src/endpoints/search.rs +++ b/src/endpoints/search.rs @@ -163,8 +163,6 @@ pub enum SearchTopicsError { #[error("Not modified")] Status304, - #[error("Preview header missing")] - Status415(PostProjectsCreateForAuthenticatedUserResponse415), #[error("Status code: {}", code)] Generic { code: u16 }, } @@ -1231,16 +1229,9 @@ impl<'api> Search<'api> { /// /// 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` - /// /// [GitHub API docs for repos](https://docs.github.com/rest/reference/search#search-repositories) /// - /// The `repos_async` endpoint is enabled with the `mercy` cargo feature. - /// /// --- - #[cfg(feature = "mercy")] pub async fn repos_async(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/repositories", super::GITHUB_BASE_API_URL); @@ -1252,7 +1243,7 @@ impl<'api> Search<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.mercy-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -1289,17 +1280,10 @@ impl<'api> Search<'api> { /// /// 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` - /// /// [GitHub API docs for repos](https://docs.github.com/rest/reference/search#search-repositories) /// - /// The `repos` endpoint is enabled with the `mercy` cargo feature. - /// /// --- #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "mercy")] pub fn repos(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/repositories", super::GITHUB_BASE_API_URL); @@ -1312,7 +1296,7 @@ impl<'api> Search<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.mercy-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -1351,10 +1335,7 @@ impl<'api> Search<'api> { /// /// [GitHub API docs for topics](https://docs.github.com/rest/reference/search#search-topics) /// - /// The `topics_async` endpoint is enabled with the `mercy` cargo feature. - /// /// --- - #[cfg(feature = "mercy")] pub async fn topics_async(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/topics", super::GITHUB_BASE_API_URL); @@ -1366,7 +1347,7 @@ impl<'api> Search<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.mercy-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -1382,7 +1363,6 @@ impl<'api> Search<'api> { } else { match github_response.status_code() { 304 => Err(SearchTopicsError::Status304), - 415 => Err(SearchTopicsError::Status415(crate::adapters::to_json_async(github_response).await?)), code => Err(SearchTopicsError::Generic { code }), } } @@ -1404,11 +1384,8 @@ impl<'api> Search<'api> { /// /// [GitHub API docs for topics](https://docs.github.com/rest/reference/search#search-topics) /// - /// The `topics` endpoint is enabled with the `mercy` cargo feature. - /// /// --- #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "mercy")] pub fn topics(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/topics", super::GITHUB_BASE_API_URL); @@ -1421,7 +1398,7 @@ impl<'api> Search<'api> { uri: request_uri, body: None, method: "GET", - headers: vec![("Accept", "application/vnd.github.mercy-preview+json"), ] + headers: vec![] }; let request = GitHubRequestBuilder::build(req, self.auth)?; @@ -1437,7 +1414,6 @@ impl<'api> Search<'api> { } else { match github_response.status_code() { 304 => Err(SearchTopicsError::Status304), - 415 => Err(SearchTopicsError::Status415(crate::adapters::to_json(github_response)?)), code => Err(SearchTopicsError::Generic { code }), } } diff --git a/src/endpoints/secret_scanning.rs b/src/endpoints/secret_scanning.rs index 6107905..bdfc328 100644 --- a/src/endpoints/secret_scanning.rs +++ b/src/endpoints/secret_scanning.rs @@ -54,7 +54,7 @@ pub enum SecretScanningGetAlertError { Generic { code: u16 }, } -/// Errors for the [List secret scanning alerts by organization](SecretScanning::list_alerts_for_org_async()) endpoint. +/// Errors for the [List secret scanning alerts for an organization](SecretScanning::list_alerts_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecretScanningListAlertsForOrgError { #[error(transparent)] @@ -96,6 +96,27 @@ pub enum SecretScanningListAlertsForRepoError { Generic { code: u16 }, } +/// Errors for the [List locations for a secret scanning alert](SecretScanning::list_locations_for_alert_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum SecretScanningListLocationsForAlertError { + #[error(transparent)] + AdapterError(#[from] AdapterError), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + + + // -- endpoint errors + + #[error("Repository is public, or secret scanning is disabled for the repository, or the resource is not found")] + Status404, + #[error("Service unavailable")] + Status503(GetSearchUsersResponse503), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + /// Errors for the [Update a secret scanning alert](SecretScanning::update_alert_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecretScanningUpdateAlertError { @@ -120,12 +141,12 @@ pub enum SecretScanningUpdateAlertError { } -/// Query parameters for the [List secret scanning alerts by organization](SecretScanning::list_alerts_for_org_async()) endpoint. +/// Query parameters for the [List secret scanning alerts for an organization](SecretScanning::list_alerts_for_org_async()) endpoint. #[derive(Default, Serialize)] pub struct SecretScanningListAlertsForOrgParams<'req> { /// Set to `open` or `resolved` to only list secret scanning alerts in a specific state. state: Option<&'req str>, - /// A comma-separated list of secret types to return. By default all secret types are returned. + /// 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). secret_type: Option<&'req 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`. resolution: Option<&'req str>, @@ -151,7 +172,7 @@ impl<'req> SecretScanningListAlertsForOrgParams<'req> { } } - /// A comma-separated list of secret types to return. By default all secret types are returned. + /// 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). pub fn secret_type(self, secret_type: &'req str) -> Self { Self { state: self.state, @@ -290,6 +311,46 @@ impl<'enc> From<&'enc PerPage> for SecretScanningListAlertsForRepoParams<'enc> { } } } +/// Query parameters for the [List locations for a secret scanning alert](SecretScanning::list_locations_for_alert_async()) endpoint. +#[derive(Default, Serialize)] +pub struct SecretScanningListLocationsForAlertParams { + /// Page number of the results to fetch. + page: Option, + /// Results per page (max 100) + per_page: Option +} + +impl SecretScanningListLocationsForAlertParams { + pub fn new() -> Self { + Self::default() + } + + /// Page number of the results to fetch. + pub fn page(self, page: u16) -> Self { + Self { + page: Some(page), + per_page: self.per_page, + } + } + + /// Results per page (max 100) + pub fn per_page(self, per_page: u16) -> Self { + Self { + page: self.page, + per_page: Some(per_page), + } + } +} + +impl<'enc> From<&'enc PerPage> for SecretScanningListLocationsForAlertParams { + fn from(per_page: &'enc PerPage) -> Self { + Self { + per_page: Some(per_page.per_page), + page: Some(per_page.page), + ..Default::default() + } + } +} impl<'api> SecretScanning<'api> { /// --- @@ -381,14 +442,14 @@ impl<'api> SecretScanning<'api> { /// --- /// - /// # List secret scanning alerts by organization + /// # List secret scanning alerts for an organization /// - /// Lists all secret scanning alerts for all eligible repositories in an organization, from newest to oldest. + /// Lists secret scanning alerts for eligible repositories in an organization, 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. /// /// GitHub Apps must have the `secret_scanning_alerts` read permission to use this endpoint. /// - /// [GitHub API docs for list_alerts_for_org](https://docs.github.com/rest/reference/secret-scanning#list-secret-scanning-alerts-by-organization) + /// [GitHub API docs for list_alerts_for_org](https://docs.github.com/rest/reference/secret-scanning#list-secret-scanning-alerts-for-an-organization) /// /// --- pub async fn list_alerts_for_org_async(&self, org: &str, query_params: Option>>) -> Result, SecretScanningListAlertsForOrgError> { @@ -428,14 +489,14 @@ impl<'api> SecretScanning<'api> { /// --- /// - /// # List secret scanning alerts by organization + /// # List secret scanning alerts for an organization /// - /// Lists all secret scanning alerts for all eligible repositories in an organization, from newest to oldest. + /// Lists secret scanning alerts for eligible repositories in an organization, 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. /// /// GitHub Apps must have the `secret_scanning_alerts` read permission to use this endpoint. /// - /// [GitHub API docs for list_alerts_for_org](https://docs.github.com/rest/reference/secret-scanning#list-secret-scanning-alerts-by-organization) + /// [GitHub API docs for list_alerts_for_org](https://docs.github.com/rest/reference/secret-scanning#list-secret-scanning-alerts-for-an-organization) /// /// --- #[cfg(not(target_arch = "wasm32"))] @@ -479,7 +540,7 @@ impl<'api> SecretScanning<'api> { /// /// # List secret scanning alerts for a repository /// - /// 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 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. /// /// GitHub Apps must have the `secret_scanning_alerts` read permission to use this endpoint. /// @@ -525,7 +586,7 @@ impl<'api> SecretScanning<'api> { /// /// # List secret scanning alerts for a repository /// - /// 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 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. /// /// GitHub Apps must have the `secret_scanning_alerts` read permission to use this endpoint. /// @@ -569,6 +630,100 @@ impl<'api> SecretScanning<'api> { } } + /// --- + /// + /// # List locations for a secret scanning alert + /// + /// Lists all locations for a given secret scanning alert for 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. + /// + /// GitHub Apps must have the `secret_scanning_alerts` read permission to use this endpoint. + /// + /// [GitHub API docs for list_locations_for_alert](https://docs.github.com/rest/reference/secret-scanning#list-locations-for-a-secret-scanning-alert) + /// + /// --- + pub async fn list_locations_for_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber, query_params: Option>) -> Result, SecretScanningListLocationsForAlertError> { + + let mut request_uri = format!("{}/repos/{}/{}/secret-scanning/alerts/{}/locations", super::GITHUB_BASE_API_URL, owner, repo, alert_number); + + if let Some(params) = query_params { + request_uri.push_str("?"); + request_uri.push_str(&serde_urlencoded::to_string(params.into())?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json_async(github_response).await?) + } else { + match github_response.status_code() { + 404 => Err(SecretScanningListLocationsForAlertError::Status404), + 503 => Err(SecretScanningListLocationsForAlertError::Status503(crate::adapters::to_json_async(github_response).await?)), + code => Err(SecretScanningListLocationsForAlertError::Generic { code }), + } + } + } + + /// --- + /// + /// # List locations for a secret scanning alert + /// + /// Lists all locations for a given secret scanning alert for 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. + /// + /// GitHub Apps must have the `secret_scanning_alerts` read permission to use this endpoint. + /// + /// [GitHub API docs for list_locations_for_alert](https://docs.github.com/rest/reference/secret-scanning#list-locations-for-a-secret-scanning-alert) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn list_locations_for_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber, query_params: Option>) -> Result, SecretScanningListLocationsForAlertError> { + + let mut request_uri = format!("{}/repos/{}/{}/secret-scanning/alerts/{}/locations", super::GITHUB_BASE_API_URL, owner, repo, alert_number); + + if let Some(params) = query_params { + request_uri.push_str("?"); + let qp: SecretScanningListLocationsForAlertParams = params.into(); + request_uri.push_str(&serde_urlencoded::to_string(qp)?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = GitHubRequestBuilder::build(req, self.auth)?; + + // -- + + let github_response = crate::adapters::fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(crate::adapters::to_json(github_response)?) + } else { + match github_response.status_code() { + 404 => Err(SecretScanningListLocationsForAlertError::Status404), + 503 => Err(SecretScanningListLocationsForAlertError::Status503(crate::adapters::to_json(github_response)?)), + code => Err(SecretScanningListLocationsForAlertError::Generic { code }), + } + } + } + /// --- /// /// # Update a secret scanning alert diff --git a/src/lib.rs b/src/lib.rs index 25873ce..ad9245d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,7 @@ //! //! ```nocompile //! [dependencies] -//! roctogen = "0.11" +//! roctogen = "0.12" //! ``` //! //! # API @@ -62,6 +62,7 @@ //! - [Checks](https://docs.rs/roctogen/latest/roctogen/endpoints/checks/struct.Checks.html) //! - [Billing](https://docs.rs/roctogen/latest/roctogen/endpoints/billing/struct.Billing.html) //! - [Interactions](https://docs.rs/roctogen/latest/roctogen/endpoints/interactions/struct.Interactions.html) +//! - [Codespaces](https://docs.rs/roctogen/latest/roctogen/endpoints/codespaces/struct.Codespaces.html) //! - [Emojis](https://docs.rs/roctogen/latest/roctogen/endpoints/emojis/struct.Emojis.html) //! //! # Usage diff --git a/src/models.rs b/src/models.rs index 8227117..05c3188 100644 --- a/src/models.rs +++ b/src/models.rs @@ -182,6 +182,32 @@ pub struct AddedtoprojectissueeventProjectCard { pub previous_column_name: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct AdvancedSecurityActiveCommitters { + #[serde(skip_serializing_if="Option::is_none")] + pub total_advanced_security_committers: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub repositories: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct AdvancedSecurityActiveCommittersRepository { + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub advanced_security_committers: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub advanced_security_committers_breakdown: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct AdvancedSecurityActiveCommittersUser { + #[serde(skip_serializing_if="Option::is_none")] + pub user_login: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub last_pushed_date: Option, +} + /// The time that the alert was created in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ`. pub type AlertCreatedAt = DateTime; @@ -198,6 +224,9 @@ pub struct AlertInstancesUrl { /// The security alert number. pub type AlertNumber = i32; +/// The time that the alert was last updated in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ`. +pub type AlertUpdatedAt = DateTime; + /// The REST API URL of the alert resource. #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct AlertUrl { @@ -365,9 +394,6 @@ pub struct AppPermissions { /// The level of permission to grant the access token for checks on code. Can be one of: `read` or `write`. #[serde(skip_serializing_if="Option::is_none")] pub checks: Option, - /// The level of permission to grant the access token for notification of content references and creation content attachments. Can be one of: `read` or `write`. - #[serde(skip_serializing_if="Option::is_none")] - pub content_references: Option, /// The level of permission to grant the access token for repository contents, commits, branches, downloads, releases, and merges. Can be one of: `read` or `write`. #[serde(skip_serializing_if="Option::is_none")] pub contents: Option, @@ -413,7 +439,7 @@ pub struct AppPermissions { /// The level of permission to grant the access token for commit statuses. Can be one of: `read` or `write`. #[serde(skip_serializing_if="Option::is_none")] pub statuses: Option, - /// The level of permission to grant the access token to retrieve Dependabot alerts. Can be one of: `read`. + /// The level of permission to grant the access token to manage Dependabot alerts. Can be one of: `read` or `write`. #[serde(skip_serializing_if="Option::is_none")] pub vulnerability_alerts: Option, /// The level of permission to grant the access token to update GitHub Actions workflow files. Can be one of: `write`. @@ -431,7 +457,7 @@ pub struct AppPermissions { /// The level of permission to grant the access token for viewing an organization's plan. Can be one of: `read`. #[serde(skip_serializing_if="Option::is_none")] pub organization_plan: Option, - /// The level of permission to grant the access token to manage organization projects, columns, and cards. Can be one of: `read`, `write`, or `admin`. + /// The level of permission to grant the access token to manage organization projects and projects beta (where available). Can be one of: `read`, `write`, or `admin`. #[serde(skip_serializing_if="Option::is_none")] pub organization_projects: Option, /// The level of permission to grant the access token for organization packages published to GitHub Packages. Can be one of: `read` or `write`. @@ -921,6 +947,125 @@ pub struct PatchOauthAuthorizationsUpdateAuthorization { pub fingerprint: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostReposCreateCommitComment { + /// The contents of the comment. + #[serde(skip_serializing_if="Option::is_none")] + pub body: Option, + /// Relative path of the file to comment on. + #[serde(skip_serializing_if="Option::is_none")] + pub path: Option, + /// Line index in the diff to comment on. + #[serde(skip_serializing_if="Option::is_none")] + pub position: Option, + /// **Deprecated**. Use **position** parameter instead. Line number in the file to comment on. + #[serde(skip_serializing_if="Option::is_none")] + pub line: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutReposCreateOrUpdateFileContents { + /// The commit message. + #[serde(skip_serializing_if="Option::is_none")] + pub message: Option, + /// The new file content, using Base64 encoding. + #[serde(skip_serializing_if="Option::is_none")] + pub content: Option, + /// **Required if you are updating a file**. The blob SHA of the file being replaced. + #[serde(skip_serializing_if="Option::is_none")] + pub sha: Option, + /// The branch name. Default: the repository’s default branch (usually `master`) + #[serde(skip_serializing_if="Option::is_none")] + pub branch: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub committer: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub author: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct DeleteReposDeleteFile { + /// The commit message. + #[serde(skip_serializing_if="Option::is_none")] + pub message: Option, + /// The blob SHA of the file being replaced. + #[serde(skip_serializing_if="Option::is_none")] + pub sha: Option, + /// The branch name. Default: the repository’s default branch (usually `master`) + #[serde(skip_serializing_if="Option::is_none")] + pub branch: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub committer: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub author: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostReposCreateDeployment { + /// The ref to deploy. This can be a branch, tag, or SHA. + #[serde(rename = "ref")] + #[serde(skip_serializing_if="Option::is_none")] + pub git_ref: Option, + /// Specifies a task to execute (e.g., `deploy` or `deploy:migrations`). + #[serde(skip_serializing_if="Option::is_none")] + pub task: Option, + /// Attempts to automatically merge the default branch into the requested ref, if it's behind the default branch. + #[serde(skip_serializing_if="Option::is_none")] + pub auto_merge: Option, + /// The [status](https://docs.github.com/rest/reference/repos#statuses) contexts to verify against commit status checks. If you omit this parameter, GitHub verifies all unique contexts before creating a deployment. To bypass checking entirely, pass an empty array. Defaults to all unique contexts. + #[serde(skip_serializing_if="Option::is_none")] + pub required_contexts: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub payload: Option, + /// Name for the target deployment environment (e.g., `production`, `staging`, `qa`). + #[serde(skip_serializing_if="Option::is_none")] + pub environment: Option, + /// Short description of the deployment. + #[serde(skip_serializing_if="Option::is_none")] + pub description: Option, + /// Specifies if the given environment is specific to the deployment and will no longer exist at some point in the future. Default: `false` + #[serde(skip_serializing_if="Option::is_none")] + pub transient_environment: Option, + /// Specifies if the given environment is one that end-users directly interact with. Default: `true` when `environment` is `production` and `false` otherwise. + #[serde(skip_serializing_if="Option::is_none")] + pub production_environment: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostReposCreateDeploymentStatus { + /// The state of the status. Can be one of `error`, `failure`, `inactive`, `in_progress`, `queued`, `pending`, or `success`. When you set a transient deployment to `inactive`, the deployment will be shown as `destroyed` in GitHub. + #[serde(skip_serializing_if="Option::is_none")] + pub state: Option, + /// The target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. **Note:** It's recommended to use the `log_url` parameter, which replaces `target_url`. + #[serde(skip_serializing_if="Option::is_none")] + pub target_url: Option, + /// The full URL of the deployment's output. This parameter replaces `target_url`. We will continue to accept `target_url` to support legacy uses, but we recommend replacing `target_url` with `log_url`. Setting `log_url` will automatically set `target_url` to the same value. Default: `\"\"` + #[serde(skip_serializing_if="Option::is_none")] + pub log_url: Option, + /// A short description of the status. The maximum description length is 140 characters. + #[serde(skip_serializing_if="Option::is_none")] + pub description: Option, + /// Name for the target deployment environment, which can be changed when setting a deploy status. For example, `production`, `staging`, or `qa`. + #[serde(skip_serializing_if="Option::is_none")] + pub environment: Option, + /// Sets the URL for accessing your environment. Default: `\"\"` + #[serde(skip_serializing_if="Option::is_none")] + pub environment_url: Option, + /// Adds a new `inactive` status to all prior non-transient, non-production environment deployments with the same repository and `environment` name as the created status's deployment. An `inactive` status is only added to deployments that had a `success` state. Default: `true` + #[serde(skip_serializing_if="Option::is_none")] + pub auto_inactive: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostReposCreateDispatchEvent { + /// A custom webhook event name. + #[serde(skip_serializing_if="Option::is_none")] + pub event_type: Option, + /// JSON payload with extra information about the webhook event that your action or worklow may use. + #[serde(skip_serializing_if="Option::is_none")] + pub client_payload: Option>>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutReposCreateOrUpdateEnvironment { #[serde(skip_serializing_if="Option::is_none")] @@ -969,6 +1114,14 @@ pub struct PostGitCreateCommit { pub signature: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutEnterpriseAdminSetGithubActionsPermissionsEnterprise { + #[serde(skip_serializing_if="Option::is_none")] + pub enabled_organizations: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub allowed_actions: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostGitCreateRef { /// The name of the fully qualified reference (ie: `refs/heads/master`). If it doesn't start with 'refs' and have at least two slashes, it will be rejected. @@ -1054,14 +1207,6 @@ pub struct PatchReposUpdateWebhook { pub active: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutEnterpriseAdminSetGithubActionsPermissionsEnterprise { - #[serde(skip_serializing_if="Option::is_none")] - pub enabled_organizations: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub allowed_actions: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchReposUpdateWebhookConfigForRepo { #[serde(skip_serializing_if="Option::is_none")] @@ -1117,6 +1262,13 @@ pub struct PatchMigrationsMapCommitAuthor { pub name: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutEnterpriseAdminSetSelectedOrganizationsEnabledGithubActionsEnterprise { + /// List of organization IDs to enable for GitHub Actions. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_organization_ids: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchMigrationsSetLfsPreference { /// Can be one of `opt_in` (large files will be stored using Git LFS) or `opt_out` (large files will be removed during the import). @@ -1190,13 +1342,6 @@ pub struct PatchIssuesUpdate { pub assignees: Option>, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutEnterpriseAdminSetSelectedOrganizationsEnabledGithubActionsEnterprise { - /// List of organization IDs to enable for GitHub Actions. - #[serde(skip_serializing_if="Option::is_none")] - pub selected_organization_ids: Option>, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostIssuesAddAssignees { /// Usernames of people to assign this issue to. _NOTE: Only users with push access can add assignees to an issue. Assignees are silently ignored otherwise._ @@ -1251,6 +1396,25 @@ impl From for PutIssuesSetLabels { } } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostEnterpriseAdminCreateSelfHostedRunnerGroupForEnterprise { + /// Name of the runner group. + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + /// Visibility of a runner group. You can select all organizations or select individual organization. Can be one of: `all` or `selected` + #[serde(skip_serializing_if="Option::is_none")] + pub visibility: Option, + /// List of organization IDs that can access the runner group. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_organization_ids: Option>, + /// List of runner IDs to add to the runner group. + #[serde(skip_serializing_if="Option::is_none")] + pub runners: Option>, + /// Whether the runner group can be used by `public` repositories. + #[serde(skip_serializing_if="Option::is_none")] + pub allows_public_repositories: Option, +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum PostIssuesAddLabels { @@ -1319,7 +1483,7 @@ pub struct PostIssuesCreateLabel { /// The [hexadecimal color code](http://www.color-hex.com/) for the label, without the leading `#`. #[serde(skip_serializing_if="Option::is_none")] pub color: Option, - /// A short description of the label. + /// A short description of the label. Must be 100 characters or fewer. #[serde(skip_serializing_if="Option::is_none")] pub description: Option, } @@ -1332,27 +1496,11 @@ pub struct PatchIssuesUpdateLabel { /// The [hexadecimal color code](http://www.color-hex.com/) for the label, without the leading `#`. #[serde(skip_serializing_if="Option::is_none")] pub color: Option, - /// A short description of the label. + /// A short description of the label. Must be 100 characters or fewer. #[serde(skip_serializing_if="Option::is_none")] pub description: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostEnterpriseAdminCreateSelfHostedRunnerGroupForEnterprise { - /// Name of the runner group. - #[serde(skip_serializing_if="Option::is_none")] - pub name: Option, - /// Visibility of a runner group. You can select all organizations or select individual organization. Can be one of: `all` or `selected` - #[serde(skip_serializing_if="Option::is_none")] - pub visibility: Option, - /// List of organization IDs that can access the runner group. - #[serde(skip_serializing_if="Option::is_none")] - pub selected_organization_ids: Option>, - /// List of runner IDs to add to the runner group. - #[serde(skip_serializing_if="Option::is_none")] - pub runners: Option>, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostReposMergeUpstream { /// The name of the branch which should be updated to match upstream. @@ -1405,6 +1553,19 @@ pub struct PatchIssuesUpdateMilestone { pub due_on: Option>, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PatchEnterpriseAdminUpdateSelfHostedRunnerGroupForEnterprise { + /// Name of the runner group. + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + /// Visibility of a runner group. You can select all organizations or select individual organizations. Can be one of: `all` or `selected` + #[serde(skip_serializing_if="Option::is_none")] + pub visibility: Option, + /// Whether the runner group can be used by `public` repositories. + #[serde(skip_serializing_if="Option::is_none")] + pub allows_public_repositories: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutActivityMarkRepoNotificationsAsRead { /// Describes the last point that notifications were checked. Anything updated since this time will not be marked as read. If you omit this parameter, all notifications are marked as read. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Default: The current timestamp. @@ -1480,16 +1641,6 @@ pub struct PatchPullsUpdateReviewComment { pub body: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PatchEnterpriseAdminUpdateSelfHostedRunnerGroupForEnterprise { - /// Name of the runner group. - #[serde(skip_serializing_if="Option::is_none")] - pub name: Option, - /// Visibility of a runner group. You can select all organizations or select individual organizations. Can be one of: `all` or `selected` - #[serde(skip_serializing_if="Option::is_none")] - pub visibility: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostReactionsCreateForPullRequestReviewComment { /// The [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types) to add to the pull request review comment. @@ -1516,6 +1667,22 @@ pub struct PatchPullsUpdate { pub maintainer_can_modify: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostCodespacesCreateWithPrForAuthenticatedUser { + /// Location for this codespace + #[serde(skip_serializing_if="Option::is_none")] + pub location: Option, + /// Machine type to use for this codespace + #[serde(skip_serializing_if="Option::is_none")] + pub machine: Option, + /// Working directory for this codespace + #[serde(skip_serializing_if="Option::is_none")] + pub working_directory: Option, + /// Time in minutes before codespace stops from inactivity + #[serde(skip_serializing_if="Option::is_none")] + pub idle_timeout_minutes: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostPullsCreateReviewComment { /// The text of the review comment. @@ -1527,25 +1694,33 @@ pub struct PostPullsCreateReviewComment { /// The relative path to the file that necessitates a comment. #[serde(skip_serializing_if="Option::is_none")] pub path: Option, - /// **Required without `comfort-fade` preview**. The position in the diff where you want to add a review comment. Note this value is not the same as the line number in the file. For help finding the position value, read the note above. + /// **Required without `comfort-fade` preview unless using `in_reply_to`**. The position in the diff where you want to add a review comment. Note this value is not the same as the line number in the file. For help finding the position value, read the note above. #[serde(skip_serializing_if="Option::is_none")] pub position: Option, - /// **Required with `comfort-fade` preview**. In a split diff view, the side of the diff that the pull request's changes appear on. Can be `LEFT` or `RIGHT`. Use `LEFT` for deletions that appear in red. Use `RIGHT` for additions that appear in green or unchanged lines that appear in white and are shown for context. For a multi-line comment, side represents whether the last line of the comment range is a deletion or addition. For more information, see \"[Diff view options](https://help.github.com/en/articles/about-comparing-branches-in-pull-requests#diff-view-options)\" in the GitHub Help documentation. + /// **Required with `comfort-fade` preview unless using `in_reply_to`**. In a split diff view, the side of the diff that the pull request's changes appear on. Can be `LEFT` or `RIGHT`. Use `LEFT` for deletions that appear in red. Use `RIGHT` for additions that appear in green or unchanged lines that appear in white and are shown for context. For a multi-line comment, side represents whether the last line of the comment range is a deletion or addition. For more information, see \"[Diff view options](https://help.github.com/en/articles/about-comparing-branches-in-pull-requests#diff-view-options)\" in the GitHub Help documentation. #[serde(skip_serializing_if="Option::is_none")] pub side: Option, - /// **Required with `comfort-fade` preview**. The line of the blob in the pull request diff that the comment applies to. For a multi-line comment, the last line of the range that your comment applies to. + /// **Required with `comfort-fade` preview unless using `in_reply_to`**. The line of the blob in the pull request diff that the comment applies to. For a multi-line comment, the last line of the range that your comment applies to. #[serde(skip_serializing_if="Option::is_none")] pub line: Option, - /// **Required when using multi-line comments**. To create multi-line comments, you must use the `comfort-fade` preview header. The `start_line` is the first line in the pull request diff that your multi-line comment applies to. To learn more about multi-line comments, see \"[Commenting on a pull request](https://help.github.com/en/articles/commenting-on-a-pull-request#adding-line-comments-to-a-pull-request)\" in the GitHub Help documentation. + /// **Required when using multi-line comments unless using `in_reply_to`**. To create multi-line comments, you must use the `comfort-fade` preview header. The `start_line` is the first line in the pull request diff that your multi-line comment applies to. To learn more about multi-line comments, see \"[Commenting on a pull request](https://help.github.com/en/articles/commenting-on-a-pull-request#adding-line-comments-to-a-pull-request)\" in the GitHub Help documentation. #[serde(skip_serializing_if="Option::is_none")] pub start_line: Option, - /// **Required when using multi-line comments**. To create multi-line comments, you must use the `comfort-fade` preview header. The `start_side` is the starting side of the diff that the comment applies to. Can be `LEFT` or `RIGHT`. To learn more about multi-line comments, see \"[Commenting on a pull request](https://help.github.com/en/articles/commenting-on-a-pull-request#adding-line-comments-to-a-pull-request)\" in the GitHub Help documentation. See `side` in this table for additional context. + /// **Required when using multi-line comments unless using `in_reply_to`**. To create multi-line comments, you must use the `comfort-fade` preview header. The `start_side` is the starting side of the diff that the comment applies to. Can be `LEFT` or `RIGHT`. To learn more about multi-line comments, see \"[Commenting on a pull request](https://help.github.com/en/articles/commenting-on-a-pull-request#adding-line-comments-to-a-pull-request)\" in the GitHub Help documentation. See `side` in this table for additional context. #[serde(skip_serializing_if="Option::is_none")] pub start_side: Option, + /// The ID of the review comment to reply to. To find the ID of a review comment with [\"List review comments on a pull request\"](#list-review-comments-on-a-pull-request). When specified, all parameters other than `body` in the request body are ignored. #[serde(skip_serializing_if="Option::is_none")] pub in_reply_to: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutEnterpriseAdminSetOrgAccessToSelfHostedRunnerGroupInEnterprise { + /// List of organization IDs that can access the runner group. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_organization_ids: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostPullsCreateReplyForReviewComment { /// The text of the review comment. @@ -1631,13 +1806,6 @@ pub struct PutPullsDismissReview { pub event: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutEnterpriseAdminSetOrgAccessToSelfHostedRunnerGroupInEnterprise { - /// List of organization IDs that can access the runner group. - #[serde(skip_serializing_if="Option::is_none")] - pub selected_organization_ids: Option>, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostPullsSubmitReview { /// The body text of the pull request review @@ -1683,6 +1851,13 @@ pub struct PostReposCreateRelease { pub generate_release_notes: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutEnterpriseAdminSetSelfHostedRunnersInGroupForEnterprise { + /// List of runner IDs to add to the runner group. + #[serde(skip_serializing_if="Option::is_none")] + pub runners: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchReposUpdateReleaseAsset { /// The file name of the asset. @@ -1778,15 +1953,8 @@ pub struct PutActivitySetRepoSubscription { } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutEnterpriseAdminSetSelfHostedRunnersInGroupForEnterprise { - /// List of runner IDs to add to the runner group. - #[serde(skip_serializing_if="Option::is_none")] - pub runners: Option>, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutReposReplaceAllTopics { - /// An array of topics to add to the repository. Pass one or more topics to _replace_ the set of existing topics. Send an empty array (`[]`) to clear all topics from the repository. **Note:** Topic `names` cannot contain uppercase letters. +pub struct PutReposReplaceAllTopics { + /// An array of topics to add to the repository. Pass one or more topics to _replace_ the set of existing topics. Send an empty array (`[]`) to clear all topics from the repository. **Note:** Topic `names` cannot contain uppercase letters. #[serde(skip_serializing_if="Option::is_none")] pub names: Option>, } @@ -1820,6 +1988,13 @@ pub struct PostReposCreateUsingTemplate { pub private: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutEnterpriseAdminSetCustomLabelsForSelfHostedRunnerForEnterprise { + /// The names of the custom labels to set for the runner. You can pass an empty array to remove all custom labels. + #[serde(skip_serializing_if="Option::is_none")] + pub labels: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutActionsCreateOrUpdateEnvironmentSecret { /// Value for your secret, encrypted with [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages) using the public key retrieved from the [Get an environment public key](https://docs.github.com/rest/reference/actions#get-an-environment-public-key) endpoint. @@ -1916,18 +2091,6 @@ pub struct PatchEnterpriseAdminUpdateAttributeForEnterpriseUser { pub operations: Option>, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostGistsCreate { - /// Description of the gist - #[serde(skip_serializing_if="Option::is_none")] - pub description: Option, - /// Names and content for the files that make up the gist - #[serde(skip_serializing_if="Option::is_none")] - pub files: Option>, - #[serde(skip_serializing_if="Option::is_none")] - pub public: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostScimProvisionAndInviteUser { /// Configured by the admin. Could be an email, login, or username @@ -1990,6 +2153,13 @@ pub struct PatchScimUpdateAttributeForUser { pub operations: Option>, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostEnterpriseAdminAddCustomLabelsToSelfHostedRunnerForEnterprise { + /// The names of the custom labels to add to the runner. + #[serde(skip_serializing_if="Option::is_none")] + pub labels: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchTeamsUpdateLegacy { /// The name of the team. @@ -2060,26 +2230,6 @@ pub struct PostReactionsCreateForTeamDiscussionLegacy { pub content: Option, } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PatchGistsUpdate { - PatchGistsUpdateVariant0(Value), -} - -impl From for PatchGistsUpdate { - fn from(value: Value) -> Self { - PatchGistsUpdate::PatchGistsUpdateVariant0(value) - } -} - -impl Display for PatchGistsUpdate { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - match self { - PatchGistsUpdate::PatchGistsUpdateVariant0(value) => write!(f, "{}", value), - } - } -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutTeamsAddOrUpdateMembershipForUserLegacy { /// The role that this user should have in the team. Can be one of: \\* `member` - a normal member of the team. \\* `maintainer` - a team maintainer. Able to add/remove other team members, promote other team members to team maintainer, and edit the team's name and description. @@ -2101,6 +2251,18 @@ pub struct PutTeamsAddOrUpdateRepoPermissionsLegacy { pub permission: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostGistsCreate { + /// Description of the gist + #[serde(skip_serializing_if="Option::is_none")] + pub description: Option, + /// Names and content for the files that make up the gist + #[serde(skip_serializing_if="Option::is_none")] + pub files: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub public: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchTeamsCreateOrUpdateIdpGroupConnectionsLegacy { /// The IdP groups you want to connect to a GitHub team. When updating, the new `groups` object will replace the original one. You must include any existing groups that you don't want to remove. @@ -2138,6 +2300,45 @@ pub struct PatchUsersUpdateAuthenticated { pub bio: Option, } +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PostCodespacesCreateForAuthenticatedUser { + PostCodespacesCreateForAuthenticatedUserVariant0(HashMap), +} + +impl From> for PostCodespacesCreateForAuthenticatedUser { + fn from(value: HashMap) -> Self { + PostCodespacesCreateForAuthenticatedUser::PostCodespacesCreateForAuthenticatedUserVariant0(value) + } +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutCodespacesCreateOrUpdateSecretForAuthenticatedUser { + /// Value for your secret, encrypted with [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages) using the public key retrieved from the [Get the public key for the authenticated user](https://docs.github.com/rest/reference/codespaces#get-the-public-key-for-the-authenticated-user) endpoint. + #[serde(skip_serializing_if="Option::is_none")] + pub encrypted_value: Option, + /// ID of the key you used to encrypt the secret. + #[serde(skip_serializing_if="Option::is_none")] + pub key_id: Option, + /// An array of repository ids that can access the user secret. You can manage the list of selected repositories using the [List selected repositories for a user secret](https://docs.github.com/rest/reference/codespaces#list-selected-repositories-for-a-user-secret), [Set selected repositories for a user secret](https://docs.github.com/rest/reference/codespaces#set-selected-repositories-for-a-user-secret), and [Remove a selected repository from a user secret](https://docs.github.com/rest/reference/codespaces#remove-a-selected-repository-from-a-user-secret) endpoints. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_repository_ids: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutCodespacesSetRepositoriesForSecretForAuthenticatedUser { + /// An array of repository ids for which a codespace can access the secret. You can manage the list of selected repositories using the [List selected repositories for a user secret](https://docs.github.com/rest/reference/codespaces#list-selected-repositories-for-a-user-secret), [Add a selected repository to a user secret](https://docs.github.com/rest/reference/codespaces#add-a-selected-repository-to-a-user-secret), and [Remove a selected repository from a user secret](https://docs.github.com/rest/reference/codespaces#remove-a-selected-repository-from-a-user-secret) endpoints. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_repository_ids: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PatchCodespacesUpdateForAuthenticatedUser { + /// A valid machine to transition this codespace to. + #[serde(skip_serializing_if="Option::is_none")] + pub machine: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchUsersSetPrimaryEmailVisibilityForAuthenticatedUser { /// Denotes whether an email is publicly visible. @@ -2204,6 +2405,33 @@ pub struct PostUsersCreateGpgKeyForAuthenticatedUser { pub armored_public_key: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct DeleteAppsDeleteAuthorization { + /// The OAuth access token used to authenticate to the GitHub API. + #[serde(skip_serializing_if="Option::is_none")] + pub access_token: Option, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PatchGistsUpdate { + PatchGistsUpdateVariant0(Value), +} + +impl From for PatchGistsUpdate { + fn from(value: Value) -> Self { + PatchGistsUpdate::PatchGistsUpdateVariant0(value) + } +} + +impl Display for PatchGistsUpdate { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match self { + PatchGistsUpdate::PatchGistsUpdateVariant0(value) => write!(f, "{}", value), + } + } +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostUsersCreatePublicSshKeyForAuthenticatedUser { /// A descriptive name for the new key. @@ -2214,13 +2442,6 @@ pub struct PostUsersCreatePublicSshKeyForAuthenticatedUser { pub key: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostGistsCreateComment { - /// The comment text. - #[serde(skip_serializing_if="Option::is_none")] - pub body: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchOrgsUpdateMembershipForAuthenticatedUser { /// The state that the membership should be in. Only `\"active\"` will be accepted. @@ -2318,10 +2539,10 @@ pub struct PostReposCreateForAuthenticatedUser { } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct DeleteAppsDeleteAuthorization { - /// The OAuth access token used to authenticate to the GitHub API. +pub struct PostGistsCreateComment { + /// The comment text. #[serde(skip_serializing_if="Option::is_none")] - pub access_token: Option, + pub body: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -2336,10 +2557,10 @@ pub struct PostMarkdownRender { /// The Markdown text to render in HTML. #[serde(skip_serializing_if="Option::is_none")] pub text: Option, - /// The rendering mode. + /// The rendering mode. Can be either `markdown` or `gfm`. #[serde(skip_serializing_if="Option::is_none")] pub mode: Option, - /// The repository context to use when creating references in `gfm` mode. + /// The repository context to use when creating references in `gfm` mode. For example, setting `context` to `octo-org/octo-repo` will change the text `#42` into an HTML link to issue 42 in the `octo-org/octo-repo` repository. #[serde(skip_serializing_if="Option::is_none")] pub context: Option, } @@ -2417,6 +2638,9 @@ pub struct PatchOrgsUpdate { /// Toggles whether organization members can create private GitHub Pages sites. Can be one of: \\* `true` - all organization members can create private GitHub Pages sites. \\* `false` - no organization members can create private GitHub Pages sites. Existing published sites will not be impacted. #[serde(skip_serializing_if="Option::is_none")] pub members_can_create_private_pages: Option, + /// Toggles whether organization members can fork private organization repositories. Can be one of: \\* `true` - all organization members can fork private repositories within the organization. \\* `false` - no organization members can fork private repositories within the organization. + #[serde(skip_serializing_if="Option::is_none")] + pub members_can_fork_private_repositories: Option, #[serde(skip_serializing_if="Option::is_none")] pub blog: Option, } @@ -2450,6 +2674,16 @@ pub struct PostActionsCreateSelfHostedRunnerGroupForOrg { /// List of runner IDs to add to the runner group. #[serde(skip_serializing_if="Option::is_none")] pub runners: Option>, + /// Whether the runner group can be used by `public` repositories. + #[serde(skip_serializing_if="Option::is_none")] + pub allows_public_repositories: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostAppsCheckToken { + /// The access_token of the OAuth application. + #[serde(skip_serializing_if="Option::is_none")] + pub access_token: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -2460,6 +2694,9 @@ pub struct PatchActionsUpdateSelfHostedRunnerGroupForOrg { /// Visibility of a runner group. You can select all repositories, select individual repositories, or all private repositories. Can be one of: `all`, `selected`, or `private`. #[serde(skip_serializing_if="Option::is_none")] pub visibility: Option, + /// Whether the runner group can be used by `public` repositories. + #[serde(skip_serializing_if="Option::is_none")] + pub allows_public_repositories: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -2470,17 +2707,24 @@ pub struct PutActionsSetRepoAccessToSelfHostedRunnerGroupInOrg { } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostAppsCheckToken { - /// The access_token of the OAuth application. +pub struct PutActionsSetSelfHostedRunnersInGroupForOrg { + /// List of runner IDs to add to the runner group. #[serde(skip_serializing_if="Option::is_none")] - pub access_token: Option, + pub runners: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutActionsSetSelfHostedRunnersInGroupForOrg { - /// List of runner IDs to add to the runner group. +pub struct PutActionsSetCustomLabelsForSelfHostedRunnerForOrg { + /// The names of the custom labels to set for the runner. You can pass an empty array to remove all custom labels. #[serde(skip_serializing_if="Option::is_none")] - pub runners: Option>, + pub labels: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostActionsAddCustomLabelsToSelfHostedRunnerForOrg { + /// The names of the custom labels to add to the runner. + #[serde(skip_serializing_if="Option::is_none")] + pub labels: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -2547,6 +2791,13 @@ pub struct PatchOrgsUpdateWebhookConfigForOrg { pub insecure_ssl: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct DeleteAppsDeleteToken { + /// The OAuth access token used to authenticate to the GitHub API. + #[serde(skip_serializing_if="Option::is_none")] + pub access_token: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostOrgsCreateInvitation { /// **Required unless you provide `email`**. GitHub user ID for the person you are inviting. @@ -2601,13 +2852,6 @@ pub struct PostProjectsCreateForOrg { pub body: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct DeleteAppsDeleteToken { - /// The OAuth access token used to authenticate to the GitHub API. - #[serde(skip_serializing_if="Option::is_none")] - pub access_token: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostReposCreateInOrg { /// The name of the repository. @@ -2740,6 +2984,13 @@ pub struct PostTeamsCreateDiscussionCommentInOrg { pub body: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PatchAppsResetToken { + /// The access_token of the OAuth application. + #[serde(skip_serializing_if="Option::is_none")] + pub access_token: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchTeamsUpdateDiscussionCommentInOrg { /// The discussion comment's body text. @@ -2768,13 +3019,6 @@ pub struct PatchTeamsLinkExternalIdpGroupToTeamForOrg { pub group_id: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PatchAppsResetToken { - /// The access_token of the OAuth application. - #[serde(skip_serializing_if="Option::is_none")] - pub access_token: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutTeamsAddOrUpdateMembershipForUserInOrg { /// The role that this user should have in the team. Can be one of: \\* `member` - a normal member of the team. \\* `maintainer` - a team maintainer. Able to add/remove other team members, promote other team members to team maintainer, and edit the team's name and description. @@ -2791,7 +3035,7 @@ pub struct PutTeamsAddOrUpdateProjectPermissionsInOrg { #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutTeamsAddOrUpdateRepoPermissionsInOrg { - /// The permission to grant the team on this repository. Can be one of: \\* `pull` - team members can pull, but not push to or administer this repository. \\* `push` - team members can pull and push, but not administer this repository. \\* `admin` - team members can pull, push and administer this repository. \\* `maintain` - team members can manage the repository without access to sensitive or destructive actions. Recommended for project managers. Only applies to repositories owned by organizations. \\* `triage` - team members can proactively manage issues and pull requests without write access. Recommended for contributors who triage a repository. Only applies to repositories owned by organizations. If no permission is specified, the team's `permission` attribute will be used to determine what permission to grant the team on this repository. + /// The permission to grant the team on this repository. Can be one of: \\* `pull` - team members can pull, but not push to or administer this repository. \\* `push` - team members can pull and push, but not administer this repository. \\* `admin` - team members can pull, push and administer this repository. \\* `maintain` - team members can manage the repository without access to sensitive or destructive actions. Recommended for project managers. Only applies to repositories owned by organizations. \\* `triage` - team members can proactively manage issues and pull requests without write access. Recommended for contributors who triage a repository. Only applies to repositories owned by organizations. \\* custom repository role name - A custom repository role if the owning organization has defined any. If no permission is specified, the team's `permission` attribute will be used to determine what permission to grant the team on this repository. #[serde(skip_serializing_if="Option::is_none")] pub permission: Option, } @@ -2823,6 +3067,27 @@ pub struct PostProjectsMoveCard { pub column_id: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostAppsScopeToken { + /// The OAuth access token used to authenticate to the GitHub API. + #[serde(skip_serializing_if="Option::is_none")] + pub access_token: Option, + /// The name of the user or organization to scope the user-to-server access token to. **Required** unless `target_id` is specified. + #[serde(skip_serializing_if="Option::is_none")] + pub target: Option, + /// The ID of the user or organization to scope the user-to-server access token to. **Required** unless `target` is specified. + #[serde(skip_serializing_if="Option::is_none")] + pub target_id: Option, + /// The list of repository names to scope the user-to-server access token to. `repositories` may not be specified if `repository_ids` is specified. + #[serde(skip_serializing_if="Option::is_none")] + pub repositories: Option>, + /// The list of repository IDs to scope the user-to-server access token to. `repository_ids` may not be specified if `repositories` is specified. + #[serde(skip_serializing_if="Option::is_none")] + pub repository_ids: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub permissions: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchProjectsUpdateColumn { /// Name of the project column @@ -2868,27 +3133,6 @@ pub struct PatchProjectsUpdate { pub private: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostAppsScopeToken { - /// The OAuth access token used to authenticate to the GitHub API. - #[serde(skip_serializing_if="Option::is_none")] - pub access_token: Option, - /// The name of the user or organization to scope the user-to-server access token to. **Required** unless `target_id` is specified. - #[serde(skip_serializing_if="Option::is_none")] - pub target: Option, - /// The ID of the user or organization to scope the user-to-server access token to. **Required** unless `target` is specified. - #[serde(skip_serializing_if="Option::is_none")] - pub target_id: Option, - /// The list of repository names to scope the user-to-server access token to. `repositories` may not be specified if `repository_ids` is specified. - #[serde(skip_serializing_if="Option::is_none")] - pub repositories: Option>, - /// The list of repository IDs to scope the user-to-server access token to. `repository_ids` may not be specified if `repositories` is specified. - #[serde(skip_serializing_if="Option::is_none")] - pub repository_ids: Option>, - #[serde(skip_serializing_if="Option::is_none")] - pub permissions: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutProjectsAddCollaborator { /// The permission to grant the collaborator. @@ -2968,6 +3212,42 @@ pub struct PutActionsSetGithubActionsPermissionsRepository { pub allowed_actions: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutActionsSetCustomLabelsForSelfHostedRunnerForRepo { + /// The names of the custom labels to set for the runner. You can pass an empty array to remove all custom labels. + #[serde(skip_serializing_if="Option::is_none")] + pub labels: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostActionsAddCustomLabelsToSelfHostedRunnerForRepo { + /// The names of the custom labels to add to the runner. + #[serde(skip_serializing_if="Option::is_none")] + pub labels: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostOauthAuthorizationsCreateAuthorization { + /// A list of scopes that this authorization is in. + #[serde(skip_serializing_if="Option::is_none")] + pub scopes: Option>, + /// A note to remind you what the OAuth token is for. + #[serde(skip_serializing_if="Option::is_none")] + pub note: Option, + /// A URL to remind you what app the OAuth token is for. + #[serde(skip_serializing_if="Option::is_none")] + pub note_url: Option, + /// The OAuth app client key for which to create the token. + #[serde(skip_serializing_if="Option::is_none")] + pub client_id: Option, + /// The OAuth app client secret for which to create the token. + #[serde(skip_serializing_if="Option::is_none")] + pub client_secret: Option, + /// A unique string to distinguish an authorization from others created for the same client ID and user. + #[serde(skip_serializing_if="Option::is_none")] + pub fingerprint: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostActionsReviewPendingDeploymentsForRun { /// The list of environment ids to approve or reject @@ -3047,31 +3327,11 @@ pub struct PatchReposUpdatePullRequestReviewProtection { /// Blocks merging pull requests until [code owners](https://help.github.com/articles/about-code-owners/) have reviewed. #[serde(skip_serializing_if="Option::is_none")] pub require_code_owner_reviews: Option, - /// Specifies the number of reviewers required to approve pull requests. Use a number between 1 and 6. + /// Specifies the number of reviewers required to approve pull requests. Use a number between 1 and 6 or 0 to not require reviewers. #[serde(skip_serializing_if="Option::is_none")] pub required_approving_review_count: Option, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostOauthAuthorizationsCreateAuthorization { - /// A list of scopes that this authorization is in. #[serde(skip_serializing_if="Option::is_none")] - pub scopes: Option>, - /// A note to remind you what the OAuth token is for. - #[serde(skip_serializing_if="Option::is_none")] - pub note: Option, - /// A URL to remind you what app the OAuth token is for. - #[serde(skip_serializing_if="Option::is_none")] - pub note_url: Option, - /// The OAuth app client key for which to create the token. - #[serde(skip_serializing_if="Option::is_none")] - pub client_id: Option, - /// The OAuth app client secret for which to create the token. - #[serde(skip_serializing_if="Option::is_none")] - pub client_secret: Option, - /// A unique string to distinguish an authorization from others created for the same client ID and user. - #[serde(skip_serializing_if="Option::is_none")] - pub fingerprint: Option, + pub bypass_pull_request_allowances: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -3079,9 +3339,12 @@ pub struct PatchReposUpdateStatusCheckProtection { /// Require branches to be up to date before merging. #[serde(skip_serializing_if="Option::is_none")] pub strict: Option, - /// The list of status checks to require in order to merge into this branch + /// **Deprecated**: The list of status checks to require in order to merge into this branch. If any of these checks have recently been set by a particular GitHub App, they will be required to come from that app in future for the branch to merge. Use `checks` instead of `contexts` for more fine-grained control. #[serde(skip_serializing_if="Option::is_none")] pub contexts: Option>, + /// The list of status checks to require in order to merge into this branch. + #[serde(skip_serializing_if="Option::is_none")] + pub checks: Option>, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] @@ -3141,6 +3404,25 @@ impl From> for DeleteReposRemoveStatusCheckContexts { } } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutOauthAuthorizationsGetOrCreateAuthorizationForApp { + /// The OAuth app client secret for which to create the token. + #[serde(skip_serializing_if="Option::is_none")] + pub client_secret: Option, + /// A list of scopes that this authorization is in. + #[serde(skip_serializing_if="Option::is_none")] + pub scopes: Option>, + /// A note to remind you what the OAuth token is for. + #[serde(skip_serializing_if="Option::is_none")] + pub note: Option, + /// A URL to remind you what app the OAuth token is for. + #[serde(skip_serializing_if="Option::is_none")] + pub note_url: Option, + /// A unique string to distinguish an authorization from others created for the same client ID and user. + #[serde(skip_serializing_if="Option::is_none")] + pub fingerprint: Option, +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum PutReposSetAppAccessRestrictions { @@ -3255,25 +3537,6 @@ impl From> for DeleteReposRemoveTeamAccessRestrictions { } } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutOauthAuthorizationsGetOrCreateAuthorizationForApp { - /// The OAuth app client secret for which to create the token. - #[serde(skip_serializing_if="Option::is_none")] - pub client_secret: Option, - /// A list of scopes that this authorization is in. - #[serde(skip_serializing_if="Option::is_none")] - pub scopes: Option>, - /// A note to remind you what the OAuth token is for. - #[serde(skip_serializing_if="Option::is_none")] - pub note: Option, - /// A URL to remind you what app the OAuth token is for. - #[serde(skip_serializing_if="Option::is_none")] - pub note_url: Option, - /// A unique string to distinguish an authorization from others created for the same client ID and user. - #[serde(skip_serializing_if="Option::is_none")] - pub fingerprint: Option, -} - #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum PutReposSetUserAccessRestrictions { @@ -3338,6 +3601,22 @@ pub struct PostReposRenameBranch { pub new_name: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutOauthAuthorizationsGetOrCreateAuthorizationForAppAndFingerprint { + /// The OAuth app client secret for which to create the token. + #[serde(skip_serializing_if="Option::is_none")] + pub client_secret: Option, + /// A list of scopes that this authorization is in. + #[serde(skip_serializing_if="Option::is_none")] + pub scopes: Option>, + /// A note to remind you what the OAuth token is for. + #[serde(skip_serializing_if="Option::is_none")] + pub note: Option, + /// A URL to remind you what app the OAuth token is for. + #[serde(skip_serializing_if="Option::is_none")] + pub note_url: Option, +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum PostChecksCreate { @@ -3405,24 +3684,28 @@ pub struct PostCodeScanningUploadSarif { } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutOauthAuthorizationsGetOrCreateAuthorizationForAppAndFingerprint { - /// The OAuth app client secret for which to create the token. +pub struct PostCodespacesCreateWithRepoForAuthenticatedUser { + /// Git ref (typically a branch name) for this codespace + #[serde(rename = "ref")] #[serde(skip_serializing_if="Option::is_none")] - pub client_secret: Option, - /// A list of scopes that this authorization is in. + pub git_ref: Option, + /// Location for this codespace #[serde(skip_serializing_if="Option::is_none")] - pub scopes: Option>, - /// A note to remind you what the OAuth token is for. + pub location: Option, + /// Machine type to use for this codespace #[serde(skip_serializing_if="Option::is_none")] - pub note: Option, - /// A URL to remind you what app the OAuth token is for. + pub machine: Option, + /// Working directory for this codespace #[serde(skip_serializing_if="Option::is_none")] - pub note_url: Option, + pub working_directory: Option, + /// Time in minutes before codespace stops from inactivity + #[serde(skip_serializing_if="Option::is_none")] + pub idle_timeout_minutes: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutReposAddCollaborator { - /// The permission to grant the collaborator. **Only valid on organization-owned repositories.** Can be one of: \\* `pull` - can pull, but not push to or administer this repository. \\* `push` - can pull and push, but not administer this repository. \\* `admin` - can pull, push and administer this repository. \\* `maintain` - Recommended for project managers who need to manage the repository without access to sensitive or destructive actions. \\* `triage` - Recommended for contributors who need to proactively manage issues and pull requests without write access. + /// The permission to grant the collaborator. **Only valid on organization-owned repositories.** Can be one of: \\* `pull` - can pull, but not push to or administer this repository. \\* `push` - can pull and push, but not administer this repository. \\* `admin` - can pull, push and administer this repository. \\* `maintain` - Recommended for project managers who need to manage the repository without access to sensitive or destructive actions. \\* `triage` - Recommended for contributors who need to proactively manage issues and pull requests without write access. \\* custom repository role name - A custom repository role, if the owning organization has defined any. #[serde(skip_serializing_if="Option::is_none")] pub permission: Option, #[serde(skip_serializing_if="Option::is_none")] @@ -3443,135 +3726,6 @@ pub struct PostReactionsCreateForCommitComment { pub content: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostReposCreateCommitComment { - /// The contents of the comment. - #[serde(skip_serializing_if="Option::is_none")] - pub body: Option, - /// Relative path of the file to comment on. - #[serde(skip_serializing_if="Option::is_none")] - pub path: Option, - /// Line index in the diff to comment on. - #[serde(skip_serializing_if="Option::is_none")] - pub position: Option, - /// **Deprecated**. Use **position** parameter instead. Line number in the file to comment on. - #[serde(skip_serializing_if="Option::is_none")] - pub line: Option, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostAppsCreateContentAttachment { - /// The title of the attachment - #[serde(skip_serializing_if="Option::is_none")] - pub title: Option, - /// The body of the attachment - #[serde(skip_serializing_if="Option::is_none")] - pub body: Option, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutReposCreateOrUpdateFileContents { - /// The commit message. - #[serde(skip_serializing_if="Option::is_none")] - pub message: Option, - /// The new file content, using Base64 encoding. - #[serde(skip_serializing_if="Option::is_none")] - pub content: Option, - /// **Required if you are updating a file**. The blob SHA of the file being replaced. - #[serde(skip_serializing_if="Option::is_none")] - pub sha: Option, - /// The branch name. Default: the repository’s default branch (usually `master`) - #[serde(skip_serializing_if="Option::is_none")] - pub branch: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub committer: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub author: Option, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct DeleteReposDeleteFile { - /// The commit message. - #[serde(skip_serializing_if="Option::is_none")] - pub message: Option, - /// The blob SHA of the file being replaced. - #[serde(skip_serializing_if="Option::is_none")] - pub sha: Option, - /// The branch name. Default: the repository’s default branch (usually `master`) - #[serde(skip_serializing_if="Option::is_none")] - pub branch: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub committer: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub author: Option, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostReposCreateDeployment { - /// The ref to deploy. This can be a branch, tag, or SHA. - #[serde(rename = "ref")] - #[serde(skip_serializing_if="Option::is_none")] - pub git_ref: Option, - /// Specifies a task to execute (e.g., `deploy` or `deploy:migrations`). - #[serde(skip_serializing_if="Option::is_none")] - pub task: Option, - /// Attempts to automatically merge the default branch into the requested ref, if it's behind the default branch. - #[serde(skip_serializing_if="Option::is_none")] - pub auto_merge: Option, - /// The [status](https://docs.github.com/rest/reference/repos#statuses) contexts to verify against commit status checks. If you omit this parameter, GitHub verifies all unique contexts before creating a deployment. To bypass checking entirely, pass an empty array. Defaults to all unique contexts. - #[serde(skip_serializing_if="Option::is_none")] - pub required_contexts: Option>, - #[serde(skip_serializing_if="Option::is_none")] - pub payload: Option, - /// Name for the target deployment environment (e.g., `production`, `staging`, `qa`). - #[serde(skip_serializing_if="Option::is_none")] - pub environment: Option, - /// Short description of the deployment. - #[serde(skip_serializing_if="Option::is_none")] - pub description: Option, - /// Specifies if the given environment is specific to the deployment and will no longer exist at some point in the future. Default: `false` - #[serde(skip_serializing_if="Option::is_none")] - pub transient_environment: Option, - /// Specifies if the given environment is one that end-users directly interact with. Default: `true` when `environment` is `production` and `false` otherwise. - #[serde(skip_serializing_if="Option::is_none")] - pub production_environment: Option, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostReposCreateDeploymentStatus { - /// The state of the status. Can be one of `error`, `failure`, `inactive`, `in_progress`, `queued` `pending`, or `success`. When you set a transient deployment to `inactive`, the deployment will be shown as `destroyed` in GitHub. - #[serde(skip_serializing_if="Option::is_none")] - pub state: Option, - /// The target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. **Note:** It's recommended to use the `log_url` parameter, which replaces `target_url`. - #[serde(skip_serializing_if="Option::is_none")] - pub target_url: Option, - /// The full URL of the deployment's output. This parameter replaces `target_url`. We will continue to accept `target_url` to support legacy uses, but we recommend replacing `target_url` with `log_url`. Setting `log_url` will automatically set `target_url` to the same value. Default: `\"\"` - #[serde(skip_serializing_if="Option::is_none")] - pub log_url: Option, - /// A short description of the status. The maximum description length is 140 characters. - #[serde(skip_serializing_if="Option::is_none")] - pub description: Option, - /// Name for the target deployment environment, which can be changed when setting a deploy status. For example, `production`, `staging`, or `qa`. - #[serde(skip_serializing_if="Option::is_none")] - pub environment: Option, - /// Sets the URL for accessing your environment. Default: `\"\"` - #[serde(skip_serializing_if="Option::is_none")] - pub environment_url: Option, - /// Adds a new `inactive` status to all prior non-transient, non-production environment deployments with the same repository and `environment` name as the created status's deployment. An `inactive` status is only added to deployments that had a `success` state. Default: `true` - #[serde(skip_serializing_if="Option::is_none")] - pub auto_inactive: Option, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostReposCreateDispatchEvent { - /// A custom webhook event name. - #[serde(skip_serializing_if="Option::is_none")] - pub event_type: Option, - /// JSON payload with extra information about the webhook event that your action or worklow may use. - #[serde(skip_serializing_if="Option::is_none")] - pub client_payload: Option>>, -} - /// Branch Protection #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct BranchProtection { @@ -3580,7 +3734,7 @@ pub struct BranchProtection { #[serde(skip_serializing_if="Option::is_none")] pub enabled: Option, #[serde(skip_serializing_if="Option::is_none")] - pub required_status_checks: Option, + pub required_status_checks: Option, #[serde(skip_serializing_if="Option::is_none")] pub enforce_admins: Option, #[serde(skip_serializing_if="Option::is_none")] @@ -3668,20 +3822,6 @@ pub struct BranchprotectionRequiredSignatures { pub enabled: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct BranchprotectionRequiredStatusChecks { - #[serde(skip_serializing_if="Option::is_none")] - pub url: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub enforcement_level: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub contexts: Option>, - #[serde(skip_serializing_if="Option::is_none")] - pub contexts_url: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub strict: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct BranchrestrictionpolicyApps { #[serde(skip_serializing_if="Option::is_none")] @@ -3924,6 +4064,10 @@ pub struct CheckSuite { pub latest_check_runs_count: Option, #[serde(skip_serializing_if="Option::is_none")] pub check_runs_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub rerequestable: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub runs_rerequestable: Option, } /// Check suite configuration preferences for a repository. @@ -4018,6 +4162,8 @@ pub struct CodeScanningAlert { #[serde(skip_serializing_if="Option::is_none")] pub created_at: Option, #[serde(skip_serializing_if="Option::is_none")] + pub updated_at: Option, + #[serde(skip_serializing_if="Option::is_none")] pub url: Option, #[serde(skip_serializing_if="Option::is_none")] pub html_url: Option, @@ -4026,6 +4172,8 @@ pub struct CodeScanningAlert { #[serde(skip_serializing_if="Option::is_none")] pub state: Option, #[serde(skip_serializing_if="Option::is_none")] + pub fixed_at: Option, + #[serde(skip_serializing_if="Option::is_none")] pub dismissed_by: Option, #[serde(skip_serializing_if="Option::is_none")] pub dismissed_at: Option, @@ -4131,6 +4279,9 @@ impl std::str::FromStr for CodeScanningAlertDismissedReason { pub struct CodeScanningAlertEnvironment { } +/// The time that the alert was no longer detected and was considered fixed in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ`. +pub type CodeScanningAlertFixedAt = DateTime; + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct CodeScanningAlertInstance { #[serde(rename = "ref")] @@ -4164,6 +4315,8 @@ pub struct CodeScanningAlertItems { #[serde(skip_serializing_if="Option::is_none")] pub created_at: Option, #[serde(skip_serializing_if="Option::is_none")] + pub updated_at: Option, + #[serde(skip_serializing_if="Option::is_none")] pub url: Option, #[serde(skip_serializing_if="Option::is_none")] pub html_url: Option, @@ -4172,6 +4325,8 @@ pub struct CodeScanningAlertItems { #[serde(skip_serializing_if="Option::is_none")] pub state: Option, #[serde(skip_serializing_if="Option::is_none")] + pub fixed_at: Option, + #[serde(skip_serializing_if="Option::is_none")] pub dismissed_by: Option, #[serde(skip_serializing_if="Option::is_none")] pub dismissed_at: Option, @@ -4236,6 +4391,9 @@ pub struct CodeScanningAlertRuleSummary { /// The name of the rule used to detect the alert. #[serde(skip_serializing_if="Option::is_none")] pub name: Option, + /// A set of tags applicable for the rule. + #[serde(skip_serializing_if="Option::is_none")] + pub tags: Option>, /// The severity of the alert. #[serde(skip_serializing_if="Option::is_none")] pub severity: Option, @@ -4441,57 +4599,206 @@ pub struct CodeScanningRef { #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct CodeScanningSarifsReceipt { #[serde(skip_serializing_if="Option::is_none")] - pub id: Option, - /// The REST API URL for checking the status of the upload. + pub id: Option, + /// The REST API URL for checking the status of the upload. + #[serde(skip_serializing_if="Option::is_none")] + pub url: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct CodeScanningSarifsStatus { + /// `pending` files have not yet been processed, while `complete` means results from the SARIF have been stored. `failed` files have either not been processed at all, or could only be partially processed. + #[serde(skip_serializing_if="Option::is_none")] + pub processing_status: Option, + /// The REST API URL for getting the analyses associated with the upload. + #[serde(skip_serializing_if="Option::is_none")] + pub analyses_url: Option, + /// Any errors that ocurred during processing of the delivery. + #[serde(skip_serializing_if="Option::is_none")] + pub errors: Option>, +} + +/// Code Search Result Item +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct CodeSearchResultItem { + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub path: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub sha: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub git_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub html_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub repository: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub score: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub file_size: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub language: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub last_modified_at: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub line_numbers: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub text_matches: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct CodescanningalertinstanceMessage { + #[serde(skip_serializing_if="Option::is_none")] + pub text: Option, +} + +/// A codespace. +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct Codespace { + #[serde(skip_serializing_if="Option::is_none")] + pub id: Option, + /// Automatically generated name of this codespace. + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + /// UUID identifying this codespace's environment. + #[serde(skip_serializing_if="Option::is_none")] + pub environment_id: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub owner: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub billable_owner: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub repository: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub machine: Option, + /// Whether the codespace was created from a prebuild. + #[serde(skip_serializing_if="Option::is_none")] + pub prebuild: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub created_at: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub updated_at: Option>, + /// Last known time this codespace was started. + #[serde(skip_serializing_if="Option::is_none")] + pub last_used_at: Option>, + /// State of this codespace. + #[serde(skip_serializing_if="Option::is_none")] + pub state: Option, + /// API URL for this codespace. #[serde(skip_serializing_if="Option::is_none")] pub url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub git_status: Option, + /// The Azure region where this codespace is located. + #[serde(skip_serializing_if="Option::is_none")] + pub location: Option, + /// The number of minutes of inactivity after which this codespace will be automatically stopped. + #[serde(skip_serializing_if="Option::is_none")] + pub idle_timeout_minutes: Option, + /// URL to access this codespace on the web. + #[serde(skip_serializing_if="Option::is_none")] + pub web_url: Option, + /// API URL to access available alternate machine types for this codespace. + #[serde(skip_serializing_if="Option::is_none")] + pub machines_url: Option, + /// API URL to start this codespace. + #[serde(skip_serializing_if="Option::is_none")] + pub start_url: Option, + /// API URL to stop this codespace. + #[serde(skip_serializing_if="Option::is_none")] + pub stop_url: Option, + /// API URL for the Pull Request associated with this codespace, if any. + #[serde(skip_serializing_if="Option::is_none")] + pub pulls_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub recent_folders: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub runtime_constraints: Option, } +/// Details about the codespace's git repository. #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct CodeScanningSarifsStatus { - /// `pending` files have not yet been processed, while `complete` means all results in the SARIF have been stored. +pub struct CodespaceGitStatus { + /// The number of commits the local repository is ahead of the remote. #[serde(skip_serializing_if="Option::is_none")] - pub processing_status: Option, - /// The REST API URL for getting the analyses associated with the upload. + pub ahead: Option, + /// The number of commits the local repository is behind the remote. #[serde(skip_serializing_if="Option::is_none")] - pub analyses_url: Option, + pub behind: Option, + /// Whether the local repository has unpushed changes. + #[serde(skip_serializing_if="Option::is_none")] + pub has_unpushed_changes: Option, + /// Whether the local repository has uncommitted changes. + #[serde(skip_serializing_if="Option::is_none")] + pub has_uncommitted_changes: Option, + /// The current branch (or SHA if in detached HEAD state) of the local repository. + #[serde(rename = "ref")] + #[serde(skip_serializing_if="Option::is_none")] + pub git_ref: Option, } -/// Code Search Result Item +/// A description of the machine powering a codespace. #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct CodeSearchResultItem { +pub struct CodespaceMachine { + /// The name of the machine. #[serde(skip_serializing_if="Option::is_none")] pub name: Option, + /// The display name of the machine includes cores, memory, and storage. #[serde(skip_serializing_if="Option::is_none")] - pub path: Option, + pub display_name: Option, + /// The operating system of the machine. #[serde(skip_serializing_if="Option::is_none")] - pub sha: Option, + pub operating_system: Option, + /// How much storage is available to the codespace. #[serde(skip_serializing_if="Option::is_none")] - pub url: Option, + pub storage_in_bytes: Option, + /// How much memory is available to the codespace. #[serde(skip_serializing_if="Option::is_none")] - pub git_url: Option, + pub memory_in_bytes: Option, + /// How many cores are available to the codespace. #[serde(skip_serializing_if="Option::is_none")] - pub html_url: Option, + pub cpus: Option, + /// Whether a prebuild is currently available when creating a codespace for this machine and repository. If a branch was not specified as a ref, the default branch will be assumed. Value will be \"null\" if prebuilds are not supported or prebuild availability could not be determined. Value is the type of prebuild available, or \"none\" if none are available. #[serde(skip_serializing_if="Option::is_none")] - pub repository: Option, + pub prebuild_availability: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct CodespaceRuntimeConstraints { + /// The privacy settings a user can select from when forwarding a port. #[serde(skip_serializing_if="Option::is_none")] - pub score: Option, + pub allowed_port_privacy_settings: Option>, +} + +/// Secrets for a GitHub Codespace. +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct CodespacesSecret { + /// The name of the secret. #[serde(skip_serializing_if="Option::is_none")] - pub file_size: Option, + pub name: Option, #[serde(skip_serializing_if="Option::is_none")] - pub language: Option, + pub created_at: Option>, #[serde(skip_serializing_if="Option::is_none")] - pub last_modified_at: Option>, + pub updated_at: Option>, + /// Visibility of a secret #[serde(skip_serializing_if="Option::is_none")] - pub line_numbers: Option>, + pub visibility: Option, #[serde(skip_serializing_if="Option::is_none")] - pub text_matches: Option, + pub selected_repositories_url: Option, } +/// The public key used for setting user Codespaces' Secrets. #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct CodescanningalertinstanceMessage { +pub struct CodespacesUserPublicKey { + /// The identifier for the key. #[serde(skip_serializing_if="Option::is_none")] - pub text: Option, + pub key_id: Option, + /// The Base64 encoded public key. + #[serde(skip_serializing_if="Option::is_none")] + pub key: Option, } /// Collaborator @@ -4540,6 +4847,8 @@ pub struct Collaborator { pub site_admin: Option, #[serde(skip_serializing_if="Option::is_none")] pub permissions: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub role_name: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -4612,7 +4921,7 @@ pub struct Commit { #[serde(skip_serializing_if="Option::is_none")] pub stats: Option, #[serde(skip_serializing_if="Option::is_none")] - pub files: Option>, + pub files: Option>, } /// Commit Activity @@ -4716,32 +5025,6 @@ pub struct CommitComparison { pub files: Option>, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct CommitFiles { - #[serde(skip_serializing_if="Option::is_none")] - pub filename: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub additions: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub deletions: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub changes: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub status: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub raw_url: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub blob_url: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub patch: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub sha: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub contents_url: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub previous_filename: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct CommitParents { #[serde(skip_serializing_if="Option::is_none")] @@ -4857,7 +5140,7 @@ pub struct CommunityprofileFiles { #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct ContainerMetadata { #[serde(skip_serializing_if="Option::is_none")] - pub tags: Option>, + pub tags: Option>, } /// A list of directory items @@ -4897,23 +5180,6 @@ pub struct ContentFile { pub submodule_git_url: Option, } -/// Content Reference attachments allow you to provide context around URLs posted in comments -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct ContentReferenceAttachment { - /// The ID of the attachment - #[serde(skip_serializing_if="Option::is_none")] - pub id: Option, - /// The title of the attachment - #[serde(skip_serializing_if="Option::is_none")] - pub title: Option, - /// The body of the attachment - #[serde(skip_serializing_if="Option::is_none")] - pub body: Option, - /// The node_id of the content attachment - #[serde(skip_serializing_if="Option::is_none")] - pub node_id: Option, -} - /// An object describing a symlink #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct ContentSubmodule { @@ -5458,7 +5724,7 @@ pub struct DiffEntry { #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct DockerMetadata { #[serde(skip_serializing_if="Option::is_none")] - pub tag: Option>, + pub tag: Option>, } /// Email @@ -6965,6 +7231,22 @@ pub struct GetEnterpriseAdminListOrgAccessToSelfHostedRunnerGroupInEnterpriseRes pub organizations: Option>, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct GetActionsListRepoAccessToSelfHostedRunnerGroupInOrgResponse200 { + #[serde(skip_serializing_if="Option::is_none")] + pub total_count: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub repositories: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct GetActionsListSelfHostedRunnersForRepoResponse200 { + #[serde(skip_serializing_if="Option::is_none")] + pub total_count: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub runners: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct GetActionsListOrgSecretsResponse200 { #[serde(skip_serializing_if="Option::is_none")] @@ -6974,7 +7256,7 @@ pub struct GetActionsListOrgSecretsResponse200 { } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetActionsListSelectedReposForOrgSecretResponse200 { +pub struct GetCodespacesListRepositoriesForSecretForAuthenticatedUserResponse200 { #[serde(skip_serializing_if="Option::is_none")] pub total_count: Option, #[serde(skip_serializing_if="Option::is_none")] @@ -7040,6 +7322,14 @@ pub struct GetActionsListEnvironmentSecretsResponse200 { pub secrets: Option>, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct GetEnterpriseAdminListSelfHostedRunnerGroupsForEnterpriseResponse200 { + #[serde(skip_serializing_if="Option::is_none")] + pub total_count: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub runner_groups: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct GetActionsListRepoWorkflowsResponse200 { #[serde(skip_serializing_if="Option::is_none")] @@ -7057,11 +7347,19 @@ pub struct GetChecksListForRefResponse200 { } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetEnterpriseAdminListSelfHostedRunnerGroupsForEnterpriseResponse200 { +pub struct GetCodespacesListForAuthenticatedUserResponse200 { #[serde(skip_serializing_if="Option::is_none")] - pub total_count: Option, + pub total_count: Option, #[serde(skip_serializing_if="Option::is_none")] - pub runner_groups: Option>, + pub codespaces: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct GetCodespacesCodespaceMachinesForAuthenticatedUserResponse200 { + #[serde(skip_serializing_if="Option::is_none")] + pub total_count: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub machines: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -7074,34 +7372,34 @@ pub struct GetChecksListSuitesForRefResponse200 { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum InlineResponse20021 { - InlineResponse20021Variant0(ContentDirectory), - InlineResponse20021Variant1(ContentFile), - InlineResponse20021Variant2(ContentSymlink), - InlineResponse20021Variant3(ContentSubmodule), +pub enum InlineResponse20025 { + InlineResponse20025Variant0(ContentDirectory), + InlineResponse20025Variant1(ContentFile), + InlineResponse20025Variant2(ContentSymlink), + InlineResponse20025Variant3(ContentSubmodule), } -impl From for InlineResponse20021 { +impl From for InlineResponse20025 { fn from(value: ContentDirectory) -> Self { - InlineResponse20021::InlineResponse20021Variant0(value) + InlineResponse20025::InlineResponse20025Variant0(value) } } -impl From for InlineResponse20021 { +impl From for InlineResponse20025 { fn from(value: ContentFile) -> Self { - InlineResponse20021::InlineResponse20021Variant1(value) + InlineResponse20025::InlineResponse20025Variant1(value) } } -impl From for InlineResponse20021 { +impl From for InlineResponse20025 { fn from(value: ContentSymlink) -> Self { - InlineResponse20021::InlineResponse20021Variant2(value) + InlineResponse20025::InlineResponse20025Variant2(value) } } -impl From for InlineResponse20021 { +impl From for InlineResponse20025 { fn from(value: ContentSubmodule) -> Self { - InlineResponse20021::InlineResponse20021Variant3(value) + InlineResponse20025::InlineResponse20025Variant3(value) } } @@ -7153,6 +7451,14 @@ pub struct GetSearchCommitsResponse200 { pub items: Option>, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct GetActionsListSelfHostedRunnersInGroupForOrgResponse200 { + #[serde(skip_serializing_if="Option::is_none")] + pub total_count: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub runners: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct GetSearchIssuesAndPullRequestsResponse200 { #[serde(skip_serializing_if="Option::is_none")] @@ -7193,14 +7499,6 @@ pub struct GetSearchTopicsResponse200 { pub items: Option>, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetActionsListSelfHostedRunnersInGroupForOrgResponse200 { - #[serde(skip_serializing_if="Option::is_none")] - pub total_count: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub runners: Option>, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct GetSearchUsersResponse200 { #[serde(skip_serializing_if="Option::is_none")] @@ -7230,6 +7528,14 @@ impl From for GetUsersGetByUsernameResponse200 { } } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct GetCodespacesListSecretsForAuthenticatedUserResponse200 { + #[serde(skip_serializing_if="Option::is_none")] + pub total_count: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub secrets: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct GetAppsListInstallationReposForAuthenticatedUserResponse200 { #[serde(skip_serializing_if="Option::is_none")] @@ -7268,45 +7574,46 @@ pub struct GetEnterpriseAdminListSelfHostedRunnersForEnterpriseResponse200 { } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetAppsListReposAccessibleToInstallationResponse200 { +pub struct DeleteActionsRemoveCustomLabelFromSelfHostedRunnerForRepoResponse200 { #[serde(skip_serializing_if="Option::is_none")] pub total_count: Option, #[serde(skip_serializing_if="Option::is_none")] - pub repositories: Option>, - #[serde(skip_serializing_if="Option::is_none")] - pub repository_selection: Option, + pub labels: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetActionsListSelectedRepositoriesEnabledGithubActionsOrganizationResponse200 { +pub struct GetAppsListReposAccessibleToInstallationResponse200 { #[serde(skip_serializing_if="Option::is_none")] - pub total_count: Option, + pub total_count: Option, #[serde(skip_serializing_if="Option::is_none")] pub repositories: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub repository_selection: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetActionsListSelfHostedRunnerGroupsForOrgResponse200 { +pub struct GetOrgsListCustomRolesResponse200 { + /// The number of custom roles in this organization #[serde(skip_serializing_if="Option::is_none")] - pub total_count: Option, + pub total_count: Option, #[serde(skip_serializing_if="Option::is_none")] - pub runner_groups: Option>, + pub custom_roles: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetActionsListRepoAccessToSelfHostedRunnerGroupInOrgResponse200 { +pub struct GetActionsListSelectedRepositoriesEnabledGithubActionsOrganizationResponse200 { #[serde(skip_serializing_if="Option::is_none")] pub total_count: Option, #[serde(skip_serializing_if="Option::is_none")] - pub repositories: Option>, + pub repositories: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetActionsListSelfHostedRunnersForRepoResponse200 { +pub struct GetActionsListSelfHostedRunnerGroupsForOrgResponse200 { #[serde(skip_serializing_if="Option::is_none")] - pub total_count: Option, + pub total_count: Option, #[serde(skip_serializing_if="Option::is_none")] - pub runners: Option>, + pub runner_groups: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -7773,6 +8080,8 @@ pub struct Issue { #[serde(skip_serializing_if="Option::is_none")] pub updated_at: Option>, #[serde(skip_serializing_if="Option::is_none")] + pub draft: Option, + #[serde(skip_serializing_if="Option::is_none")] pub closed_by: Option, #[serde(skip_serializing_if="Option::is_none")] pub body_html: Option, @@ -7846,7 +8155,7 @@ pub struct IssueEvent { #[serde(skip_serializing_if="Option::is_none")] pub created_at: Option>, #[serde(skip_serializing_if="Option::is_none")] - pub issue: Option, + pub issue: Option, #[serde(skip_serializing_if="Option::is_none")] pub label: Option, #[serde(skip_serializing_if="Option::is_none")] @@ -8836,6 +9145,8 @@ pub struct MinimalRepository { #[serde(skip_serializing_if="Option::is_none")] pub permissions: Option, #[serde(skip_serializing_if="Option::is_none")] + pub role_name: Option, + #[serde(skip_serializing_if="Option::is_none")] pub template_repository: Option, #[serde(skip_serializing_if="Option::is_none")] pub temp_clone_token: Option, @@ -8902,13 +9213,89 @@ pub struct MovedColumnInProjectIssueEvent { #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct NullableCodeOfConductSimple { #[serde(skip_serializing_if="Option::is_none")] - pub url: Option, + pub url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub key: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub html_url: Option, +} + +/// A description of the machine powering a codespace. +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct NullableCodespaceMachine { + /// The name of the machine. + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + /// The display name of the machine includes cores, memory, and storage. + #[serde(skip_serializing_if="Option::is_none")] + pub display_name: Option, + /// The operating system of the machine. + #[serde(skip_serializing_if="Option::is_none")] + pub operating_system: Option, + /// How much storage is available to the codespace. + #[serde(skip_serializing_if="Option::is_none")] + pub storage_in_bytes: Option, + /// How much memory is available to the codespace. + #[serde(skip_serializing_if="Option::is_none")] + pub memory_in_bytes: Option, + /// How many cores are available to the codespace. + #[serde(skip_serializing_if="Option::is_none")] + pub cpus: Option, + /// Whether a prebuild is currently available when creating a codespace for this machine and repository. If a branch was not specified as a ref, the default branch will be assumed. Value will be \"null\" if prebuilds are not supported or prebuild availability could not be determined. Value is the type of prebuild available, or \"none\" if none are available. + #[serde(skip_serializing_if="Option::is_none")] + pub prebuild_availability: Option, +} + +/// Collaborator +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct NullableCollaborator { + #[serde(skip_serializing_if="Option::is_none")] + pub login: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub id: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub email: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub avatar_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub gravatar_id: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub html_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub followers_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub following_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub gists_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub starred_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub subscriptions_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub organizations_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub repos_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub events_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub received_events_url: Option, + #[serde(rename = "type")] + #[serde(skip_serializing_if="Option::is_none")] + pub _type: Option, #[serde(skip_serializing_if="Option::is_none")] - pub key: Option, + pub site_admin: Option, #[serde(skip_serializing_if="Option::is_none")] - pub name: Option, + pub permissions: Option, #[serde(skip_serializing_if="Option::is_none")] - pub html_url: Option, + pub role_name: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -8974,6 +9361,83 @@ pub struct NullableIntegration { pub pem: Option, } +/// Issues are a great way to keep track of tasks, enhancements, and bugs for your projects. +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct NullableIssue { + #[serde(skip_serializing_if="Option::is_none")] + pub id: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub node_id: Option, + /// URL for the issue + #[serde(skip_serializing_if="Option::is_none")] + pub url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub repository_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub labels_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub comments_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub events_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub html_url: Option, + /// Number uniquely identifying the issue within its repository + #[serde(skip_serializing_if="Option::is_none")] + pub number: Option, + /// State of the issue; either 'open' or 'closed' + #[serde(skip_serializing_if="Option::is_none")] + pub state: Option, + /// Title of the issue + #[serde(skip_serializing_if="Option::is_none")] + pub title: Option, + /// Contents of the issue + #[serde(skip_serializing_if="Option::is_none")] + pub body: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub user: Option, + /// Labels to associate with this issue; pass one or more label names to replace the set of labels on this issue; send an empty array to clear all labels from the issue; note that the labels are silently dropped for users without push access to the repository + #[serde(skip_serializing_if="Option::is_none")] + pub labels: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub assignee: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub assignees: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub milestone: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub locked: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub active_lock_reason: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub comments: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub pull_request: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub closed_at: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub created_at: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub updated_at: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub draft: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub closed_by: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub body_html: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub body_text: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub timeline_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub repository: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub performed_via_github_app: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub author_association: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub reactions: Option, +} + /// License Simple #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct NullableLicenseSimple { @@ -9181,6 +9645,8 @@ pub struct NullableMinimalRepository { #[serde(skip_serializing_if="Option::is_none")] pub permissions: Option, #[serde(skip_serializing_if="Option::is_none")] + pub role_name: Option, + #[serde(skip_serializing_if="Option::is_none")] pub template_repository: Option, #[serde(skip_serializing_if="Option::is_none")] pub temp_clone_token: Option, @@ -9535,6 +10001,25 @@ pub struct NullablesimplecommitAuthor { pub email: Option, } +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PostReposCreateDeploymentPayloadEnum { + PostReposCreateDeploymentPayloadEnumVariant0(HashMap>), + PostReposCreateDeploymentPayloadEnumVariant1(String), +} + +impl From>> for PostReposCreateDeploymentPayloadEnum { + fn from(value: HashMap>) -> Self { + PostReposCreateDeploymentPayloadEnum::PostReposCreateDeploymentPayloadEnumVariant0(value) + } +} + +impl From for PostReposCreateDeploymentPayloadEnum { + fn from(value: String) -> Self { + PostReposCreateDeploymentPayloadEnum::PostReposCreateDeploymentPayloadEnumVariant1(value) + } +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum PostIssuesCreateLabelsItemsEnum { @@ -9668,25 +10153,6 @@ impl From for PostGistsCreatePublicEnum { } } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PostReposCreateDeploymentPayloadEnum { - PostReposCreateDeploymentPayloadEnumVariant0(HashMap>), - PostReposCreateDeploymentPayloadEnumVariant1(String), -} - -impl From>> for PostReposCreateDeploymentPayloadEnum { - fn from(value: HashMap>) -> Self { - PostReposCreateDeploymentPayloadEnum::PostReposCreateDeploymentPayloadEnumVariant0(value) - } -} - -impl From for PostReposCreateDeploymentPayloadEnum { - fn from(value: String) -> Self { - PostReposCreateDeploymentPayloadEnum::PostReposCreateDeploymentPayloadEnumVariant1(value) - } -} - #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum DeploymentPayload { @@ -9727,53 +10193,46 @@ impl From> for IssueLabelsItems { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum ScimuserOperationsValue { - ScimuserOperationsValueVariant0(String), - ScimuserOperationsValueVariant1(HashMap), - ScimuserOperationsValueVariant2(Vec), +pub enum NullableIssueLabelsItems { + NullableIssueLabelsItemsVariant0(String), + NullableIssueLabelsItemsVariant1(HashMap), } -impl From for ScimuserOperationsValue { +impl From for NullableIssueLabelsItems { fn from(value: String) -> Self { - ScimuserOperationsValue::ScimuserOperationsValueVariant0(value) + NullableIssueLabelsItems::NullableIssueLabelsItemsVariant0(value) } } -impl From> for ScimuserOperationsValue { +impl From> for NullableIssueLabelsItems { fn from(value: HashMap) -> Self { - ScimuserOperationsValue::ScimuserOperationsValueVariant1(value) - } -} - -impl From> for ScimuserOperationsValue { - fn from(value: Vec) -> Self { - ScimuserOperationsValue::ScimuserOperationsValueVariant2(value) + NullableIssueLabelsItems::NullableIssueLabelsItemsVariant1(value) } } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValue { - Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValueVariant0(String), - Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValueVariant1(HashMap), - Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValueVariant2(Vec), +pub enum ScimuserOperationsValue { + ScimuserOperationsValueVariant0(String), + ScimuserOperationsValueVariant1(HashMap), + ScimuserOperationsValueVariant2(Vec), } -impl From for Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValue { +impl From for ScimuserOperationsValue { fn from(value: String) -> Self { - Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValue::Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValueVariant0(value) + ScimuserOperationsValue::ScimuserOperationsValueVariant0(value) } } -impl From> for Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValue { +impl From> for ScimuserOperationsValue { fn from(value: HashMap) -> Self { - Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValue::Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValueVariant1(value) + ScimuserOperationsValue::ScimuserOperationsValueVariant1(value) } } -impl From> for Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValue { +impl From> for ScimuserOperationsValue { fn from(value: Vec) -> Self { - Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValue::Scimv2enterprisesenterpriseGroupsscimGroupIdOperationsValueVariant2(value) + ScimuserOperationsValue::ScimuserOperationsValueVariant2(value) } } @@ -9803,6 +10262,18 @@ impl From for Scimv2organizationsorgUsersscimUserIdOperationsValue { } } +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SecretScanningLocationDetails { + SecretScanningLocationDetailsVariant0(SecretScanningLocationCommit), +} + +impl From for SecretScanningLocationDetails { + fn from(value: SecretScanningLocationCommit) -> Self { + SecretScanningLocationDetails::SecretScanningLocationDetailsVariant0(value) + } +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum ValidationerrorErrorsValue { @@ -9895,6 +10366,15 @@ pub struct OrganizationActionsSecret { pub selected_repositories_url: Option, } +/// Custom repository roles created by organization administrators +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct OrganizationCustomRepositoryRole { + #[serde(skip_serializing_if="Option::is_none")] + pub id: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, +} + /// Organization Full #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct OrganizationFull { @@ -9990,6 +10470,8 @@ pub struct OrganizationFull { #[serde(skip_serializing_if="Option::is_none")] pub members_can_create_private_pages: Option, #[serde(skip_serializing_if="Option::is_none")] + pub members_can_fork_private_repositories: Option, + #[serde(skip_serializing_if="Option::is_none")] pub updated_at: Option>, } @@ -10250,7 +10732,7 @@ pub struct Page { /// The Pages site's custom domain #[serde(skip_serializing_if="Option::is_none")] pub cname: Option, - /// The state if the domain is protected + /// The state if the domain is verified #[serde(skip_serializing_if="Option::is_none")] pub protected_domain_state: Option, /// The timestamp when a pending domain becomes unverified. @@ -10327,7 +10809,7 @@ pub struct PagesHttpsCertificate { pub description: Option, /// Array of the domain set and its alternate name (if it is configured) #[serde(skip_serializing_if="Option::is_none")] - pub domains: Option>, + pub domains: Option>, #[serde(skip_serializing_if="Option::is_none")] pub expires_at: Option>, } @@ -10721,6 +11203,8 @@ pub struct ProtectedBranchPullRequestReview { #[serde(skip_serializing_if="Option::is_none")] pub dismissal_restrictions: Option, #[serde(skip_serializing_if="Option::is_none")] + pub bypass_pull_request_allowances: Option, + #[serde(skip_serializing_if="Option::is_none")] pub dismiss_stale_reviews: Option, #[serde(skip_serializing_if="Option::is_none")] pub require_code_owner_reviews: Option, @@ -10728,6 +11212,23 @@ pub struct ProtectedBranchPullRequestReview { pub required_approving_review_count: Option, } +/// Protected Branch Required Status Check +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct ProtectedBranchRequiredStatusCheck { + #[serde(skip_serializing_if="Option::is_none")] + pub url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub enforcement_level: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub contexts: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub checks: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub contexts_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub strict: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct ProtectedbranchEnforceAdmins { #[serde(skip_serializing_if="Option::is_none")] @@ -10754,6 +11255,16 @@ pub struct ProtectedbranchRequiredPullRequestReviews { pub required_approving_review_count: Option, #[serde(skip_serializing_if="Option::is_none")] pub dismissal_restrictions: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub bypass_pull_request_allowances: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct ProtectedbranchRequiredPullRequestReviewsBypassPullRequestAllowances { + #[serde(skip_serializing_if="Option::is_none")] + pub users: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub teams: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -10770,6 +11281,17 @@ pub struct ProtectedbranchRequiredPullRequestReviewsDismissalRestrictions { pub teams: Option>, } +/// Allow specific users or teams to bypass pull request requirements. Set to `null` to disable. +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct ProtectedbranchpullrequestreviewBypassPullRequestAllowances { + /// The list of users allowed to bypass pull request requirements. + #[serde(skip_serializing_if="Option::is_none")] + pub users: Option>, + /// The list of teams allowed to bypass pull request requirements. + #[serde(skip_serializing_if="Option::is_none")] + pub teams: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct ProtectedbranchpullrequestreviewDismissalRestrictions { /// The list of users with review dismissal access. @@ -10786,6 +11308,14 @@ pub struct ProtectedbranchpullrequestreviewDismissalRestrictions { pub teams_url: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct ProtectedbranchrequiredstatuscheckChecks { + #[serde(skip_serializing_if="Option::is_none")] + pub context: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub app_id: Option, +} + /// Public User #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PublicUser { @@ -11801,6 +12331,8 @@ pub struct RatelimitoverviewResources { pub code_scanning_upload: Option, #[serde(skip_serializing_if="Option::is_none")] pub actions_runner_registration: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub scim: Option, } /// Reactions to conversations provide a way to help people express their feelings more simply and effectively. @@ -12404,7 +12936,9 @@ pub struct RepositoryCollaboratorPermission { #[serde(skip_serializing_if="Option::is_none")] pub permission: Option, #[serde(skip_serializing_if="Option::is_none")] - pub user: Option, + pub role_name: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub user: Option, } /// Repository invitations let you manage who you collaborate with. @@ -12628,6 +13162,8 @@ pub struct RepositoryTemplateRepository { #[serde(skip_serializing_if="Option::is_none")] pub delete_branch_on_merge: Option, #[serde(skip_serializing_if="Option::is_none")] + pub allow_update_branch: Option, + #[serde(skip_serializing_if="Option::is_none")] pub allow_merge_commit: Option, #[serde(skip_serializing_if="Option::is_none")] pub subscribers_count: Option, @@ -12726,9 +13262,22 @@ pub struct ReposownerrepobranchesbranchprotectionRequiredPullRequestReviews { /// Blocks merging pull requests until [code owners](https://help.github.com/articles/about-code-owners/) review them. #[serde(skip_serializing_if="Option::is_none")] pub require_code_owner_reviews: Option, - /// Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6. + /// Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6 or 0 to not require reviewers. #[serde(skip_serializing_if="Option::is_none")] pub required_approving_review_count: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub bypass_pull_request_allowances: Option, +} + +/// Allow specific users or teams to bypass pull request requirements. Set to `null` to disable. +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct ReposownerrepobranchesbranchprotectionRequiredPullRequestReviewsBypassPullRequestAllowances { + /// The list of user `login`s allowed to bypass pull request requirements. + #[serde(skip_serializing_if="Option::is_none")] + pub users: Option>, + /// The list of team `slug`s allowed to bypass pull request requirements. + #[serde(skip_serializing_if="Option::is_none")] + pub teams: Option>, } /// Specify which users and teams can dismiss pull request reviews. Pass an empty `dismissal_restrictions` object to disable. User and team `dismissal_restrictions` are only available for organization-owned repositories. Omit this parameter for personal repositories. @@ -12748,9 +13297,22 @@ pub struct ReposownerrepobranchesbranchprotectionRequiredStatusChecks { /// Require branches to be up to date before merging. #[serde(skip_serializing_if="Option::is_none")] pub strict: Option, - /// The list of status checks to require in order to merge into this branch + /// **Deprecated**: The list of status checks to require in order to merge into this branch. If any of these checks have recently been set by a particular GitHub App, they will be required to come from that app in future for the branch to merge. Use `checks` instead of `contexts` for more fine-grained control. #[serde(skip_serializing_if="Option::is_none")] pub contexts: Option>, + /// The list of status checks to require in order to merge into this branch. + #[serde(skip_serializing_if="Option::is_none")] + pub checks: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct ReposownerrepobranchesbranchprotectionRequiredStatusChecksChecks { + /// The name of the required check + #[serde(skip_serializing_if="Option::is_none")] + pub context: Option, + /// The ID of the GitHub App that must provide this check. Omit this field to automatically select the GitHub App that has recently provided this check, or any app if it was not set by a GitHub App. Pass -1 to explicitly allow any app to set the status. + #[serde(skip_serializing_if="Option::is_none")] + pub app_id: Option, } /// Restrict who can push to the protected branch. User, app, and team `restrictions` are only available for organization-owned repositories. Set to `null` to disable. @@ -13257,7 +13819,7 @@ pub struct Runner { #[serde(skip_serializing_if="Option::is_none")] pub busy: Option, #[serde(skip_serializing_if="Option::is_none")] - pub labels: Option>, + pub labels: Option>, } /// Runner Application @@ -13319,8 +13881,9 @@ pub struct RunnerGroupsOrg { pub allows_public_repositories: Option, } +/// A label for a self hosted runner #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct RunnerLabels { +pub struct RunnerLabel { /// Unique identifier of the label. #[serde(skip_serializing_if="Option::is_none")] pub id: Option, @@ -13655,8 +14218,9 @@ pub struct Scimv2enterprisesenterpriseGroupsscimGroupIdOperations { pub op: Option, #[serde(skip_serializing_if="Option::is_none")] pub path: Option, + /// Can be any value - string, number, array or object. #[serde(skip_serializing_if="Option::is_none")] - pub value: Option, + pub value: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -13861,6 +14425,48 @@ impl std::str::FromStr for SecretScanningAlertState { } } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct SecretScanningLocation { + /// The location type. Because secrets may be found in different types of resources (ie. code, comments, issues), this field identifies the type of resource where the secret was found. + #[serde(rename = "type")] + #[serde(skip_serializing_if="Option::is_none")] + pub _type: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub details: Option, +} + +/// Represents a 'commit' secret scanning location type. This location type shows that a secret was detected inside a commit to a repository. +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct SecretScanningLocationCommit { + /// The file path in the repository + #[serde(skip_serializing_if="Option::is_none")] + pub path: Option, + /// Line number at which the secret starts in the file + #[serde(skip_serializing_if="Option::is_none")] + pub start_line: Option, + /// Line number at which the secret ends in the file + #[serde(skip_serializing_if="Option::is_none")] + pub end_line: Option, + /// The column at which the secret starts within the start line when the file is interpreted as 8BIT ASCII + #[serde(skip_serializing_if="Option::is_none")] + pub start_column: Option, + /// The column at which the secret ends within the end line when the file is interpreted as 8BIT ASCII + #[serde(skip_serializing_if="Option::is_none")] + pub end_column: Option, + /// SHA-1 hash ID of the associated blob + #[serde(skip_serializing_if="Option::is_none")] + pub blob_sha: Option, + /// The API URL to get the associated blob resource + #[serde(skip_serializing_if="Option::is_none")] + pub blob_url: Option, + /// SHA-1 hash ID of the associated commit + #[serde(skip_serializing_if="Option::is_none")] + pub commit_sha: Option, + /// The API URL to get the associated commit resource + #[serde(skip_serializing_if="Option::is_none")] + pub commit_url: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutActionsSetAllowedActionsRepository { /// Whether GitHub-owned actions are allowed. For example, this includes the actions in the `actions` organization. @@ -14057,9 +14663,19 @@ pub struct StatusCheckPolicy { #[serde(skip_serializing_if="Option::is_none")] pub contexts: Option>, #[serde(skip_serializing_if="Option::is_none")] + pub checks: Option>, + #[serde(skip_serializing_if="Option::is_none")] pub contexts_url: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct StatuscheckpolicyChecks { + #[serde(skip_serializing_if="Option::is_none")] + pub context: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub app_id: Option, +} + /// Tag #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct Tag { @@ -14320,6 +14936,8 @@ pub struct TeamRepository { #[serde(skip_serializing_if="Option::is_none")] pub permissions: Option, #[serde(skip_serializing_if="Option::is_none")] + pub role_name: Option, + #[serde(skip_serializing_if="Option::is_none")] pub owner: Option, /// Whether the repository is private or public. #[serde(skip_serializing_if="Option::is_none")] @@ -15208,6 +15826,17 @@ pub struct UserSearchResultItem { pub suspended_at: Option>, } +/// Pull request number for this codespace +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct UsercodespacesPullRequest { + /// Pull request number + #[serde(skip_serializing_if="Option::is_none")] + pub pull_request_number: Option, + /// Repository id for this codespace + #[serde(skip_serializing_if="Option::is_none")] + pub repository_id: Option, +} + /// Validation Error #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct ValidationError { diff --git a/templates/lib.mustache b/templates/lib.mustache index dc2ef97..986a700 100644 --- a/templates/lib.mustache +++ b/templates/lib.mustache @@ -19,7 +19,7 @@ //! //! ```nocompile //! [dependencies] -//! roctogen = "0.11" +//! roctogen = "0.12" //! ``` //! //! # API