Skip to content

Commit

Permalink
chore: Update models according to upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
fussybeaver committed Nov 19, 2024
1 parent c632414 commit 24caf55
Show file tree
Hide file tree
Showing 17 changed files with 5,251 additions and 2,207 deletions.
4 changes: 2 additions & 2 deletions src/endpoints/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2325,7 +2325,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
///
/// # List events for the authenticated user
///
/// If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events.
/// If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. _Optional_: use the fine-grained token with following permission set to view private events: "Events" user permissions (read).
///
/// > [!NOTE]
/// > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
Expand Down Expand Up @@ -2370,7 +2370,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
///
/// # List events for the authenticated user
///
/// If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events.
/// If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. _Optional_: use the fine-grained token with following permission set to view private events: "Events" user permissions (read).
///
/// > [!NOTE]
/// > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
Expand Down
19 changes: 1 addition & 18 deletions src/endpoints/apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,9 +1527,7 @@ pub struct AppsListWebhookDeliveriesParams<'req> {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// Used for pagination: the starting delivery from which the page of deliveries is fetched. Refer to the `link` header for the next and previous page cursors.
cursor: Option<&'req str>,

redelivery: Option<bool>
cursor: Option<&'req str>
}

impl<'req> AppsListWebhookDeliveriesParams<'req> {
Expand All @@ -1542,7 +1540,6 @@ impl<'req> AppsListWebhookDeliveriesParams<'req> {
Self {
per_page: Some(per_page),
cursor: self.cursor,
redelivery: self.redelivery,
}
}

Expand All @@ -1551,16 +1548,6 @@ impl<'req> AppsListWebhookDeliveriesParams<'req> {
Self {
per_page: self.per_page,
cursor: Some(cursor),
redelivery: self.redelivery,
}
}


pub fn redelivery(self, redelivery: bool) -> Self {
Self {
per_page: self.per_page,
cursor: self.cursor,
redelivery: Some(redelivery),
}
}
}
Expand Down Expand Up @@ -1826,8 +1813,6 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
///
/// Optionally, use the `permissions` body parameter to specify the permissions that the installation access token should have. If `permissions` is not specified, the installation access token will have all of the permissions that were granted to the app. The installation access token cannot be granted permissions that the app was not granted.
///
/// When using the repository or permission parameters to reduce the access of the token, the complexity of the token is increased due to both the number of permissions in the request and the number of repositories the token will have access to. If the complexity is too large, the token will fail to be issued. If this occurs, the error message will indicate the maximum number of repositories that should be requested. For the average application requesting 8 permissions, this limit is around 5000 repositories. With fewer permissions requested, more repositories are supported.
///
/// You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint.
///
/// [GitHub API docs for create_installation_access_token](https://docs.github.com/rest/apps/apps#create-an-installation-access-token-for-an-app)
Expand Down Expand Up @@ -1876,8 +1861,6 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
///
/// Optionally, use the `permissions` body parameter to specify the permissions that the installation access token should have. If `permissions` is not specified, the installation access token will have all of the permissions that were granted to the app. The installation access token cannot be granted permissions that the app was not granted.
///
/// When using the repository or permission parameters to reduce the access of the token, the complexity of the token is increased due to both the number of permissions in the request and the number of repositories the token will have access to. If the complexity is too large, the token will fail to be issued. If this occurs, the error message will indicate the maximum number of repositories that should be requested. For the average application requesting 8 permissions, this limit is around 5000 repositories. With fewer permissions requested, more repositories are supported.
///
/// You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint.
///
/// [GitHub API docs for create_installation_access_token](https://docs.github.com/rest/apps/apps#create-an-installation-access-token-for-an-app)
Expand Down
129 changes: 123 additions & 6 deletions src/endpoints/code_scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,36 @@ impl From<CodeScanningDeleteAnalysisError> for AdapterError {
}
}

/// Errors for the [Delete a CodeQL database](CodeScanning::delete_codeql_database_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum CodeScanningDeleteCodeqlDatabaseError {
#[error("Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Service unavailable")]
Status503(PostCodespacesCreateForAuthenticatedUserResponse503),
#[error("Status code: {}", code)]
Generic { code: u16 },
}

impl From<CodeScanningDeleteCodeqlDatabaseError> for AdapterError {
fn from(err: CodeScanningDeleteCodeqlDatabaseError) -> Self {
let (description, status_code) = match err {
CodeScanningDeleteCodeqlDatabaseError::Status403(_) => (String::from("Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository"), 403),
CodeScanningDeleteCodeqlDatabaseError::Status404(_) => (String::from("Resource not found"), 404),
CodeScanningDeleteCodeqlDatabaseError::Status503(_) => (String::from("Service unavailable"), 503),
CodeScanningDeleteCodeqlDatabaseError::Generic { code } => (String::from("Generic"), code)
};

Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}

/// Errors for the [Get a code scanning alert](CodeScanning::get_alert_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum CodeScanningGetAlertError {
Expand Down Expand Up @@ -1596,6 +1626,93 @@ impl<'api, C: Client> CodeScanning<'api, C> where AdapterError: From<<C as Clien
}
}

