Skip to content

Commit

Permalink
Merge pull request #56 from fussybeaver/ND-0.12
Browse files Browse the repository at this point in the history
Upstream changes (codespaces)
  • Loading branch information
fussybeaver authored Jan 6, 2022
2 parents d62b5eb + 2f7c214 commit 228cceb
Show file tree
Hide file tree
Showing 18 changed files with 6,384 additions and 1,051 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Add the following to your `Cargo.toml` file

```nocompile
[dependencies]
roctogen = "0.9"
roctogen = "0.12"
```

## API
Expand Down Expand Up @@ -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
Expand Down
1,452 changes: 1,265 additions & 187 deletions src/endpoints/actions.rs

Large diffs are not rendered by default.

152 changes: 4 additions & 148 deletions src/endpoints/apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<ContentReferenceAttachment, AppsCreateContentAttachmentError> {

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<ContentReferenceAttachment, AppsCreateContentAttachmentError> {

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
Expand Down Expand Up @@ -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<impl Into<AppsListInstallationReposForAuthenticatedUserParams>>) -> Result<GetAppsListInstallationReposForAuthenticatedUserResponse200, AppsListInstallationReposForAuthenticatedUserError> {

let mut request_uri = format!("{}/user/installations/{}/repositories", super::GITHUB_BASE_API_URL, installation_id);
Expand All @@ -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)?;
Expand Down Expand Up @@ -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<impl Into<AppsListInstallationReposForAuthenticatedUserParams>>) -> Result<GetAppsListInstallationReposForAuthenticatedUserResponse200, AppsListInstallationReposForAuthenticatedUserError> {

let mut request_uri = format!("{}/user/installations/{}/repositories", super::GITHUB_BASE_API_URL, installation_id);
Expand All @@ -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)?;
Expand Down Expand Up @@ -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<impl Into<AppsListReposAccessibleToInstallationParams>>) -> Result<GetAppsListReposAccessibleToInstallationResponse200, AppsListReposAccessibleToInstallationError> {

let mut request_uri = format!("{}/installation/repositories", super::GITHUB_BASE_API_URL);
Expand All @@ -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)?;
Expand Down Expand Up @@ -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<impl Into<AppsListReposAccessibleToInstallationParams>>) -> Result<GetAppsListReposAccessibleToInstallationResponse200, AppsListReposAccessibleToInstallationError> {

let mut request_uri = format!("{}/installation/repositories", super::GITHUB_BASE_API_URL);
Expand All @@ -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)?;
Expand Down
Loading

0 comments on commit 228cceb

Please sign in to comment.