/// ---
///
/// # Delete a CodeQL database
///
/// Deletes a CodeQL database for a language in a repository.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
///
/// [GitHub API docs for delete_codeql_database](https://docs.github.com/rest/code-scanning/code-scanning#delete-a-codeql-database)
///
/// ---
pub async fn delete_codeql_database_async(&self, owner: &str, repo: &str, language: &str) -> Result<(), AdapterError> {

let request_uri = format!("{}/repos/{}/{}/code-scanning/codeql/databases/{}", super::GITHUB_BASE_API_URL, owner, repo, language);


let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};

let request = self.client.build(req)?;

// --

let github_response = self.client.fetch_async(request).await?;

// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(CodeScanningDeleteCodeqlDatabaseError::Status403(github_response.to_json_async().await?).into()),
404 => Err(CodeScanningDeleteCodeqlDatabaseError::Status404(github_response.to_json_async().await?).into()),
503 => Err(CodeScanningDeleteCodeqlDatabaseError::Status503(github_response.to_json_async().await?).into()),
code => Err(CodeScanningDeleteCodeqlDatabaseError::Generic { code }.into()),
}
}
}

/// ---
///
/// # Delete a CodeQL database
///
/// Deletes a CodeQL database for a language in a repository.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
///
/// [GitHub API docs for delete_codeql_database](https://docs.github.com/rest/code-scanning/code-scanning#delete-a-codeql-database)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_codeql_database(&self, owner: &str, repo: &str, language: &str) -> Result<(), AdapterError> {

let request_uri = format!("{}/repos/{}/{}/code-scanning/codeql/databases/{}", super::GITHUB_BASE_API_URL, owner, repo, language);


let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};

let request = self.client.build(req)?;

// --

let github_response = self.client.fetch(request)?;

// --

if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(CodeScanningDeleteCodeqlDatabaseError::Status403(github_response.to_json()?).into()),
404 => Err(CodeScanningDeleteCodeqlDatabaseError::Status404(github_response.to_json()?).into()),
503 => Err(CodeScanningDeleteCodeqlDatabaseError::Status503(github_response.to_json()?).into()),
code => Err(CodeScanningDeleteCodeqlDatabaseError::Generic { code }.into()),
}
}
}

/// ---
///
/// # Get a code scanning alert
Expand Down Expand Up @@ -1812,7 +1929,7 @@ impl<'api, C: Client> CodeScanning<'api, C> where AdapterError: From<<C as Clien
/// your HTTP client is configured to follow redirects or use the `Location` header
/// to make a second request to get the redirect URL.
///
/// OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
///
/// [GitHub API docs for get_codeql_database](https://docs.github.com/rest/code-scanning/code-scanning#get-a-codeql-database-for-a-repository)
///
Expand Down Expand Up @@ -1862,7 +1979,7 @@ impl<'api, C: Client> CodeScanning<'api, C> where AdapterError: From<<C as Clien
/// your HTTP client is configured to follow redirects or use the `Location` header
/// to make a second request to get the redirect URL.
///
/// OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
///
/// [GitHub API docs for get_codeql_database](https://docs.github.com/rest/code-scanning/code-scanning#get-a-codeql-database-for-a-repository)
///
Expand Down Expand Up @@ -2549,7 +2666,7 @@ impl<'api, C: Client> CodeScanning<'api, C> where AdapterError: From<<C as Clien
///
/// Lists the CodeQL databases that are available in a repository.
///
/// OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
///
/// [GitHub API docs for list_codeql_databases](https://docs.github.com/rest/code-scanning/code-scanning#list-codeql-databases-for-a-repository)
///
Expand Down Expand Up @@ -2592,7 +2709,7 @@ impl<'api, C: Client> CodeScanning<'api, C> where AdapterError: From<<C as Clien
///
/// Lists the CodeQL databases that are available in a repository.
///
/// OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
///
/// [GitHub API docs for list_codeql_databases](https://docs.github.com/rest/code-scanning/code-scanning#list-codeql-databases-for-a-repository)
///
Expand Down Expand Up @@ -2646,7 +2763,7 @@ impl<'api, C: Client> CodeScanning<'api, C> where AdapterError: From<<C as Clien
/// and `0` is returned in this field.
///
/// > [!WARNING]
/// > **Deprecation notice:** The `tool_name` field is deprecated and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the `tool` field.
/// > **Closing down notice:** The `tool_name` field is closing down and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the `tool` field.
///
/// OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
///
Expand Down Expand Up @@ -2705,7 +2822,7 @@ impl<'api, C: Client> CodeScanning<'api, C> where AdapterError: From<<C as Clien
/// and `0` is returned in this field.
///
/// > [!WARNING]
/// > **Deprecation notice:** The `tool_name` field is deprecated and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the `tool` field.
/// > **Closing down notice:** The `tool_name` field is closing down and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the `tool` field.
///
/// OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
///
Expand Down
Loading

0 comments on commit 24caf55

Please sign in to comment.